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

enable cargo workspace and path dependencies to work seamlessly #684

Merged
merged 5 commits into from
Jun 7, 2022

Conversation

Emilgardis
Copy link
Member

@Emilgardis Emilgardis commented Apr 6, 2022

This will allow cargo workspaces to work seamlessly with cross, assuming they don't reference anything outside the current workspace root. This change also automatically mounts (if needed) path dependencies.

If they do reference things outside the workspace root, and that fact is not know to cargo metadata (e.g, it's not a workspace member or a path dependency), you'll have to mount it with

[build.env]
volumes = ["THING"]

and set $THING="/path/to/thing" (we need to work on accessibility for this feature too, a lot of reported issues are solved by it)

I'm sure there is an issue directly related to workspaces, but I can't find any.

fixes #388

Copy link
Member Author

@Emilgardis Emilgardis left a comment

Choose a reason for hiding this comment

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

@Emilgardis
Copy link
Member Author

We can also use workspace_members and mount members as volumes if they are not on the same "root" folder.

we can also walk through all non-workspace packages, and if source is path+file://, mount that as well.

This will effectively make path dependencies zero-cost, as long as those paths are defined and shown with cargo metadata

@Emilgardis
Copy link
Member Author

this is possibly an argument for using cargo as a library, but that locks us to the features of the specific cargo version that is used.

@Emilgardis
Copy link
Member Author

I've created https://github.com/cross-rs/test-workspace to test against

src/docker.rs Outdated Show resolved Hide resolved
@Emilgardis Emilgardis force-pushed the cargo-workspace branch 2 times, most recently from 2efc53b to 7860d47 Compare April 7, 2022 17:54
@Emilgardis
Copy link
Member Author

bors try --target x86_64-unknown-linux-gnu

bors bot added a commit that referenced this pull request Apr 7, 2022
@bors
Copy link
Contributor

bors bot commented Apr 7, 2022

try

Build succeeded:

CHANGELOG.md Outdated Show resolved Hide resolved
README.md Outdated
Comment on lines 358 to 361
However, you may use Cargo's `--manifest-path` option to reference your
target crate, executed from a common root directory from which all your
dependencies are available.
Copy link
Member Author

Choose a reason for hiding this comment

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

modify

ci/test.sh Outdated Show resolved Hide resolved
Comment on lines +72 to +74
// TODO: Also filter out things that are in workspace, but not a workspace member
self.non_workspace_members().filter_map(|p| p.crate_path())
}
Copy link
Member Author

Choose a reason for hiding this comment

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

this todo is not super important, but probably good to have since it minifies the mounts needed

src/cargo.rs Outdated Show resolved Hide resolved
src/cargo.rs Outdated Show resolved Hide resolved
src/docker.rs Show resolved Hide resolved
@Emilgardis
Copy link
Member Author

Emilgardis commented Apr 7, 2022

it works! https://github.com/cross-rs/cross/runs/5873527788?check_suite_focus=true#step:7:1482

image

If anyone is able to review this before it's actually ready, please do <3

@Emilgardis
Copy link
Member Author

ping @wngr

this integrates #494

src/main.rs Outdated Show resolved Hide resolved
@Emilgardis
Copy link
Member Author

bors try

bors bot added a commit that referenced this pull request Apr 7, 2022
@bors
Copy link
Contributor

bors bot commented Apr 7, 2022

try

Build succeeded:

src/cargo.rs Show resolved Hide resolved
@Emilgardis Emilgardis marked this pull request as ready for review April 29, 2022 16:18
@Emilgardis Emilgardis requested a review from a team as a code owner April 29, 2022 16:18
@Emilgardis Emilgardis changed the title enable cargo workspaces to work seamlessly enable cargo workspaces and local dependencies to work seamlessly May 8, 2022
@Emilgardis Emilgardis changed the title enable cargo workspaces and local dependencies to work seamlessly enable cargo workspace and path dependencies to work seamlessly May 8, 2022
@Emilgardis Emilgardis linked an issue May 20, 2022 that may be closed by this pull request
@Emilgardis Emilgardis force-pushed the cargo-workspace branch 3 times, most recently from b777258 to 4bc0b65 Compare May 26, 2022 10:33
@Emilgardis
Copy link
Member Author

bors try --target *unknown-linux-gnu

bors bot added a commit that referenced this pull request Jun 3, 2022
@bors
Copy link
Contributor

bors bot commented Jun 3, 2022

try

Build succeeded:

@Emilgardis Emilgardis requested a review from a team June 7, 2022 02:49
@Alexhuszagh Alexhuszagh self-requested a review June 7, 2022 05:22
@Alexhuszagh Alexhuszagh self-assigned this Jun 7, 2022
@Alexhuszagh Alexhuszagh dismissed their stale review June 7, 2022 15:56

Outdated, needs new tests.

ci/test.sh Show resolved Hide resolved
Ensure we build the entire workspace using the `--workspace` flag both with and without the manifest path, and also ensure we build the binary with all our workspace dependencies.
Copy link
Contributor

@Alexhuszagh Alexhuszagh left a comment

Choose a reason for hiding this comment

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

Everything looks great and the updated tests all pass. I believe this is ready to merge. Should I r+ it?

@Alexhuszagh
Copy link
Contributor

bors r+

bors bot added a commit that referenced this pull request Jun 7, 2022
684: enable cargo workspace and path dependencies to work seamlessly r=Alexhuszagh a=Emilgardis

This will allow cargo workspaces to work seamlessly with cross, assuming they don't reference anything outside the current workspace root. This change also automatically mounts (if needed) path dependencies.

If they do reference things outside the workspace root, and that fact is not know to `cargo metadata` (e.g, it's not a workspace member or a path dependency), you'll have to mount it with

```toml
[build.env]
volumes = ["THING"]
```

and set `$THING="/path/to/thing"` (we need to work on accessibility for this feature too, a lot of reported issues are solved by it)

I'm sure there is an issue directly related to workspaces, but I can't find any.

fixes #388 

Co-authored-by: Emil Gardström <emil.gardstrom@gmail.com>
Co-authored-by: wngr <oliver@wngr.de>
Co-authored-by: Alexander Huszagh <ahuszagh@gmail.com>
@bors
Copy link
Contributor

bors bot commented Jun 7, 2022

Build failed:

`"${@}"` is an unbound variable on Bash 3.2, while `"$@"` is not, and Bash 3.2 is the pre-installed version on macOS.
@Alexhuszagh
Copy link
Contributor

bors try --target x86_64-apple-darwin

bors bot added a commit that referenced this pull request Jun 7, 2022
@bors
Copy link
Contributor

bors bot commented Jun 7, 2022

try

Build succeeded:

@Alexhuszagh
Copy link
Contributor

bors r+

@bors
Copy link
Contributor

bors bot commented Jun 7, 2022

Build succeeded:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--manifest-path not working Building with local dependencies
4 participants