Skip to content

Commit f008fb2

Browse files
committed
web: Allow building an MVP vanilla WASM module
1 parent 6a8f77c commit f008fb2

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

web/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ In this project, you may run the following commands to build all packages:
106106
- There is `npm run build:dual-wasm` as well, to build a second WebAssembly module that makes use of some WebAssembly extensions,
107107
potentially resulting in better performance in browsers that support them, at the expense of longer build time.
108108
- `npm run build:repro` enables reproducible builds. Note that this also requires a `version_seal.json`, which is not provided in the normal Git repository - only specially-marked reproducible source archives. Running this without a version seal will generate one based on the current state of your environment.
109+
- With either of the prior two commands, you can set the environment variable `BUILD_WASM_MVP=1`. This will build the vanilla WASM module using nightly Rust and disable all WebAssembly features that Rust enables by default. You will first need to run the command `rustup target add wasm32-unknown-unknown --toolchain nightly` so nightly Rust can also output WebAssembly.
109110

110111
From here, you may follow the instructions to [use Ruffle on your website](packages/selfhosted/README.md),
111112
run a demo locally with `npm run demo`, or [install the extension in your browser](https://github.com/ruffle-rs/ruffle/wiki/Using-Ruffle#browser-extension).

web/packages/core/tools/build_wasm.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,25 @@ function cargoBuild({
4242
profile,
4343
features,
4444
rustFlags,
45+
extensions,
4546
}: {
4647
profile?: string;
4748
features?: string[];
4849
rustFlags?: string[];
50+
extensions?: boolean;
4951
}) {
50-
let args = ["build", "--locked", "--target", "wasm32-unknown-unknown"];
52+
let args =
53+
!extensions && process.env["BUILD_WASM_MVP"]
54+
? [
55+
"+nightly",
56+
"build",
57+
"--locked",
58+
"-Z",
59+
"build-std=std,panic_abort",
60+
"--target",
61+
"wasm32-unknown-unknown",
62+
]
63+
: ["build", "--locked", "--target", "wasm32-unknown-unknown"];
5164
if (profile) {
5265
args.push("--profile", profile);
5366
}
@@ -99,9 +112,13 @@ function buildWasm(
99112
let originalWasmPath;
100113
if (wasmSource === "cargo" || wasmSource === "cargo_and_store") {
101114
console.log(`Building ${flavor} with cargo...`);
115+
if (process.env["BUILD_WASM_MVP"]) {
116+
rustFlags.push("-C", "target-cpu=mvp");
117+
}
102118
cargoBuild({
103119
profile,
104120
rustFlags,
121+
extensions,
105122
});
106123
originalWasmPath = `../../../target/wasm32-unknown-unknown/${profile}/ruffle_web.wasm`;
107124
if (wasmSource === "cargo_and_store") {

0 commit comments

Comments
 (0)