diff --git a/bear/main.py.in b/bear/main.py.in index 973f7cf7..48b5f504 100644 --- a/bear/main.py.in +++ b/bear/main.py.in @@ -530,13 +530,22 @@ class Compilation: """ This method creates a compilation database entry. """ source = os.path.relpath(self.source, self.directory) - output = ['-o', self.output] if self.output else [] - return { - 'file': source, - 'arguments': - [self.compiler, self.phase] + self.flags + output + [source], - 'directory': self.directory - } + if self.output: + return { + 'file': source, + 'arguments': + [self.compiler, self.phase] + self.flags + + ['-o', self.output] + [source], + 'directory': self.directory, + 'output': self.output + } + else: + return { + 'file': source, + 'arguments': + [self.compiler, self.phase] + self.flags + [source], + 'directory': self.directory + } @classmethod def from_db_entry(cls, entry, category): diff --git a/test/functional/cases/result/assembly_sources.fts b/test/functional/cases/result/assembly_sources.fts index 330c3cb9..9c79d588 100644 --- a/test/functional/cases/result/assembly_sources.fts +++ b/test/functional/cases/result/assembly_sources.fts @@ -45,7 +45,8 @@ cat > "${root_dir}/expected.json" << EOF "main.s" ], "directory": "${root_dir}/src", - "file": "main.s" + "file": "main.s", + "output": "main.o" }, { "arguments": [ @@ -56,7 +57,8 @@ cat > "${root_dir}/expected.json" << EOF "main.c" ], "directory": "${root_dir}/src", - "file": "main.c" + "file": "main.c", + "output": "main.s" } ] EOF diff --git a/test/functional/cases/result/define_with_quote.fts b/test/functional/cases/result/define_with_quote.fts index cb3ba76c..e2fad7ad 100644 --- a/test/functional/cases/result/define_with_quote.fts +++ b/test/functional/cases/result/define_with_quote.fts @@ -49,7 +49,8 @@ cat > "${root_dir}/expected.json" << EOF { "arguments": ["c++", "-c", "-DEXPORT=extern \"C\"", "-o", "hello", "src/main.cpp"], "directory": "${root_dir}", - "file": "src/main.cpp" + "file": "src/main.cpp", + "output": "hello" } ] EOF diff --git a/test/functional/cases/result/define_with_unicode.fts b/test/functional/cases/result/define_with_unicode.fts index 9e2deb36..020938da 100644 --- a/test/functional/cases/result/define_with_unicode.fts +++ b/test/functional/cases/result/define_with_unicode.fts @@ -50,12 +50,14 @@ cat > "${root_dir}/expected.json" << EOF { "arguments": ["cc", "-c", "-DMESSAGE=\u041a\u0430\u043a \u0434\u0435\u043b\u0430?", "-o", "hello", "src/main.c"], "directory": "${root_dir}", - "file": "src/main.c" + "file": "src/main.c", + "output": "hello" }, { "arguments": ["cc", "-c", "-DMESSAGE=\u05de\u05d4 \u05e9\u05dc\u05d5\u05de\u05da?", "-o", "hello", "src/main.c"], "directory": "${root_dir}", - "file": "src/main.c" + "file": "src/main.c", + "output": "hello" } ] EOF diff --git a/test/functional/cases/result/flags_filtered.fts b/test/functional/cases/result/flags_filtered.fts index 6bfd3802..f68cfcd8 100644 --- a/test/functional/cases/result/flags_filtered.fts +++ b/test/functional/cases/result/flags_filtered.fts @@ -75,22 +75,26 @@ cat > "${root_dir}/expected.json" << EOF { "command": "cc -c -fpic -o one.o lib.c", "directory": "${root_dir}/src", - "file": "lib.c" + "file": "lib.c", + "output": "one.o" }, { "command": "cc -c -fpic -o two.o lib.c", "directory": "${root_dir}/src", - "file": "lib.c" + "file": "lib.c", + "output": "two.o" }, { "command": "cc -c -o fooflag_one main.c", "directory": "${root_dir}/src", - "file": "main.c" + "file": "main.c", + "output": "fooflag_one" }, { "command": "cc -c -o fooflag_two main.c", "directory": "${root_dir}/src", - "file": "main.c" + "file": "main.c", + "output": "fooflag_two" } ] EOF diff --git a/test/functional/cases/result/output_kept.fts b/test/functional/cases/result/output_kept.fts index 3118bf05..81a1a7c4 100644 --- a/test/functional/cases/result/output_kept.fts +++ b/test/functional/cases/result/output_kept.fts @@ -41,7 +41,8 @@ cat > "${root_dir}/expected.json" << EOF { "command": "cc -c -o src/empty.o src/empty.c", "directory": "${root_dir}", - "file": "src/empty.c" + "file": "src/empty.c", + "output": "src/empty.o" } , { @@ -53,7 +54,8 @@ cat > "${root_dir}/expected.json" << EOF { "command": "cc -c -o empty.obj empty.c", "directory": "${root_dir}/src", - "file": "empty.c" + "file": "empty.c", + "output": "empty.obj" } , { diff --git a/test/functional/tools/cdb_diff.py b/test/functional/tools/cdb_diff.py index b764f30d..c855d14e 100755 --- a/test/functional/tools/cdb_diff.py +++ b/test/functional/tools/cdb_diff.py @@ -42,7 +42,8 @@ def smooth(entry): os.path.normpath(os.path.join(directory, entry['file'])) arguments = entry['command'].split() if 'command' in entry else \ entry['arguments'] - return '-'.join([source[::-1]] + arguments) + output = entry['output'] if 'output' in entry else '' + return '-'.join([source[::-1]] + arguments + [output]) def main():