Browse Source

Fix appveyor CI

pipelines/143601543
eidheim 6 years ago
parent
commit
696264e623
  1. 9
      .appveyor.yml
  2. 17
      src/compile_commands.cc
  3. 14
      src/grep.cc

9
.appveyor.yml

@ -2,7 +2,7 @@ platform:
- x64 - x64
environment: environment:
MSYSTEM: MSYS MSYSTEM: MINGW64
CTEST_OUTPUT_ON_FAILURE: 1 CTEST_OUTPUT_ON_FAILURE: 1
cache: cache:
@ -11,9 +11,8 @@ cache:
before_build: before_build:
- git submodule update --init --recursive - 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 "pacman --noconfirm -Syyuu"
- 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 "pacman --noconfirm --needed -S make mingw-w64-x86_64-{cmake,toolchain,clang,gtkmm3,gtksourceviewmm3,boost,aspell,aspell-en,libgit2,universal-ctags-git,libffi}"
- 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}"
build_script: 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"

17
src/compile_commands.cc

@ -13,9 +13,13 @@ CompileCommands::FindSystemIncludePaths::FindSystemIncludePaths() {
return; return;
std::string line; std::string line;
while(std::getline(stdout_stream, 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)) { while(std::getline(stdout_stream, line)) {
if(!line.empty() && line[0] == ' ') { if(!line.empty() && line[0] == ' ') {
#ifdef _WIN32
if(line.back() == '\r')
line.pop_back();
#endif
auto end = line.find(" (framework directory)", 1); auto end = line.find(" (framework directory)", 1);
if(end == std::string::npos) if(end == std::string::npos)
include_paths.emplace_back(line.substr(1, end)); include_paths.emplace_back(line.substr(1, end));
@ -167,6 +171,17 @@ std::vector<std::string> CompileCommands::get_arguments(const boost::filesystem:
arguments.emplace_back("-I" + path); arguments.emplace_back("-I" + path);
for(auto &path : system_include_paths.framework_paths) for(auto &path : system_include_paths.framework_paths)
arguments.emplace_back("-F" + path); 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 { else {
auto clang_version_string = clangmm::to_string(clang_getClangVersion()); auto clang_version_string = clangmm::to_string(clang_getClangVersion());

14
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 { 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<std::pair<size_t, size_t>> positions; std::vector<std::pair<size_t, size_t>> positions;
size_t file_end = std::string::npos, line_end = std::string::npos; size_t file_end = std::string::npos, line_end = std::string::npos;
if(color_codes_to_markup) { 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); location.markup = std::move(line);
auto file = location.markup.substr(0, file_end); auto file = location.markup.substr(0, file_end);
if(!only_for_file.empty() && file != only_for_file) 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; return location;
#endif
}
location.file_path = std::move(file); location.file_path = std::move(file);
try { try {
location.line = std::stoul(location.markup.substr(file_end + 1, line_end - file_end)) - 1; location.line = std::stoul(location.markup.substr(file_end + 1, line_end - file_end)) - 1;

Loading…
Cancel
Save