shake

minimal build system that generates Ninja build files

git clone https://9o.is/git/shake.git

commit 9307c3bb35aaf7bbc2a8270c9bf380b0d1a026e5
parent 5a5001bc1ed40966e7e23e0bdee86a5434a5ad35
Author: Jul <jul@9o.is>
Date:   Wed, 18 Mar 2026 16:24:34 +0800

add SHAKE_FORMAT to handle ninja description formatting

Diffstat:
Mexample/simple/Shakefile | 2++
Mshake | 15++++++++++-----
2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/example/simple/Shakefile b/example/simple/Shakefile @@ -3,6 +3,8 @@ let CFLAGS ${CFLAGS:--Wall -Wextra -g} let PREFIX ${PREFIX:-/usr/local} let DESTDIR ${DESTDIR:-} +SHAKE_FORMAT='%6s %s' + rule cc $CC $CFLAGS -c $in -o $out bind description CC $in diff --git a/shake b/shake @@ -10,6 +10,7 @@ DIR=. OUTDIR=. NINJA_FILES=$SHAKEDIR/local.ninja GEN_FILES="./Shakefile $SHAKE_BIN" +SHAKE_FORMAT= usage() { printf "usage: shake [options] [directory] @@ -123,6 +124,7 @@ _shake_close() { fi printf 'build %s: gen | %s\n' "$shakedir/local.ninja $shakedir/local.ins $shakedir/local.out" "$GEN_FILES" >&3 + bind description SHAKE $dir printf 'build $dir/ninja: phony %s\n' "$NINJA_FILES" >&3 fi @@ -185,10 +187,14 @@ let() { bind() { printf ' %s =' "$1" >&3 - for _v in ${*:2}; do - printf ' %s' "$_v" >&3 - done - printf '\n' >&3 + if [ "$1" == description ] && [ -n "$SHAKE_FORMAT" ]; then + printf "$SHAKE_FORMAT\n" "$2" "${*:3}" | sed 's| |$ |g' >&3 + else + for _v in ${*:2}; do + printf ' %s' "$_v" >&3 + done + printf '\n' >&3 + fi } _shake_prefix() { @@ -434,7 +440,6 @@ let outdir $OUTDIR let shakedir $SHAKEDIR rule gen "$SHAKE_BIN $dir" -bind description SHAKE $dir bind generator 1 bind restat 1