Skip to content

Commit 4a906fe

Browse files
author
Dane Springmeyer
committed
ensure we only generate compile commands for a correct match
1 parent 3bfd077 commit 4a906fe

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

scripts/generate_compile_commands.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import re
77

88
# Script to generate compile_commands.json based on Makefile output
9-
# Works by accepting Makefile output from stdin, parsing it, and
9+
# Works by accepting Makefile output from stdin, parsing it, and
1010
# turning into json records. These are then printed to stdout.
1111
# More details on the compile_commands format at:
1212
# https://clang.llvm.org/docs/JSONCompilationDatabase.html
@@ -28,11 +28,12 @@ def generate():
2828
for line in sys.stdin.readlines():
2929
if TOKEN_DENOTING_COMPILED_FILE in line:
3030
match = matcher.match(line)
31-
compile_commands.append({
32-
"directory": build_dir,
33-
"command": line.strip(),
34-
"file": os.path.normpath(os.path.join(build_dir,match.group(2)))
35-
})
31+
if match:
32+
compile_commands.append({
33+
"directory": build_dir,
34+
"command": line.strip(),
35+
"file": os.path.normpath(os.path.join(build_dir,match.group(2)))
36+
})
3637
print(json.dumps(compile_commands,indent=4))
3738

3839
if __name__ == '__main__':

0 commit comments

Comments
 (0)