Skip to content

Commit

Permalink
Compatibility improvements for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dylon committed Feb 23, 2024
1 parent 566c1ec commit cd933a5
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 24 deletions.
52 changes: 44 additions & 8 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ jobs:
- uses: conda-incubator/setup-miniconda@v3
with:
auto-activate-base: false
environment-file: environment.yml
activate-environment: ll-cpp
# environment-file: environment.yml
# activate-environment: ll-cpp
environment-file: environment-demo.yml
activate-environment: ll-cpp-demo
miniforge-version: latest
use-mamba: true
channels: conda-forge
Expand All @@ -44,12 +46,46 @@ jobs:
cmake --install build --config ${{ matrix.build_type }}
popd
- name: Configure CMake
- name: Configure liblevenshtein-cpp
shell: bash -el {0}
run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBUILD_TESTS=ON
# FIXME: GTest or RapidCheck do not work on Windows
# run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBUILD_TESTS=ON
run: >
cmake -B build
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
- name: Build and Test
- name: Build liblevenshtein-cpp
shell: bash -el {0}
run: |
cmake --build build --config ${{ matrix.build_type }}
./build/test/Debug/test-liblevenshtein.exe
run: cmake --build build --config ${{ matrix.build_type }}

# FIXME: GTest or RapidCheck do not work on Windows
# - name: Test liblevenshtein-cpp
# shell: bash -el {0}
# run: ./build/test/${{ matrix.build_type }}/test-liblevenshtein.exe

- name: Install liblevenshtein-cpp
shell: bash -el {0}
run: cmake --install build --config ${{ matrix.build_type }}

- name: Configure liblevenshtein-demo
working-directory: example
shell: bash -el {0}
run: >
cmake -B build
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
- name: Build liblevenshtein-demo
working-directory: example
shell: bash -el {0}
run: cmake --build build --config ${{ matrix.build_type }}

- name: Run liblevenshtein-demo
working-directory: example
shell: bash -el {0}
run: >
./scripts/run-demo.exp
./build/${{ matrix.build_type }}/liblevenshtein-demo.exe
--dictionary-path resources/programming-languages.txt
--serialization-path build/programming-languages.pb
8 changes: 5 additions & 3 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
SET(CMAKE_C_FLAGS_DEBUG "-g -O0")
if(NOT MSVC)
SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
SET(CMAKE_C_FLAGS_DEBUG "-g -O0")
endif()

set(CMAKE_COMPILE_WARNING_AS_ERROR ON)

set(CMAKE_VERBOSE_MAKEFILE ON)

find_package(Protobuf REQUIRED)
find_package(Protobuf CONFIG REQUIRED)
find_package(liblevenshtein REQUIRED)

add_executable(${PROJECT_NAME})
Expand Down
4 changes: 2 additions & 2 deletions example/src/command_line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ auto CommandLine::parse_opts() -> bool {
std::cerr << "Either --dictionary-path=<PATH> or "
"--serialization-path=<PATH> must exist"
<< std::endl;
std::cerr << "--dictionary_path=" << _dictionary_path << std::endl;
std::cerr << "--serialization_path=" << _serialization_path << std::endl;
std::cerr << "--dictionary-path=" << _dictionary_path << std::endl;
std::cerr << "--serialization-path=" << _serialization_path << std::endl;
_return_code = ReturnCode::RETURN_FILE_NOT_EXISTS;
return false;
}
Expand Down
13 changes: 2 additions & 11 deletions src/liblevenshtein/serialization/serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@ namespace llp = liblevenshtein::proto;

namespace liblevenshtein {

#if _MSC_VER && !__INTEL_COMPILER
#pragma warning(push)
#pragma warning(disable : 4717)
#endif

auto serialize_protobuf(Dawg *dawg, const fs::path &path) -> bool {
return serialize_protobuf(dawg, path.c_str());
return serialize_protobuf(dawg, path.generic_string());
}

auto serialize_protobuf(Dawg *dawg, const std::string &path) -> bool {
Expand All @@ -47,7 +42,7 @@ auto serialize_protobuf(Dawg *dawg, std::ostream &output) -> bool {
}

auto deserialize_protobuf(const fs::path &path) -> Dawg * {
return deserialize_protobuf(path.c_str());
return deserialize_protobuf(path.generic_string());
}

auto deserialize_protobuf(const std::string &path) -> Dawg * {
Expand All @@ -70,10 +65,6 @@ auto deserialize_protobuf(std::istream &input) -> Dawg * {
return dawg;
}

#if _MSC_VER && !__INTEL_COMPILER
#pragma warning(pop)
#endif

void collect_nodes(DawgNode *source, std::set<uint64_t> &node_ids,
std::set<uint64_t> &final_node_ids) {
auto source_id = reinterpret_cast<uint64_t>(source);
Expand Down

0 comments on commit cd933a5

Please sign in to comment.