Browse Source

Added workaround MacOS missing resource-dir

merge-requests/413/head
eidheim 3 years ago
parent
commit
42c1103001
  1. 19
      src/compile_commands.cpp
  2. 1
      src/compile_commands.hpp

19
src/compile_commands.cpp

@ -23,11 +23,16 @@ CompileCommands::FindSystemIncludePaths::FindSystemIncludePaths() {
if(line.back() == '\r')
line.pop_back();
#endif
auto end = line.find(" (framework directory)", 1);
if(end == std::string::npos)
include_paths.emplace_back(line.substr(1, end));
else
framework_paths.emplace_back(line.substr(1, end));
if(ends_with(line, " (framework directory)"))
framework_paths.emplace_back(line.substr(1, line.size() - 22 - 1));
else {
#ifdef __APPLE__
// Workaround for missing resource-dir
if(line == " /Library/Developer/CommandLineTools/usr/lib/clang/14.0.3/include")
resource_path = "/Library/Developer/CommandLineTools/usr/lib/clang/14.0.3";
#endif
include_paths.emplace_back(line.substr(1));
}
}
else
return;
@ -176,6 +181,10 @@ std::vector<std::string> CompileCommands::get_arguments(const boost::filesystem:
static FindSystemIncludePaths system_include_paths;
if(system_include_paths) {
if(!system_include_paths.resource_path.empty()) {
arguments.emplace_back("-resource-dir");
arguments.emplace_back(system_include_paths.resource_path);
}
for(auto &path : system_include_paths.include_paths)
arguments.emplace_back("-I" + sysroot + path);
for(auto &path : system_include_paths.framework_paths)

1
src/compile_commands.hpp

@ -9,6 +9,7 @@ public:
int exit_status;
public:
std::string resource_path;
std::vector<std::string> include_paths;
std::vector<std::string> framework_paths;
operator bool() const { return exit_status == 0; }

Loading…
Cancel
Save