Skip to content

Commit b599d7f

Browse files
committed
ci: Problem match kernel compile
If the step exits with an error, log the problem match, if not, do not since it would result in unrelated and duplicated warnings Signed-off-by: Jorge Marques <jorge.marques@analog.com>
1 parent feb07c1 commit b599d7f

File tree

1 file changed

+60
-5
lines changed

1 file changed

+60
-5
lines changed

‎ci/build.sh

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,21 +346,76 @@ compile_devicetree() {
346346
}
347347

348348
compile_kernel() {
349+
local tmp_log_file=.ci_compile_kernel_log
349350
local err=0
351+
local regex='^[[:alnum:]/._-]+:[[:digit:]]+:[[:digit:]]+: .*$'
352+
local fail=0
353+
local warn=0
354+
local msg=
355+
356+
# At this step, we only problem match if it exits with an error code
357+
# because we don't want duplicated errors/warnings on sparse,
358+
# neither warnings unrelated to the patch, but if the kernel
359+
# does not even compile, the checkers don't run and the reason
360+
# is at this step.
350361

351362
echo "compile kernel"
352363

353-
# At this step, we don't problem match
354-
# because we don't want duplicated errors/warnings on sparse,
355-
# neither warnings unrelated to the patch
364+
echo > $tmp_log_file
365+
yes n 2>/dev/null | \
366+
make -j$(nproc) 2>&1 | \
367+
(while IFS= read -r row; do
368+
echo $row
369+
if [[ "$row" =~ $regex ]]; then
370+
if [[ "$found" == "1" ]]; then
371+
echo $msg >> $tmp_log_file
372+
msg=
373+
fi
374+
375+
found=0
376+
IFS=':' read -r -a list <<< "$row"
377+
378+
file=$(echo ${list[0]} | xargs)
379+
line=${list[1]}
380+
col=${list[2]}
381+
type=$(echo ${list[3]} | xargs)
382+
msg_=${list[4]}
383+
384+
if [[ "$type" == "warning" ]]; then
385+
warn=1
386+
elif [[ "$type" == "error" ]]; then
387+
fail=1
388+
fi
356389

357-
yes n 2>/dev/null | make -j$(nproc) C=1 ; err=$?
390+
if [[ ! "$type" == "note" ]]; then
391+
found=1
392+
msg="::$type file=$file,line=$line,col=$col::$msg_"
393+
fi
394+
395+
else
396+
if [[ $found == "1" ]]; then
397+
msg=${msg}%0A${row}
398+
fi
399+
fi
400+
done) ; err=${PIPESTATUS[1]}
358401

359402
if [[ $err -ne 0 ]]; then
403+
while read -r line; do
404+
echo $line
405+
done <$tmp_log_file
406+
fail=1
407+
fi
408+
rm $tmp_log_file
409+
410+
if [[ "$fail" == "1" ]]; then
360411
set_step_fail "kernel"
361412
fi
362413

363-
python3.11 scripts/clang-tools/gen_compile_commands.py
414+
if [[ "$warn" == "1" ]]; then
415+
set_step_warn "kernel"
416+
fi
417+
418+
python3.11 scripts/clang-tools/gen_compile_commands.py
364419

365420
return $err
366421
}

0 commit comments

Comments
 (0)