Variables that a package consumer might want to adjust should be placed at the top of the file so they are immediately visible. Any constants shall live below those (just the SRC folder, really).
45 lines
1.5 KiB
Makefile
45 lines
1.5 KiB
Makefile
# This script produces a web build. If you aren't trying to do that, it is
|
|
# entirely useless to you.
|
|
|
|
# Patch these to select a different build profile or target
|
|
# The target shouldn't change any time soon. WASM64, I guess. Other targets
|
|
# aren't aimed at the web, so you shouldn't be using this makefile.
|
|
CARGO_TARGET := wasm32-unknown-unknown
|
|
CARGO_PROFILE := wasm-release
|
|
|
|
SRC_DIR = ./src
|
|
SRCS := $(wildcard $(SRC_DIR)/**)
|
|
|
|
.PHONY: clean full-clean web tarball
|
|
|
|
web: out/boids.js out/boids_bg.wasm out/index.html
|
|
|
|
tarball: boids_web_root.tar
|
|
|
|
boids_web_root.tar: out/boids.js out/boids_bg.wasm out/index.html
|
|
tar -caf $@ $^
|
|
|
|
target/$(CARGO_TARGET)/$(CARGO_PROFILE)/another-boids-in-rust.wasm: $(SRCS) Cargo.lock Cargo.toml
|
|
cargo build --profile $(CARGO_PROFILE) --target $(CARGO_TARGET)
|
|
|
|
out:
|
|
mkdir $@
|
|
|
|
# Both the JS and WASM files are generated by the wasm-bindgen call, so both
|
|
# get to be on the target half of this recipe.
|
|
out/boids.js out/boids_bg.wasm &: target/$(CARGO_TARGET)/$(CARGO_PROFILE)/another-boids-in-rust.wasm | out
|
|
wasm-bindgen --no-typescript --target web --out-dir ./out/ --out-name boids target/$(CARGO_TARGET)/$(CARGO_PROFILE)/another-boids-in-rust.wasm
|
|
|
|
out/index.html: www/index.html
|
|
cp -a $< $@
|
|
|
|
# Clean the web build, but not the Cargo cache. Cargo handles it's own caching
|
|
# and I don't want to obliterate it all the time.
|
|
clean:
|
|
rm -rf out/ boids_web_root.tar
|
|
|
|
# Delete everything, including the Cargo build cache. In case someone needs
|
|
# this, I guess.
|
|
full-clean: clean
|
|
cargo clean
|