File tree Expand file tree Collapse file tree 3 files changed +59
-1
lines changed Expand file tree Collapse file tree 3 files changed +59
-1
lines changed Original file line number Diff line number Diff line change 1+ name : Precompile Checks
2+
3+ on :
4+ push :
5+ branches :
6+ - master
7+ paths : ['**/*.c', '**/*.cpp']
8+ pull_request :
9+ types : [opened, synchronize, reopened]
10+ paths : ['**/*.c', '**/*.cpp']
11+
12+ jobs :
13+ precompile-check :
14+ runs-on : ubuntu-latest
15+
16+ steps :
17+ - name : Checkout Repository
18+ uses : actions/checkout@v4
19+
20+ - name : Run Forbidden Includes Check
21+ run : bash scripts/precompile-checks.sh
Original file line number Diff line number Diff line change @@ -211,7 +211,7 @@ ifdef GGML_VULKAN
211211 BUILD_TARGETS += vulkan-shaders-gen
212212endif
213213
214- default : $(BUILD_TARGETS ) $(LEGACY_TARGETS_BUILD )
214+ default : precompile_checks $(BUILD_TARGETS ) $(LEGACY_TARGETS_BUILD )
215215
216216test : $(TEST_TARGETS )
217217 @failures=0; \
@@ -248,6 +248,10 @@ test: $(TEST_TARGETS)
248248
249249all : $(BUILD_TARGETS ) $(TEST_TARGETS ) $(LEGACY_TARGETS_BUILD )
250250
251+ # Run the forbidden includes check before every build
252+ precompile_checks :
253+ @bash ./scripts/precompile-checks.sh
254+
251255ifdef RISCV_CROSS_COMPILE
252256CC := riscv64-unknown-linux-gnu-gcc
253257CXX := riscv64-unknown-linux-gnu-g++
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # This runs some pre compilation sanity checks that certain project rules and guidelines are kept
4+ # This will not contain any signifiant logic, but mostly just obvious and easily greppable checks
5+
6+ ERROR_FOUND=0
7+
8+
9+ # # START OF INCLUDES EXCLUDED FROM EXAMPLES FOLDER ##
10+ SRC_DIR=" ./examples"
11+ FORBIDDEN_HEADERS=(" llama-impl.h" )
12+ echo " 🔍 Scanning for forbidden includes in $SRC_DIR ..."
13+ for HEADER in " ${FORBIDDEN_HEADERS[@]} " ; do
14+ MATCHES=$( grep -rn --include=\* .{c,cpp} " #include \" $HEADER \" " " $SRC_DIR " 2> /dev/null)
15+
16+ if [[ -n " $MATCHES " ]]; then
17+ echo " ❌ Forbidden include detected: $HEADER "
18+ echo " $MATCHES " | while IFS=: read -r FILE LINE _; do
19+ echo " ::error file=$FILE ,line=$LINE ::Forbidden include: $HEADER in $FILE at line $LINE "
20+ done
21+ ERROR_FOUND=1
22+ fi
23+
24+ done
25+ # # END OF INCLUDES EXCLUDED FROM EXAMPLES FOLDER ##
26+
27+
28+ if [[ " $ERROR_FOUND " -eq 1 ]]; then
29+ echo " ❌ Forbidden includes found. Please remove!"
30+ exit 1
31+ else
32+ echo " ✅ No forbidden includes found."
33+ fi
You can’t perform that action at this time.
0 commit comments