Skip to content

Commit

Permalink
Split all-is-cubes-wasm package out of the main workspace.
Browse files Browse the repository at this point in the history
This has the advantage that, by being its own workspace, it can have its
own `.cargo/config.toml` which specifies (including to rust-analyzer)
that it should *always* be built for wasm, so we can have IDE assistance
with editing the wasm-only code. It also means we don't have to
carefully `cfg` out all the wasm code (though a small amount is useful
for host-side tests).

Future work: We should also consider splitting the wasm builds in CI
for more parallelism, since they share no artifacts except for `xtask`.
  • Loading branch information
kpreid committed Nov 26, 2023
1 parent 6c9c1c2 commit 06fc0b3
Show file tree
Hide file tree
Showing 8 changed files with 2,403 additions and 97 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"rust-analyzer.linkedProjects": [
"Cargo.toml",
"fuzz/Cargo.toml",
],
"all-is-cubes-wasm/Cargo.toml",
]
}
81 changes: 0 additions & 81 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,22 @@ members = [
"all-is-cubes-mesh",
"all-is-cubes-server",
"all-is-cubes-ui",
"all-is-cubes-wasm",
"test-renderers",
"tools/xtask",

# Workspaces generally expect to be able to compile everything for the same target,
# but all-is-cubes-wasm only compiles on wasm and all-is-cubes-desktop doesn't.
# Specific advantages:
# * The wasm workspace has Cargo config telling it to be built for wasm32-unknown-unknown,
# which rust-analyzer picks up, so all IDE assistance works.
#
# Disadvantages, or advantages of the alternative of merely `cfg`-disabling all the wasm-only
# code:
# * `cargo fmt`, `cargo tree`, etc. don't work on this code (but `xtask` provides
# all-workspaces commands).
#
# "all-is-cubes-wasm",

# Including this makes the fuzz targets automatically built so we know they aren't broken.
# But, `cargo test` sometimes ignores `[[bin]] test = false` directives,
# https://github.com/rust-lang/cargo/issues/8338
Expand Down Expand Up @@ -85,6 +97,7 @@ wasm-bindgen-futures = "0.4.34"
wgpu = { version = "0.18.0", features = ["expose-ids"] }
yield-progress = { version = "0.1.4", default-features = false }

# Note: Lints are also necessarily redefined in the workspaces other than this one.
[workspace.lints]
rust.rust_2018_idioms = "deny"
rust.unsafe_op_in_unsafe_fn = "deny"
Expand Down
2 changes: 2 additions & 0 deletions all-is-cubes-wasm/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
target = "wasm32-unknown-unknown"
Loading

0 comments on commit 06fc0b3

Please sign in to comment.