Skip to content

Conversation

@csmoe
Copy link
Contributor

@csmoe csmoe commented Jul 3, 2019

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 3, 2019
@matklad
Copy link
Contributor

matklad commented Jul 3, 2019

The current work-around for this is to launch cargo metadata, which is not to pretty: mitsuhiko/insta@943e7bc

The potential gotcha here is that workspace situation is different between locally developed crate, and crate as it exists on crates.io: in the latter case, we remove all workspace structure and just store a flat list of crates.

@csmoe
Copy link
Contributor Author

csmoe commented Jul 4, 2019

@matklad
I cloned regex crate which has a build.rs and [workspace], then append this into its build.rs:

let ws = std::env::var("CARGO_WORKSPACE_MANIFEST_DIR").unwrap();
println!("{:?}", ws);

add regex as a dep of a local crate foo's workspace member a/Cargo.toml:

regex = { version = "1.1", path = "../../regex"}

built foo with this patch:

foo > ../../cargo/target/debug/cargo b -vv

it printed the snippet:

Running `xxx/foo/target/debug/build/regex-2724514c799c31b5/build-script-build`
[regex 1.1.7] "/Users/xxx/foo"
Running `CARGO_WORKSPACE_MANIFEST_DIR=xxx/regex CARGO_PKG_NAME=regex
CARGO_PKG_REPOSITORY='https://github.com/rust-lang/regex'

As we can see, WORKSPACE_DIR was still xxx/regex when building regex itself, but for regex's build-script, it was xxx/foo.
so I thought it was ok, any dangerous cases I missed?

@alexcrichton
Copy link
Member

Thanks for the PR @csmoe and sorry for the delay in review!

This sort of feature has a bit of history at this point, so I think it's worth paging that in as well. In addition to #7036 there's a lot more discussion on #3946 along with a closed PR and rationale for why the PR was closed.

Could this perhaps address some of the feedback in those threads to indicate why we would merge this instead?

@csmoe
Copy link
Contributor Author

csmoe commented Jul 16, 2019

Thanks for reviewing :), the problems wasn't addressed.
So, closed.

@csmoe csmoe closed this Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cargo Workspace Provided build scripts ROOT Directory

4 participants