13 Commits

Author SHA1 Message Date
d1941217c4 Release v0.5.0
Some checks failed
check / stable / fmt (push) Successful in 21s
check / beta / clippy (push) Failing after 1m15s
check / semver (push) Has been cancelled
check / nightly / doc (push) Has been cancelled
check / ubuntu / stable / features (push) Has been cancelled
check / ubuntu / 1.79.0 (push) Has been cancelled
check / stable / clippy (push) Has been cancelled
2025-11-08 11:07:04 -06:00
ba5183b30d Remove bogus dependencies from build container
These are only required for Linux builds, not WASM/WASI builds.
2025-11-08 10:59:30 -06:00
3e3bbd973f Update Dockerfile to use the new Make-based build
I'm going to run into consistency problems at some point, so I'm going
to get ahead of that by updating the container build process.
2025-11-08 10:58:48 -06:00
5abe894354 Add a bunch of CSS
Some checks failed
check / beta / clippy (push) Has been cancelled
check / stable / clippy (push) Has been cancelled
check / semver (push) Has been cancelled
check / nightly / doc (push) Has been cancelled
check / ubuntu / stable / features (push) Has been cancelled
check / ubuntu / 1.79.0 (push) Has been cancelled
check / stable / fmt (push) Has been cancelled
It's not amazing work, but now there's *something.*
2025-11-08 10:37:34 -06:00
86483497e9 Add an install target 2025-11-06 14:18:18 -06:00
3f6a4ae532 Set charset & viewport meta tags 2025-11-06 13:24:11 -06:00
7a5148dc74 Update the README with new web build variant info 2025-11-06 12:19:26 -06:00
8d4b033922 Add the tarball-standalone recipe(s)
Some checks failed
check / stable / fmt (push) Successful in 21s
check / beta / clippy (push) Failing after 54s
check / stable / clippy (push) Failing after 49s
check / semver (push) Failing after 5m25s
check / nightly / doc (push) Successful in 2m22s
check / ubuntu / stable / features (push) Successful in 2m32s
check / ubuntu / 1.79.0 (push) Failing after 26s
I forgot to put this in when I added the phony target. Oops.
2025-11-06 10:46:13 -06:00
0c915b025e HTML-installing targets remove the other one
This is actually a build configuration task, but I don't have a tool to
do that (no `./configure.sh` to run!).

To work around this, I'll just have each of the html-installing targets
install their own and remove the other. That way back-to-back builds
don't accidentally contaminate each other. The WASM and JS files are
identical, so they don't need this treatment.
2025-11-06 10:22:44 -06:00
15a1d5c6de New build variants: "standalone" and "bundle-able"
The `web-standalone` target does what the old `web` target did: Produce
the WASM, JS, and an index.html so the output can be served up directly.

The new `web` target renames the "index.html" to "boids.html" so it can
be used as a submodule/subpage in a larger website build.
2025-11-06 10:20:30 -06:00
e7e5337f22 Place Makefile 'configurables' up top
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).
2025-11-06 09:54:30 -06:00
e65deec5ea Rename the Makefile, add usage note at the top
I had named it makefile_web" in an effort to communicate to the user
that the Make-based build path is only for web builds. It's annoying to
type all that out, though, and it doesn't seem like other projects
follow this convention. I'll just put a usage note at the top. It's not
like the Makefile can be mis-used to make a non-web version. There is no
footgun here.
2025-11-06 09:43:11 -06:00
29d0b644ec Remove fly.toml from repo
Some checks failed
check / stable / fmt (push) Successful in 51s
check / beta / clippy (push) Failing after 1m18s
check / stable / clippy (push) Failing after 1m0s
check / semver (push) Failing after 5m49s
check / nightly / doc (push) Successful in 2m20s
check / ubuntu / stable / features (push) Successful in 2m26s
check / ubuntu / 1.79.0 (push) Failing after 28s
As a general rule, this probably shouldn't be in the main repo. I've
also deleted the Fly app, so it doesn't need to exist anywhere.
2025-11-04 14:03:55 -06:00
8 changed files with 138 additions and 98 deletions

30
Cargo.lock generated
View File

