Make clang_compilation_database add-on always output complete listings.

This commit is contained in:
DragoonX6 2017-02-16 20:30:30 +01:00 committed by Thomas Nagy
parent acd41beef1
commit 0c541f606a
1 changed files with 21 additions and 0 deletions

View File

@ -66,3 +66,24 @@ def write_compilation_database(ctx):
root = list(clang_db.values())
database_file.write(json.dumps(root, indent=2))
# Override the runnable_status function to do a dummy/dry run when the file doesn't need to be compiled.
# This will make sure compile_commands.json is always fully up to date.
# Previously you could end up with a partial compile_commands.json if the build failed.
for x in ('c', 'cxx'):
t = Task.classes[x]
def runnable_status(self):
def exec_command(cmd, **kw):
pass
run_status = self.old_runnable_status()
if run_status == Task.SKIP_ME:
setattr(self, 'old_exec_command', getattr(self, 'exec_command', None))
setattr(self, 'exec_command', exec_command)
self.run()
setattr(self, 'exec_command', getattr(self, 'old_exec_command', None))
return run_status
setattr(t, 'old_runnable_status', getattr(t, 'runnable_status', None))
setattr(t, 'runnable_status', runnable_status)