-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathbuild.py
58 lines (53 loc) · 1.46 KB
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
import os
import subprocess
root_dir = os.path.dirname(__file__)
# A couple of steps are necessary to get this build working which makes it slightly
# nonstandard compared to most other builds.
#
# * First, the Rust standard library needs to be recompiled with atomics
# enabled. to do that we use Cargo's unstable `-Zbuild-std` feature.
#
# * Next we need to compile everything with the `atomics` and `bulk-memory`
# features enabled, ensuring that LLVM will generate atomic instructions,
# shared memory, passive segments, etc.
os.environ.update(
{"RUSTFLAGS": "-C target-feature=+atomics,+bulk-memory,+mutable-globals"}
)
subprocess.run(
[
"cargo",
"build",
"--target",
"wasm32-unknown-unknown",
"--release",
"-Zbuild-std=std,panic_abort",
],
cwd=root_dir,
).check_returncode()
# Note the usage of `--target no-modules` here which is required for passing
# the memory import to each Wasm module.
subprocess.run(
[
"cargo",
"run",
"-p",
"wasm-bindgen-cli",
"--",
os.path.join(
root_dir,
"..",
"..",
"target",
"wasm32-unknown-unknown",
"release",
"wasm_audio_worklet.wasm",
),
"--out-dir",
os.path.join(root_dir, "pkg"),
"--target",
"web",
"--split-linked-modules",
],
cwd=root_dir,
).check_returncode()