Congratulations to Tea Deliverers

This commit is contained in:
Fangrui Song 2018-05-13 19:09:26 -07:00
parent 36729818c3
commit f9e1e8cbdc
3 changed files with 21 additions and 34 deletions

View File

@ -12,6 +12,7 @@ option(SYSTEM_CLANG "Use system installation of Clang instead of \
downloading Clang" OFF) downloading Clang" OFF)
option(ASAN "Compile with address sanitizers" OFF) option(ASAN "Compile with address sanitizers" OFF)
option(CLANG_USE_BUNDLED_LIBC++ "Let Clang use bundled libc++" 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 # Sources for the executable are specified at end of CMakeLists.txt
add_executable(ccls "") add_executable(ccls "")
@ -105,11 +106,7 @@ endif()
# See cmake/FindClang.cmake # See cmake/FindClang.cmake
find_package(Clang ${CLANG_VERSION} REQUIRED) find_package(Clang ${CLANG_VERSION} REQUIRED)
find_package(Curses REQUIRED)
target_link_libraries(ccls PRIVATE Clang::Clang) 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 # Enable threading support
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)

View File

@ -71,9 +71,13 @@ set(_Clang_REQUIRED_VARS Clang_LIBRARY Clang_INCLUDE_DIR Clang_EXECUTABLE
_Clang_find_library(Clang_LIBRARY clang) _Clang_find_library(Clang_LIBRARY clang)
_Clang_find_add_library(clangDriver) _Clang_find_add_library(clangDriver)
_Clang_find_add_library(clangBasic) _Clang_find_add_library(clangBasic)
_Clang_find_add_library(LLVMOption) if(USE_SHARED_LLVM)
_Clang_find_add_library(LLVMSupport) _Clang_find_add_library(LLVM)
_Clang_find_add_library(LLVMDemangle) 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_INCLUDE_DIR clang-c/Index.h)
_Clang_find_path(Clang_BUILD_INCLUDE_DIR clang/Driver/Options.inc) _Clang_find_path(Clang_BUILD_INCLUDE_DIR clang/Driver/Options.inc)
_Clang_find_path(LLVM_INCLUDE_DIR llvm/PassInfo.h) _Clang_find_path(LLVM_INCLUDE_DIR llvm/PassInfo.h)
@ -113,5 +117,6 @@ if(Clang_FOUND AND NOT TARGET Clang::Clang)
IMPORTED_LOCATION ${Clang_LIBRARY} IMPORTED_LOCATION ${Clang_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES "${Clang_INCLUDE_DIR};${Clang_BUILD_INCLUDE_DIR};${LLVM_INCLUDE_DIR};${LLVM_BUILD_INCLUDE_DIR}") 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() endif()

View File

@ -5,23 +5,20 @@ using namespace llvm;
#include <utility> #include <utility>
static void GetFilesInFolderHelper( void GetFilesInFolder(std::string folder,
std::string folder, bool recursive,
bool recursive, bool dir_prefix,
std::string output_prefix, const std::function<void(const std::string&)>& handler) {
const std::function<void(const std::string&)>& handler) { EnsureEndsInSlash(folder);
std::error_code ec; std::error_code ec;
if (recursive) if (recursive)
for (sys::fs::recursive_directory_iterator I(folder, ec), E; I != E && !ec; for (sys::fs::recursive_directory_iterator I(folder, ec), E; I != E && !ec;
I.increment(ec)) { I.increment(ec)) {
std::string path = I->path(), filename = sys::path::filename(path); std::string path = I->path(), filename = sys::path::filename(path);
if (filename[0] != '.' || filename == ".ccls") { if (filename[0] != '.' || filename == ".ccls") {
SmallString<256> Path; if (!dir_prefix)
if (output_prefix.size()) { path = path.substr(folder.size());
sys::path::append(Path, output_prefix, path); handler(path);
handler(Path.str());
} else
handler(path);
} }
} }
else else
@ -29,21 +26,9 @@ static void GetFilesInFolderHelper(
I.increment(ec)) { I.increment(ec)) {
std::string path = I->path(), filename = sys::path::filename(path); std::string path = I->path(), filename = sys::path::filename(path);
if (filename[0] != '.' || filename == ".ccls") { if (filename[0] != '.' || filename == ".ccls") {
SmallString<256> Path; if (!dir_prefix)
if (output_prefix.size()) { path = path.substr(folder.size());
sys::path::append(Path, output_prefix, path); handler(path);
handler(Path.str());
} else
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);
}