commit - 68a0e61661c30964596d7a026d7b80157700f492
commit + 1c18143de8ce8c88e3a0e1b303d93e8e458fbb42
blob - e07056d9626b1a47daeff48629abd1b53732c20c
blob + 581075845b1c4c214c56fed9f07a5d7fbb525804
--- .gitignore
+++ .gitignore
-# redo
-.redo/
+# knit
+.knit/
+.venv-stamp
bin/*
-!bin/*.do
# python
.venv/
# zig
blob - f56f2198a67ba8444edb02005b53a3795a7fed34 (mode 644)
blob + /dev/null
--- all.do
+++ /dev/null
-exec >&2
-redo-ifchange \
- bin/dam bin/lastfm_rs bin/plants \
- bin/pmn bin/pracomer bin/speediness \
- bin/wrd \
- bin/mpd_add_to_playlist bin/mpd_add_to_queue bin/mpd_edit_queue \
- bin/mpd_update_library bin/mpd_update_queue \
- bin/diggah bin/lazymaster bin/nts bin/shuffle bin/kundali \
- bin/hue bin/reflink-snap
blob - d775f2e089d7c96a17209aea5723657c5a70c7f2 (mode 644)
blob + /dev/null
--- bin/dam.do
+++ /dev/null
-exec >&2
-redo-ifchange ../Cargo.toml ../Cargo.lock ../rust-toolchain.toml \
- ../.cargo/config.toml ../dam/Cargo.toml $(find ../dam/src -name '*.rs')
-(cd .. && cargo build --release -p dam)
-cp ../target/release/dam "$3"
blob - d5ee820eda03940a9e1238a29796744995ef1f3a (mode 644)
blob + /dev/null
--- bin/default.do
+++ /dev/null
-# Catch-all: builds the mpd_* C binaries from ../mpd/<name>.c.
-exec >&2
-case "$1" in
-mpd_*) ;;
-*)
- echo "bin/default.do: no rule to build '$1'"
- exit 1
- ;;
-esac
-redo-ifchange "../mpd/$1.c"
-/usr/bin/cc \
- -Wall \
- -Wextra \
- -O2 \
- -march=native \
- -mtune=native \
- -fanalyzer \
- -Wshadow \
- -fstack-protector-strong \
- -D_FORTIFY_SOURCE=2 \
- -fPIE \
- -Wformat \
- -Werror=format-security \
- -Wnull-dereference \
- -Wdangling-pointer \
- -Wtrampolines \
- -Walloca \
- -Wcast-align=strict \
- -Wdate-time \
- -Wfloat-equal \
- -Wpointer-arith \
- -Wredundant-decls \
- -Wswitch-default \
- -Wvla \
- -Wwrite-strings \
- -o "$3" "../mpd/$1.c" \
- -lmpdclient \
- -Wl,-z,relro \
- -Wl,-z,now
blob - 2bd54e1990cb50ffdac8f4cc5334354dcd236043 (mode 644)
blob + /dev/null
--- bin/diggah.do
+++ /dev/null
-exec >&2
-redo-ifchange venv-stamp ../diggah/diggah.py
-root=$(cd .. && pwd)
-cat > "$3" <<EOF
-#!/bin/sh
-exec "$root/.venv/bin/python" "$root/diggah/diggah.py" "\$@"
-EOF
-chmod +x "$3"
blob - 2c4f612d9a0ca63a94b7da18909338fb4663bced (mode 644)
blob + /dev/null
--- bin/hue.do
+++ /dev/null
-exec >&2
-redo-ifchange ../hue/bin/hue $(find ../hue/lib -name '*.rb')
-root=$(cd .. && pwd)
-cat > "$3" <<EOF
-#!/bin/sh
-exec ruby -I"$root/hue/lib" "$root/hue/bin/hue" "\$@"
-EOF
-chmod +x "$3"
\ No newline at end of file
blob - a25508311932daabb5b8c8ac83b94766e44230ef (mode 644)
blob + /dev/null
--- bin/kundali.do
+++ /dev/null
-exec >&2
-redo-ifchange venv-stamp ../kundali/kundali.py
-root=$(cd .. && pwd)
-cat > "$3" <<EOF
-#!/bin/sh
-exec "$root/.venv/bin/python" "$root/kundali/kundali.py" "\$@"
-EOF
-chmod +x "$3"
blob - 22e8d8f29e7cea6edeb22cd7841b645996ebde32 (mode 644)
blob + /dev/null
--- bin/lastfm_rs.do
+++ /dev/null
-exec >&2
-redo-ifchange ../Cargo.toml ../Cargo.lock ../rust-toolchain.toml \
- ../.cargo/config.toml ../lastfm_rs/Cargo.toml $(find ../lastfm_rs/src -name '*.rs')
-(cd .. && cargo build --release -p lastfm_rs)
-cp ../target/release/lastfm_rs "$3"
blob - 7bbcf73c24355bb246bf7a5cb8ec94528f67b86c (mode 644)
blob + /dev/null
--- bin/lazymaster.do
+++ /dev/null
-exec >&2
-redo-ifchange venv-stamp ../lazymaster/lazymaster.py
-root=$(cd .. && pwd)
-cat > "$3" <<EOF
-#!/bin/sh
-exec "$root/.venv/bin/python" "$root/lazymaster/lazymaster.py" "\$@"
-EOF
-chmod +x "$3"
blob - 1908ae2cfcd97ef4d225589334020925296dae27 (mode 644)
blob + /dev/null
--- bin/nts.do
+++ /dev/null
-exec >&2
-redo-ifchange venv-stamp ../nts/nts.py
-root=$(cd .. && pwd)
-cat > "$3" <<EOF
-#!/bin/sh
-exec "$root/.venv/bin/python" "$root/nts/nts.py" "\$@"
-EOF
-chmod +x "$3"
blob - 6a45b66bc4cd1dd55997bc0350be2976cc0f550e (mode 644)
blob + /dev/null
--- bin/plants.do
+++ /dev/null
-exec >&2
-redo-ifchange ../Cargo.toml ../Cargo.lock ../rust-toolchain.toml \
- ../.cargo/config.toml ../plants/Cargo.toml $(find ../plants/src -name '*.rs')
-(cd .. && cargo build --release -p plants)
-cp ../target/release/plants "$3"
blob - 91e5ae3ecd900a6b97c1fd34165fc73b7501745c (mode 644)
blob + /dev/null
--- bin/pmn.do
+++ /dev/null
-exec >&2
-redo-ifchange ../pmn/build.zig ../pmn/build.zig.zon $(find ../pmn/src -name '*.zig')
-(cd ../pmn && zig build -Doptimize=ReleaseSafe)
-cp ../pmn/zig-out/bin/pmn "$3"
blob - 3eb653776af5ff48fcf423d11b787cd4cf195479 (mode 644)
blob + /dev/null
--- bin/pracomer.do
+++ /dev/null
-exec >&2
-redo-ifchange ../pracomer/build.zig ../pracomer/build.zig.zon $(find ../pracomer/src -name '*.zig')
-(cd ../pracomer && zig build -Doptimize=ReleaseSafe)
-cp ../pracomer/zig-out/bin/pracomer "$3"
blob - 7055fe62b65958c49a27283067c7291b9d0c3dc1 (mode 644)
blob + /dev/null
--- bin/reflink-snap.do
+++ /dev/null
-exec >&2
-redo-ifchange ../reflink-snap/reflink-snap.rb
-root=$(cd .. && pwd)
-cat > "$3" <<EOF
-#!/bin/sh
-exec ruby "$root/reflink-snap/reflink-snap.rb" "\$@"
-EOF
-chmod +x "$3"
\ No newline at end of file
blob - 3a0c0fdf888ff3b8c4180cd62e0fe0ce420471aa (mode 644)
blob + /dev/null
--- bin/shuffle.do
+++ /dev/null
-exec >&2
-redo-ifchange venv-stamp ../shuffle/shuffle.py
-root=$(cd .. && pwd)
-cat > "$3" <<EOF
-#!/bin/sh
-exec "$root/.venv/bin/python" "$root/shuffle/shuffle.py" "\$@"
-EOF
-chmod +x "$3"
blob - 9fa3e3596f046517b7a9b186232ccc709a02069c (mode 644)
blob + /dev/null
--- bin/speediness.do
+++ /dev/null
-exec >&2
-redo-ifchange ../speediness/build.zig ../speediness/build.zig.zon $(find ../speediness/src -name '*.zig')
-(cd ../speediness && zig build -Doptimize=ReleaseSafe)
-cp ../speediness/zig-out/bin/speediness "$3"
blob - c51a12ccdf8fe21a8683d33fae4b3f0323710248 (mode 644)
blob + /dev/null
--- bin/venv-stamp.do
+++ /dev/null
-exec >&2
-redo-ifchange ../requirements.txt
-python3 -m venv ../.venv
-../.venv/bin/pip install --quiet --require-hashes -r ../requirements.txt
-sha256sum ../requirements.txt > "$3"
blob - 40ce77ec8a2d932ba532421de8b05aa2b8f083c2 (mode 644)
blob + /dev/null
--- bin/wrd.do
+++ /dev/null
-exec >&2
-redo-ifchange ../wrd/go.mod $(find ../wrd -name '*.go')
-case "$3" in
-/*) out=$3 ;;
-*) out=$PWD/$3 ;;
-esac
-(cd ../wrd && go build -o "$out" .)
blob - /dev/null
blob + 470a9d2fbe8cb274400e2916aa7169d44a728d57 (mode 644)
--- /dev/null
+++ knitfile
+knit = require("knit")
+
+root = knit.abs(".")
+
+cflags := -Wall -Wextra -O2 -march=native -mtune=native -fanalyzer -Wshadow -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fPIE -Wformat -Werror=format-security -Wnull-dereference -Wdangling-pointer -Wtrampolines -Walloca -Wcast-align=strict -Wdate-time -Wfloat-equal -Wpointer-arith -Wredundant-decls -Wswitch-default -Wvla -Wwrite-strings
+ldflags := -lmpdclient -Wl,-z,relro -Wl,-z,now
+cc := /usr/bin/cc
+
+hue_rb := hue/lib/hue.rb hue/lib/hue/bridge.rb hue/lib/hue/bulb.rb hue/lib/hue/cli.rb hue/lib/hue/colors.rb hue/lib/hue/animations/candle.rb hue/lib/hue/animations/sunrise.rb hue/lib/hue/cli/command.rb hue/lib/hue/colors/color.rb hue/lib/hue/colors/color_temperature.rb hue/lib/hue/colors/hue_saturation.rb hue/lib/hue/colors/rgb.rb hue/lib/hue/colors/xy.rb hue/lib/hue/config/abstract.rb hue/lib/hue/config/application.rb hue/lib/hue/config/bridge.rb hue/lib/hue/extensions/bridge.rb hue/lib/hue/extensions/bulb.rb hue/lib/hue/extensions/hue.rb hue/lib/hue/utilities/indentation.rb hue/lib/hue/cli/commands/delete.rb hue/lib/hue/cli/commands/light.rb hue/lib/hue/cli/commands/lights.rb hue/lib/hue/cli/commands/register.rb hue/lib/hue/cli/processors/light_state_alias.rb
+
+return b{
+$ bin/dam: Cargo.toml Cargo.lock rust-toolchain.toml dam/Cargo.toml $(knit.glob("dam/src/*.rs"))
+ cargo build --release -p dam
+ cp target/release/dam $output
+
+$ bin/lastfm_rs: Cargo.toml Cargo.lock rust-toolchain.toml lastfm_rs/Cargo.toml $(knit.glob("lastfm_rs/src/*.rs"))
+ cargo build --release -p lastfm_rs
+ cp target/release/lastfm_rs $output
+
+$ bin/plants: Cargo.toml Cargo.lock rust-toolchain.toml plants/Cargo.toml $(knit.glob("plants/src/*.rs"))
+ cargo build --release -p plants
+ cp target/release/plants $output
+
+$ bin/pmn: pmn/build.zig pmn/build.zig.zon $(knit.glob("pmn/src/*.zig"))
+ cd pmn && zig build -Doptimize=ReleaseSafe
+ cp pmn/zig-out/bin/pmn $output
+
+$ bin/pracomer: pracomer/build.zig pracomer/build.zig.zon $(knit.glob("pracomer/src/*.zig"))
+ cd pracomer && zig build -Doptimize=ReleaseSafe
+ cp pracomer/zig-out/bin/pracomer $output
+
+$ bin/speediness: speediness/build.zig speediness/build.zig.zon $(knit.glob("speediness/src/*.zig"))
+ cd speediness && zig build -Doptimize=ReleaseSafe
+ cp speediness/zig-out/bin/speediness $output
+
+$ bin/wrd: wrd/go.mod $(knit.glob("wrd/*.go"))
+ cd wrd && go build -o $(root)/$output .
+
+$ bin/mpd_add_to_playlist: mpd/mpd_add_to_playlist.c
+ $cc $cflags -o $output $input $ldflags
+
+$ bin/mpd_add_to_queue: mpd/mpd_add_to_queue.c
+ $cc $cflags -o $output $input $ldflags
+
+$ bin/mpd_edit_queue: mpd/mpd_edit_queue.c
+ $cc $cflags -o $output $input $ldflags
+
+$ bin/mpd_update_library: mpd/mpd_update_library.c
+ $cc $cflags -o $output $input $ldflags
+
+$ bin/mpd_update_queue: mpd/mpd_update_queue.c
+ $cc $cflags -o $output $input $ldflags
+
+$ .venv-stamp: requirements.txt
+ python3 -m venv .venv
+ .venv/bin/pip install --quiet --require-hashes -r requirements.txt
+ sha256sum requirements.txt > $output
+
+$ bin/diggah: .venv-stamp diggah/diggah.py
+ printf '#!/bin/sh\nexec "%s/.venv/bin/python" "%s/diggah/diggah.py" "$$@"\n' $root $root > $output
+ chmod +x $output
+
+$ bin/kundali: .venv-stamp kundali/kundali.py
+ printf '#!/bin/sh\nexec "%s/.venv/bin/python" "%s/kundali/kundali.py" "$$@"\n' $root $root > $output
+ chmod +x $output
+
+$ bin/lazymaster: .venv-stamp lazymaster/lazymaster.py
+ printf '#!/bin/sh\nexec "%s/.venv/bin/python" "%s/lazymaster/lazymaster.py" "$$@"\n' $root $root > $output
+ chmod +x $output
+
+$ bin/nts: .venv-stamp nts/nts.py
+ printf '#!/bin/sh\nexec "%s/.venv/bin/python" "%s/nts/nts.py" "$$@"\n' $root $root > $output
+ chmod +x $output
+
+$ bin/shuffle: .venv-stamp shuffle/shuffle.py
+ printf '#!/bin/sh\nexec "%s/.venv/bin/python" "%s/shuffle/shuffle.py" "$$@"\n' $root $root > $output
+ chmod +x $output
+
+$ bin/hue: hue/bin/hue $hue_rb
+ printf '#!/bin/sh\nexec ruby -I"%s/hue/lib" "%s/hue/bin/hue" "$$@"\n' $root $root > $output
+ chmod +x $output
+
+$ bin/reflink-snap: reflink-snap/reflink-snap.rb
+ printf '#!/bin/sh\nexec ruby "%s/reflink-snap/reflink-snap.rb" "$$@"\n' $root > $output
+ chmod +x $output
+
+$ all:VB: bin/dam bin/lastfm_rs bin/plants \
+ bin/pmn bin/pracomer bin/speediness \
+ bin/wrd \
+ bin/mpd_add_to_playlist bin/mpd_add_to_queue bin/mpd_edit_queue \
+ bin/mpd_update_library bin/mpd_update_queue \
+ bin/diggah bin/lazymaster bin/nts bin/shuffle bin/kundali \
+ bin/hue bin/reflink-snap
+}
blob - 990076b8d8a33b648cbdc7daad015cd4cbfaf95f
blob + c431e972f2bea551cee2dd3b6b9584e3a2dc1ce0
--- justfile
+++ justfile
-redo := "redo"
+knit := "knit"
cargo := "cargo"
deploy_dir := home_directory() / ".local/bin"
# Build every tool
all:
- {{ redo }} all
+ {{ knit }} all
# Build one or more tools, e.g. just build lazymaster
build +targets:
- {{ redo }} {{ "bin/" + replace(targets, " ", " bin/") }}
+ {{ knit }} {{ "bin/" + replace(targets, " ", " bin/") }}
# Build and run a tool
run target *args:
- @{{ redo }} bin/{{ target }} && ./bin/{{ target }} {{ args }}
+ @{{ knit }} bin/{{ target }} && ./bin/{{ target }} {{ args }}
# Build and copy tools to ~/.local/bin
deploy +targets:
@for target in {{ targets }}; do \
case "$target" in mpd) bins="{{ mpd_bins }}" ;; *) bins="$target" ;; esac; \
for bin in $bins; do \
- {{ redo }} bin/"$bin" && \
+ {{ knit }} bin/"$bin" && \
install -m 755 bin/"$bin" {{ deploy_dir }}/ && \
echo "deployed $bin to {{ deploy_dir }}"; \
done; \
# Update `requirements.txt` lockfile from requirements.in
pip-update:
- {{ redo }} bin/venv-stamp
+ {{ knit }} .venv-stamp
.venv/bin/pip install --quiet pip-tools
.venv/bin/pip-compile --generate-hashes --strip-extras requirements.in -o requirements.txt
clean:
{{ cargo }} clean
for dir in pmn pracomer speediness; do rm -rf "$dir"/zig-out "$dir"/.zig-cache; done
- find bin -type f ! -name '*.do' -delete
- rm -rf .venv .redo
+ find bin -type f -delete
+ rm -rf .venv .knit .venv-stamp