Skip to content

Commit

Permalink
tools: improve include_check
Browse files Browse the repository at this point in the history
allow files matching a regex to be skipped (or webauthn.h will
always fail, since it is vendored), and use a safer construction
when looping over header files. while here, adjust the output to be
slightly more useful.
  • Loading branch information
martelletto committed Jun 17, 2024
1 parent 8baf44f commit f0f551c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tools/include_check.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
#!/bin/sh
#!/bin/sh -u

# Copyright (c) 2019 Yubico AB. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# SPDX-License-Identifier: BSD-2-Clause

SKIP='(webauthn.h)'

check() {
for f in $(find $1 -maxdepth 1 -name '*.h'); do
echo "#include \"$f\"" | \
cc $CFLAGS -Isrc -xc -c - -o /dev/null 2>&1
echo "$f $CFLAGS $?"
try="cc $CFLAGS -Isrc -xc -c - -o /dev/null 2>&1"
git ls-files "$1" | grep '.*\.h$' | while read -r header; do
if echo "$header" | grep -Eq "$SKIP"; then
echo "Skipping $header"
else
body="#include \"$header\""
echo "echo $body | $try"
echo "$body" | eval "$try"
fi
done
}

Expand Down

0 comments on commit f0f551c

Please sign in to comment.