diff --git a/.appveyor.yml b/.appveyor.yml index e2c2a8c..bd3626a 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,7 +2,7 @@ platform: - x64 environment: - MSYSTEM: MSYS + MSYSTEM: MINGW64 CTEST_OUTPUT_ON_FAILURE: 1 cache: @@ -11,9 +11,8 @@ cache: before_build: - git submodule update --init --recursive - - C:\msys64\usr\bin\bash -lc "export PATH=/mingw64/bin:/usr/local/bin:/usr/bin:/bin && pacman --noconfirm --remove --cascade mingw-w64-x86_64-{gcc-ada,gcc-objc,termcap,ncurses}" || true - - C:\msys64\usr\bin\bash -lc "export PATH=/mingw64/bin:/usr/local/bin:/usr/bin:/bin && pacman --noconfirm --ask 20 --sync --refresh --sysupgrade" - - C:\msys64\usr\bin\bash -lc "export PATH=/mingw64/bin:/usr/local/bin:/usr/bin:/bin && pacman --noconfirm --needed --sync make mingw-w64-x86_64-{cmake,toolchain,clang,gtkmm3,gtksourceviewmm3,boost,aspell,aspell-en,libgit2,universal-ctags-git}" + - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syyuu" + - C:\msys64\usr\bin\bash -lc "pacman --noconfirm --needed -S make mingw-w64-x86_64-{cmake,toolchain,clang,gtkmm3,gtksourceviewmm3,boost,aspell,aspell-en,libgit2,universal-ctags-git,libffi}" build_script: - - C:\msys64\usr\bin\bash -lc "export PATH=/mingw64/bin:/usr/local/bin:/usr/bin:/bin && cd $APPVEYOR_BUILD_FOLDER && mkdir build && cd build && cmake -G\"MSYS Makefiles\" -DCMAKE_INSTALL_PREFIX=/mingw64 -DBUILD_TESTING=1 .. && make -j$(nproc) && make test" + - C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && mkdir build && cd build && cmake -G\"MSYS Makefiles\" -DCMAKE_INSTALL_PREFIX=/mingw64 -DBUILD_TESTING=1 .. && make -j$(nproc) && make test" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e561798..c55830b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,9 +33,9 @@ thread-safety-analysis: image: cppit/jucipp:arch stage: test script: - - mkdir build && cd build - - CXX=clang++ CXXFLAGS="-Werror -Wno-deprecated-declarations" cmake .. - - make -j$(nproc) + - mkdir build && cd build + - CXX=clang++ CXXFLAGS="-Werror -Wno-deprecated-declarations" cmake .. + - make -j$(nproc) debian-testing: image: cppit/jucipp:debian-testing <<: *compile diff --git a/src/compile_commands.cc b/src/compile_commands.cc index f1b2a2f..1422e75 100644 --- a/src/compile_commands.cc +++ b/src/compile_commands.cc @@ -13,9 +13,13 @@ CompileCommands::FindSystemIncludePaths::FindSystemIncludePaths() { return; std::string line; while(std::getline(stdout_stream, line)) { - if(line == "#include <...> search starts here:") { + if(line.compare(0, 34, "#include <...> search starts here:") == 0) { while(std::getline(stdout_stream, line)) { if(!line.empty() && line[0] == ' ') { +#ifdef _WIN32 + if(line.back() == '\r') + line.pop_back(); +#endif auto end = line.find(" (framework directory)", 1); if(end == std::string::npos) include_paths.emplace_back(line.substr(1, end)); @@ -167,6 +171,17 @@ std::vector CompileCommands::get_arguments(const boost::filesystem: arguments.emplace_back("-I" + path); for(auto &path : system_include_paths.framework_paths) arguments.emplace_back("-F" + path); +#ifdef _WIN32 + auto clang_version_string = clangmm::to_string(clang_getClangVersion()); + const static std::regex clang_version_regex(R"(^[A-Za-z ]+([0-9.]+).*$)"); + 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 != nullptr) + arguments.emplace_back("-I" + (boost::filesystem::path(env_msystem_prefix) / "lib/clang" / clang_version / "include").string()); + } +#endif } else { auto clang_version_string = clangmm::to_string(clang_getClangVersion()); diff --git a/src/grep.cc b/src/grep.cc index 290f452..44dd983 100644 --- a/src/grep.cc +++ b/src/grep.cc @@ -45,6 +45,11 @@ Grep::operator bool() { } Grep::Location Grep::get_location(std::string line, bool color_codes_to_markup, bool include_offset, const std::string &only_for_file) const { +#ifdef _WIN32 + if(!line.empty() && line.back() == '\r') + line.pop_back(); +#endif + std::vector> positions; size_t file_end = std::string::npos, line_end = std::string::npos; if(color_codes_to_markup) { @@ -106,8 +111,15 @@ Grep::Location Grep::get_location(std::string line, bool color_codes_to_markup, location.markup = std::move(line); auto file = location.markup.substr(0, file_end); - if(!only_for_file.empty() && file != only_for_file) - return location; + if(!only_for_file.empty()) { +#ifdef _WIN32 + if(boost::filesystem::path(file) != boost::filesystem::path(only_for_file)) + return location; +#else + if(file != only_for_file) + return location; +#endif + } location.file_path = std::move(file); try { location.line = std::stoul(location.markup.substr(file_end + 1, line_end - file_end)) - 1;