|
|
|
@ -84,7 +84,6 @@ std::vector<std::string> CompileCommands::get_arguments(const boost::filesystem: |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if defined(__APPLE__) |
|
|
|
|
|
|
|
static auto resource_path = []() -> std::string { |
|
|
|
static auto resource_path = []() -> std::string { |
|
|
|
boost::system::error_code ec; |
|
|
|
boost::system::error_code ec; |
|
|
|
for(boost::filesystem::directory_iterator it(boost::filesystem::path(LIBCLANG_LIBRARY_DIR) / "clang", ec), end; it != end; ++it) { |
|
|
|
for(boost::filesystem::directory_iterator it(boost::filesystem::path(LIBCLANG_LIBRARY_DIR) / "clang", ec), end; it != end; ++it) { |
|
|
|
@ -97,42 +96,6 @@ std::vector<std::string> CompileCommands::get_arguments(const boost::filesystem: |
|
|
|
arguments.emplace_back("-resource-dir"); |
|
|
|
arguments.emplace_back("-resource-dir"); |
|
|
|
arguments.emplace_back(resource_path); |
|
|
|
arguments.emplace_back(resource_path); |
|
|
|
} |
|
|
|
} |
|
|
|
#elif defined(_WIN32) |
|
|
|
|
|
|
|
auto clang_version_string = clangmm::to_string(clang_getClangVersion()); |
|
|
|
|
|
|
|
const static std::regex clang_version_regex(R"(^[A-Za-z ]+([0-9.]+).*$)", std::regex::optimize); |
|
|
|
|
|
|
|
std::smatch sm; |
|
|
|
|
|
|
|
if(std::regex_match(clang_version_string, sm, clang_version_regex)) { |
|
|
|
|
|
|
|
auto clang_version = sm[1].str(); |
|
|
|
|
|
|
|
auto env_msystem_prefix = std::getenv("MSYSTEM_PREFIX"); |
|
|
|
|
|
|
|
if(env_msystem_prefix) |
|
|
|
|
|
|
|
arguments.emplace_back("-I" + (boost::filesystem::path(env_msystem_prefix) / "lib/clang" / clang_version / "include").string()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
static auto resource_path = []() -> std::string { |
|
|
|
|
|
|
|
if(!filesystem::find_executable("clang++").empty()) { |
|
|
|
|
|
|
|
std::stringstream stdin_stream, stdout_stream; |
|
|
|
|
|
|
|
auto exit_status = Terminal::get().process(stdin_stream, stdout_stream, "clang++ -print-resource-dir"); |
|
|
|
|
|
|
|
if(exit_status != 0) |
|
|
|
|
|
|
|
return {}; |
|
|
|
|
|
|
|
auto path = stdout_stream.str(); |
|
|
|
|
|
|
|
if(!path.empty()) |
|
|
|
|
|
|
|
path.pop_back(); |
|
|
|
|
|
|
|
return path; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
boost::system::error_code ec; |
|
|
|
|
|
|
|
for(boost::filesystem::directory_iterator it(boost::filesystem::path(LIBCLANG_LIBRARY_DIR) / "clang", ec), end; it != end; ++it) { |
|
|
|
|
|
|
|
if(boost::filesystem::is_directory(it->path() / "include", ec)) |
|
|
|
|
|
|
|
return it->path().string(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return {}; |
|
|
|
|
|
|
|
}(); |
|
|
|
|
|
|
|
if(!resource_path.empty()) { |
|
|
|
|
|
|
|
arguments.emplace_back("-resource-dir"); |
|
|
|
|
|
|
|
arguments.emplace_back(resource_path); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Do not add -fretain-comments-from-system-headers if pch is used, since the pch was most likely made without this flag
|
|
|
|
// Do not add -fretain-comments-from-system-headers if pch is used, since the pch was most likely made without this flag
|
|
|
|
if(std::none_of(arguments.begin(), arguments.end(), [](const std::string &argument) { return argument == "-include-pch"; })) |
|
|
|
if(std::none_of(arguments.begin(), arguments.end(), [](const std::string &argument) { return argument == "-include-pch"; })) |
|
|
|
|