Skip to content

Commit 0f0af8c

Browse files
committed
wip awk cpp handler
1 parent 29a1b84 commit 0f0af8c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,20 @@ fi
150150
# add preprocessor flags
151151
comp+=("$CPPFLAGS")
152152

153+
# run c preprocessor
154+
# (strip shebang line)
155+
# 2025-10-06 currently breaks on C++ files (cannot recognize w/o extension)
156+
cpp() {
157+
local -r file="$1"
158+
if test -f "$file"; then
159+
awk '!(NR == 1 && /^#!/)' "$file" | command cpp -
160+
fi
161+
}
162+
153163
# hash all of our data
154164
prehash="$CC ${comp[*]}" # compiler + flags and files
155-
for f in "${comp[@]}"; do
156-
[ -f "$f" ] && prehash+="$f $(cpp "$f" 2>&1)"
165+
for file in "${comp[@]}"; do
166+
prehash+="$file $(cpp "$file")"
157167
done
158168

159169
# hash everything into one unique identifier, for caching purposes

0 commit comments

Comments
 (0)