-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
A-cachingArea: caching of dependencies, repositories, and build artifactsArea: caching of dependencies, repositories, and build artifactsS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Description
Currently you can add dependencies using path or git. Cargo assumes this is a location to source code, which it will then proceed to build.
My use-case stems from integrating Cargo into a private build and dependency management system. I need to be able to tell Cargo to only worry about building the current package. That is, I will tell it where the other already-built libraries are.
Consider two projects: a (lib) and b (bin) such that b depends on a:
[package]
name = "b"
version = "0.0.1"
authors = ["me <[email protected]>"]
[dependencies.a]
path = "/tmp/rust-crates/a"A clean build will output something like:
> cargo build -v master untracked
Compiling a v0.0.1 (file:///private/tmp/rust-crates/b)
Running `rustc /tmp/rust-crates/a/src/lib.rs --crate-name a --crate-type lib -g -C metadata=10d34ebdfa7a5b84 -C extra-filename=-10d34ebdfa7a5b84 --out-dir /private/tmp/rust-crates/b/target/deps --emit=dep-info,link -L dependency=/private/tmp/rust-crates/b/target/deps -L dependency=/private/tmp/rust-crates/b/target/deps`
/tmp/rust-crates/a/src/lib.rs:1:1: 3:2 warning: function is never used: `it_works`, #[warn(dead_code)] on by default
/tmp/rust-crates/a/src/lib.rs:1 fn it_works() {
/tmp/rust-crates/a/src/lib.rs:2 println!("a works");
/tmp/rust-crates/a/src/lib.rs:3 }
Compiling b v0.0.1 (file:///private/tmp/rust-crates/b)
Running `rustc /private/tmp/rust-crates/b/src/lib.rs --crate-name b --crate-type lib -g -C metadata=429959f67e51bc23 -C extra-filename=-429959f67e51bc23 --out-dir /private/tmp/rust-crates/b/target --emit=dep-info,link -L dependency=/private/tmp/rust-crates/b/target -L dependency=/private/tmp/rust-crates/b/target/deps --extern a=/private/tmp/rust-crates/b/target/deps/liba-10d34ebdfa7a5b84.rlib`
/private/tmp/rust-crates/b/src/lib.rs:1:1: 3:2 warning: function is never used: `it_works`, #[warn(dead_code)] on by default
/private/tmp/rust-crates/b/src/lib.rs:1 fn it_works() {
/private/tmp/rust-crates/b/src/lib.rs:2 println!("b works");
/private/tmp/rust-crates/b/src/lib.rs:3 }
Importantly:
--extern a=/private/tmp/rust-crates/b/target/deps/liba-10d34ebdfa7a5b84.rlib
Would it make sense to expose a extern option (in dependencies.a) for low level customization?
[dependencies.a]
extern = "/private/tmp/rust-crates/b/target/deps/liba-10d34ebdfa7a5b84.rlib"This can be worked around by using a build script along the lines of:
use std::io::fs;
fn main() {
let from = Path::new("/tmp/rust-crates/a/target/liba-b2092cdbfc1953bd.rlib");
let to = Path::new("/tmp/rust-crates/b/blah/liba-b2092cdbfc1953bd.rlib");
fs::copy(&from, &to).unwrap();
println!("cargo:rustc-flags=-L /tmp/rust-crates/b/blah");
}But it is not ideal to have to do this with every project.
Xaeroxe, KSXGitHub, ruuda, russelldavis, mooman219 and 55 more
Metadata
Metadata
Assignees
Labels
A-cachingArea: caching of dependencies, repositories, and build artifactsArea: caching of dependencies, repositories, and build artifactsS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.