Created
December 4, 2024 08:29
-
-
Save izabera/1d8f5e66fd523247e465eb125db8d832 to your computer and use it in GitHub Desktop.
dumb "build system" in 10 lines of posix sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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