linux-qubasis
linux oasis port as a qubes template
git clone https://9o.is/git/linux-qubasis.git
commit 1663704718d5056d72e09bdd974434ee71473177 parent 7d6f9dcc0e7ec907ea0b399c33b139c2f1758e66 Author: Jul <jul@9o.is> Date: Sat, 8 Nov 2025 04:18:34 -0500 make rule ninja function more dynamic Diffstat:
| M | ninja/functions.sh | | | 32 | ++++++++++++++++++++++++++++++-- |
| M | pkg/awk/gen.sh | | | 23 | +++-------------------- |
| M | pkg/e2fsprogs/gen.sh | | | 2 | +- |
| M | pkg/linux-headers/gen.sh | | | 11 | ++++------- |
| M | pkg/netbsd-curses/gen.sh | | | 19 | +++++++++---------- |
| M | pkg/perp/gen.sh | | | 13 | ++++--------- |
| M | pkg/probe/gen.sh | | | 33 | +++++++++++++++------------------ |
| M | pkg/rc/gen.sh | | | 7 | ++----- |
| M | pkg/sbase/gen.sh | | | 2 | +- |
| M | pkg/st/gen.sh | | | 4 | +--- |
10 files changed, 70 insertions(+), 76 deletions(-)
diff --git a/ninja/functions.sh b/ninja/functions.sh @@ -27,8 +27,36 @@ default() { } rule() { - printf 'rule %s\n' $1 >> "$_ninja_writepath" - bind 'command' "$2" + _desc='$out' + + case "$1" in + -o) + _desc=$2 + shift 2 + ;; + esac + + _rule=$1 + _cmd="$2" + + printf 'rule %s\n' $_rule >> "$_ninja_writepath" + bind command "$_cmd" + bind description "$_rule $_desc" + + _dep='' + for _v in $_cmd; do + case "$_v" in + *$dir/* | *$hostdir/* | *$outdir/* | *$srcdir/*) + _dep="$_dep \$${_v#*$}" + ;; + esac + done + + if [ "$_dep" ]; then + _dep="'|'$_dep" + fi + + eval "$_rule() { _out="'$1'"; shift; build $_rule \""'$_out'"\" "'$*'" $_dep; }" } build() { diff --git a/pkg/awk/gen.sh b/pkg/awk/gen.sh @@ -14,30 +14,13 @@ cflags " " rule yacc '$hostdir/yacc $yaccflags $in >/dev/null' -bind description 'YACC $out' - rule maketab '$hostdir/maketab $in >$out' -bind description 'MAKETAB $out' - -yacc() { - _out=${2-} - - if [ ! $_out ]; then - _out=${1##*/} - _out=${_out%.*} - fi - - build yacc "$yaccdir/$_out.tab.c $yaccdir/$_out.tab.h" $1 '|' $hostdir/yacc - bind yaccflags "-d -b $yaccdir/$_out" -} - -maketab() { - build maketab $1 $2 '|' $hostdir/maketab -} dep $yaccdir/awkgram.tab.h -yacc awkgram.y +yacc '$yaccdir/awkgram.tab.c $yaccdir/awkgram.tab.h' awkgram.y +bind yaccflags -d -b $yaccdir/awkgram + maketab $yaccdir/proctab.c $yaccdir/awkgram.tab.h host() { diff --git a/pkg/e2fsprogs/gen.sh b/pkg/e2fsprogs/gen.sh @@ -62,7 +62,7 @@ host() { } rule gen_crc32ctable '$hostdir/gen_crc32ctable >$out' -build gen_crc32ctable _include/crc32c_table.h '|' $hostdir/gen_crc32ctable +build gen_crc32ctable _include/crc32c_table.h include --prefix ext2fs $dir/ext2_types.h include $outdir/include/ext2fs/ext2_err.h diff --git a/pkg/linux-headers/gen.sh b/pkg/linux-headers/gen.sh @@ -12,11 +12,8 @@ case $TARGET_ARCH in *) error "Unsupported arch $TARGET_ARCH";; esac -rule header 'sed -E -f $dir/header.sed $in >$out.tmp && { $hostdir/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $out.tmp >$out; [ $$? -le 1 ]; } && rm $out.tmp' -bind description 'LINUX HEADER $out' - -rule wrapper 'printf "#include <asm-generic/%s>\n" $file >$out' -bind description 'LINUX HEADER $out' +rule linux_header 'sed -E -f $dir/header.sed $in >$out.tmp && { $hostdir/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $out.tmp >$out; [ $$? -le 1 ]; } && rm $out.tmp' +rule linux_wrapper 'printf "#include <asm-generic/%s>\n" $file >$out' host() { exe unifdef scripts/unifdef.c @@ -25,7 +22,7 @@ host() { uapi_headers() { while read -r src; do outfile=$outdir/include/${src#*/uapi/} - build header $outfile $src '|' $dir/header.sed $hostdir/unifdef + linux_header $outfile $src include $outfile done <$DIR/$1 } @@ -33,7 +30,7 @@ uapi_headers() { asm_headers() { while read -r src; do outfile=$outdir/include/asm/$src - build wrapper $outfile + linux_wrapper $outfile bind file $src include $outfile done <$DIR/$1 diff --git a/pkg/netbsd-curses/gen.sh b/pkg/netbsd-curses/gen.sh @@ -27,14 +27,6 @@ include " lib/libpanel/panel.h " -rule nbperf 'TOOL_NBPERF=$hostdir/nbperf $in >$out' -bind description 'NBPERF $out' - -nbperf() { - build nbperf $2 lib/libterminfo/$1 $3 '|' $hostdir/nbperf - dep $outdir/$2 -} - host() { cflags " -I $srcdir/compat @@ -60,8 +52,15 @@ host() { " } -nbperf genhash deps/hash.c lib/libterminfo/term.h -nbperf genthash deps/termcap_hash.c lib/libterminfo/termcap_map.c +rule nbperf 'TOOL_NBPERF=$hostdir/nbperf $in >$out' + +nbperf deps/hash.c lib/libterminfo/genhash lib/libterminfo/term.h +nbperf deps/termcap_hash.c lib/libterminfo/genthash lib/libterminfo/termcap_map.c + +dep " + $outdir/deps/hash.c + $outdir/deps/termcap_hash.c +" lib libterminfo.a " compat/cdbr.c diff --git a/pkg/perp/gen.sh b/pkg/perp/gen.sh @@ -18,13 +18,8 @@ cflags " " rule outvec '$hostdir/mk_outvec >$out' -bind description 'OUTVEC $out' - rule rlimit '$hostdir/mk_rlimit >$out' -bind description 'RLIMIT $out' - rule sysstr '$hostdir/mksysstr $type >$out' -bind description 'SYSSTR $out' host() { exe mk_outvec lasagna/outvec/mk_outvec.c @@ -32,13 +27,13 @@ host() { exe mksysstr lasagna/sysstr/mksysstr.c } -build outvec _include/outvec_STDOUT.h '|' $hostdir/mk_outvec -build rlimit _include/rlimit_defs.c.in '|' $hostdir/mk_rlimit +outvec _include/outvec_STDOUT.h +rlimit _include/rlimit_defs.c.in -build sysstr _include/sysstr_errno.c.in '|' $hostdir/mksysstr +sysstr _include/sysstr_errno.c.in bind type errno -build sysstr _include/sysstr_signo.c.in '|' $hostdir/mksysstr +sysstr _include/sysstr_signo.c.in bind type signo dep " diff --git a/pkg/probe/gen.sh b/pkg/probe/gen.sh @@ -1,26 +1,23 @@ -rule probe 'sh $dir/probe.sh $var $out $cc $cflags $ldflags -x c -o /dev/null $in' -bind description 'PROBE $var' +rule -o '$var' probe 'sh $dir/probe.sh $var $out $cc $cflags $ldflags -x c -o /dev/null $in' +rule -o '$var' probesize 'sh $dir/probe-size.sh $var $out $cc $cflags -c -x c -o /dev/null $in' -rule probe-size 'sh $dir/probe-size.sh $var $out $cc $cflags -c -x c -o /dev/null $in' -bind description 'PROBE SIZE $var' - -probe() { - build probe $1 $dir/$1 '|' $dir/probe.sh +_probe() { + probe $1 $dir/$1 bind var $1 } -probesize() { - build probe-size $1 $dir/$1 '|' $dir/probe-size.sh +_probesize() { + probesize $1 $dir/$1 bind var $1 } -probe HAVE__THREAD_LOCAL -probe HAVE_IMMINTRIN_H -probe HAVE__MM_CLMULEPI64_SI128 -probe HAVE__MM_MOVEMASK_EPI8 -probe HAVE___BUILTIN_ASSUME_ALIGNED -probe HAVE___BUILTIN_BSWAP16 +_probe HAVE__THREAD_LOCAL +_probe HAVE_IMMINTRIN_H +_probe HAVE__MM_CLMULEPI64_SI128 +_probe HAVE__MM_MOVEMASK_EPI8 +_probe HAVE___BUILTIN_ASSUME_ALIGNED +_probe HAVE___BUILTIN_BSWAP16 -probesize SIZEOF_SIZE_T -probesize SIZEOF_LONG -probesize SIZEOF_TIME_T +_probesize SIZEOF_SIZE_T +_probesize SIZEOF_LONG +_probesize SIZEOF_TIME_T diff --git a/pkg/rc/gen.sh b/pkg/rc/gen.sh @@ -14,18 +14,15 @@ cflags " " rule mkstatval '$hostdir/mkstatval >$out' -bind description 'MKSTATVAL $out' - rule mksignal '$hostdir/mksignal $out' -bind description 'MKSIGNAL $out' host() { exe mksignal mksignal.c exe mkstatval mkstatval.c } -build mksignal '_include/sigmsgs.h _c/sigmsgs.c' '|' $hostdir/mksignal -build mkstatval _include/statval.h '|' $hostdir/mkstatval +mksignal '_include/sigmsgs.h _c/sigmsgs.c' +mkstatval _include/statval.h dep " bestline/headers diff --git a/pkg/sbase/gen.sh b/pkg/sbase/gen.sh @@ -83,7 +83,7 @@ lib libutf.a " " rule getconf '$srcdir/scripts/getconf.sh >$out' -build getconf include/getconf.h '|' scripts/getconf.sh +getconf include/getconf.h dep $outdir/include/getconf.h diff --git a/pkg/st/gen.sh b/pkg/st/gen.sh @@ -29,9 +29,7 @@ setv ldflags " " rule tic '$hostdir/tic -x -o $out $in' -bind description 'TIC $out' - -build tic terminfo st.info '|' $hostdir/tic +tic terminfo st.info exe st " st.c