-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·46 lines (38 loc) · 1.13 KB
/
build.sh
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
#!/bin/bash
set -e
cd "$(dirname "$0")"
mkdir -p build
npx esbuild src/asyncglk.ts \
--bundle \
--format=esm \
--outfile=build/asyncglk.js \
--packages=external \
--platform=node
# Build the docker image if it doesn't exist
DOCKER_TAG=$(sha1sum src/Dockerfile)
DOCKER_TAG=${DOCKER_TAG:0:8}
if [ -z "$(docker images -q emglken:$DOCKER_TAG 2> /dev/null)" ]; then
echo "Building Emglken Docker image emglken:$DOCKER_TAG"
docker build -f src/Dockerfile --tag emglken:$DOCKER_TAG src
fi
DEBUG=
if [[ $DEBUG ]]; then
CMAKE_TYPE="Debug"
else
RUST_TARGET="--release"
CMAKE_TYPE="Release"
fi
docker run --rm -t \
-u $(id -u):$(id -g) \
-v $(pwd):/src \
-v $HOME/.cargo/registry:/.cargo/registry \
emglken:$DOCKER_TAG \
/bin/bash -c -e " \\
RUSTFLAGS=-Csymbol-mangling-version=v0 cargo build \\
--manifest-path=remglk/Cargo.toml \\
$RUST_TARGET \\
--target=wasm32-unknown-emscripten; \\
emcmake cmake -DCMAKE_BUILD_TYPE=$CMAKE_TYPE -S . -B build; \\
emmake make -j$(nproc) --no-print-directory -C build \\
"
./tools/write-file-sizes.js