diff options
author | EuAndreh <eu@euandre.org> | 2021-09-07 11:50:44 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2021-09-07 11:50:44 -0300 |
commit | 4c3879e2a2b3b6bc13638e3614fe1a733c7046d1 (patch) | |
tree | c5f36afca413937947607b822d8b25423135bb69 | |
parent | Makefile: Indent target dependencies (diff) | |
download | gistatic-4c3879e2a2b3b6bc13638e3614fe1a733c7046d1.tar.gz gistatic-4c3879e2a2b3b6bc13638e3614fe1a733c7046d1.tar.xz |
aux/prune-includes.sh: WIP version of brute force "#include" pruner
-rwxr-xr-x | aux/prune-includes.sh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/aux/prune-includes.sh b/aux/prune-includes.sh new file mode 100755 index 0000000..3a10fa2 --- /dev/null +++ b/aux/prune-includes.sh @@ -0,0 +1,24 @@ +#!/bin/sh +set -eu + +. aux/lib.sh + +prune() { + file="$1" + lines="$(grep -n '^#include ' "$file" | cut -d: -f1)" + ORIG="$(mkstemp)" + cp "$file" "$ORIG" + for line in $lines; do + sed "${line}d" "$ORIG" > "$file" + if make -e; then + prune "$file" + break + else + cp "$ORIG" "$file" + fi + done +} + +for f in "$@"; do + prune "$f" +done |