Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move to One Big Cargo Workspace #219

Merged
merged 12 commits into from
Aug 9, 2023
Merged

chore: move to One Big Cargo Workspace #219

merged 12 commits into from
Aug 9, 2023

Conversation

hawkw
Copy link
Contributor

@hawkw hawkw commented Aug 9, 2023

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:

# 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 issues
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, 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.

hawkw added 10 commits August 9, 2023 09:23
This is needed when building new versions of `llvm-tools`.
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:

```console
# 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.

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
??????? ??? ????????? ???
Copy link
Contributor

@jamesmunns jamesmunns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, it would be nice to document somewhere the nightly cargo trickery we are using and why, and link to the related tracking issues so we know when we can get rid of them, but if it still works and produces valid binaries for the various targets, no objections here.

@hawkw
Copy link
Contributor Author

hawkw commented Aug 9, 2023

Overall LGTM, it would be nice to document somewhere the nightly cargo trickery we are using and why, and link to the related tracking issues so we know when we can get rid of them, but if it still works and produces valid binaries for the various targets, no objections here.

Mostly, we are just using features that haven't yet been stabilized. These aren't workarounds for bugs, per se. I'm happy to add links to the tracking issues for those features.

@hawkw
Copy link
Contributor Author

hawkw commented Aug 9, 2023

@jamesmunns 069c07a adds comments explaining the various unstable features & stuff.

@hawkw hawkw merged commit be4ccd9 into main Aug 9, 2023
4 checks passed
@hawkw hawkw deleted the eliza/one-big-workspace branch August 9, 2023 20:50
hawkw added a commit that referenced this pull request Aug 9, 2023
Depends on #219.

This branch adds an initial implementation of an x86_64 platform target for
mnemOS, using the [`mycelium` x86 HAL][hal]. Currently, I haven't implemented
drivers for the UART, keyboard, or emb-display service (using the framebuffer as
the display), so we don't have SerMux, Forth, trace-proto, or anything else
interesting. However, what we *do* have is a basic bootable image with a timer,
allocator, and rudimentary kernel run loop, and --- as you can see here --- it
works:

![image](https://github.com/tosc-rs/mnemos/assets/2796466/8b6785cd-9a66-4735-8b03-02b8a191016f)

I've also added new `just` commands for building x86_64 images and running them
in QEMU for development.

[hal]: https://github.com/hawkw/mycelium/tree/main/hal-x86_64
@jamesmunns jamesmunns added the area: tools & build Related to host developer tools, including tracing, Crowtty and build processes label Aug 10, 2023
@hawkw hawkw added this to the x86_64 basic bringup milestone Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: tools & build Related to host developer tools, including tracing, Crowtty and build processes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants