Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use multi-value with interface types #1764

Merged
merged 10 commits into from
Sep 16, 2019
62 changes: 42 additions & 20 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ jobs:
toolchain: nightly
- template: ci/azure-install-node.yml
- template: ci/azure-install-geckodriver.yml
- template: ci/azure-install-sccache.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- script: cargo test
displayName: "Builds on native"
- script: cargo test --target wasm32-unknown-unknown
Expand All @@ -31,6 +32,8 @@ jobs:
displayName: "Futures test suite on native"
- script: cargo test -p wasm-bindgen-futures --target wasm32-unknown-unknown
displayName: "Futures test suite on wasm"
- script: cargo test -p wasm-bindgen-multi-value-xform
displayName: "multi-value xform tests on native"
- script: |
set -e
curl https://nodejs.org/download/nightly/v13.0.0-nightly2019081215b2d13310/node-v13.0.0-nightly2019081215b2d13310-linux-x64.tar.xz | tar xJf -
Expand All @@ -56,7 +59,8 @@ jobs:
toolchain: nightly
- template: ci/azure-install-node.yml
- template: ci/azure-install-geckodriver.yml
- template: ci/azure-install-sccache.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- script: cargo test --target wasm32-unknown-unknown
displayName: "wasm-bindgen test suite"
env:
Expand All @@ -78,14 +82,16 @@ jobs:
parameters:
toolchain: nightly
- template: ci/azure-install-node.yml
- template: ci/azure-install-sccache.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- script: cargo test --target wasm32-unknown-unknown --features nightly --test wasm

- job: test_cli
displayName: "Run wasm-bindgen-cli crate tests"
steps:
- template: ci/azure-install-rust.yml
- template: ci/azure-install-sccache.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- script: rustup target add wasm32-unknown-unknown
displayName: "install wasm target"
- script: cargo test -p wasm-bindgen-cli-support
Expand All @@ -102,7 +108,8 @@ jobs:
toolchain: nightly
- template: ci/azure-install-node.yml
- template: ci/azure-install-geckodriver.yml
- template: ci/azure-install-sccache.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- script: cargo build --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown
- script: cargo build --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --features Node
- script: cargo build --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --features Element
Expand All @@ -118,7 +125,8 @@ jobs:
toolchain: nightly
- template: ci/azure-install-node.yml
- template: ci/azure-install-geckodriver.yml
- template: ci/azure-install-sccache.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- script: cargo test -p js-sys --target wasm32-unknown-unknown

- job: test_webidl
Expand All @@ -129,7 +137,8 @@ jobs:
parameters:
toolchain: nightly
- template: ci/azure-install-node.yml
#- template: ci/azure-install-sccache.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- script: cargo test -p wasm-bindgen-webidl
- script: cargo test -p webidl-tests --target wasm32-unknown-unknown
env:
Expand All @@ -143,19 +152,23 @@ jobs:
parameters:
toolchain: nightly
- template: ci/azure-install-node.yml
- template: ci/azure-install-sccache.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- script: cargo test -p wasm-bindgen-macro

- job: test_wasm_interpreter
displayName: "Run wasm-bindgen-wasm-interpreter tests"
steps:
- template: ci/azure-install-rust.yml
- template: ci/azure-install-sccache.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- script: |
git clone https://github.com/WebAssembly/wabt
mkdir -p wabt/build
cd wabt/build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=off -DCMAKE_CXX_COMPILER_LAUNCHER=$RUSTC_WRAPPER
# Temporarily disable sccache because it is failing on CI.
# cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=off -DCMAKE_CXX_COMPILER_LAUNCHER=$RUSTC_WRAPPER
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=off
cmake --build . -- -j$(nproc)
echo "##vso[task.prependpath]$PWD"
- script: cargo test -p wasm-bindgen-wasm-interpreter
Expand All @@ -164,7 +177,8 @@ jobs:
displayName: "Test TypeScript output of wasm-bindgen"
steps:
- template: ci/azure-install-rust.yml
- template: ci/azure-install-sccache.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- template: ci/azure-install-node.yml
- script: cd crates/typescript-tests && ./run.sh

