Added handling of query-driver target and using default driver for '.'
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -43,6 +43,7 @@ void query_driver_output_extractor::execute()
|
||||
|
||||
system_include_paths_.clear();
|
||||
extract_system_include_paths(driver_output);
|
||||
extract_target(driver_output);
|
||||
|
||||
if (system_include_paths_.empty()) {
|
||||
throw query_driver_no_paths(fmt::format(
|
||||
@@ -55,6 +56,20 @@ void query_driver_output_extractor::execute()
|
||||
fmt::join(system_include_paths_, ","));
|
||||
}
|
||||
|
||||
void query_driver_output_extractor::extract_target(const std::string &output)
|
||||
{
|
||||
std::istringstream f(output);
|
||||
std::string line;
|
||||
|
||||
while (std::getline(f, line)) {
|
||||
line = trim(line);
|
||||
if (util::starts_with(line, std::string{"Target: "})) {
|
||||
target_ = line.substr(strlen("Target: "));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void query_driver_output_extractor::extract_system_include_paths(
|
||||
const std::string &output)
|
||||
{
|
||||
@@ -84,4 +99,8 @@ query_driver_output_extractor::system_include_paths() const
|
||||
return system_include_paths_;
|
||||
}
|
||||
|
||||
const std::string &query_driver_output_extractor::target() const
|
||||
{
|
||||
return target_;
|
||||
}
|
||||
} // namespace clanguml::util
|
||||
@@ -35,13 +35,18 @@ public:
|
||||
|
||||
void execute();
|
||||
|
||||
void extract_target(const std::string &output);
|
||||
|
||||
void extract_system_include_paths(const std::string &output);
|
||||
|
||||
const std::vector<std::string> &system_include_paths() const;
|
||||
|
||||
const std::string &target() const;
|
||||
|
||||
private:
|
||||
const std::string command_;
|
||||
const std::string language_;
|
||||
std::string target_;
|
||||
std::vector<std::string> system_include_paths_;
|
||||
};
|
||||
} // namespace clanguml::util
|
||||
Reference in New Issue
Block a user