shake

minimal build system that generates Ninja build files

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

commit 5a5001bc1ed40966e7e23e0bdee86a5434a5ad35
parent a834872d388cd578b39c3dd196b46121a3ca3708
Author: Jul <jul@9o.is>
Date:   Wed, 18 Mar 2026 15:08:21 +0800

change var command to let

Diffstat:
MREADME.md | 20++++++++++----------
Mexample/nested/Shakefile | 10+++++-----
Mexample/nested/bin/Shakefile | 2+-
Mexample/simple/Shakefile | 8++++----
Mshake | 18+++++++++---------
5 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/README.md b/README.md @@ -32,8 +32,8 @@ Run the installation script: 1. **Create a Shakefile** in your project root: ```sh -var CC ${CC:-cc} -var CFLAGS ${CFLAGS:--Wall -g} +let CC ${CC:-cc} +let CFLAGS ${CFLAGS:--Wall -g} rule cc '$CC $CFLAGS -c $in -o $out' bind description 'CC $in' @@ -75,8 +75,8 @@ Shake supports recursive builds - each subdirectory can have its own Shakefile: # Root Shakefile (extends the example above) shake lib -var LIBDIR $dir/lib -var CFLAGS $CFLAGS -I$LIBDIR +let LIBDIR $dir/lib +let CFLAGS $CFLAGS -I$LIBDIR cc main.o: main.c - $LIBDIR/lib.h link hello: main.o $LIBDIR/lib.a @@ -84,7 +84,7 @@ link hello: main.o $LIBDIR/lib.a ```sh # lib/Shakefile -var AR ${AR:-ar} +let AR ${AR:-ar} rule ar '$AR rcs $out $in' bind description 'AR $out' @@ -131,14 +131,14 @@ you can run shake from any subdirectory. ### Variables -Define variables with `var`: +Define variables with `let`: ```sh -var CC ${CC:-cc} -var CFLAGS -Wall -g +let CC ${CC:-cc} +let CFLAGS -Wall -g ``` -Variables can reference environment variables with `${VAR:-default}` syntax. The var +Variables can reference environment variables with `${VAR:-default}` syntax. The let command essentially writes a variable to the ninja file, and defines a shell variable so you can refer to it from any Shakefile. @@ -206,7 +206,7 @@ Each subdirectory should have its own `Shakefile`. Shake generates Ninja files f Two special variables are automatically available: - `$dir` - the directory containing the current Shakefile -- `$outdir` - the output directory (can be overridden with `-o` or var command) +- `$outdir` - the output directory (can be overridden with `-o` or let command) ### Import Files diff --git a/example/nested/Shakefile b/example/nested/Shakefile @@ -1,8 +1,8 @@ -var CC ${CC:-cc} -var CFLAGS ${CFLAGS:--Wall -Wextra -g} -var PREFIX ${PREFIX:-/usr/local} -var DESTDIR ${DESTDIR:-} -var LIBDIR $dir/lib +let CC ${CC:-cc} +let CFLAGS ${CFLAGS:--Wall -Wextra -g} +let PREFIX ${PREFIX:-/usr/local} +let DESTDIR ${DESTDIR:-} +let LIBDIR $dir/lib rule cc $CC $CFLAGS -c $in -o $out bind description CC $in diff --git a/example/nested/bin/Shakefile b/example/nested/bin/Shakefile @@ -1,4 +1,4 @@ -var CFLAGS $CFLAGS -I $LIBDIR +let CFLAGS $CFLAGS -I $LIBDIR cc main.o: main.c - $LIBDIR/lib.h link hello: main.o $LIBDIR/lib.a diff --git a/example/simple/Shakefile b/example/simple/Shakefile @@ -1,7 +1,7 @@ -var CC ${CC:-cc} -var CFLAGS ${CFLAGS:--Wall -Wextra -g} -var PREFIX ${PREFIX:-/usr/local} -var DESTDIR ${DESTDIR:-} +let CC ${CC:-cc} +let CFLAGS ${CFLAGS:--Wall -Wextra -g} +let PREFIX ${PREFIX:-/usr/local} +let DESTDIR ${DESTDIR:-} rule cc $CC $CFLAGS -c $in -o $out bind description CC $in diff --git a/shake b/shake @@ -162,9 +162,9 @@ shake() { NINJA_FILES=$shakedir/local.ninja _shake_open - var dir $dir/$1 - var outdir $outdir/$1 - var shakedir $shakedir/$1 + let dir $dir/$1 + let outdir $outdir/$1 + let shakedir $shakedir/$1 [ "${2-}" ] && eval "$2 $1" . $DIR/Shakefile @@ -174,7 +174,7 @@ shake() { fi } -var() { +let() { printf '%s =' "$1" >&3 for _v in ${*:2}; do printf ' %s' "$_v" >&3 @@ -427,11 +427,11 @@ out='$out' opts='$opts' _shake_open -var ninja_required_version 1.8 -var builddir $SHAKEDIR -var dir $DIR -var outdir $OUTDIR -var shakedir $SHAKEDIR +let ninja_required_version 1.8 +let builddir $SHAKEDIR +let dir $DIR +let outdir $OUTDIR +let shakedir $SHAKEDIR rule gen "$SHAKE_BIN $dir" bind description SHAKE $dir