abstreet/web/bin/build-wasm
Michael Kirk 4f81f186af
embed mode and reworked web build system (#592)
* root element id from Settings, respect element size

* Plumb assets root via settings

* adapt crates to new wasm api

* more FileLoader cleanup

* use tsc bin from node_modules

* avoid spurious unlink errors

GNU Make considers the src/*/wasm_pkg targets as intermediate build
files and attempted to `rm` them. We can stop that my marking them as
`.PRECIOUS`

https://www.gnu.org/software/make/manual/html_node/Special-Targets.html

* `open` doesn't work on Linux

We could do something with xdg-open, but meh, not worth having platform
dependent logic for this.

* fix typo, clarify instructions

* make server compatible with older python install on linux

* revert change - we dont want to include music on web

the leading "-" means exclude a subdir of an included dir.

* better wrap of comments

* fix misfire in copy/pasted comment

* update docs
2021-04-01 19:31:02 -07:00

37 lines
659 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"}"
cd $PROJECT_ROOT/$CRATE_NAME
wasm-pack build $WASM_PACK_FLAGS --target web --out-dir "${PROJECT_ROOT}/web/src/${JS_NAME}/wasm_pkg" -- --no-default-features --features wasm