rust-cross / cargo-zigbuild

Compile Cargo project with zig as linker
MIT License
1.43k stars 51 forks source link

Fix Windows CMake build error #175

Closed messense closed 1 week ago

messense commented 11 months ago

Closes #174


Generated summary (powered by Graphite) > # TL;DR > This pull request modifies the CI.yml and zig.rs files to improve error handling and to set the CMake variables as cache variables. > > # What changed > In the CI.yml file, the `set -e` command was replaced with `set -euo pipefail` to ensure that the script stops on the first error it encounters and does not ignore any errors. This change was made in multiple places in the file. > > In the zig.rs file, the CMake variables `CMAKE_C_COMPILER`, `CMAKE_CXX_COMPILER`, `CMAKE_LINKER`, and `CMAKE_RANLIB` are now set as cache variables. This is done by appending `CACHE FILEPATH ""` to the `set` command. This change ensures that the variables are stored in the CMake cache and can be reused in subsequent CMake runs. > > # How to test > To test these changes, you can run the CI workflow. If the workflow completes successfully, it means that the changes are working as expected. You can also manually run the commands in the CI.yml file and check if they stop execution upon encountering an error. > > To test the changes in the zig.rs file, you can run a CMake build and check if the CMake variables are correctly set as cache variables. You can do this by inspecting the CMakeCache.txt file or by using the `cmake -LH` command. > > # Why make this change > The changes in the CI.yml file improve error handling by ensuring that the script stops execution when it encounters an error. This can help in identifying and fixing issues more quickly. > > The changes in the zig.rs file make the CMake build process more efficient by storing the CMake variables in the cache. This can speed up subsequent CMake runs as the variables do not need to be recalculated.