From 3ba92f5c4b7ac2988393604667d2b8cea34a2064 Mon Sep 17 00:00:00 2001 From: Tomicyo Date: Sun, 11 Nov 2018 10:24:16 +0800 Subject: [PATCH] fix msvc15 compile issues --- .appveyor.yml | 22 ++++++++++++++++++++++ CMakeLists.txt | 1 + README.md | 1 + cmake/FindClang.cmake | 7 ++++--- src/clang_tu.cc | 3 ++- src/lsp.cc | 1 + src/position.cc | 3 ++- src/position.hh | 7 ++++--- 8 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 .appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 00000000..3ef7b19a --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,22 @@ +version: "{build}" + +os: Visual Studio 2017 + +platform: + - x64 + +build: + parallel: true # enable MSBuild parallel builds + verbosity: minimal + +install: + - if not exist llvm.tar.xz appveyor DownloadFile "https://ziglang.org/deps/llvm+clang-7.0.0-win64-msvc-release.tar.xz" -FileName llvm.tar.xz + - 7z e -txz llvm.tar.xz + - 7z x llvm.tar + - git submodule update --init --recursive +build_script: + - cmake -G"Visual Studio 15 2017 Win64" -H. -Bbuild -DCMAKE_BUILD_TYPE=Release -DSYSTEM_CLANG=ON -DCLANG_ROOT=C:\projects\ccls\llvm+clang-7.0.0-win64-msvc-release + - cmake --build build --target ccls --config Release + +artifacts: + - path: build\Release diff --git a/CMakeLists.txt b/CMakeLists.txt index abe0e04b..a7c71741 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,7 @@ if(MSVC) /wd4068 # Disable unknown pragma warning $<$:/FS> ) + target_link_libraries(ccls PRIVATE Mincore.lib) else() # Common GCC/Clang(Linux) options target_compile_options(ccls PRIVATE diff --git a/README.md b/README.md index 81d25dc5..1777d6df 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Telegram](https://img.shields.io/badge/telegram-@cclsp-blue.svg)](https://telegram.me/cclsp) [![Gitter](https://img.shields.io/badge/gitter-ccls--project-blue.svg?logo=gitter-white)](https://gitter.im/ccls-project/ccls) +[![Build status](https://ci.appveyor.com/api/projects/status/kx26jsnijv3326ja?svg=true)](https://ci.appveyor.com/project/DsoTsin/ccls) ccls, which originates from [cquery](https://github.com/cquery-project/cquery), is a C/C++/Objective-C language server. diff --git a/cmake/FindClang.cmake b/cmake/FindClang.cmake index e56e25dd..5748f71f 100644 --- a/cmake/FindClang.cmake +++ b/cmake/FindClang.cmake @@ -143,9 +143,10 @@ if(Clang_FOUND AND NOT TARGET Clang::Clang) set_target_properties(Clang::Clang PROPERTIES IMPORTED_LOCATION ${Clang_LIBRARY} INTERFACE_INCLUDE_DIRECTORIES "${Clang_INCLUDE_DIR};${Clang_BUILD_INCLUDE_DIR};${LLVM_INCLUDE_DIR};${LLVM_BUILD_INCLUDE_DIR}") - - find_package(Curses REQUIRED) - find_package(ZLIB REQUIRED) + if(NOT WIN32) + find_package(Curses REQUIRED) + find_package(ZLIB REQUIRED) + endif() set_property(TARGET Clang::Clang PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES "${_Clang_LIBRARIES};${CURSES_LIBRARIES};${ZLIB_LIBRARIES}") if(MINGW) set_property(TARGET Clang::Clang APPEND_STRING PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES ";version") diff --git a/src/clang_tu.cc b/src/clang_tu.cc index 91fa2e38..73f6b15a 100644 --- a/src/clang_tu.cc +++ b/src/clang_tu.cc @@ -45,7 +45,8 @@ static Pos Decomposed2LineAndCol(const SourceManager &SM, std::pair I) { int l = SM.getLineNumber(I.first, I.second) - 1, c = SM.getColumnNumber(I.first, I.second) - 1; - return {(int16_t)std::min(l, INT16_MAX), (int16_t)std::min(c, INT16_MAX)}; + return {(int16_t)std::min(l, INT16_MAX), + (int16_t)std::min(c, INT16_MAX)}; } Range FromCharSourceRange(const SourceManager &SM, const LangOptions &LangOpts, diff --git a/src/lsp.cc b/src/lsp.cc index 9adc2f42..67801952 100644 --- a/src/lsp.cc +++ b/src/lsp.cc @@ -19,6 +19,7 @@ limitations under the License. #include "serializers/json.hh" #include +#include namespace ccls { void Reflect(Reader &visitor, RequestId &value) { diff --git a/src/position.cc b/src/position.cc index 2a124c5b..3f657465 100644 --- a/src/position.cc +++ b/src/position.cc @@ -20,6 +20,7 @@ limitations under the License. #include #include #include +#include namespace ccls { Pos Pos::FromString(const std::string &encoded) { @@ -57,7 +58,7 @@ Range Range::FromString(const std::string &encoded) { bool Range::Contains(int line, int column) const { if (line > INT16_MAX) return false; - Pos p{int16_t(line), int16_t(std::min(column, INT16_MAX))}; + Pos p{int16_t(line), int16_t(std::min(column, INT16_MAX))}; return !(p < start) && p < end; } diff --git a/src/position.hh b/src/position.hh index 794c7af2..53d47fe5 100644 --- a/src/position.hh +++ b/src/position.hh @@ -76,13 +76,14 @@ void Reflect(Writer &visitor, Range &value); namespace std { template <> struct hash { std::size_t operator()(ccls::Range x) const { - union U { + /*union U { ccls::Range range = {}; uint64_t u64; } u; static_assert(sizeof(ccls::Range) == 8); - u.range = x; - return hash()(u.u64); + u.range = x;*/ + std::string data((const char*)&x, sizeof(x)); + return hash()(data); } }; } // namespace std