Expand All @@ -175,7 +189,8 @@ jobs:
# TODO: switch this back to `stable` when async/await is stable
parameters:
toolchain: nightly
- template: ci/azure-install-sccache.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- template: ci/azure-install-wasm-pack.yml
- script: mv _package.json package.json && npm install && rm package.json
displayName: "run npm install"
Expand All @@ -197,7 +212,8 @@ jobs:
- template: ci/azure-install-rust.yml
parameters:
toolchain: nightly-2019-08-27
- template: ci/azure-install-sccache.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- script: rustup component add rust-src
displayName: "install rust-src"
- script: cargo install xargo
Expand All @@ -220,7 +236,8 @@ jobs:
# TODO: switch this back to `stable` when async/await is stable
parameters:
toolchain: nightly
- template: ci/azure-install-sccache.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- template: ci/azure-install-wasm-pack.yml
- script: wasm-pack build --target web benchmarks
displayName: "build benchmarks"
Expand All @@ -235,7 +252,8 @@ jobs:
displayName: "Dist Linux binary"
steps:
- template: ci/azure-install-rust.yml
- template: ci/azure-install-sccache.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- script: rustup target add x86_64-unknown-linux-musl
- script: |
sudo apt update -y
Expand All @@ -258,7 +276,8 @@ jobs:
vmImage: macOS-10.13
steps:
- template: ci/azure-install-rust.yml
- template: ci/azure-install-sccache.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- script: cargo build --manifest-path crates/cli/Cargo.toml --release
env:
MACOSX_DEPLOYMENT_TARGET: 10.7
Expand All @@ -272,15 +291,17 @@ jobs:
vmImage: vs2017-win2016
steps:
- template: ci/azure-install-rust.yml
- template: ci/azure-install-sccache.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- script: cargo build --manifest-path crates/cli/Cargo.toml --release
env:
RUSTFLAGS: -Ctarget-feature=+crt-static
- template: ci/azure-create-tarball.yml
parameters:
name: dist_windows
- script: "%RUSTC_WRAPPER% -s"
- script: cat sccache.log
# Temporarily disable sccache because it is failing on CI.
# - script: "%RUSTC_WRAPPER% -s"
# - script: cat sccache.log

- job: doc_book
displayName: "Doc - build the book"
Expand All @@ -306,7 +327,8 @@ jobs:
# Install rustfmt so we can format the web-sys bindings
- script: rustup component add rustfmt
displayName: "Install rustfmt"
- template: ci/azure-install-sccache.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- script: cargo doc --no-deps --features 'nightly serde-serialize'
displayName: "Document wasm-bindgen"
- script: cargo doc --no-deps --manifest-path crates/js-sys/Cargo.toml
Expand Down
2 changes: 1 addition & 1 deletion crates/anyref-xform/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ edition = '2018'

[dependencies]
failure = "0.1"
walrus = "0.11.0"
walrus = "0.12.0"
6 changes: 4 additions & 2 deletions crates/cli-support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ log = "0.4"
rustc-demangle = "0.1.13"
serde_json = "1.0"
tempfile = "3.0"
walrus = "0.11.0"
walrus = "0.12.0"
wasm-bindgen-anyref-xform = { path = '../anyref-xform', version = '=0.2.50' }
wasm-bindgen-shared = { path = "../shared", version = '=0.2.50' }
wasm-bindgen-multi-value-xform = { path = '../multi-value-xform', version = '=0.2.50' }
wasm-bindgen-threads-xform = { path = '../threads-xform', version = '=0.2.50' }
wasm-bindgen-wasm-conventions = { path = '../wasm-conventions', version = '=0.2.50' }
wasm-bindgen-wasm-interpreter = { path = "../wasm-interpreter", version = '=0.2.50' }
wasm-webidl-bindings = "0.4.0"
wasm-webidl-bindings = "0.5.0"
29 changes: 17 additions & 12 deletions crates/cli-support/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,10 @@ impl<'a> Context<'a> {
};

let default_module_path = match self.config.mode {
OutputMode::Web => {
"\
OutputMode::Web => "\
if (typeof module === 'undefined') {
module = import.meta.url.replace(/\\.js$/, '_bg.wasm');
}"
}
}",
_ => "",
};

Expand Down Expand Up @@ -872,21 +870,30 @@ impl<'a> Context<'a> {

match self.config.encode_into {
EncodeInto::Always if !shared => {
self.global(&format!("
self.global(&format!(
"
const encodeString = {};
", encode_into));
",
encode_into
));
}
EncodeInto::Test if !shared => {
self.global(&format!("
self.global(&format!(
"
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
? {}
: {});
", encode_into, encode));
",
encode_into, encode
));
}
_ => {
self.global(&format!("
self.global(&format!(
"
const encodeString = {};
", encode));
",
encode
));
}
}

Expand Down Expand Up @@ -1080,7 +1087,6 @@ impl<'a> Context<'a> {
fields: Vec::new(),
})?;
self.global(&format!("let cached{} = new {}{};", s, name, args));

} else if !self.config.mode.always_run_in_browser() {
self.global(&format!(
"
Expand All @@ -1090,7 +1096,6 @@ impl<'a> Context<'a> {
s
));
self.global(&format!("let cached{0} = new l{0}{1};", s, args));

} else {
self.global(&format!("let cached{0} = new {0}{1};", s, args));
}
Expand Down
Loading