-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add a method for a dependency to 'push' an artifact up the dependency tree #5644
Comments
Currently, Cargo does not support working with arbitrary artifacts, resources, etc: it handles only dependencies between Rust libraries, where a Rust library is a very rigidly defined concept. While it is possible in theory to add such feature to Cargo, it would definitely require a significant amount of design work, and I personally not sure that it aligns well with the way Cargo works today. I wonder if this can be solved outside of Cargo, though? Presumably, you need the binary in the specific location to make packaging and tests work? Could you explicitly run |
winpty is in a different repository to alacritty, if I understand your suggestion correctly we'd need to add a build script to clone winpty, build it, copy it to alacritty and build alacritty. In my mind that's basically complex enough to require a makefile, which is not ideal considering this is exclusively for Windows... I know cargo is not currently planning to deal with this and I respect the decision to not want to add features to try to deal with it without much planning. However I feel like this is a pretty simple solution that wouldn't get in the way of any future work. |
Hm, the binary that you are interested in is actually in C++, and not in Rust, right? I've missed this originally. I was trying to say that something like this works: ~/tmp/foo master*
λ cat Cargo.toml
[package]
name = "foo"
version = "0.1.0"
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
[dependencies]
ripgrep = "*"
~/tmp/foo master*
λ cargo build -p ripgrep --bin rg
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
~/tmp/foo master*
λ ls target/debug/ | ./target/debug/rg rg
.rwxr-xr-x 44M matklad 27 Jun 0:22 rg
.rw-r--r-- 1.2k matklad 27 Jun 0:22 rg.d but you can't use this trick if the binary is in C++... |
Yeah it's built by the build script. Repository is here, on the rust branch. |
FYI there has been interest in "artifact dependencies", see rust-lang/rfcs#2887 |
Motivation: alacritty/alacritty#1374 (comment)
In the case above our binary crate depends on another binary (winpty-agent) which is built by one of it's dependants. At the moment there is no easy way for our crate to access artifacts produced in a dependencies target directory, unless it's a library linked by cargo.
My suggestion is too add an output to the build script called 'publishes' which contains a name of an artifact produced by the build script. Setting this will make cargo copy it into any crates which require it as a dependency. In this scenario
winpty-sys
ANDwinpty
would setpublishes
to the name of the binary. It would be copied into winpty's target directory, then into alacritty's target directory.The text was updated successfully, but these errors were encountered: