Skip to content

Commit fb71845

Browse files
committed
Add tools/check-headers.sh to check whether headers are self-contained
1 parent 88be4e8 commit fb71845

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,21 @@ jobs:
738738
g++ -Werror include/*.h
739739
clang -Werror -x c++-header include/*.h
740740
741+
headers:
742+
name: "Self-contained headers"
743+
runs-on: ubuntu-latest
744+
745+
steps:
746+
- name: Checkout
747+
uses: actions/checkout@v5
748+
749+
- name: Test script
750+
run: |
751+
./tools/check-headers.sh \
752+
src/field.h \
753+
src/hash.h \
754+
src/hash_impl.h
755+
741756
sage:
742757
name: "SageMath prover"
743758
runs-on: ubuntu-latest

tools/check-headers.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
builddir=$(mktemp -d)
6+
trap 'rm -rf "$builddir"' EXIT INT TERM
7+
8+
for header in "$@"; do
9+
source_file="${builddir}/${header%.h}.c"
10+
object_file="${builddir}/${header%.h}.o"
11+
mkdir -p "$(dirname "$source_file")"
12+
cp "$header" "$source_file"
13+
14+
cc -I include -I src -c "$source_file" -o "$object_file"
15+
exit_code=$?
16+
if [ $exit_code -ne 0 ]; then
17+
exit $exit_code
18+
fi
19+
20+
echo "$header... OK"
21+
done

0 commit comments

Comments
 (0)