linux-qubasis
linux oasis port as a qubes template
git clone https://9o.is/git/linux-qubasis.git
commit 9890299c89456842be8d23ce80cf6eda2c0fb446 parent 6462caea207dc6f167f485d92c0678ccdde5f754 Author: Jul <jul@9o.is> Date: Thu, 28 Aug 2025 12:15:08 +0800 reduce quoting in ninja functions Diffstat:
| M | ninja/functions.sh | | | 103 | +++++++++++++++++++++++++++++++++++++++---------------------------------------- |
1 file changed, 51 insertions(+), 52 deletions(-)
diff --git a/ninja/functions.sh b/ninja/functions.sh @@ -159,7 +159,7 @@ gen() { _ninja_queue_subgen= _ninja_init() { - _ninja_initglobals "$1" + _ninja_initglobals $1 mkdir -p "${_ninja_writepath%/*}" printf '' > "$_ninja_writepath" } @@ -173,26 +173,26 @@ _ninja_complete() { mv "$_ninja_writepath" "${_ninja_writepath%.*}" - if [ "$_ninja_type" = 'root' ]; then + if [ $_ninja_type = root ]; then ln -sf "$_ninja_ninjadir"/$_ninja_file "$_ninja_basedir"/build.ninja fi } _ninja_initglobals() { _ninja_basedir="${_ninja_basedir-$basedir}" - _ninja_dir="$_ninja_basedir/$1" + _ninja_dir="$_ninja_basedir"/$1 _ninja_ninjadir="$_ninja_basedir"/$BUILDDIR/ninja - case "$1" in + case $1 in .) _ninja_type=root _ninja_file=root.ninja ;; pkg/*|tpl/*) - _ninja_type="${1%%/*}" - _ninja_gendir="$1" + _ninja_type=${1%%/*} + _ninja_gendir=$1 - if [ "${_ninja_host-}" ]; then + if [ ${_ninja_host-} ]; then _ninja_file=host/${1#*/}.ninja else _ninja_file=$1.ninja @@ -217,23 +217,9 @@ _ninja_initglobals() { } _ninja_setv_init() { - setv gendir "$1" + setv gendir $1 setv tgtdir '$gendir' - case $_ninja_type in - pkg) - setv dir '$basedir/$gendir' - setv outdir '$builddir/$gendir' - setv srcdir '$dir/repo' - ;; - tpl) - setv dir '$basedir/$gendir' - setv outdir '$builddir/$gendir' - setv rootdir '$outdir/root' - ;; - - esac - basedir='$basedir' builddir='$builddir' ninjadir='$ninjadir' @@ -248,23 +234,36 @@ _ninja_setv_init() { objdir='$outdir/_obj' unset -f host + + case $_ninja_type in + pkg) + setv dir $basedir/$gendir + setv outdir $builddir/$gendir + setv srcdir $dir/repo + ;; + tpl) + setv dir $basedir/$gendir + setv outdir $builddir/$gendir + setv rootdir $outdir/root + ;; + esac } _ninja_prefix() { - _var="$1"; shift - _prefix="$1"; shift - _vs='' + _var=$1; shift + _prefix=$1; shift + _vs= for _v in $*; do case $_v in \$*) ;; - *) _v="$_prefix/$_v";; + *) _v=$_prefix/$_v;; esac if [ "$_vs" ]; then _vs="$_vs $_v" else - _vs="$_v" + _vs=$_v fi done @@ -285,7 +284,7 @@ _ninja_fspec() { } _ninja_fspec_file() { - _v1="$1"; shift + _v1=$1; shift if [ ! "$*" ]; then _ninja_buffer_fspec_files="$_ninja_buffer_fspec_files $pkgdir/$_v1/_files/_all" @@ -331,7 +330,7 @@ _ninja_flush_exe() { set -- $_ninja_buffer_exe - _out="$1"; shift; + _out=$1; shift _ninja_compile $* if [ "$_objs" ]; then @@ -358,7 +357,7 @@ _ninja_flush_lib() { set -- $_ninja_buffer_lib - _out="$1"; shift; + _out=$1; shift _srcs= _ninja_compile $* @@ -378,13 +377,13 @@ _ninja_flush_lib() { _ninja_flush_subninjas() { for _v in $_ninja_buffer_subgen; do - printf 'subninja $ninjadir/%s.ninja\n' "$_v" >> "$_ninja_writepath" + printf 'subninja $ninjadir/%s.ninja\n' $_v >> "$_ninja_writepath" done - if [ ! "${_ninja_host-}" ] && command -v host >/dev/null 2>&1; then + if [ ! ${_ninja_host-} ] && command -v host >/dev/null 2>&1; then _srcs="$( - _ninja_host='true' - _ninja_init "$_ninja_gendir" + _ninja_host=true + _ninja_init $_ninja_gendir setv outdir $builddir/host setv tgtdir $gendir/host @@ -400,13 +399,13 @@ _ninja_flush_subninjas() { _ninja_complete )" - printf 'subninja $ninjadir/host/%s.ninja\n' "${_ninja_gendir#*/}" >> "$_ninja_writepath" + printf 'subninja $ninjadir/host/%s.ninja\n' ${_ninja_gendir#*/} >> "$_ninja_writepath" _ninja_buffer_sync="$_ninja_buffer_sync $_srcs" fi } _ninja_flush_build() { - if [ "${_ninja_host-}" ]; then + if [ ${_ninja_host-} ]; then return fi @@ -424,14 +423,14 @@ _ninja_flush_build() { } _ninja_flush_sync() { - if [ "${_ninja_host-}" ]; then + if [ ${_ninja_host-} ]; then printf "$_ninja_buffer_sync" return fi _srcs= - if [ "$_ninja_type" != 'root' ]; then + if [ $_ninja_type != root ]; then _srcs=$outdir/_files/_version fi @@ -439,9 +438,9 @@ _ninja_flush_sync() { _srcs="$_srcs \$tgtdir/$_v/sync" done - build phony $tgtdir/sync "$_srcs" + build phony $tgtdir/sync $_srcs - if [ "$_ninja_type" = 'root' ]; then + if [ $_ninja_type = root ]; then return fi @@ -456,7 +455,7 @@ _ninja_flush_sync() { return fi - _ninja_dedup _ninja_buffer_sync "$_ninja_buffer_sync" + _ninja_dedup _ninja_buffer_sync $_ninja_buffer_sync build phony "$_ninja_buffer_sync" $outdir/_files/_version } @@ -465,7 +464,7 @@ _ninja_flush_deps() { return fi - build phony $tgtdir/deps "$_ninja_buffer_deps" + build phony $tgtdir/deps $_ninja_buffer_deps } _ninja_flush_headers() { @@ -481,11 +480,11 @@ _ninja_flush_headers() { build copy $_out $_src done - build phony $tgtdir/headers "$_srcs" + build phony $tgtdir/headers $_srcs } _ninja_flush_fspec() { - if [ "$_ninja_type" = 'root' ] || [ "${_ninja_host-}" ]; then + if [ $_ninja_type = root ] || [ ${_ninja_host-} ]; then return fi @@ -496,15 +495,15 @@ _ninja_flush_fspec() { _srcs=$(printf "$_ninja_buffer_fspec" | while read -r line; do set -- $line - path="$1" - type="$2" - mode="$3" - src="${4-}" + path=$1 + type=$2 + mode=$3 + src=${4-} - out="$outdir/_files/${path##*/}" + out=$outdir/_files/${path##*/} dep='| $basedir/ninja/fspec.sh $hostdir/fspec-hash' - if [ "$type" = 'reg' ]; then + if [ $type = reg ]; then build fspec $out $outdir/${path##*/} $dep else build fspec $out $dep @@ -514,7 +513,7 @@ _ninja_flush_fspec() { bind type $type bind mode $mode - if [ "$type" = 'sym' ]; then + if [ $type = sym ]; then bind target $src fi @@ -523,7 +522,7 @@ _ninja_flush_fspec() { build cat $outdir/_files/_all $_srcs $_ninja_buffer_fspec_files - if [ "$_ninja_type" = 'tpl' ]; then + if [ $_ninja_type = tpl ]; then build fspec-tar $outdir/rootfs.tar.zst $outdir/_files/_all fi }