33
44scriptDir=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd )
55
6+ # Parse inputs
7+ special_case_build=0
8+ tolerate_ccmram_overflow=0
9+ if [ " $1 " == " --tolerate-ccmram-overflow" ]; then
10+ special_case_build=1
11+ tolerate_ccmram_overflow=1
12+ shift
13+ fi
14+
615${scriptDir} /test " ${@ } "
716${scriptDir} /test_python " ${@ } "
8- ${scriptDir} /make " ${@ } "
9- ${scriptDir} /check_elf
17+
18+ if [ ${special_case_build} -eq 0 ]; then
19+ ${scriptDir} /make " ${@ } "
20+ ${scriptDir} /check_elf
21+ exit 0
22+ elif [ ${tolerate_ccmram_overflow} -eq 1 ]; then
23+ # Only issue a warning for CCMRAM overflow
24+
25+ # Catch build output
26+ set +e
27+ build_log=$( ${scriptDir} /make " ${@ } " 2>&1 )
28+ build_status=$?
29+ set -e
30+ printf ' %s\n' " ${build_log} "
31+
32+ if [ ${build_status} -eq 0 ]; then
33+ ${scriptDir} /check_elf
34+ exit 0
35+ fi
36+
37+ # Check for CCMRAM overflow
38+ overflow_line=$( grep " region \` CCMRAM' overflowed" <<< " ${build_log}" || true)
39+ if [ -z " ${overflow_line} " ]; then
40+ exit ${build_status}
41+ fi
42+
43+ # Confirm the overflow is the *only* problem: any other linker diagnostic or
44+ # compile error means a real regression is hiding alongside it.
45+ ld_lines=$( grep -E " arm-none-eabi/bin/ld:" <<< " ${build_log}" || true)
46+ unexpected_ld_lines=$( grep -v -E " will not fit in region \` CCMRAM'|region \` CCMRAM' overflowed by [0-9]+ bytes" <<< " ${ld_lines}" || true)
47+ compile_errors=$( grep -E " : error:" <<< " ${build_log}" | grep -v -F " collect2: error: ld returned 1 exit status" || true)
48+
49+ if [ -n " ${unexpected_ld_lines} " ] || [ -n " ${compile_errors} " ]; then
50+ exit ${build_status}
51+ fi
52+
53+ overflow_bytes=$( sed -n " s/.*region \` CCMRAM' overflowed by \([0-9]*\) bytes.*/\1/p" <<< " ${overflow_line}" | head -1)
54+ echo " ::warning::kbuild-targets (allyesconfig): CCMRAM overflow, by ${overflow_bytes} bytes — check_elf skipped, no .elf was produced."
55+
56+ exit 0
57+ else
58+ echo " Uknown special case build."
59+ exit 1
60+ fi
0 commit comments