From 2dd0d0e247e6aba97670edb5560f4b3764b58780 Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Tue, 27 Jun 2023 16:55:40 +1000 Subject: [PATCH 01/13] Add support for -pc-windows-gnu targets --- .github/workflows/windows.yml | 18 ++++++++++++++ src/lib.rs | 44 ++++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index fe5db93..1436894 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -40,6 +40,24 @@ jobs: VCPKG_DEFAULT_TRIPLET: "x86-windows", VCPKGRS_DYNAMIC: 1, } + - { + target: "x86_64-pc-windows-gnu", + VCPKG_DEFAULT_TRIPLET: "x64-mingw-static", + } + - { + target: "x86_64-pc-windows-gnu", + VCPKG_DEFAULT_TRIPLET: "x64-mingw-dynamic", + VCPKGRS_DYNAMIC: 1, + } + - { + target: "i686-pc-windows-gnu", + VCPKG_DEFAULT_TRIPLET: "x86-mingw-static", + } + - { + target: "i686-pc-windows-gnu", + VCPKG_DEFAULT_TRIPLET: "x86-mingw-dynamic", + VCPKGRS_DYNAMIC: 1, + } fail-fast: false steps: - uses: actions/checkout@v2 diff --git a/src/lib.rs b/src/lib.rs index b586b96..955bbc7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -229,6 +229,9 @@ pub enum Error { /// Could not understand vcpkg installation VcpkgInstallation(String), + /// Unsupported target CPU architecture + UnsupportedArchitecture, + #[doc(hidden)] __Nonexhaustive, } @@ -242,6 +245,7 @@ impl error::Error for Error { Error::VcpkgNotFound(_) => "could not find Vcpkg tree", Error::LibNotFound(_) => "could not find library in Vcpkg tree", Error::VcpkgInstallation(_) => "could not look up details of packages in vcpkg tree", + Error::UnsupportedArchitecture => "target CPU architcture is not supported", Error::__Nonexhaustive => panic!(), } } @@ -261,7 +265,7 @@ impl fmt::Display for Error { Error::RequiredEnvMissing(ref name) => write!(f, "Aborted because {} is not set", name), Error::NotMSVC => write!( f, - "the vcpkg-rs Vcpkg build helper can only find libraries built for the MSVC ABI." + "the vcpkg-rs Vcpkg build helper can only find libraries built for the GNU or MSVC ABI." ), Error::VcpkgNotFound(ref detail) => write!(f, "Could not find Vcpkg tree: {}", detail), Error::LibNotFound(ref detail) => { @@ -272,6 +276,7 @@ impl fmt::Display for Error { "Could not look up details of packages in vcpkg tree {}", detail ), + Error::UnsupportedArchitecture => write!(f, "vcpkg-rs does not support the target CPU architecture."), Error::__Nonexhaustive => panic!(), } } @@ -1364,6 +1369,43 @@ fn detect_target_triplet() -> Result { lib_suffix: "a".into(), strip_lib_prefix: true, }) + } else if target.ends_with("-pc-windows-gnu") { + if target.starts_with("x86_64-") { + if is_definitely_dynamic { + Ok(TargetTriplet { + triplet: "x64-mingw-dynamic".into(), + is_static: false, + lib_suffix: "a".into(), + strip_lib_prefix: true, + }) + } else { + Ok(TargetTriplet { + triplet: "x64-mingw-static".into(), + is_static: true, + lib_suffix: "a".into(), + strip_lib_prefix: true, + }) + } + } else if target.starts_with("i686-") { + if is_definitely_dynamic { + Ok(TargetTriplet { + triplet: "x86-mingw-dynamic".into(), + is_static: false, + lib_suffix: "a".into(), + strip_lib_prefix: true, + }) + } else { + Ok(TargetTriplet { + triplet: "x86-mingw-static".into(), + is_static: true, + lib_suffix: "a".into(), + strip_lib_prefix: true, + }) + } + } else { + // Rust doesn't support aarch64-pc-windows-gnu :( + Err(Error::UnsupportedArchitecture) + } } else if !target.contains("-pc-windows-msvc") { Err(Error::NotMSVC) } else if target.starts_with("x86_64-") { From 433286b8b07ca76988f2ff98e1e00bd5c632c3bb Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Tue, 27 Jun 2023 17:26:27 +1000 Subject: [PATCH 02/13] fixup tests --- src/lib.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 955bbc7..1d107f5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1499,16 +1499,16 @@ mod tests { fn do_nothing_for_unsupported_target() { let _g = LOCK.lock(); env::set_var("VCPKG_ROOT", "/"); - env::set_var("TARGET", "x86_64-pc-windows-gnu"); + env::set_var("TARGET", "x86_64-pc-windows-invalid"); assert!(match ::probe_package("foo") { Err(Error::NotMSVC) => true, _ => false, }); - env::set_var("TARGET", "x86_64-pc-windows-gnu"); - assert_eq!(env::var("TARGET"), Ok("x86_64-pc-windows-gnu".to_string())); + env::set_var("TARGET", "aarch64-pc-windows-gnu"); + assert_eq!(env::var("TARGET"), Ok("aarch64-pc-windows-gnu".to_string())); assert!(match ::probe_package("foo") { - Err(Error::NotMSVC) => true, + Err(Error::UnsupportedArchitecture) => true, _ => false, }); env::remove_var("TARGET"); @@ -1640,6 +1640,8 @@ mod tests { for target in &[ "x86_64-apple-darwin", "i686-pc-windows-msvc", + // TODO: add test data for platforms + // "x86_64-pc-windows-gnu", // "x86_64-pc-windows-msvc", // "x86_64-unknown-linux-gnu", ] { From c12ed95c649a4d08ba986a46c2fa3209be8bc35e Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Tue, 27 Jun 2023 17:41:18 +1000 Subject: [PATCH 03/13] Disable i686-pc-windows-gnu in CI due to missing tools in image --- .github/workflows/windows.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 1436894..2aee2ae 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -49,15 +49,16 @@ jobs: VCPKG_DEFAULT_TRIPLET: "x64-mingw-dynamic", VCPKGRS_DYNAMIC: 1, } - - { - target: "i686-pc-windows-gnu", - VCPKG_DEFAULT_TRIPLET: "x86-mingw-static", - } - - { - target: "i686-pc-windows-gnu", - VCPKG_DEFAULT_TRIPLET: "x86-mingw-dynamic", - VCPKGRS_DYNAMIC: 1, - } + # GitHub Actions doesn't have an i686 Mingw compiler. + # - { + # target: "i686-pc-windows-gnu", + # VCPKG_DEFAULT_TRIPLET: "x86-mingw-static", + # } + # - { + # target: "i686-pc-windows-gnu", + # VCPKG_DEFAULT_TRIPLET: "x86-mingw-dynamic", + # VCPKGRS_DYNAMIC: 1, + # } fail-fast: false steps: - uses: actions/checkout@v2 From 43b7168691897f706c1b635728f752274baa930d Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Tue, 27 Jun 2023 18:11:05 +1000 Subject: [PATCH 04/13] patch around libz --- .github/workflows/windows.yml | 2 +- systest/Cargo.toml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 2aee2ae..7bb32b2 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -117,5 +117,5 @@ jobs: ${VCPKG_ROOT}/vcpkg.exe install curl zeromq openssl cargo build --target ${{ matrix.config.target }} --all cargo test --target ${{ matrix.config.target }} --all - cargo run --target ${{ matrix.config.target }} --manifest-path vcpkg_cli/Cargo.toml -- probe curl + cargo run --target ${{ matrix.config.target }} --manifest-path vcpkg_cli/Cargo.toml -- --target ${{ matrix.config.target }} probe curl cargo run --target ${{ matrix.config.target }} --manifest-path systest/Cargo.toml diff --git a/systest/Cargo.toml b/systest/Cargo.toml index 3798ecb..72fd12a 100644 --- a/systest/Cargo.toml +++ b/systest/Cargo.toml @@ -12,7 +12,8 @@ extras=["zmq-sys"] # versions do not build curl = "*" libz-sys = "*" -openssl-sys = "*" +# TODO: roll back to upstream once vcpkg issue fixed +openssl-sys = { git = "https://github.com/micolous/libz-sys", branch = "vcpkg" } zmq-sys = { git = "https://github.com/mcgoo/rust-zmq", branch = "vcpkg", optional=true } # always test against the vcpkg crate in this repo From 26e4daf5b998664389e98b9d319dea49515dde68 Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Tue, 27 Jun 2023 18:24:24 +1000 Subject: [PATCH 05/13] patch libz-sys --- systest/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/systest/Cargo.toml b/systest/Cargo.toml index 72fd12a..cacb3ac 100644 --- a/systest/Cargo.toml +++ b/systest/Cargo.toml @@ -11,9 +11,9 @@ extras=["zmq-sys"] # the purpose of this project is to fail in CI if the latest # versions do not build curl = "*" -libz-sys = "*" # TODO: roll back to upstream once vcpkg issue fixed -openssl-sys = { git = "https://github.com/micolous/libz-sys", branch = "vcpkg" } +libz-sys = { git = "https://github.com/micolous/libz-sys", branch = "vcpkg" } +openssl-sys = "*" zmq-sys = { git = "https://github.com/mcgoo/rust-zmq", branch = "vcpkg", optional=true } # always test against the vcpkg crate in this repo From 6dfa5681b3351fc288644fef762742dfb16b6986 Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Tue, 27 Jun 2023 18:41:41 +1000 Subject: [PATCH 06/13] patch libz harder for libcurl --- systest/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/systest/Cargo.toml b/systest/Cargo.toml index cacb3ac..357c53d 100644 --- a/systest/Cargo.toml +++ b/systest/Cargo.toml @@ -19,6 +19,7 @@ zmq-sys = { git = "https://github.com/mcgoo/rust-zmq", branch = "vcpkg", optiona # always test against the vcpkg crate in this repo [patch.crates-io] vcpkg = { path = '../' } +libz-sys = { git = "https://github.com/micolous/libz-sys", branch = "vcpkg" } [patch.'https://github.com/mcgoo/vcpkg-rs'] vcpkg = { path = '../' } From 899f582e8e652a6c80d1c687f7d6e0fc619b173f Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Wed, 28 Jun 2023 10:37:00 +1000 Subject: [PATCH 07/13] switch to vcpkg branches for everything --- systest/Cargo.toml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/systest/Cargo.toml b/systest/Cargo.toml index 357c53d..eddcff1 100644 --- a/systest/Cargo.toml +++ b/systest/Cargo.toml @@ -11,15 +11,17 @@ extras=["zmq-sys"] # the purpose of this project is to fail in CI if the latest # versions do not build curl = "*" -# TODO: roll back to upstream once vcpkg issue fixed -libz-sys = { git = "https://github.com/micolous/libz-sys", branch = "vcpkg" } +libz-sys = "*" openssl-sys = "*" zmq-sys = { git = "https://github.com/mcgoo/rust-zmq", branch = "vcpkg", optional=true } # always test against the vcpkg crate in this repo [patch.crates-io] vcpkg = { path = '../' } +# TODO: roll back to upstream once PRs merged +curl = { git = "https://github.com/micolous/curl-rust", branch = "vcpkg" } libz-sys = { git = "https://github.com/micolous/libz-sys", branch = "vcpkg" } +openssl-sys = { git = "https://github.com/micolous/rust-openssl", branch = "vcpkg" } [patch.'https://github.com/mcgoo/vcpkg-rs'] vcpkg = { path = '../' } From dc6239c7da403f3c09a1aa16d8aa7665256938e9 Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Mon, 28 Aug 2023 16:45:32 +1000 Subject: [PATCH 08/13] use upstream libz-sys and openssl-sys as PRs are merged --- systest/Cargo.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/systest/Cargo.toml b/systest/Cargo.toml index eddcff1..46e62b1 100644 --- a/systest/Cargo.toml +++ b/systest/Cargo.toml @@ -20,8 +20,6 @@ zmq-sys = { git = "https://github.com/mcgoo/rust-zmq", branch = "vcpkg", optiona vcpkg = { path = '../' } # TODO: roll back to upstream once PRs merged curl = { git = "https://github.com/micolous/curl-rust", branch = "vcpkg" } -libz-sys = { git = "https://github.com/micolous/libz-sys", branch = "vcpkg" } -openssl-sys = { git = "https://github.com/micolous/rust-openssl", branch = "vcpkg" } [patch.'https://github.com/mcgoo/vcpkg-rs'] vcpkg = { path = '../' } From 2a7927805456d1965f2a1d3f4269025e72c994db Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Mon, 28 Aug 2023 17:00:33 +1000 Subject: [PATCH 09/13] make curl optional, dont build it on *-pc-windows-gnu --- .github/workflows/windows.yml | 27 +++++++++++++-------------- systest/Cargo.toml | 5 ++--- systest/src/main.rs | 2 ++ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 7bb32b2..cee4eee 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -16,29 +16,35 @@ jobs: target: "x86_64-pc-windows-msvc", VCPKG_DEFAULT_TRIPLET: "x64-windows-static", RUSTFLAGS: "-Ctarget-feature=+crt-static", + features: "curl", } - { target: "x86_64-pc-windows-msvc", VCPKG_DEFAULT_TRIPLET: "x64-windows-static-md", + features: "curl", } - { target: "x86_64-pc-windows-msvc", VCPKG_DEFAULT_TRIPLET: "x64-windows", VCPKGRS_DYNAMIC: 1, + features: "curl", } - { target: "i686-pc-windows-msvc", VCPKG_DEFAULT_TRIPLET: "x86-windows-static", RUSTFLAGS: "-Ctarget-feature=+crt-static", + features: "curl", } - { target: "i686-pc-windows-msvc", VCPKG_DEFAULT_TRIPLET: "x86-windows-static-md", + features: "curl", } - { target: "i686-pc-windows-msvc", VCPKG_DEFAULT_TRIPLET: "x86-windows", VCPKGRS_DYNAMIC: 1, + features: "curl", } - { target: "x86_64-pc-windows-gnu", @@ -49,19 +55,9 @@ jobs: VCPKG_DEFAULT_TRIPLET: "x64-mingw-dynamic", VCPKGRS_DYNAMIC: 1, } - # GitHub Actions doesn't have an i686 Mingw compiler. - # - { - # target: "i686-pc-windows-gnu", - # VCPKG_DEFAULT_TRIPLET: "x86-mingw-static", - # } - # - { - # target: "i686-pc-windows-gnu", - # VCPKG_DEFAULT_TRIPLET: "x86-mingw-dynamic", - # VCPKGRS_DYNAMIC: 1, - # } fail-fast: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Dump GitHub context env: GITHUB_CONTEXT: ${{ toJson(github) }} @@ -114,8 +110,11 @@ jobs: echo VCPKG_ROOT=${VCPKG_ROOT} echo dyn=${{ matrix.config.VCPKGRS_DYNAMIC }} if [ '${{ matrix.config.VCPKGRS_DYNAMIC }}' != '' ] ; then export VCPKGRS_DYNAMIC=1 ; fi - ${VCPKG_ROOT}/vcpkg.exe install curl zeromq openssl + ${VCPKG_ROOT}/vcpkg.exe install zlib zeromq openssl + if [ '${{ matrix.config.features }}' =~ 'curl' ] + ${VCPKG_ROOT}/vcpkg.exe install curl + fi cargo build --target ${{ matrix.config.target }} --all cargo test --target ${{ matrix.config.target }} --all - cargo run --target ${{ matrix.config.target }} --manifest-path vcpkg_cli/Cargo.toml -- --target ${{ matrix.config.target }} probe curl - cargo run --target ${{ matrix.config.target }} --manifest-path systest/Cargo.toml + cargo run --target ${{ matrix.config.target }} --manifest-path vcpkg_cli/Cargo.toml -- --target ${{ matrix.config.target }} probe zlib + cargo run --target ${{ matrix.config.target }} --manifest-path systest/Cargo.toml --features '${{ matrix.config.features }}' diff --git a/systest/Cargo.toml b/systest/Cargo.toml index 46e62b1..a475779 100644 --- a/systest/Cargo.toml +++ b/systest/Cargo.toml @@ -4,13 +4,14 @@ version = "0.1.0" authors = ["Jim McGrath "] [features] +curl=["dep:curl"] extras=["zmq-sys"] [dependencies] # using * for the dependency version is appropriate here since # the purpose of this project is to fail in CI if the latest # versions do not build -curl = "*" +curl = { version = "*", optional = true } libz-sys = "*" openssl-sys = "*" zmq-sys = { git = "https://github.com/mcgoo/rust-zmq", branch = "vcpkg", optional=true } @@ -18,8 +19,6 @@ zmq-sys = { git = "https://github.com/mcgoo/rust-zmq", branch = "vcpkg", optiona # always test against the vcpkg crate in this repo [patch.crates-io] vcpkg = { path = '../' } -# TODO: roll back to upstream once PRs merged -curl = { git = "https://github.com/micolous/curl-rust", branch = "vcpkg" } [patch.'https://github.com/mcgoo/vcpkg-rs'] vcpkg = { path = '../' } diff --git a/systest/src/main.rs b/systest/src/main.rs index 64a2910..8c51b10 100644 --- a/systest/src/main.rs +++ b/systest/src/main.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "curl")] extern crate curl; extern crate libz_sys; extern crate openssl_sys; @@ -8,6 +9,7 @@ extern crate zmq_sys; use std::ffi::CStr; fn main() { + #[cfg(feature = "curl")] println!("curl version is {:?}!", curl::Version::get().version()); unsafe { From cd51414aac0ec351358a09c371d33060972b98bd Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Mon, 28 Aug 2023 17:13:32 +1000 Subject: [PATCH 10/13] bash syntax error --- .github/workflows/windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index cee4eee..a769a6e 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -111,7 +111,7 @@ jobs: echo dyn=${{ matrix.config.VCPKGRS_DYNAMIC }} if [ '${{ matrix.config.VCPKGRS_DYNAMIC }}' != '' ] ; then export VCPKGRS_DYNAMIC=1 ; fi ${VCPKG_ROOT}/vcpkg.exe install zlib zeromq openssl - if [ '${{ matrix.config.features }}' =~ 'curl' ] + if [ '${{ matrix.config.features }}' =~ 'curl' ]; then ${VCPKG_ROOT}/vcpkg.exe install curl fi cargo build --target ${{ matrix.config.target }} --all From 69ecbb8b5b37d847e8459d75c0ba45840d8641ae Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Mon, 28 Aug 2023 17:31:52 +1000 Subject: [PATCH 11/13] remove zeromq from systest, because it is never used --- .github/workflows/windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index a769a6e..65874db 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -110,7 +110,7 @@ jobs: echo VCPKG_ROOT=${VCPKG_ROOT} echo dyn=${{ matrix.config.VCPKGRS_DYNAMIC }} if [ '${{ matrix.config.VCPKGRS_DYNAMIC }}' != '' ] ; then export VCPKGRS_DYNAMIC=1 ; fi - ${VCPKG_ROOT}/vcpkg.exe install zlib zeromq openssl + ${VCPKG_ROOT}/vcpkg.exe install zlib openssl if [ '${{ matrix.config.features }}' =~ 'curl' ]; then ${VCPKG_ROOT}/vcpkg.exe install curl fi From 6cf05e4331531d84cc1c1f4da3a80f4623498f5a Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Mon, 28 Aug 2023 17:34:01 +1000 Subject: [PATCH 12/13] fix another syntax error --- .github/workflows/windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 65874db..d8eae51 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -111,7 +111,7 @@ jobs: echo dyn=${{ matrix.config.VCPKGRS_DYNAMIC }} if [ '${{ matrix.config.VCPKGRS_DYNAMIC }}' != '' ] ; then export VCPKGRS_DYNAMIC=1 ; fi ${VCPKG_ROOT}/vcpkg.exe install zlib openssl - if [ '${{ matrix.config.features }}' =~ 'curl' ]; then + if [[ '${{ matrix.config.features }}' =~ 'curl' ]]; then ${VCPKG_ROOT}/vcpkg.exe install curl fi cargo build --target ${{ matrix.config.target }} --all From 5ae52970f6ba5062493b24b74d491c05d6c98933 Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Tue, 29 Aug 2023 11:03:33 +1000 Subject: [PATCH 13/13] print openssl version, and message when curl is disabled --- systest/src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/systest/src/main.rs b/systest/src/main.rs index 8c51b10..75935d9 100644 --- a/systest/src/main.rs +++ b/systest/src/main.rs @@ -11,6 +11,8 @@ use std::ffi::CStr; fn main() { #[cfg(feature = "curl")] println!("curl version is {:?}!", curl::Version::get().version()); + #[cfg(not(feature = "curl"))] + println!("curl test disabled in this build!"); unsafe { println!( @@ -19,9 +21,13 @@ fn main() { ); } - //unsafe{ println!("openssl version is {:?}!", CStr::from_ptr(openssl_sys::SSLEAY_VERSION));} openssl_sys::init(); - // println!("openssl version is {}!", openssl_sys::OPENSSL_VERSION); + unsafe { + println!( + "openssl version is {:?}!", + CStr::from_ptr(openssl_sys::OpenSSL_version(openssl_sys::OPENSSL_VERSION)) + ); + } // unsafe {let ctx = zmq_sys::zmq_init(1); }