diff --git a/src/compile_commands.cpp b/src/compile_commands.cpp index 61ba967..0f3a2ef 100644 --- a/src/compile_commands.cpp +++ b/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 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) diff --git a/src/compile_commands.hpp b/src/compile_commands.hpp index a76ee8a..77b77fa 100644 --- a/src/compile_commands.hpp +++ b/src/compile_commands.hpp @@ -9,6 +9,7 @@ public: int exit_status; public: + std::string resource_path; std::vector include_paths; std::vector framework_paths; operator bool() const { return exit_status == 0; }