From 15f95e592b280dcb312aae5bf0e7696e845a2e6f Mon Sep 17 00:00:00 2001 From: Christophe De Wagter Date: Sat, 15 Jun 2024 22:08:03 +0200 Subject: [PATCH] Summary of compile errors (#3314) --- Makefile | 9 ++++- sw/tools/parse_compile_logs.py | 69 ++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100755 sw/tools/parse_compile_logs.py diff --git a/Makefile b/Makefile index a8a95059ed..667fdcfbce 100644 --- a/Makefile +++ b/Makefile @@ -304,7 +304,8 @@ test: test_math test_examples test_modules # subset of airframes for coverity test to pass the limited build time on travis test_coverity: all - CONF_XML=conf/conf_tests_coverity.xml prove tests/aircrafts/ + CONF_XML=conf/conf_tests_coverity.xml prove tests/aircrafts/ 2>&1 | tee ./var/compile.log + python ./sw/tools/parse_compile_logs.py # test AggieAir conf test_aggieair: all @@ -345,6 +346,12 @@ test_all_confs: all opencv_bebop test_math: make -C tests/math +test_full: + make -C ./ test_all_confs 2>&1 | tee ./var/compile.log + python ./sw/tools/parse_compile_logs.py | tee ./issues.md + + + .PHONY: all print_build_version _print_building _save_build_version init dox ground_segment ground_segment.opt \ subdirs $(SUBDIRS) conf ext libpprz libpprzlink.update libpprzlink.install cockpit cockpit.opt tmtc tmtc.opt generators\ static sim_static opencv_bebop\ diff --git a/sw/tools/parse_compile_logs.py b/sw/tools/parse_compile_logs.py new file mode 100755 index 0000000000..19a6920e58 --- /dev/null +++ b/sw/tools/parse_compile_logs.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python + +# Parse compiler logs and generate a summary of the errors and warnings +# Load log file from var/compiler.log + +import os +import sys +import re + +def parse_log(log_file): + with open(log_file, 'r') as f: + lines = f.readlines() + + errors = [] + conf = '' + airframe = '' + module = '' + + for line in lines: + if 'Testing all aircrafts in conf: ' in line: + conf = line.split('Testing all aircrafts in conf: ')[1].strip() + #print(conf) + elif 'tests/modules/test_modules.py' in line: + conf = 'modules' + elif 'compiling AIRCRAFT: [' in line: + airframe = line.split('compiling AIRCRAFT: [')[1].strip().strip(']').replace('] TARGET: [', ' --- ' ) + #print('\t-',airframe) + if conf == 'modules': + if ('ok ' in line) and ('_0' in line): + airframe = line.strip() + + if conf and airframe: + if 'error:' in line: + errors.append((conf, airframe, line.strip())) + if 'warning:' in line: + errors.append((conf, airframe, line.strip())) + + return errors + +def print_errors(errors): + last_conf = '' + last_airframe = '' + if len(errors) == 0: + print(' - everything looks OK!') + return + for conf, airframe, error in errors: + if conf != last_conf: + print('') + print(conf+':') + print('-' * len(conf)) + last_conf = conf + last_airframe = '' + + if airframe != last_airframe: + print(' - ',airframe) + last_airframe = airframe + + print('\t- [ ] ```',error, '```') + + +if __name__ == '__main__': + print('=========================') + print('|| SUMMARY ||') + print('=========================') + log_file = './var/compile.log' + errors = parse_log(log_file) + print_errors(errors) + +