From 70b01ba867dc8f7595a7743a7bef2c579aa63824 Mon Sep 17 00:00:00 2001 From: eidheim Date: Mon, 19 Jun 2023 17:40:16 +0200 Subject: [PATCH] Further improvements to libclang's resource path --- src/compile_commands.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/compile_commands.cpp b/src/compile_commands.cpp index 0c3adc4..49c8c79 100644 --- a/src/compile_commands.cpp +++ b/src/compile_commands.cpp @@ -87,8 +87,10 @@ std::vector CompileCommands::get_arguments(const boost::filesystem: #if defined(__APPLE__) static auto resource_path = []() -> std::string { boost::system::error_code ec; - for(boost::filesystem::directory_iterator it(boost::filesystem::path(LIBCLANG_LIBRARY_DIR) / "clang", ec), end; it != end; ++it) - return it->path().string(); + 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()) { @@ -119,8 +121,10 @@ std::vector CompileCommands::get_arguments(const boost::filesystem: } else { boost::system::error_code ec; - for(boost::filesystem::directory_iterator it(boost::filesystem::path(LIBCLANG_LIBRARY_DIR) / "clang", ec), end; it != end; ++it) - return it->path().string(); + 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 {}; }();