You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.6 KiB
Plaintext

VERSION := `git rev-parse --short HEAD`
bindgen profile name:
mkdir -p ./dist/{{name}}
wasm-bindgen \
--no-typescript \
--target web \
--out-dir ./dist/{{name}} \
--out-name "bin" \
${CARGO_TARGET_DIR}/wasm32-unknown-unknown/{{profile}}/{{name}}.wasm
optimize NAME:
# Size pass
wasm-opt -Oz \
-o dist/{{NAME}}/bin_bg-tmp.wasm \
./dist/{{NAME}}/bin_bg.wasm
# Replace old bin with new (compressed) bin
mv ./dist/{{NAME}}/bin_bg-tmp.wasm ./dist/{{NAME}}/bin_bg.wasm
build-example EXAMPLE:
cargo build --example {{EXAMPLE}} --profile wasm-dev --target wasm32-unknown-unknown
build-bin GAME:
# wasm binary
cargo build --bin {{GAME}} --profile wasm-release --target wasm32-unknown-unknown
example NAME: (build-example NAME) (bindgen "wasm-dev" "examples"/NAME)
cp web/example.html ./dist/examples/{{NAME}}/index.html
# Build the web version
web GAME: (build-bin GAME) (bindgen "wasm-release" GAME) (optimize GAME)
# base directory
mkdir -p dist/{{GAME}}/assets/{{GAME}}
# index.html
cp ./web/{{GAME}}.html ./dist/{{GAME}}/index.html
# assest
rm -rf dist/{{GAME}}/assets/{{GAME}}
cp -r assets/{{GAME}} dist/{{GAME}}/assets/{{GAME}}
# Helpful shorthand to serve files
serve GAME: (web GAME)
simple-http-server dist/{{GAME}}
itchio-dry GAME: (web GAME)
butler push --dry-run dist/{{GAME}} popgame/{{GAME}}:html5 --userversion={{VERSION}}
itchio GAME: (web GAME)
butler push dist/{{GAME}} popgame/{{GAME}}:html5 --userversion={{VERSION}}
clean:
rm -rf dist/*