|
1 | 1 | #!/usr/bin/env bash
|
2 | 2 | set -ex
|
3 | 3 |
|
| 4 | +working_dir="$(pwd)" |
| 5 | +script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" |
| 6 | + |
| 7 | +# Ensure apt-get is current, because otherwise bootstrapping might fail |
| 8 | +sudo apt-get update -y |
| 9 | + |
| 10 | +# Ensure the Rust version matches that used by Gecko, and can compile to WASI |
| 11 | +rustup update 1.55.0 |
| 12 | +rustup default 1.55.0 |
| 13 | +rustup target add wasm32-wasi |
| 14 | + |
4 | 15 | if [[ ! -a gecko-dev ]]
|
5 | 16 | then
|
6 |
| - # Ensure apt-get is current, because otherwise bootstrapping might fail |
7 |
| - sudo apt-get update -y |
8 |
| - |
9 |
| - # Ensure the Rust version matches that used by Gecko, and can compile to WASI |
10 |
| - rustup update 1.54.0 |
11 |
| - rustup default 1.54.0 |
12 |
| - rustup target add wasm32-wasi |
13 | 17 |
|
14 | 18 | # Clone Gecko repository at the required revision
|
15 | 19 | mkdir gecko-dev
|
16 | 20 | cd gecko-dev
|
17 | 21 |
|
18 | 22 | git init
|
19 |
| - git remote add origin $(cat ../gecko-repository) |
20 |
| - git fetch --depth 1 origin $(cat ../gecko-revision) |
21 |
| - git checkout FETCH_HEAD |
22 |
| - |
23 |
| - # Use Gecko's build system bootstrapping to ensure all dependencies are installed |
24 |
| - ./mach bootstrap --application-choice=js |
25 |
| - |
| 23 | + git remote add --no-tags -t wasi-embedding origin $(cat $script_dir/gecko-repository) |
26 | 24 | cd ..
|
27 | 25 | fi
|
28 | 26 |
|
| 27 | +cd gecko-dev |
| 28 | +git fetch --depth 1 origin $(cat $script_dir/gecko-revision) |
| 29 | +git checkout FETCH_HEAD |
| 30 | + |
| 31 | +# Use Gecko's build system bootstrapping to ensure all dependencies are installed |
| 32 | +./mach bootstrap --application-choice=js |
| 33 | + |
| 34 | +# ... except, that doesn't install the wasi-sysroot, which we need, so we do that manually. |
| 35 | +cd ~/.mozbuild |
| 36 | +_virtualenvs/mach/bin/python \ |
| 37 | + ${working_dir}/gecko-dev/mach \ |
| 38 | + artifact \ |
| 39 | + toolchain \ |
| 40 | + --bootstrap \ |
| 41 | + --from-build \ |
| 42 | + sysroot-wasm32-wasi |
| 43 | + |
| 44 | +cd ${working_dir} |
| 45 | + |
29 | 46 | flags="--optimize --no-debug --build-only"
|
30 | 47 | rust_lib_dir="release"
|
31 | 48 | if [[ $1 == 'debug' ]]
|
|
37 | 54 | echo $flags $rust_lib_dir
|
38 | 55 |
|
39 | 56 | # Build SpiderMonkey for WASI
|
40 |
| -MOZ_FETCHES_DIR=~/.mozbuild gecko-dev/js/src/devtools/automation/autospider.py --objdir=obj $flags wasi |
| 57 | +MOZ_FETCHES_DIR=~/.mozbuild CC=~/.mozbuild/clang/bin/clang gecko-dev/js/src/devtools/automation/autospider.py --objdir=obj $flags wasi |
41 | 58 |
|
42 | 59 | # Copy header, object, and static lib files
|
| 60 | +rm -rf lib include |
43 | 61 | mkdir lib
|
44 | 62 |
|
45 | 63 | cd obj
|
46 | 64 | cp -Lr dist/include ..
|
47 |
| -cp $(cat ../object-files.list) ../lib |
| 65 | +cp $(cat $script_dir/object-files.list) ../lib |
48 | 66 | cp js/src/build/libjs_static.a wasm32-wasi/${rust_lib_dir}/libjsrust.a ../lib
|
0 commit comments