Skip to content

Commit e63b5d4

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

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,18 @@ 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@v4
748+
749+
- name: Test script
750+
run: |
751+
./tools/check_header.sh src/field.h
752+
741753
sage:
742754
name: "SageMath prover"
743755
runs-on: ubuntu-latest

tools/check_header.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
set -u
4+
5+
for header in "$@"; do
6+
source_file=${header%.h}.c
7+
object_file=${header%.h}.o
8+
mv "$header" "$source_file"
9+
gcc -c "$source_file" -o "$object_file"
10+
exit_code=$?
11+
mv "$source_file" "$header"
12+
if [ $exit_code -ne 0 ]; then
13+
exit $exit_code
14+
fi
15+
echo "$header... OK"
16+
done

0 commit comments

Comments
 (0)