From eca864ec8ea09ae25600dc7f1f21f1da61b6628c Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Tue, 28 Oct 2025 16:07:24 -0500 Subject: [PATCH] Use vars to hold target & profile in makefile_web I might sometimes build different profiles, so this gives me somewhere to change them. It *does not work* for debug builds because of how cargo works. So that sucks. I can't think of a reason anyone would seriously want to change the target, but I've made that a variable, too. WASM64 exists, but I can't get a read on it's availability across browsers. The benefit seems to be accessing >4GB of memory, which is not important for this project. Other targets are for "desktop" platforms and so shouldn't be using the makefile. --- makefile_web | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/makefile_web b/makefile_web index 4411489f..73dddafb 100644 --- a/makefile_web +++ b/makefile_web @@ -1,6 +1,12 @@ SRC_DIR = ./src SRCS := $(wildcard $(SRC_DIR)/**) +# 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 + .PHONY: clean full-clean web tarball web: out/boids.js out/boids_bg.wasm out/index.html @@ -10,16 +16,16 @@ tarball: boids_web_root.tar boids_web_root.tar: out/boids.js out/boids_bg.wasm out/index.html tar -caf $@ $< -target/wasm32-unknown-unknown/wasm-release/another-boids-in-rust.wasm: $(SRCS) - cargo build --profile wasm-release --target wasm32-unknown-unknown +target/$(CARGO_TARGET)/$(CARGO_PROFILE)/another-boids-in-rust.wasm: $(SRCS) + 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/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/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 $< $@