@@ -346,21 +346,76 @@ compile_devicetree() {
346
346
}
347
347
348
348
compile_kernel () {
349
+ local tmp_log_file=.ci_compile_kernel_log
349
350
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.
350
361
351
362
echo " compile kernel"
352
363
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
356
389
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]}
358
401
359
402
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
360
411
set_step_fail " kernel"
361
412
fi
362
413
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
364
419
365
420
return $err
366
421
}
0 commit comments