mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 03:35:51 +03:00
41 lines
745 B
Bash
Executable File
41 lines
745 B
Bash
Executable File
#!/bin/bash
|
|
set -euf -o pipefail
|
|
|
|
PROJECT_ROOT=$(git rev-parse --show-toplevel)
|
|
|
|
BIN_NAME=$0
|
|
function usage {
|
|
cat <<EOS
|
|
Usage:
|
|
$BIN_NAME <crate name> <js pkg name if different from crate name>
|
|
Example:
|
|
$BIN_NAME widgetry_demo
|
|
$BIN_NAME game abstreet
|
|
EOS
|
|
}
|
|
|
|
if [ $# -eq 0 ]; then
|
|
usage
|
|
exit1
|
|
fi
|
|
|
|
CRATE_NAME="${1}"
|
|
|
|
shift
|
|
|
|
if [ $# -eq 0 ]; then
|
|
JS_NAME="${CRATE_NAME}"
|
|
else
|
|
JS_NAME="${1}"
|
|
fi
|
|
|
|
# Default to a dev build
|
|
WASM_PACK_FLAGS="${WASM_PACK_FLAGS:-"--dev"}"
|
|
|
|
if [ $CRATE_NAME == widgetry_demo ]; then
|
|
cd $PROJECT_ROOT/$CRATE_NAME
|
|
else
|
|
cd $PROJECT_ROOT/apps/$CRATE_NAME
|
|
fi
|
|
wasm-pack build $WASM_PACK_FLAGS --target web --out-dir "${PROJECT_ROOT}/web/src/${JS_NAME}/wasm_pkg" -- --no-default-features --features wasm
|