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
#!/bin/bash
path="$(dirname $1)"
file="$(basename $1)"
# Workaround for
# https://github.com/kripken/emscripten/issues/4542
# Consider a project with this struct
# ├── src
# │ ├── bin
# │ │ └── prog.rs
# │ └── lib.rs
# ├── benches
# │ └── b.rs
# ├── examples
# │ └── a.rs
# └── tests
# └── t.rs
#
# We expect that the artifacts will be generated in
# (where ? = release or debug)
#
# target/wasm32-unknown-emscripten/?/deps/
# for tests and benches
#
# target/wasm32-unknown-emscripten/?/examples/
# for examples
#
# target/wasm32-unknown-emscripten/?/
# for main programs (main.rs and bin/*.rs)
#
# Because of https://github.com/kripken/emscripten/issues/4542
# the script must be executed from where the dependencies are.
base="$(basename $path)"
if [ "$base" != "deps" -a "$base" != "examples" ]; then
# main programs requeries the artifacts in $path/deps
cd "$path/deps"
exec /node-*/bin/node "../$file"
else
# all deps of tests, benches and examples are in $path dir
cd "$path"
exec /node-*/bin/node "$file"
fi