Skip to content

Instantly share code, notes, and snippets.

@izabera
Created December 4, 2024 08:29
Show Gist options
  • Save izabera/1d8f5e66fd523247e465eb125db8d832 to your computer and use it in GitHub Desktop.
Save izabera/1d8f5e66fd523247e465eb125db8d832 to your computer and use it in GitHub Desktop.
dumb "build system" in 10 lines of posix sh
#!/usr/bin/env dumb
input fentry.cpp count.hpp
output fentry.o
cmd clang++ -std=c++17 -ggdb3 -fPIC -mgeneral-regs-only -c fentry.cpp
input count.cpp count.hpp
output count.o
cmd clang++ -std=c++17 -ggdb3 -fPIC -c count.cpp
input count.o fentry.o
output count.so
cmd clang++ -std=c++17 -ggdb3 -fPIC -shared -fvisibility=hidden count.o fentry.o -o count.so
input user.cpp
output user
cmd clang++ -std=c++17 -ggdb3 -pg -mfentry user.cpp -o user -fsanitize=address
#!/bin/sh -f
input() { in=$*; }
output() { out=; for i do out="$out -o -newer $i"; done; }
cmd() {
if ! find -L $in -prune \( ${out# -o } \) -exec false {} + 2>/dev/null; then
echo cmd: $@ >&2
$@ || { e=$?; rm -f $out; exit $e; }
fi
}
for i in ${@-./build.dumb}; do . $i; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment