From e4f098951ef22b1dab743d2008501d083fb64424 Mon Sep 17 00:00:00 2001 From: messense Date: Sun, 10 Sep 2023 19:24:43 +0800 Subject: [PATCH 1/2] Fix Windows CMake `Invalid character escape '\U'` error --- .github/workflows/CI.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 39acae6..dee21ae 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -76,7 +76,7 @@ jobs: if: matrix.toolchain != '1.63.0' shell: bash run: | - set -e + set -euo pipefail git clone --recurse-submodules https://github.com/gyscos/zstd-rs.git tests/zstd-rs cargo run zigbuild --manifest-path tests/zstd-rs/Cargo.toml --features bindgen --target aarch64-unknown-linux-gnu cargo run zigbuild --manifest-path tests/zstd-rs/Cargo.toml --features bindgen --target x86_64-pc-windows-gnu @@ -97,7 +97,7 @@ jobs: env: SDK: MacOSX11.3.sdk run: | - set -e + set -euo pipefail curl -sqL https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/$SDK.tar.xz | tar -Jx export SDKROOT=$PWD/$SDK @@ -127,7 +127,9 @@ jobs: ldd -r -v ./target/x86_64-unknown-linux-gnu/debug/cargo-zigbuild ./target/x86_64-unknown-linux-gnu/debug/cargo-zigbuild --help - name: Linux - Test glibc build + shell: bash run: | + set -euo pipefail cargo run zigbuild --target aarch64-unknown-linux-gnu cargo run zigbuild --target aarch64-unknown-linux-gnu.2.17 @@ -142,6 +144,7 @@ jobs: - name: Linux - Test glibc run/test if: matrix.os == 'ubuntu-latest' run: | + set -euo pipefail # Install qemu for `cargo-zigbuild run` support sudo apt-get update sudo apt-get install -y qemu-user qemu-user-static gcc-aarch64-linux-gnu binfmt-support @@ -160,7 +163,9 @@ jobs: cargo run zigbuild --target aarch64-unknown-linux-musl cargo run zigbuild --target aarch64-unknown-linux-musl --manifest-path tests/hello-rustls/Cargo.toml - name: Windows - Test gnu build + shell: bash run: | + set -euo pipefail cargo run zigbuild --target x86_64-pc-windows-gnu cargo run zigbuild --target x86_64-pc-windows-gnu --manifest-path tests/hello-windows/Cargo.toml cargo run zigbuild --target i686-pc-windows-gnu @@ -171,7 +176,9 @@ jobs: cargo run zigbuild --target aarch64-unknown-linux-gnu --manifest-path tests/hello-rustls/Cargo.toml --features curl - name: Windows - Test run if: matrix.os == 'windows-latest' + shell: bash run: | + set -euo pipefail ./target/x86_64-pc-windows-gnu/debug/cargo-zigbuild.exe zigbuild --help ./tests/hello-windows/target/x86_64-pc-windows-gnu/debug/hello-windows.exe From 296f90519239941e615488841015057bd7597fe4 Mon Sep 17 00:00:00 2001 From: messense Date: Sun, 10 Sep 2023 22:25:04 +0800 Subject: [PATCH 2/2] Try set CMAKE_LINKER --- src/zig.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/zig.rs b/src/zig.rs index 9fcf748..f98c6b8 100644 --- a/src/zig.rs +++ b/src/zig.rs @@ -866,9 +866,10 @@ impl Zig { r#" set(CMAKE_SYSTEM_NAME {system_name}) set(CMAKE_SYSTEM_PROCESSOR {system_processor}) -set(CMAKE_C_COMPILER {cc}) -set(CMAKE_CXX_COMPILER {cxx}) -set(CMAKE_RANLIB {ranlib})"#, +set(CMAKE_C_COMPILER {cc} CACHE FILEPATH "") +set(CMAKE_CXX_COMPILER {cxx} CACHE FILEPATH "") +set(CMAKE_LINKER {cc} CACHE FILEPATH "") +set(CMAKE_RANLIB {ranlib} CACHE FILEPATH "")"#, system_name = system_name, system_processor = system_processor, cc = zig_wrapper.cc.to_slash_lossy(), @@ -877,7 +878,7 @@ set(CMAKE_RANLIB {ranlib})"#, ); if enable_zig_ar { content.push_str(&format!( - "\nset(CMAKE_AR {})\n", + "\nset(CMAKE_AR {} CACHE FILEPATH \"\")\n", zig_wrapper.ar.to_slash_lossy() )); }