summaryrefslogtreecommitdiff
path: root/scripts/wasm_bindgen_check.sh
blob: 5f90c99c6627769ab945fcd9b6bb49e38febc933 (plain)
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
#!/usr/bin/env bash
set -eu
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$script_path/.."

if [[ $* == --skip-setup ]]
then
  echo "Skipping setup_web.sh"
else
  echo "Running setup_web.sh"
  ./scripts/setup_web.sh
fi

CRATE_NAME="egui_demo_app"
FEATURES="glow,http,persistence"

echo "Building rust…"
BUILD=debug # debug builds are faster

(cd crates/$CRATE_NAME &&
  cargo build \
    --quiet \
    --lib \
    --target wasm32-unknown-unknown \
    --no-default-features \
    --features ${FEATURES}
)

TARGET="target"

echo "Generating JS bindings for wasm…"

rm -f "${CRATE_NAME}_bg.wasm" # Remove old output (if any)

TARGET_NAME="${CRATE_NAME}.wasm"
wasm-bindgen "${TARGET}/wasm32-unknown-unknown/$BUILD/$TARGET_NAME" \
  --out-dir . --no-modules --no-typescript

# Remove output:
rm -f "${CRATE_NAME}_bg.wasm"
rm -f "${CRATE_NAME}.js"