Commit 52c15e7e authored by Ian Rogers's avatar Ian Rogers Committed by Namhyung Kim

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: default avatarIan Rogers <irogers@google.com>
Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: llvm@lists.linux.dev
Cc: Ming Wang <wangming01@loongson.cn>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Tom Rix <trix@redhat.com>
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.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
parent b20576fd
...@@ -19,7 +19,7 @@ _DEFAULT_OUTPUT = 'compile_commands.json' ...@@ -19,7 +19,7 @@ _DEFAULT_OUTPUT = 'compile_commands.json'
_DEFAULT_LOG_LEVEL = 'WARNING' _DEFAULT_LOG_LEVEL = 'WARNING'
_FILENAME_PATTERN = r'^\..*\.cmd$' _FILENAME_PATTERN = r'^\..*\.cmd$'
_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.[cS]) *(;|$)' _LINE_PATTERN = r'^(saved)?cmd_[^ ]*\.o := (?P<command_prefix>.* )(?P<file_path>[^ ]*\.[cS]) *(;|$)'
_VALID_LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] _VALID_LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']
# The tools/ directory adopts a different build system, and produces .cmd # The tools/ directory adopts a different build system, and produces .cmd
# files in a different format. Do not support it. # files in a different format. Do not support it.
...@@ -213,8 +213,8 @@ def main(): ...@@ -213,8 +213,8 @@ def main():
result = line_matcher.match(f.readline()) result = line_matcher.match(f.readline())
if result: if result:
try: try:
entry = process_line(directory, result.group(1), entry = process_line(directory, result.group('command_prefix'),
result.group(2)) result.group('file_path'))
compile_commands.append(entry) compile_commands.append(entry)
except ValueError as err: except ValueError as err:
logging.info('Could not add line from %s: %s', logging.info('Could not add line from %s: %s',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment