Skip to content

Commit be4ccd9

Browse files
authored
chore: move to One Big Cargo Workspace (#219)
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
1 parent 248be89 commit be4ccd9

File tree

36 files changed

+1153
-286
lines changed

36 files changed

+1153
-286
lines changed

.cargo/config.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
[alias]
2+
crowtty = "run --bin crowtty --release --"
3+
melpomene = "run --bin melpomene --release --"
4+
melpo = "melpomene"
5+
forth3 = "run --bin f3repl --release --"
6+
17
[build]
28
# Currently needed for `tokio-console` support.
3-
rustflags = ["--cfg", "tokio_unstable"]
9+
rustflags = ["--cfg", "tokio_unstable"]
10+
11+
[target.riscv32imac-unknown-none-elf]
12+
runner = "espflash flash --monitor"

.github/workflows/ci.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,6 @@ jobs:
136136
run: rustup show
137137
- uses: actions/checkout@v2
138138
- uses: olix0r/cargo-action-fmt@ee1ef42932e44794821dab57ef1bf7a73df8b21f
139+
- uses: extractions/setup-just@v1
139140
- name: run rustdoc
140-
run: |
141-
cargo doc \
142-
--message-format=json \
143-
--no-deps \
144-
--all-features \
145-
--workspace \
146-
--document-private-items |
147-
cargo-action-fmt
148-
env:
149-
RUSTDOCFLAGS: "--cfg docsrs -Dwarnings"
141+
run: just docs --message-format=json --document-private-items

.vscode/settings.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"rust-analyzer.check.invocationLocation": "workspace",
3+
"rust-analyzer.cargo.buildScripts.invocationLocation": "workspace",
4+
"rust-analyzer.cargo.buildScripts.overrideCommand": [
5+
"cargo",
6+
"check",
7+
"--quiet",
8+
"--message-format=json",
9+
"--all-targets"
10+
],
11+
"rust-analyzer.check.overrideCommand": [
12+
"cargo",
13+
"clippy",
14+
"--quiet",
15+
"--message-format=json",
16+
"--all-targets"
17+
],
18+
"rust-analyzer.workspace.symbol.search.scope": "workspace_and_dependencies",
19+
"rust-analyzer.typing.continueCommentsOnNewline": false
20+
}

0 commit comments

Comments
 (0)