Added handling of query-driver target and using default driver for '.'

This commit is contained in:
Bartek Kryza
2023-05-07 16:32:55 +02:00
parent d31f282816
commit 16ca3bd50a
5 changed files with 53 additions and 8 deletions

View File

@@ -94,9 +94,12 @@ void compilation_database::adjust_compilation_database(
#if !defined(_WIN32)
if (config().query_driver && !config().query_driver().empty()) {
for (auto &compile_command : commands) {
auto argv0 = config().query_driver() == "."
? compile_command.CommandLine.at(0)
: config().query_driver();
util::query_driver_output_extractor extractor{
config().query_driver(),
guess_language_from_filename(compile_command.Filename)};
argv0, guess_language_from_filename(compile_command.Filename)};
extractor.execute();
@@ -109,6 +112,12 @@ void compilation_database::adjust_compilation_database(
compile_command.CommandLine.insert(
compile_command.CommandLine.begin() + 1,
system_header_args.begin(), system_header_args.end());
if (!extractor.target().empty()) {
compile_command.CommandLine.insert(
compile_command.CommandLine.begin() + 1,
fmt::format("--target={}", extractor.target()));
}
}
}
#endif