Skip to content

Commit

Permalink
chore: move to One Big Cargo Workspace (#219)
Browse files Browse the repository at this point in the history
This commit changes the Cargo workspace setup to put all crates in One
Big Workspace, rather than having separate workspaces for some targets.
We now use the `per-package-target` unstable cargo feature to build
different crates for different targets. This means that `cargo` commands
in the root workspace now work without requiring the user to `cd` into a
particular directory to build a platform target --- for example, I can
now run:

```shell
# in the repo root directory
$ cargo build -p mnemos-d1 --bin mq-pro
```

and build a MnemOS binary for the MQ Pro, without having to `cd` into
the MQ Pro directory.

This is also necessary in order to make the `x86_64` build process added
in PR #216 work, since it relies on cargo artifact dependencies, which
appear not to work across workspaces.

One issue is that `cargo build --workspace` (and `check --workspace`,
etc) still does not work correctly, due to some [weird][1] [issues][2]
with feature unification which I don't entirely understand. However, as
a workaround, I've changed the workspace Cargo.toml to add a
[`default-members` field][3], so that running `cargo build` or `cargo
check`
_without_ `--workspace` will build the subset of crates in the
`default-members` key. This way, `cargo {build, check, etc}` in the repo
root will do something reasonable by default, and the actual platform
targets can be built/checked with `cargo $WHATEVER --package $CRATE`.
IMO, this is still substantially nicer than having a bunch of separate
workspaces.

[1]: ia0/data-encoding#47
[2]: bincode-org/bincode#556
[3]: https://doc.rust-lang.org/cargo/reference/workspaces.html#the-default-members-field
  • Loading branch information
hawkw authored Aug 9, 2023
1 parent 248be89 commit be4ccd9
Show file tree
Hide file tree
Showing 36 changed files with 1,153 additions and 286 deletions.
11 changes: 10 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
[alias]
crowtty = "run --bin crowtty --release --"
melpomene = "run --bin melpomene --release --"
melpo = "melpomene"
forth3 = "run --bin f3repl --release --"

[build]
# Currently needed for `tokio-console` support.
rustflags = ["--cfg", "tokio_unstable"]
rustflags = ["--cfg", "tokio_unstable"]

[target.riscv32imac-unknown-none-elf]
runner = "espflash flash --monitor"
12 changes: 2 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,6 @@ jobs:
run: rustup show
- uses: actions/checkout@v2
- uses: olix0r/cargo-action-fmt@ee1ef42932e44794821dab57ef1bf7a73df8b21f
- uses: extractions/setup-just@v1
- name: run rustdoc
run: |
cargo doc \
--message-format=json \
--no-deps \
--all-features \
--workspace \
--document-private-items |
cargo-action-fmt
env:
RUSTDOCFLAGS: "--cfg docsrs -Dwarnings"
run: just docs --message-format=json --document-private-items
20 changes: 20 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"rust-analyzer.check.invocationLocation": "workspace",
"rust-analyzer.cargo.buildScripts.invocationLocation": "workspace",
"rust-analyzer.cargo.buildScripts.overrideCommand": [
"cargo",
"check",
"--quiet",
"--message-format=json",
"--all-targets"
],
"rust-analyzer.check.overrideCommand": [
"cargo",
"clippy",
"--quiet",
"--message-format=json",
"--all-targets"
],
"rust-analyzer.workspace.symbol.search.scope": "workspace_and_dependencies",
"rust-analyzer.typing.continueCommentsOnNewline": false
}
Loading

0 comments on commit be4ccd9

Please sign in to comment.