Commit Graph

8 Commits

Author SHA1 Message Date
eca864ec8e 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.
2025-10-28 16:10:28 -05:00
0358935bf6 Group the WASM & JS targets so they're built once
https://www.gnu.org/software/make/manual/html_node/Multiple-Targets.html

The previous recipe told Make that each file could be produced by
running wasm-bindgen. The more correct expression is that *both* files
will be produced at the same time.

Now Make knows to only invoke the command one time to get both files if
either is out of date. Previously, multi-job builds (`-j2`) could build
the files twice -- one invocation for each out-of-date file.
2025-10-28 15:04:45 -05:00
7408f056f6 Fix: use correct name suffix for the WASM file
Maybe I should have spent more time manually running each of the steps.
Eh, whatever. Bug found and fixed.
2025-10-28 15:00:28 -05:00
370fe85d6c Make wasm binary target depend on source files
Now Make will know to rebuild the WASM binary if the source code
changes... because I forgot to do that, too. :v
2025-10-28 14:59:47 -05:00
943483503c Turn output folder into an order-only prerequisite
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.
2025-10-28 12:46:37 -05:00
3c0cf85da5 Drop extra suffix in wasm-bindgen output name
Oops, it's not supposed to have a file suffix! It's a bit annoying that
it still produces both a WASM and JS file, just not the right ones (and
no _bg.wasm at all). Especially without any warning that it is doing
something different than normal. Oh well.
2025-10-28 12:42:44 -05:00
39925b0c4e Rename WASM & JS output to match HTML
The index.html file calls for a "boids.js", so I need the Makefile to
produce one. I could change it, but that's off-topic for now so I won't.
2025-10-28 12:42:39 -05:00
4eb4fefeb2 Add a Makefile to make web builds more ergonomic
Call with `make -f makefile_web` to produce a web root for serving. Use
target "boids_web_root.tar" to bundle the files into a tarball. For...
publishing... or something.

The `wasm-server-runner` program seems to supply it's own index.html and
is doing *something* regarding MIME types -- hosting a dev build of the
Boids program results in the browser complaining about "" (empty string)
being an invalid MIME type.

I want my own index.html during testing, and I can't figure out why the
MIME type info is wrong. I've decided to automate the web-root build
process and serve it up with whatever webserver I have on hand.
2025-10-28 12:22:26 -05:00