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

Add a temporary env var to enable hashes in filenames #3022

Merged
merged 1 commit into from
Aug 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions src/cargo/ops/cargo_rustc/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,30 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
Some(metadata)
} else if unit.pkg.package_id().source_id().is_path() &&
!unit.profile.test {
// If we're not building a unit test then the root package never
// needs any metadata as it's guaranteed to not conflict with any
// other output filenames. This means that we'll have predictable
// If we're not building a unit test but we're building a path
// dependency, then we're likely compiling the "current package" or
// some package in a workspace. In this situation we pass no
// metadata by default so we'll have predictable
// file names like `target/debug/libfoo.{a,so,rlib}` and such.
None
//
// Note, though, that the compiler's build system at least wants
// path dependencies to have hashes in filenames. To account for
// that we have an extra hack here which reads the
// `__CARGO_DEFAULT_METADATA` environment variable and creates a
// hash in the filename if that's present.
//
// This environment variable should not be relied on! It's basically
// just here for rustbuild. We need a more principled method of
// doing this eventually.
if unit.target.is_lib() {
env::var("__CARGO_DEFAULT_LIB_METADATA").ok().map(|meta| {
let mut metadata = unit.pkg.generate_metadata();
metadata.mix(&meta);
metadata
})
} else {
None
}
} else {
metadata.cloned()
}
Expand Down