Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions compdb/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import subprocess
import tempfile


if __name__ == "__main__":
##
## Setup Args
Expand Down Expand Up @@ -61,21 +60,16 @@
local_exec_root = event['workspaceInfo']['localExecRoot']
print('Execution Root:', local_exec_root)

compile_command_json_db_files = []
compile_command_json_db_files = set()
for line in bazel_stderr:
if line.endswith('.compile_commands.json'):
compile_command_json_db_files.append(line.strip())
compile_command_json_db_files.add(line.strip())

##
## Collect/Fix/Merge Compilation Databases
##
print("Preparing compilation database...")

db_entries = []
for db in compile_command_json_db_files:
with open(db, 'r') as f:
db_entries.extend(json.load(f))

print("Preparing compilation database...")
def fix_db_entry(db_entry):
if 'directory' in db_entry and db_entry['directory'] == '__EXEC_ROOT__':
db_entry['directory'] = bazel_workspace if args.source_dir else local_exec_root
Expand All @@ -90,7 +84,11 @@ def fix_db_entry(db_entry):
command = command.replace('-iquote', '-I')
db_entry['command'] = command
return db_entry
db_entries = list(map(fix_db_entry, db_entries))

db_entries = []
for db in compile_command_json_db_files:
with open(db, 'r') as f:
db_entries.extend(list(map(fix_db_entry, json.load(f))))

compdb_file = os.path.join(workspace_directory, "compile_commands.json")

Expand Down