Skip to content

Commit 451e715

Browse files
committed
validate_headers.sh works with any include directory provided as an argument
1 parent 802d008 commit 451e715

5 files changed

Lines changed: 20 additions & 20 deletions

File tree

.github/workflows/build-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,4 @@ jobs:
9494
if: matrix.group == 'ffi' && inputs.os == 'ubuntu-latest'
9595
run: |
9696
sudo apt update && sudo apt install -y build-essential
97-
bash ffi-c-tests/validate-headers.sh
97+
bash ffi-c-tests/validate-headers.sh ./target/llvm-cov-target/debug/include
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#include "../../target/llvm-cov-target/debug/include/dash-spv-ffi/dash-spv-ffi.h"
1+
#include "dash-spv-ffi/dash-spv-ffi.h"
22

3-
int main() {
4-
5-
return 0;
6-
}
3+
int main() { return 0; }
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#include "../../target/llvm-cov-target/debug/include/key-wallet-ffi/key-wallet-ffi.h"
1+
#include "key-wallet-ffi/key-wallet-ffi.h"
22

3-
int main() {
4-
5-
return 0;
6-
}
3+
int main() { return 0; }
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
#include "../../target/llvm-cov-target/debug/include/dash-spv-ffi/dash-spv-ffi.h"
2-
#include "../../target/llvm-cov-target/debug/include/key-wallet-ffi/key-wallet-ffi.h"
1+
#include "dash-spv-ffi/dash-spv-ffi.h"
2+
#include "key-wallet-ffi/key-wallet-ffi.h"
33

4-
int main() {
5-
6-
return 0;
7-
}
4+
int main() { return 0; }

ffi-c-tests/validate-headers.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,22 @@ NC='\033[0m'
88
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
99
HEADER_TESTS_DIR="$SCRIPT_DIR/header-tests"
1010

11-
# Move to ffi-c-tests directory, where the script lives, and run tests
12-
cd "$SCRIPT_DIR" || exit 1
11+
if [ $# -lt 1 ]; then
12+
echo "Usage: $0 <include_dir>"
13+
exit 1
14+
fi
15+
16+
INCLUDE_DIR="$1"
17+
18+
if [ ! -d "$INCLUDE_DIR" ]; then
19+
echo "Error: INCLUDE_DIR '$INCLUDE_DIR' does not exist or is not a directory."
20+
exit 1
21+
fi
1322

1423
EXIT_CODE=0
1524

1625
for file in "$HEADER_TESTS_DIR"/*.c; do
17-
if gcc -c "$file" -o /dev/null; then
26+
if gcc -c "$file" -I"$INCLUDE_DIR" -o /dev/null; then
1827
echo -e "${GREEN}Passed: $file${NC}"
1928
else
2029
echo -e "${RED}Failed: $file${NC}"

0 commit comments

Comments
 (0)