cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.73k stars 375 forks source link

Allow setting manual project root #1274

Closed svenstaro closed 1 year ago

svenstaro commented 1 year ago

Checklist

Describe your request

My project looks like this:

myproj
 |- .git
 |- some_other_stuff/my_thing.lol
 |- the_rust_thing_im_building/
 |- the_rust_thing_im_building/Cargo.toml
 |- the_rust_thing_im_building/Cross.toml
 |- the_rust_thing_im_building/build.rs

My build.rs needs to access some_other_stuff/my_thing.lol.

When building via Cross, I get paths such as this:

-v /home/svenstaro/myproj/the_rust_thing_im_building:/project
-w /project

However, I'd like it instead to be

-v /home/svenstaro/myproj/:/project
-w /project/the_rust_thing_im_building

I don't think this currently possible but it's a use case I have fairly often as my builds might need to access resources outside the current Cargo project.

Describe why this would be a good inclusion for cross

Currently I can probably throw some CROSS_CONTAINER_OPTS at it and wrestle it into submission but it would be great if this were a supported mode of operation.

svenstaro commented 1 year ago

I also found https://github.com/cross-rs/cross/issues/405 but I'm not sure it's exactly the use case here. At least I don't see how to hack that to work for me.

Emilgardis commented 1 year ago

With current cross we have entirely gotten rid of the concept of /project, does that work better?

cargo install cross --git https://github.com/cross-rs/cross should handle this better basically

svenstaro commented 1 year ago

I see. However, I still don't see how I can easily accomplish my use case here. Is there something I'm missing?

Emilgardis commented 1 year ago

ah, sorry, you can use volumes

[build.env]
volumes = ["MY_THING=../some_other_stuff/my_thing.lol"]

or, if . is the workspace root (e.g has a Cargo.toml with [workspace] in it) it'd work fine as well.

svenstaro commented 1 year ago

Ah hm, that does work for me! I'll consider this feature request void then. Would be great if you could cut a release some time soon! Last one is fairly long ago and this seems like an important feature to have.

Emilgardis commented 1 year ago

these features should already be present in 0.2.5, and definitely yes we need to do a release...