-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Support for examples (and tests?) at the workspace level #7467
Comments
Is there a reason you can't add the examples as workspace members? That would allow them to share the same artifacts with the other members. Also, if you place the examples' code in an |
I think the main thing is that the examples are full crates which, AFAIK, is not supported in the I think adding them to the workspace is probably fine, but it'd be nice if they could be tagged as examples so they don't always build and are triggered by |
Each example can be a full package, with just one example per package, so they can each declare their own dependencies and whatnot. Like:
It is identical to your current layout, instead of placing them in the |
Hmm. If I move them, running |
Hmm. I'm not seeing any documentation for how to specify an example as a full crate. Looking at |
They will need to be added to the workspace. One way is to add To create a lib-based example, just explicitly define the example: [[example]]
name = "myexample"
crate-type = ["cdylib"] where |
Ah, thanks, that clears it up. There is one thing that one example can't specify |
Yea, that's a bit unfortunate. There is the nightly-only profile overrides which provides a way to set the profile per-package. I'm hoping it will be on the path to stabilization soon. |
Thanks for the pointers; this all seems to be working well enough for me now. I've added a comment to the cargo feature in the |
For anyone who finds this issue in the future, it should be noted that the layout described in #7467 (comment) will only work if you are using a virtual manifest, if you try the method in a workspace defined in a non-virtual manifest it will give the |
See rust-lang/cargo#7467, egui, structopt, etc are quite heavy, so making each example an isolated crate means people can just build the one example they want, and the sdk itself is also not "polluted" with every dev-dependency.
* Add built in handlers * Move event types into submodules * Add error for when a lobby secret is incorrect * Make disconnect an error rather than string * Move lobby search functionality to submodule * Add synthesized events It's useful to also emit events for some commands when they affect eg lobby state * Add LobbyStates This is just a helper that can be used to keep the state of 1 or more lobbies updated as events pertaining to them are streamed from Discord * Fixup examples and tests with changed API * Add a simple repl example * Begin adding overlay example * Windows fixes * Reorganize the repo to get isolated examples See rust-lang/cargo#7467, egui, structopt, etc are quite heavy, so making each example an isolated crate means people can just build the one example they want, and the sdk itself is also not "polluted" with every dev-dependency. * Cleanup * Fixup so that the sdk is packageable cargo won't allow using files (eg README) from above the crate root, so we just copy the files into the repo root before making the commit a release is published from * Fix deny config * Fix clippy lints * Correct publish crate * Rustfmt * Don't build examples during testing * Only run tests for the sdk itself
Wanted to add a note here since I banged my head on this for a minute while trying to add examples to my workspace: In order to do this, AFAICT, you (1) must create a full crate for each of your workspace examples (i.e. you cannot create single-file examples for a workspace) and you (2) must place your example code into the (point 2 is specified in @ehuss 's comment above above, I just skimmed too quickly and overlooked it thinking each example-crate specifies a So for clarity, my workspace dir:
My Cargo.toml:
And then my recursive
The 2 file structures I tried first which did not work as I'd initially assumed:
A general piece of feedback: It'd be nice if single-file examples worked for workspaces as they do for crates (e.g. |
I found this works without the requirement of the virtual manifest.
|
Not entirely possible to support the cargo examples at the workspace level right now. (rust-lang/cargo#7467)
For the sake of Google. Here is a nice example of a crate with grouped examples: https://github.com/tracel-ai/burn/blob/main/Cargo.toml |
Describe the problem you are trying to solve
In the graphql-client set of crates, there is an
examples
directory at the workspace level. This keeps them visible and easy to find. However, they are not part of thecargo build --examples
build at the top-level because they aren't found in the "right" location. CI ends up building them standalone which ends up causing lots of dependencies to be rebuilt again on top of the main workspace build set.Describe the solution you'd like
It would be nice if something like this were possible:
which would cause cargo to look in the
examples/
directory for example (full crates I guess?) and merge them in with the main build set (if--examples
or--all
is in effect).The text was updated successfully, but these errors were encountered: