From: Ian Rogers Date: Mon, 9 Oct 2023 18:39:02 +0000 (-0700) Subject: gen_compile_commands: Allow the line prefix to still be cmd_ X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=52c15e7e792857c42b4a926e45228e981c5a5f13;p=linux.git gen_compile_commands: Allow the line prefix to still be cmd_ Builds in tools still use the cmd_ prefix in .cmd files, so don't require the saved part. Name the groups in the line pattern match so that changing the regular expression is more robust and works with the addition of a new match group. Signed-off-by: Ian Rogers Reviewed-by: Nick Desaulniers Cc: Ravi Bangoria Cc: Mark Rutland Cc: Yang Jihong Cc: Peter Zijlstra Cc: Adrian Hunter Cc: Arnaldo Carvalho de Melo Cc: Huacai Chen Cc: Jiri Olsa Cc: Nathan Chancellor Cc: Alexander Shishkin Cc: Kan Liang Cc: llvm@lists.linux.dev Cc: Ming Wang Cc: Ingo Molnar Cc: Tom Rix Cc: bpf@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-perf-users@vger.kernel.org Link: https://lore.kernel.org/r/20231009183920.200859-2-irogers@google.com Signed-off-by: Namhyung Kim --- diff --git a/scripts/clang-tools/gen_compile_commands.py b/scripts/clang-tools/gen_compile_commands.py index a84cc5737c2c6..b43f9149893ca 100755 --- a/scripts/clang-tools/gen_compile_commands.py +++ b/scripts/clang-tools/gen_compile_commands.py @@ -19,7 +19,7 @@ _DEFAULT_OUTPUT = 'compile_commands.json' _DEFAULT_LOG_LEVEL = 'WARNING' _FILENAME_PATTERN = r'^\..*\.cmd$' -_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.[cS]) *(;|$)' +_LINE_PATTERN = r'^(saved)?cmd_[^ ]*\.o := (?P.* )(?P[^ ]*\.[cS]) *(;|$)' _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. @@ -213,8 +213,8 @@ def main(): result = line_matcher.match(f.readline()) if result: try: - entry = process_line(directory, result.group(1), - result.group(2)) + entry = process_line(directory, result.group('command_prefix'), + result.group('file_path')) compile_commands.append(entry) except ValueError as err: logging.info('Could not add line from %s: %s',