From ecc87a4d512840edfeec98a7974f954b73069330 Mon Sep 17 00:00:00 2001 From: TheVeryDarkness <3266343194@qq.com> Date: Fri, 13 Oct 2023 13:50:47 +0800 Subject: [PATCH 01/12] Basic support for targets related to wasm32 Map rust target wasm32-unknown-emscripten and wasm32-unknown-unknown to vcpkg triplet wasm32-emscripten. --- src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index b586b96..7c1d033 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1364,6 +1364,20 @@ fn detect_target_triplet() -> Result { lib_suffix: "a".into(), strip_lib_prefix: true, }) + } else if target == "wasm32-unknown-emscripten" { + Ok(TargetTriplet { + triplet: "wasm32-emscripten".into(), + is_static: true, + lib_suffix: "a".into(), + strip_lib_prefix: true, + }) + } else if target == "wasm32-unknown-unknown" { + Ok(TargetTriplet { + triplet: "wasm32-emscripten".into(), + is_static: true, + lib_suffix: "a".into(), + strip_lib_prefix: true, + }) } else if !target.contains("-pc-windows-msvc") { Err(Error::NotMSVC) } else if target.starts_with("x86_64-") { From e084b65d19dda1c010d4950b3073eedd6823dd0b Mon Sep 17 00:00:00 2001 From: TheVeryDarkness <3266343194@qq.com> Date: Fri, 13 Oct 2023 13:51:02 +0800 Subject: [PATCH 02/12] Format the codes. --- src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7c1d033..8123778 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -58,7 +58,7 @@ //! //! * `VCPKG_INSTALLED_ROOT` - Set the directory for the vcpkg installed directory. Corresponding to //! `--x-install-root` flag in `vcpkg install` command. -//! A typical use case is to set it to `vcpkg_installed` directory under build directory +//! A typical use case is to set it to `vcpkg_installed` directory under build directory //! to adapt [manifest mode of vcpkg](https://learn.microsoft.com/en-us/vcpkg/users/manifests). //! If set, this will override the default value of `VCPKG_ROOT/installed`. //! @@ -734,13 +734,13 @@ fn load_ports(target: &VcpkgTarget) -> Result, Error> { // load updates to the status file that have yet to be normalized let status_update_dir = target.status_path.join("updates"); - let paths = try!(fs::read_dir(&status_update_dir).map_err( - |e| Error::VcpkgInstallation(format!( + let paths = try!( + fs::read_dir(&status_update_dir).map_err(|e| Error::VcpkgInstallation(format!( "could not read status file updates dir ({}): {}", status_update_dir.display(), e - )) - )); + ))) + ); // get all of the paths of the update files into a Vec let mut paths = try!(paths @@ -1458,10 +1458,10 @@ mod tests { extern crate tempfile; + use self::tempfile::tempdir; use super::*; use std::env; use std::sync::Mutex; - use self::tempfile::tempdir; lazy_static! { static ref LOCK: Mutex<()> = Mutex::new(()); From 7f845a0c8f4cce61d2d30ef197555eddab3ce47d Mon Sep 17 00:00:00 2001 From: TheVeryDarkness <3266343194@qq.com> Date: Wed, 18 Oct 2023 01:40:57 +0800 Subject: [PATCH 03/12] Create wasm.yml and modify run.sh Pass extra args to run.sh. --- .github/workflows/wasm.yml | 25 +++++++++++++++++++++++++ tests/run.sh | 6 +++--- 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/wasm.yml diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml new file mode 100644 index 0000000..b5c242d --- /dev/null +++ b/.github/workflows/wasm.yml @@ -0,0 +1,25 @@ +name: WASM + +on: + push: + pull_request: + schedule: + - cron: "35 2 * * *" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Run build + run: cargo build --verbose --target wasm-unknown-unknown + - name: Run unit tests + run: cargo test --verbose --target wasm-unknown-unknown + - name: Install vcpkg + run: | + git clone https://github.com/Microsoft/vcpkg.git vcp + vcp/bootstrap-vcpkg.sh + - name: Run integration tests + run: | + tests/run.sh --target wasm-unknown-unknown diff --git a/tests/run.sh b/tests/run.sh index 01a1c86..dd36a56 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -11,12 +11,12 @@ source ../setup_vcp.sh for port in harfbuzz ; do # check that the port fails before it is installed $VCPKG_ROOT/vcpkg remove $port || true - cargo clean --manifest-path $port/Cargo.toml - cargo run --manifest-path $port/Cargo.toml && exit 2 + cargo clean $* --manifest-path $port/Cargo.toml + cargo run $* --manifest-path $port/Cargo.toml && exit 2 echo THIS FAILURE IS EXPECTED echo This is to ensure that we are not spuriously succeeding because the libraries already exist somewhere on the build machine. $VCPKG_ROOT/vcpkg install $port - cargo run --manifest-path $port/Cargo.toml + cargo run $* --manifest-path $port/Cargo.toml done From 42d067426bba8b1a2ac7d7f6328664dbbea032fb Mon Sep 17 00:00:00 2001 From: TheVeryDarkness <3266343194@qq.com> Date: Wed, 18 Oct 2023 01:52:34 +0800 Subject: [PATCH 04/12] Fixed the target name in wasm.yml --- .github/workflows/wasm.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index b5c242d..4bf9ee6 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -13,13 +13,13 @@ jobs: steps: - uses: actions/checkout@v2 - name: Run build - run: cargo build --verbose --target wasm-unknown-unknown + run: cargo build --verbose --target wasm32-unknown-unknown - name: Run unit tests - run: cargo test --verbose --target wasm-unknown-unknown + run: cargo test --verbose --target wasm32-unknown-unknown - name: Install vcpkg run: | git clone https://github.com/Microsoft/vcpkg.git vcp vcp/bootstrap-vcpkg.sh - name: Run integration tests run: | - tests/run.sh --target wasm-unknown-unknown + tests/run.sh --target wasm32-unknown-unknown From b9a4c72106358ec526fff2667e3a8a3cbff59d47 Mon Sep 17 00:00:00 2001 From: TheVeryDarkness <3266343194@qq.com> Date: Wed, 18 Oct 2023 01:55:32 +0800 Subject: [PATCH 05/12] Add wasm32-unknown-unknown target to rustup --- .github/workflows/wasm.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 4bf9ee6..2e0d92e 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -12,6 +12,8 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Add target + run: rustup target add wasm32-unknown-unknown - name: Run build run: cargo build --verbose --target wasm32-unknown-unknown - name: Run unit tests From 6c922ee5bc6da414fd027c1312c61058397f8a0c Mon Sep 17 00:00:00 2001 From: TheVeryDarkness <3266343194@qq.com> Date: Wed, 18 Oct 2023 03:01:56 +0800 Subject: [PATCH 06/12] Disable test running in wasm.yml --- .github/workflows/wasm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 2e0d92e..c9d2c75 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -16,8 +16,8 @@ jobs: run: rustup target add wasm32-unknown-unknown - name: Run build run: cargo build --verbose --target wasm32-unknown-unknown - - name: Run unit tests - run: cargo test --verbose --target wasm32-unknown-unknown + - name: Build unit tests + run: cargo test --no-run --verbose --target wasm32-unknown-unknown - name: Install vcpkg run: | git clone https://github.com/Microsoft/vcpkg.git vcp From 102bbb6f0912997a12afd10fb4b376eecab7a6fc Mon Sep 17 00:00:00 2001 From: TheVeryDarkness <3266343194@qq.com> Date: Wed, 18 Oct 2023 03:12:54 +0800 Subject: [PATCH 07/12] Fixed ci Do not run after building wasm target. --- .github/workflows/wasm.yml | 6 ++---- tests/run.sh | 6 +++--- tests/wasm.sh | 40 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 7 deletions(-) create mode 100755 tests/wasm.sh diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index c9d2c75..436b9c8 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -15,13 +15,11 @@ jobs: - name: Add target run: rustup target add wasm32-unknown-unknown - name: Run build - run: cargo build --verbose --target wasm32-unknown-unknown - - name: Build unit tests - run: cargo test --no-run --verbose --target wasm32-unknown-unknown + run: cargo build --verbose - name: Install vcpkg run: | git clone https://github.com/Microsoft/vcpkg.git vcp vcp/bootstrap-vcpkg.sh - name: Run integration tests run: | - tests/run.sh --target wasm32-unknown-unknown + tests/wasm.sh diff --git a/tests/run.sh b/tests/run.sh index dd36a56..01a1c86 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -11,12 +11,12 @@ source ../setup_vcp.sh for port in harfbuzz ; do # check that the port fails before it is installed $VCPKG_ROOT/vcpkg remove $port || true - cargo clean $* --manifest-path $port/Cargo.toml - cargo run $* --manifest-path $port/Cargo.toml && exit 2 + cargo clean --manifest-path $port/Cargo.toml + cargo run --manifest-path $port/Cargo.toml && exit 2 echo THIS FAILURE IS EXPECTED echo This is to ensure that we are not spuriously succeeding because the libraries already exist somewhere on the build machine. $VCPKG_ROOT/vcpkg install $port - cargo run $* --manifest-path $port/Cargo.toml + cargo run --manifest-path $port/Cargo.toml done diff --git a/tests/wasm.sh b/tests/wasm.sh new file mode 100755 index 0000000..0a5790a --- /dev/null +++ b/tests/wasm.sh @@ -0,0 +1,40 @@ +#!/bin/bash +set -ex + +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $SCRIPTDIR + +export CARGO_BUILD_TARGET=wasm32-unknown-unknown + +export VCPKG_ROOT=$SCRIPTDIR/../vcp + +source ../setup_vcp.sh + +for port in harfbuzz ; do + # check that the port fails before it is installed + $VCPKG_ROOT/vcpkg remove $port || true + cargo clean --manifest-path $port/Cargo.toml + cargo build --manifest-path $port/Cargo.toml && exit 2 + echo THIS FAILURE IS EXPECTED + echo This is to ensure that we are not spuriously succeeding because the libraries already exist somewhere on the build machine. + $VCPKG_ROOT/vcpkg install $port + cargo build --manifest-path $port/Cargo.toml +done + + +# check manifest mode + +# clean first +cargo clean --manifest-path top-level/Cargo.toml +unset VCPKG_INSTALLED_ROOT +rm -rf $VCPKG_ROOT/installed + +cargo build --manifest-path top-level/Cargo.toml && exit 2 +echo "This failure is expected, as we haven't installed anything from vcpkg yet." + +export VCPKG_INSTALLED_ROOT=$SCRIPTDIR/top-level/vcpkg_installed +pushd top-level +$VCPKG_ROOT/vcpkg install +popd +cargo build --manifest-path top-level/Cargo.toml +unset VCPKG_INSTALLED_ROOT From 02fe2d8b037b8e79c33d66f1a2b2500e888d731e Mon Sep 17 00:00:00 2001 From: TheVeryDarkness <3266343194@qq.com> Date: Wed, 18 Oct 2023 12:20:01 +0800 Subject: [PATCH 08/12] Set triplet in ci properly. --- tests/wasm.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/wasm.sh b/tests/wasm.sh index 0a5790a..ea39c65 100755 --- a/tests/wasm.sh +++ b/tests/wasm.sh @@ -4,6 +4,8 @@ set -ex SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $SCRIPTDIR +TRIPLET=wasm32-emscripten + export CARGO_BUILD_TARGET=wasm32-unknown-unknown export VCPKG_ROOT=$SCRIPTDIR/../vcp @@ -12,12 +14,12 @@ source ../setup_vcp.sh for port in harfbuzz ; do # check that the port fails before it is installed - $VCPKG_ROOT/vcpkg remove $port || true + $VCPKG_ROOT/vcpkg remove $port:$TRIPLET || true cargo clean --manifest-path $port/Cargo.toml cargo build --manifest-path $port/Cargo.toml && exit 2 echo THIS FAILURE IS EXPECTED echo This is to ensure that we are not spuriously succeeding because the libraries already exist somewhere on the build machine. - $VCPKG_ROOT/vcpkg install $port + $VCPKG_ROOT/vcpkg install $port:$TRIPLET cargo build --manifest-path $port/Cargo.toml done @@ -34,7 +36,7 @@ echo "This failure is expected, as we haven't installed anything from vcpkg yet. export VCPKG_INSTALLED_ROOT=$SCRIPTDIR/top-level/vcpkg_installed pushd top-level -$VCPKG_ROOT/vcpkg install +$VCPKG_ROOT/vcpkg install --triplet=$TRIPLET popd cargo build --manifest-path top-level/Cargo.toml unset VCPKG_INSTALLED_ROOT From 480e50489f558eea73d00dde65dac3fe4059ac82 Mon Sep 17 00:00:00 2001 From: TheVeryDarkness <3266343194@qq.com> Date: Wed, 18 Oct 2023 12:28:28 +0800 Subject: [PATCH 09/12] Install emsdk in ci --- .github/workflows/wasm.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 436b9c8..838b91d 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -16,6 +16,11 @@ jobs: run: rustup target add wasm32-unknown-unknown - name: Run build run: cargo build --verbose + - name: Setup emsdk with cache + uses: mymindstorm/setup-emsdk@v11 + with: + version: 1.38.40 + actions-cache-folder: 'emsdk-cache' - name: Install vcpkg run: | git clone https://github.com/Microsoft/vcpkg.git vcp From 7b26c536f65f668afe88d3a2b049ce6478575c16 Mon Sep 17 00:00:00 2001 From: TheVeryDarkness <3266343194@qq.com> Date: Wed, 18 Oct 2023 12:48:24 +0800 Subject: [PATCH 10/12] Map wasm32-*-* targets to wasm32-emscripten triplet --- src/lib.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8123778..f234b54 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1364,14 +1364,7 @@ fn detect_target_triplet() -> Result { lib_suffix: "a".into(), strip_lib_prefix: true, }) - } else if target == "wasm32-unknown-emscripten" { - Ok(TargetTriplet { - triplet: "wasm32-emscripten".into(), - is_static: true, - lib_suffix: "a".into(), - strip_lib_prefix: true, - }) - } else if target == "wasm32-unknown-unknown" { + } else if target.starts_with("wasm32-") { Ok(TargetTriplet { triplet: "wasm32-emscripten".into(), is_static: true, From 4edd92f84976e07e56fb3ba612eea2276e22e759 Mon Sep 17 00:00:00 2001 From: TheVeryDarkness <3266343194@qq.com> Date: Wed, 18 Oct 2023 13:13:04 +0800 Subject: [PATCH 11/12] Update documentation and readme for wasm32 --- README.md | 2 +- src/lib.rs | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f5aa3b9..0e248b5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# vcpkg-rs [![Windows](https://github.com/mcgoo/vcpkg-rs/workflows/Windows/badge.svg?branch=master)](https://github.com/mcgoo/vcpkg-rs/actions?query=workflow%3AWindows) [![macOS](https://github.com/mcgoo/vcpkg-rs/workflows/macOS/badge.svg?branch=master)](https://github.com/mcgoo/vcpkg-rs/actions?query=workflow%3AmacOS) [![Linux](https://github.com/mcgoo/vcpkg-rs/workflows/Linux/badge.svg?branch=master)](https://github.com/mcgoo/vcpkg-rs/actions?query=workflow%3ALinux) +# vcpkg-rs [![Windows](https://github.com/mcgoo/vcpkg-rs/workflows/Windows/badge.svg?branch=master)](https://github.com/mcgoo/vcpkg-rs/actions?query=workflow%3AWindows) [![macOS](https://github.com/mcgoo/vcpkg-rs/workflows/macOS/badge.svg?branch=master)](https://github.com/mcgoo/vcpkg-rs/actions?query=workflow%3AmacOS) [![Linux](https://github.com/mcgoo/vcpkg-rs/workflows/Linux/badge.svg?branch=master)](https://github.com/mcgoo/vcpkg-rs/actions?query=workflow%3ALinux) [![WASM](https://github.com/mcgoo/vcpkg-rs/workflows/Linux/badge.svg?branch=master)](https://github.com/mcgoo/vcpkg-rs/actions?query=workflow%3AWASM) [Documentation](https://docs.rs/vcpkg) [Changelog](CHANGELOG.md) diff --git a/src/lib.rs b/src/lib.rs index f234b54..87e13f2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,6 +46,17 @@ //! generate dynamically linked binaries, in which case you will have to arrange for //! dlls from your Vcpkg installation to be available in your path. //! +//! ## WASM 32 +//! +//! At this time, vcpkg has a single triplet for wasm32, wasm32-emscripten, +//! while rust has several targets for wasm32. +//! Currently all of these targets are mapped to wasm32-emscripten triplet. +//! +//! You can open an [issue](https://github.com/mcgoo/vcpkg-rs/issue) +//! if more wasm32 triplets come to vcpkg. +//! And just like other target, it is possibleto select a custom triplet +//! using the `VCPKGRS_TRIPLET` environment variable. +//! //! # Environment variables //! //! A number of environment variables are available to globally configure which From f9e7eaff7bf691d3ee49ed3065939ffbf6d199bb Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Tue, 14 Nov 2023 18:15:57 -0500 Subject: [PATCH 12/12] test/harfbuzz/build.rs: remove outdated comment The comment is no longer operative now that the println is gone. --- tests/harfbuzz/build.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/harfbuzz/build.rs b/tests/harfbuzz/build.rs index b9cb5fc..b79306e 100644 --- a/tests/harfbuzz/build.rs +++ b/tests/harfbuzz/build.rs @@ -4,11 +4,6 @@ extern crate vcpkg; fn main() { let libs = vcpkg::Config::new().find_package("harfbuzz").unwrap(); - // vcpkg-rs is not capable of working out the correct order to link - // libraries in. This only matters on Linux at present. (vcpkg itself - // does fine, but vcpkg-rs needs to work out how to get the link order - // from the it.) - let mut build = cc::Build::new(); build.file("src/test.c"); for inc in libs.include_paths {