mmake: -j$(nproc), passthrough o//

Now `mmake o/ape/ape.elf` works.
This commit is contained in:
Jōshin 2023-12-17 01:49:49 -05:00
parent 2b315626f3
commit b08b92248b
No known key found for this signature in database
2 changed files with 24 additions and 3 deletions

View file

@ -23,14 +23,17 @@ esac
}
local -a targs
local -a flags
local j=-j$(autoload -Uz nproc >/dev/null 2>&1 ; nproc)
while (( $# > 0 )); do
case $1 in
-*|*=*) flags+=($1); shift ;;
*) targs+=($1); shift ;;
-j*) j=$1; shift ;;
-*|*=*) flags+=($1); shift ;;
o/*) flags+=($1); shift ;; # cheat; passthru
*) targs+=($1); shift ;;
esac
done
local make
[[ -x /opt/cosmocc/bin/make ]] && make=/opt/cosmocc/bin/make
[[ -z $make ]] && make=build/bootstrap/make.com
( set -x
exec $make $flags MODE=$mode ${(@)targs/#/o/$mode/} )
exec $make $j $flags MODE=$mode ${(@)targs/#/o/$mode/} )

18
tool/zsh/nproc Normal file
View file

@ -0,0 +1,18 @@
[[ -x $(whence -p nproc) ]] && {
command nproc && {
unfunction nproc
return
}
}
[[ -x $(which sysctl) ]] && {
nproc() {
sysctl -n hw.ncpu
}
nproc && return
}
# TODO other platforms
echo nproc: no implementation found >&2
nproc() {
echo 2
}
nproc