@@ -142,7 +142,7 @@ dependencies = [
[[package]]
name = "another-boids-in-rust"
version = "0.4.0"
version = "0.5.0"
dependencies = [
"bevy",
"bevy_spatial",
@@ -1509,9 +1509,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.2.43"
version = "1.2.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "739eb0f94557554b3ca9a86d2d37bebd49c5e6d0c1d2bda35ba5bdac830befc2"
checksum = "35900b6c8d709fb1d854671ae27aeaa9eec2f8b01b364e1619a40da3e6fe2afe"
dependencies = [
"find-msvc-tools",
"jobserver",
@@ -1963,9 +1963,9 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "erased-serde"
version = "0.4.8"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "259d404d09818dec19332e31d94558aeb442fea04c817006456c24b5460bbd4b"
checksum = "89e8918065695684b2b0702da20382d5ae6065cf3327bc2d6436bd49a71ce9f3"
dependencies = [
"serde",
"serde_core",
@@ -3269,9 +3269,9 @@ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
[[package]]
name = "orbclient"
version = "0.3.48"
version = "0.3.49"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba0b26cec2e24f08ed8bb31519a9333140a6599b867dac464bb150bdb796fd43"
checksum = "247ad146e19b9437f8604c21f8652423595cf710ad108af40e77d3ae6e96b827"
dependencies = [
"libredox",
]
@@ -3501,9 +3501,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.41"
version = "1.0.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1"
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
dependencies = [
"proc-macro2",
]
@@ -3758,9 +3758,9 @@ dependencies = [
[[package]]
name = "ruzstd"
version = "0.8.1"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3640bec8aad418d7d03c72ea2de10d5c646a598f9883c7babc160d91e3c1b26c"
checksum = "e5ff0cc5e135c8870a775d3320910cd9b564ec036b4dc0b8741629020be63f01"
dependencies = [
"twox-hash",
]
@@ -3979,9 +3979,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.108"
version = "2.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917"
checksum = "2f17c7e013e88258aa9543dcbe81aca68a667a9ac37cd69c9fbc07858bfe0e2f"
dependencies = [
"proc-macro2",
"quote",
@@ -4297,9 +4297,9 @@ checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f"
[[package]]
name = "unicode-properties"
version = "0.1.3"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0"
checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d"
[[package]]
name = "unicode-script"

View File

@@ -1,6 +1,6 @@
[package]
name = "another-boids-in-rust"
version = "0.4.0"
version = "0.5.0"
edition = "2024"
license = "AGPL-3.0-only"

View File

@@ -1,19 +1,12 @@
FROM rust:1.89 AS builder
RUN apt-get update
RUN apt-get install -y --no-install-recommends libasound2-dev libudev-dev
RUN rustup target add wasm32-unknown-unknown
RUN cargo install --locked wasm-bindgen-cli
# Copy only the package manifest and source code. Otherwise changes to anything
# will cause Docker to re-run `cargo build` even when the source hasn't changed.
COPY src/ ./src
COPY Cargo.toml ./Cargo.toml
COPY Cargo.lock ./Cargo.lock
COPY . .
RUN cargo build --locked --target wasm32-unknown-unknown --profile=wasm-release
RUN wasm-bindgen --no-typescript --target web --out-dir ./out/ --out-name "boids" target/wasm32-unknown-unknown/wasm-release/another-boids-in-rust.wasm
COPY www/index.html out/index.html
RUN make -j
FROM busybox:musl
RUN mkdir -p /var/www

72
Makefile Normal file
View File

@@ -0,0 +1,72 @@
# 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
# Override DESTDIR to set a custom install path (such as your web root)
DESTDIR ?= .
SRC_DIR = ./src
SRCS := $(wildcard $(SRC_DIR)/**)
.PHONY: clean full-clean install tarball tarball-standalone web web-standalone
# "Standalone" version
# (i.e., it includes an index.html so it can be placed on a server as-is)
web-standalone: out/boids.js out/boids_bg.wasm out/index.html
# "Bundle-able" version. The host site must provide it's own HTML page.
web: out/boids.js out/boids_bg.wasm out/boids.html
tarball: boids_web_root.tar
tarball_standalone: boids_web_root_standalone.tar
boids_web_root.tar: out/boids.js out/boids_bg.wasm out/boids.html
tar -caf $@ $^
boids_web_root_standalone.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
# Copies the index page to the output
out/index.html: www/index.html
cp -a $< $@
rm -f out/boids.html
# Like `out/index.html`, but renames it for use in a larger site.
out/boids.html: www/index.html
cp -a $< $@
rm -f out/index.html
# 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 boids_web_root_standalone.tar
# Delete everything, including the Cargo build cache. In case someone needs
# this, I guess.
full-clean: clean
cargo clean
# Installation goal. It's meant to be a helper utility for moving the built
# output into the web root. Only supports the "bundle-able" mode.
install: web
install -dm0755 $(DESTDIR)
install -m0644 out/boids.js $(DESTDIR)/
install -m0644 out/boids_bg.wasm $(DESTDIR)/
install -m0644 out/boids.html $(DESTDIR)/

View File

@@ -21,13 +21,41 @@ You'll need a working Rust toolchain, of course. See the [rustup](https://rustup
### Web
This project creates a "static site," meaning a complete deployment of the site is simply copying the output folder onto a webserver.
This project creates a "static site," meaning a complete deployment of the site is simply copying the output folder onto a webserver. There are **two** ways to use this.
1. Build `make -f ./makefile_web web`
1. A standalone application which can be quickly hosted as-is. This includes the WASM, it's JS glue, and an index.html page.
2. A sub-page in a larger website. This is actually the same, but names it's HTML page "boids.html" so consumers (you) can provide their own index.html.
- I'm not using a JS Bundler at this time. If you're familiar with JS development, this probably looks like a dumb way to do it. Sorry about that.
#### Standalone build:
1. Build `make web-standalone`
2. Serve `python3 -m http.server -d ./out`
3. Visit site in browser: `http://localhost:8000`
You can use any HTTP server you like. Here, I'm using the Python3 built-in [http.server module](https://docs.python.org/3/library/http.server.html); which is **NOT** recommended for production use. Don't put that on the Internet! Alternatives include [Miniserve](https://crates.io/crates/miniserve) and [BusyBox](https://busybox.net/). The latter of which I'm using in the Docker image.
To quickly get a tarball, use `make tarball_standalone`. If you're trying to build and upload the program somewhere, this may provide a bit of convenience. Compressing it may be a good idea, too.
#### "Bundle-able" build
For a "bundle-able" build, you'll need to write your own index.html and link to the boids.html file.
Basically, just throw in a hyperlink with `<a href="boids.html">Boids</a>`
```html
<!DOCTYPE html>
<html>
<!-- your page content, etc -->
<body>
<a href="boids.html">Boids</a>
</body>
<!-- more page content, etc -->
</html>
```
As mentioned in the option 2 description, I'm not using a JS Bundler. There is no "package.json" or anything to integrate properly with a JS framework. I plan to fix that at some point, but for now there are just a bunch of files to grab.
---
You can use any HTTP server you like. In the steps above, I'm using the Python3 built-in [http.server module](https://docs.python.org/3/library/http.server.html); which is **NOT** recommended for production use. Don't put that on the Internet! Alternatives include [Miniserve](https://crates.io/crates/miniserve) and [BusyBox](https://busybox.net/). The latter of which I'm using in the Docker image.
### Web, but as a Docker Container

View File

@@ -1,25 +0,0 @@
# fly.toml app configuration file generated for boids-autumn-lake-5810 on 2025-09-03T16:02:00-05:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
app = 'boids-autumn-lake-5810'
primary_region = 'ord'
[build]
[env]
PORT = '8080'
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']
[[vm]]
memory = '256mb'
cpu_kind = 'shared'
cpus = 1

View File

@@ -1,41 +0,0 @@
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
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

View File

@@ -1,16 +1,28 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
background-color: hsl(100, 10%, 60%);
color: hsl(0, 0%, 15%);
}
h1 {
background-color: rgb(72, 97, 72);
text-align: center;
margin: auto;
padding: 0.5em;
}
canvas {
padding-left: 0;
padding-right: 0;
margin-top: 1em;
margin-left: auto;
margin-right: auto;
display: block;
outline-color: hsl(100, 100%, 15%);
outline-style: outset;
border-radius: 8px;
background-color: rgb(40%, 40%, 40%);
}
main {
margin-left: auto;
@@ -18,11 +30,12 @@
width: 70%;
}
table {
margin-bottom: 10px;
border-collapse: collapse;
}
th, td {
border: 1px solid;
padding: 2px 4px;
padding: 0.1em 0.3em;
}
</style>
</head>
@@ -91,7 +104,7 @@
<tr>
<td>Program Version</td>
<!-- This version text is completely unchecked. I'll need to do something about that. -->
<td><code>v0.4.0</code></td>
<td><code>v0.5.0</code></td>
</tr>
</table>
</article>