Skip to content

Commit

Permalink
Congratulations to Tea Deliverers
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed May 14, 2018
1 parent f145c44 commit 576959e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 34 deletions.
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ option(SYSTEM_CLANG "Use system installation of Clang instead of \
downloading Clang" OFF)
option(ASAN "Compile with address sanitizers" OFF)
option(CLANG_USE_BUNDLED_LIBC++ "Let Clang use bundled libc++" OFF)
option(USE_SHARED_LLVM "Link against libLLVM.so instead separate LLVM{Option,Support,...}" OFF)

# Sources for the executable are specified at end of CMakeLists.txt
add_executable(ccls "")
Expand Down Expand Up @@ -105,11 +106,7 @@ endif()

# See cmake/FindClang.cmake
find_package(Clang ${CLANG_VERSION} REQUIRED)
find_package(Curses REQUIRED)
target_link_libraries(ccls PRIVATE Clang::Clang)
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL Windows)
target_link_libraries(ccls PRIVATE Clang::Clang ${CURSES_LIBRARIES})
endif()

# Enable threading support
set(THREADS_PREFER_PTHREAD_FLAG ON)
Expand Down
13 changes: 9 additions & 4 deletions cmake/FindClang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ set(_Clang_REQUIRED_VARS Clang_LIBRARY Clang_INCLUDE_DIR Clang_EXECUTABLE
_Clang_find_library(Clang_LIBRARY clang)
_Clang_find_add_library(clangDriver)
_Clang_find_add_library(clangBasic)
_Clang_find_add_library(LLVMOption)
_Clang_find_add_library(LLVMSupport)
_Clang_find_add_library(LLVMDemangle)
if(USE_SHARED_LLVM)
_Clang_find_add_library(LLVM)
else()
_Clang_find_add_library(LLVMOption)
_Clang_find_add_library(LLVMSupport)
_Clang_find_add_library(LLVMDemangle)
endif()
_Clang_find_path(Clang_INCLUDE_DIR clang-c/Index.h)
_Clang_find_path(Clang_BUILD_INCLUDE_DIR clang/Driver/Options.inc)
_Clang_find_path(LLVM_INCLUDE_DIR llvm/PassInfo.h)
Expand Down Expand Up @@ -113,5 +117,6 @@ if(Clang_FOUND AND NOT TARGET Clang::Clang)
IMPORTED_LOCATION ${Clang_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES "${Clang_INCLUDE_DIR};${Clang_BUILD_INCLUDE_DIR};${LLVM_INCLUDE_DIR};${LLVM_BUILD_INCLUDE_DIR}")

set_property(TARGET Clang::Clang PROPERTY INTERFACE_LINK_LIBRARIES ${_Clang_LIBRARIES})
find_package(Curses REQUIRED)
set_property(TARGET Clang::Clang PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES "${_Clang_LIBRARIES};${CURSES_LIBRARIES}")
endif()
37 changes: 11 additions & 26 deletions src/filesystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,30 @@ using namespace llvm;

#include <utility>

static void GetFilesInFolderHelper(
std::string folder,
bool recursive,
std::string output_prefix,
const std::function<void(const std::string&)>& handler) {
void GetFilesInFolder(std::string folder,
bool recursive,
bool dir_prefix,
const std::function<void(const std::string&)>& handler) {
EnsureEndsInSlash(folder);
std::error_code ec;
if (recursive)
for (sys::fs::recursive_directory_iterator I(folder, ec), E; I != E && !ec;
I.increment(ec)) {
std::string path = I->path(), filename = sys::path::filename(path);
if (filename[0] != '.' || filename == ".ccls") {
SmallString<256> Path;
if (output_prefix.size()) {
sys::path::append(Path, output_prefix, path);
handler(Path.str());
} else
handler(path);
if (!dir_prefix)
path = path.substr(folder.size());
handler(path);
}
}
else
for (sys::fs::directory_iterator I(folder, ec), E; I != E && !ec;
I.increment(ec)) {
std::string path = I->path(), filename = sys::path::filename(path);
if (filename[0] != '.' || filename == ".ccls") {
SmallString<256> Path;
if (output_prefix.size()) {
sys::path::append(Path, output_prefix, path);
handler(Path.str());
} else
handler(path);
if (!dir_prefix)
path = path.substr(folder.size());
handler(path);
}
}
}

void GetFilesInFolder(std::string folder,
bool recursive,
bool add_folder_to_path,
const std::function<void(const std::string&)>& handler) {
EnsureEndsInSlash(folder);
GetFilesInFolderHelper(folder, recursive, add_folder_to_path ? folder : "",
handler);
}

0 comments on commit 576959e

Please sign in to comment.