From 70616f2b7d60bd1f090ea9dd2cab871b8107f5c1 Mon Sep 17 00:00:00 2001 From: DragoonX6 Date: Thu, 16 Feb 2017 20:30:30 +0100 Subject: [PATCH] Make clang_compilation_database add-on always output complete listings. --- waflib/extras/clang_compilation_database.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/waflib/extras/clang_compilation_database.py b/waflib/extras/clang_compilation_database.py index 98bf59fe..4e13d417 100644 --- a/waflib/extras/clang_compilation_database.py +++ b/waflib/extras/clang_compilation_database.py @@ -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) +