Auto fill crate version in web page

The webpage has a placeholder string instead of a hard-coded version.
This gets replaced by the Makefile with the help of a pair of `sed`
calls.

And with that, I've upgraded my ad-hoc web bundler with an ad-hoc HTML
templating engine.
This commit is contained in:
2025-12-26 09:56:06 -06:00
parent 03c7d44aad
commit e494fc6c35
2 changed files with 9 additions and 2 deletions

View File

@@ -10,8 +10,14 @@ CARGO_PROFILE := wasm-release
# Override DESTDIR to set a custom install path (such as your web root) # Override DESTDIR to set a custom install path (such as your web root)
DESTDIR ?= . DESTDIR ?= .
# # # Automatic Variables # # #
# (meaning you shouldn't modify them yourself)
#
# These are for automatically finding information or files so that they can be
# used somewhere in the build process.
SRC_DIR = ./src SRC_DIR = ./src
SRCS := $(wildcard $(SRC_DIR)/**) SRCS := $(wildcard $(SRC_DIR)/**)
CRATE_VERSION != sed -nre 's/^version = "(.*)"/\1/p' Cargo.toml
.PHONY: clean full-clean install tarball tarball-standalone web web-standalone .PHONY: clean full-clean install tarball tarball-standalone web web-standalone
@@ -48,11 +54,13 @@ out/boids.js out/boids_bg.wasm.gz &: target/$(CARGO_TARGET)/$(CARGO_PROFILE)/ano
out/index.html: www/index.html out/index.html: www/index.html
cp -a $< $@ cp -a $< $@
rm -f out/boids.html rm -f out/boids.html
sed -i -e "s/#CRATE_VERSION_PLACEHOLDER#/$(CRATE_VERSION)/" $@
# Like `out/index.html`, but renames it for use in a larger site. # Like `out/index.html`, but renames it for use in a larger site.
out/boids.html: www/index.html out/boids.html: www/index.html
cp -a $< $@ cp -a $< $@
rm -f out/index.html rm -f out/index.html
sed -i -e "s/#CRATE_VERSION_PLACEHOLDER#/$(CRATE_VERSION)/" $@
# Clean the web build, but not the Cargo cache. Cargo handles it's own caching # 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. # and I don't want to obliterate it all the time.

View File

@@ -103,8 +103,7 @@
</tr> </tr>
<tr> <tr>
<td>Program Version</td> <td>Program Version</td>
<!-- This version text is completely unchecked. I'll need to do something about that. --> <td><code>#CRATE_VERSION_PLACEHOLDER#</code></td>
<td><code>v0.6.0</code></td>
</tr> </tr>
</table> </table>
</article> </article>