This makes the output folder "required to exist" and not "required to be more recent." The folder's timestamp is updated when files are written into it. The files inside depend on the folder existing. The result is that the WASM and JS files are considered very slightly older than the folder that contains them. The result is that the folder is up-to-date but it's contents are not, thus re-building them and *again* updating the folder timestamp. The makefile was stuck constantly rebuilding things that are actually up-to-date.
33 lines
1.0 KiB
Plaintext
33 lines
1.0 KiB
Plaintext
.PHONY: clean full-clean web tarball
|
|
|
|
web: out/boids.js out/boids.wasm out/index.html
|
|
|
|
tarball: boids_web_root.tar
|
|
|
|
boids_web_root.tar: out/boids.js out/boids.wasm out/index.html
|
|
tar -caf $@ $<
|
|
|
|
target/wasm32-unknown-unknown/wasm-release/another-boids-in-rust.wasm:
|
|
cargo build --profile wasm-release --target wasm32-unknown-unknown
|
|
|
|
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.wasm: target/wasm32-unknown-unknown/wasm-release/another-boids-in-rust.wasm | out
|
|
wasm-bindgen --no-typescript --target web --out-dir ./out/ --out-name boids target/wasm32-unknown-unknown/wasm-release/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
|