Skip to content

Commit

Permalink
Merge branch 'master' into combined
Browse files Browse the repository at this point in the history
Combine two PRs together to test them.
  • Loading branch information
TheVeryDarkness committed Oct 18, 2023
2 parents 8346ada + 4edd92f commit 603ff6c
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 7 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: WASM

on:
push:
pull_request:
schedule:
- cron: "35 2 * * *"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Add target
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
vcp/bootstrap-vcpkg.sh
- name: Run integration tests
run: |
tests/wasm.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
30 changes: 24 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -58,7 +69,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`.
//!
Expand Down Expand Up @@ -734,13 +745,13 @@ fn load_ports(target: &VcpkgTarget) -> Result<BTreeMap<String, Port>, 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<PathBuf>
let mut paths = try!(paths
Expand Down Expand Up @@ -1364,6 +1375,13 @@ fn detect_target_triplet() -> Result<TargetTriplet, Error> {
lib_suffix: "a".into(),
strip_lib_prefix: true,
})
} else if target.starts_with("wasm32-") {
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-") {
Expand Down Expand Up @@ -1444,10 +1462,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(());
Expand Down
42 changes: 42 additions & 0 deletions tests/wasm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
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

source ../setup_vcp.sh

for port in harfbuzz ; do
# check that the port fails before it is installed
$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:$TRIPLET
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 --triplet=$TRIPLET
popd
cargo build --manifest-path top-level/Cargo.toml
unset VCPKG_INSTALLED_ROOT

0 comments on commit 603ff6c

Please sign in to comment.