logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git
commit: 785b495ba77ee716740523df566c560c63b4ddcc
parent b39004f210b110a4e9d77edf12012f8a4376da49
Author: Michael Forney <mforney@mforney.org>
Date:   Thu,  4 Jun 2020 19:11:30 -0700

Save stderr of probe commands

Diffstat:

Mrules.ninja4++--
Mscripts/probe-size.sh16++++++++++------
Mscripts/probe.sh11++++++-----
3 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/rules.ninja b/rules.ninja @@ -52,10 +52,10 @@ rule muse command = muse $museflags -o $out $in rule probe - command = sh $basedir/scripts/probe.sh $var $cc $cflags $ldflags -o /dev/null -x c $in >$out + command = sh $basedir/scripts/probe.sh $var $out $cc $cflags $ldflags -o /dev/null -x c $in rule probesize - command = sh $basedir/scripts/probe-size.sh $var $cc $cflags -c -o /dev/null -x c $in >$out + command = sh $basedir/scripts/probe-size.sh $var $out $cc $cflags -c -o /dev/null -x c $in # misc tools rule touch diff --git a/scripts/probe-size.sh b/scripts/probe-size.sh @@ -1,18 +1,22 @@ set -e -if [ "$#" -lt 2 ] ; then - echo 'usage: probe-size.sh var command...' >&2 +if [ "$#" -lt 3 ] ; then + printf 'usage: %s var out command...\n' "$0" >&2 exit 2 fi var=$1 -shift +out=$2 +shift 2 for size in 8 4 2 1 ; do - if "$@" -D "$var=$size" 2>/dev/null ; then - echo "#define $var $size" + echo "==> trying $var=$size..." >&2 + if "$@" -D "$var=$size" ; then + echo '==> success' >&2 + echo "#define $var $size" >"$out" exit 0 fi -done +done 2>"$out.log" +cat "$out.log" printf "%s: could not determine %s\n" "$0" "$var" >&2 exit 1 diff --git a/scripts/probe.sh b/scripts/probe.sh @@ -1,12 +1,13 @@ set -e -if [ "$#" -lt 2 ] ; then - echo 'usage: probe.sh var command...' >&2 +if [ "$#" -lt 3 ] ; then + printf 'usage: %s var out command...\n' "$0" >&2 exit 2 fi var=$1 -shift -if "$@" 2>/dev/null ; then - echo "#define $var 1" +out=$2 +shift 2 +if "$@" 2>"$out.log" ; then + echo "#define $var 1" >"$out" fi