Skip to content

Commit a42d968

Browse files
authored
fix empty compilation database (#442)
1 parent b0ce9ba commit a42d968

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/engine/mod_command_db.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,25 @@ struct database
5353
// Set up for the format and create the output database.
5454
output_flag = true;
5555
output_format = f;
56-
prop_db.reset(new property_db);
5756

5857
// Default to all targets and no regular action output.
5958
globs.noexec = true;
6059
for (int i = 0; i < DEBUG_MAX; ++i) globs.debug[i] = 0;
6160
globs.anyhow = true;
6261

63-
// Events to track the commands and exit to generate the output.
64-
add_event_callback(event_tag::pre_exec_cmd,
65-
std::function<void(TARGET *)>(
66-
[](TARGET * t) { database::get().pre_exec_cmd(t); }));
67-
add_event_callback(event_tag::exit_main,
68-
std::function<void(int)>(
69-
[](int s) { database::get().exit_main(s); }));
62+
if (!prop_db)
63+
{
64+
prop_db.reset(new property_db);
65+
// Events to track the commands and exit to generate the output.
66+
add_event_callback(event_tag::pre_exec_cmd,
67+
std::function<void(TARGET *)>([](TARGET * t) {
68+
database::get().pre_exec_cmd(t);
69+
}));
70+
add_event_callback(
71+
event_tag::exit_main, std::function<void(int)>([](int s) {
72+
database::get().exit_main(s);
73+
}));
74+
}
7075
}
7176

7277
void set_output_filename(const std::string & f) { output_filename = f; }

0 commit comments

Comments
 (0)