Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various Windows fixes #537

Merged
merged 5 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@ jobs:
- uses: ammaraskar/gcc-problem-matcher@master
- name: Build HealthGPS (debug)
if: '!cancelled()' # Run this step, even if the previous one fails
run: |
cmake --build --preset=debug-build-${{ matrix.platform }} --target=install
run: cmake --build --preset=debug-build-${{ matrix.platform }} --target=install

- name: Execute HealthGPS (debug)
if: '!cancelled()' # Run this step, even if the previous one fails
run: out/install/${{ matrix.platform }}-debug/bin/HealthGPS.Console --help

- name: Build HealthGPS (release)
if: '!cancelled()' # Run this step, even if the previous one fails
Expand All @@ -107,6 +110,10 @@ jobs:
cmake --preset=${{ matrix.platform }}-release -DWARNINGS_AS_ERRORS=ON -DBUILD_DOC=ON
cmake --build --preset=release-build-${{ matrix.platform }} --target=install

- name: Execute HealthGPS (release)
if: '!cancelled()' # Run this step, even if the previous one fails
run: out/install/${{ matrix.platform }}-release/bin/HealthGPS.Console --help

- name: Upload artifacts
if: matrix.is_main
uses: actions/upload-artifact@v4
Expand Down
23 changes: 21 additions & 2 deletions src/HealthGPS.Console/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,28 @@ target_link_libraries(
cxxopts::cxxopts
TBB::tbb)

install(TARGETS HealthGPS.Console DESTINATION "")
install(
TARGETS HealthGPS.Console
RUNTIME
ARCHIVE
LIBRARY
RUNTIME
FRAMEWORK
BUNDLE
PUBLIC_HEADER
RESOURCE)
if(WIN32)
install(IMPORTED_RUNTIME_ARTIFACTS fmt::fmt)
install(
TARGETS HealthGPS.Console
COMPONENT HealthGPS.Console
RUNTIME_DEPENDENCIES
PRE_EXCLUDE_REGEXES
"api-ms-"
"ext-ms-"
POST_EXCLUDE_REGEXES
".*system32/.*\\.dll"
DIRECTORIES
$<TARGET_FILE_DIR:HealthGPS.Console>)
endif()

install(DIRECTORY ../../schemas DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
Expand Down
2 changes: 1 addition & 1 deletion src/HealthGPS.Input/download_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

namespace hgps::input {
void download_file(const std::string &url, const std::filesystem::path &download_path) {
std::ofstream ofs{download_path};
std::ofstream ofs{download_path, std::ios::binary};

Check warning on line 36 in src/HealthGPS.Input/download_file.cpp

View check run for this annotation

Codecov / codecov/patch

src/HealthGPS.Input/download_file.cpp#L36

Added line #L36 was not covered by tests
if (!ofs) {
throw std::runtime_error(fmt::format("Failed to create file {}", download_path.string()));
}
Expand Down
9 changes: 5 additions & 4 deletions src/HealthGPS.Input/zip_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@
for (const auto &entry : zf.getEntries()) {
out_path = temp_output_directory / entry.getName();
if (entry.isDirectory()) {
if (!std::filesystem::create_directories(out_path)) {
throw std::runtime_error{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need the exception any more?

fmt::format("Failed to create directory: {}", out_path.string())};
}
// Names seem to have a trailing slash which confuses Windows, hence:
out_path /= ".";

Check warning on line 66 in src/HealthGPS.Input/zip_file.cpp

View check run for this annotation

Codecov / codecov/patch

src/HealthGPS.Input/zip_file.cpp#L66

Added line #L66 was not covered by tests

std::filesystem::create_directories(out_path);

Check warning on line 68 in src/HealthGPS.Input/zip_file.cpp

View check run for this annotation

Codecov / codecov/patch

src/HealthGPS.Input/zip_file.cpp#L68

Added line #L68 was not covered by tests
} else {
// NB: We assume all files are text files
std::ofstream ofs{out_path};
if (!ofs) {
throw std::runtime_error{
Expand Down
2 changes: 1 addition & 1 deletion src/HealthGPS/sha256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace hgps {
std::string compute_sha256_for_file(const std::filesystem::path &file_path, size_t buffer_size) {
std::ifstream ifs{file_path};
std::ifstream ifs{file_path, std::ios::binary};
if (!ifs) {
throw std::runtime_error(fmt::format("Could not read file: {}", file_path.string()));
}
Expand Down