From: Masahiro Yamada Date: Thu, 19 Aug 2021 00:57:33 +0000 (+0900) Subject: gen_compile_commands: extract compiler command from a series of commands X-Git-Tag: microblaze-v5.16~99^2~9 X-Git-Url: http://git.monstr.eu/?p=linux-2.6-microblaze.git;a=commitdiff_plain;h=265264b814c2121513eab2e1cffe196502af0961 gen_compile_commands: extract compiler command from a series of commands The current gen_compile_commands.py assumes that objects are always built by a single command. It makes sense to support cases where objects are built by a series of commands: cmd_ := ; One use-case is that is a compiler command, and an objtool command. It allows *.cmd files to contain an objtool command so that any change in it triggers object rebuilds. If ; appears after the C source file, take the first command. Signed-off-by: Masahiro Yamada Reviewed-by: Kees Cook --- diff --git a/scripts/clang-tools/gen_compile_commands.py b/scripts/clang-tools/gen_compile_commands.py index b7e9ecf16e56..0033eedce003 100755 --- a/scripts/clang-tools/gen_compile_commands.py +++ b/scripts/clang-tools/gen_compile_commands.py @@ -18,7 +18,7 @@ _DEFAULT_OUTPUT = 'compile_commands.json' _DEFAULT_LOG_LEVEL = 'WARNING' _FILENAME_PATTERN = r'^\..*\.cmd$' -_LINE_PATTERN = r'^cmd_[^ ]*\.o := (.* )([^ ]*\.c)$' +_LINE_PATTERN = r'^cmd_[^ ]*\.o := (.* )([^ ]*\.c) *(;|$)' _VALID_LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] # The tools/ directory adopts a different build system, and produces .cmd # files in a different format. Do not support it.