mirror of
https://github.com/rust-lang/cargo
synced 2024-08-24 18:15:45 +00:00
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's reliance on the idea of a "root crate" this PR is the next step. With workspaces the root crate of a compliation changes all the time, so the output needs to be the same whether a crate is at the root or not. Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise due to this discrepancy. Additionally, Cargo will no longer recompile a library when it's used as a "root crate" or not. This is fixed by taking a few steps: * Everything is now compiled into the `deps` directory, regardless of whether it's a root output or not. * If a "root crate" is being compiled, then the relevant outputs are hard-linked up one level to where they are today. This means that your binaries, dylibs, staticlibs, etc, will all show up where they used to. * The `-C metadata` flag is always omitted for path dependencies now. These dependencies are always path dependencies and already all have unique crate names. Additionally, they're the only crates in the DAG without metadata, so there's no need to provide additional metadata. This in turn means that none of the file names of the generated crates are mangled. Closes #2855
This commit is contained in:
parent
0c08bd1610
commit
0863469c8b
|
@ -73,7 +73,7 @@ pub fn clean(ws: &Workspace, opts: &CleanOptions) -> CargoResult<()> {
|
||||||
try!(cx.probe_target_info(&units));
|
try!(cx.probe_target_info(&units));
|
||||||
|
|
||||||
for unit in units.iter() {
|
for unit in units.iter() {
|
||||||
let layout = cx.layout(&unit.pkg, unit.kind);
|
let layout = cx.layout(unit);
|
||||||
try!(rm_rf(&layout.proxy().fingerprint(&unit.pkg)));
|
try!(rm_rf(&layout.proxy().fingerprint(&unit.pkg)));
|
||||||
try!(rm_rf(&layout.build(&unit.pkg)));
|
try!(rm_rf(&layout.build(&unit.pkg)));
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
|
||||||
|
|
||||||
/// Prepare this context, ensuring that all filesystem directories are in
|
/// Prepare this context, ensuring that all filesystem directories are in
|
||||||
/// place.
|
/// place.
|
||||||
pub fn prepare(&mut self, root: &Package) -> CargoResult<()> {
|
pub fn prepare(&mut self) -> CargoResult<()> {
|
||||||
let _p = profile::start("preparing layout");
|
let _p = profile::start("preparing layout");
|
||||||
|
|
||||||
try!(self.host.prepare().chain_error(|| {
|
try!(self.host.prepare().chain_error(|| {
|
||||||
|
@ -111,10 +111,9 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.compilation.root_output =
|
let layout = self.target.as_ref().unwrap_or(&self.host);
|
||||||
self.layout(root, Kind::Target).proxy().dest().to_path_buf();
|
self.compilation.root_output = layout.dest().to_path_buf();
|
||||||
self.compilation.deps_output =
|
self.compilation.deps_output = layout.deps().to_path_buf();
|
||||||
self.layout(root, Kind::Target).proxy().deps().to_path_buf();
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,9 +236,9 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the appropriate directory layout for either a plugin or not.
|
/// Returns the appropriate directory layout for either a plugin or not.
|
||||||
pub fn layout(&self, pkg: &Package, kind: Kind) -> LayoutProxy {
|
pub fn layout(&self, unit: &Unit) -> LayoutProxy {
|
||||||
let primary = pkg.package_id() == self.resolve.root();
|
let primary = unit.pkg.package_id() == self.resolve.root();
|
||||||
match kind {
|
match unit.kind {
|
||||||
Kind::Host => LayoutProxy::new(&self.host, primary),
|
Kind::Host => LayoutProxy::new(&self.host, primary),
|
||||||
Kind::Target => LayoutProxy::new(self.target.as_ref()
|
Kind::Target => LayoutProxy::new(self.target.as_ref()
|
||||||
.unwrap_or(&self.host),
|
.unwrap_or(&self.host),
|
||||||
|
@ -247,13 +246,18 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the path for plugin/dylib dependencies
|
||||||
|
pub fn host_dylib_path(&self) -> &Path {
|
||||||
|
self.host.deps()
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the appropriate output directory for the specified package and
|
/// Returns the appropriate output directory for the specified package and
|
||||||
/// target.
|
/// target.
|
||||||
pub fn out_dir(&self, unit: &Unit) -> PathBuf {
|
pub fn out_dir(&self, unit: &Unit) -> PathBuf {
|
||||||
if unit.profile.doc {
|
if unit.profile.doc {
|
||||||
self.layout(unit.pkg, unit.kind).doc_root()
|
self.layout(unit).doc_root()
|
||||||
} else {
|
} else {
|
||||||
self.layout(unit.pkg, unit.kind).out_dir(unit.pkg, unit.target)
|
self.layout(unit).out_dir(unit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +293,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
|
||||||
let mut metadata = unit.pkg.generate_metadata();
|
let mut metadata = unit.pkg.generate_metadata();
|
||||||
metadata.mix(&format!("bin-{}", unit.target.name()));
|
metadata.mix(&format!("bin-{}", unit.target.name()));
|
||||||
Some(metadata)
|
Some(metadata)
|
||||||
} else if unit.pkg.package_id() == self.resolve.root() &&
|
} else if unit.pkg.package_id().source_id().is_path() &&
|
||||||
!unit.profile.test {
|
!unit.profile.test {
|
||||||
// If we're not building a unit test then the root package never
|
// 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
|
// needs any metadata as it's guaranteed to not conflict with any
|
||||||
|
|
|
@ -87,9 +87,10 @@ pub fn prepare<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>)
|
||||||
|
|
||||||
fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>)
|
fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>)
|
||||||
-> CargoResult<(Work, Work)> {
|
-> CargoResult<(Work, Work)> {
|
||||||
|
let host_unit = Unit { kind: Kind::Host, ..*unit };
|
||||||
let (script_output, build_output) = {
|
let (script_output, build_output) = {
|
||||||
(cx.layout(unit.pkg, Kind::Host).build(unit.pkg),
|
(cx.layout(&host_unit).build(unit.pkg),
|
||||||
cx.layout(unit.pkg, unit.kind).build_out(unit.pkg))
|
cx.layout(unit).build_out(unit.pkg))
|
||||||
};
|
};
|
||||||
|
|
||||||
// Building the command to execute
|
// Building the command to execute
|
||||||
|
@ -161,8 +162,8 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>)
|
||||||
};
|
};
|
||||||
cx.build_explicit_deps.insert(*unit, (output_file.clone(), rerun_if_changed));
|
cx.build_explicit_deps.insert(*unit, (output_file.clone(), rerun_if_changed));
|
||||||
|
|
||||||
try!(fs::create_dir_all(&cx.layout(unit.pkg, Kind::Host).build(unit.pkg)));
|
try!(fs::create_dir_all(&cx.layout(&host_unit).build(unit.pkg)));
|
||||||
try!(fs::create_dir_all(&cx.layout(unit.pkg, unit.kind).build(unit.pkg)));
|
try!(fs::create_dir_all(&cx.layout(unit).build(unit.pkg)));
|
||||||
|
|
||||||
// Prepare the unit of "dirty work" which will actually run the custom build
|
// Prepare the unit of "dirty work" which will actually run the custom build
|
||||||
// command.
|
// command.
|
||||||
|
|
|
@ -497,7 +497,7 @@ pub fn prepare_init(cx: &mut Context, unit: &Unit) -> CargoResult<()> {
|
||||||
|
|
||||||
/// Return the (old, new) location for fingerprints for a package
|
/// Return the (old, new) location for fingerprints for a package
|
||||||
pub fn dir(cx: &Context, unit: &Unit) -> PathBuf {
|
pub fn dir(cx: &Context, unit: &Unit) -> PathBuf {
|
||||||
cx.layout(unit.pkg, unit.kind).proxy().fingerprint(unit.pkg)
|
cx.layout(unit).proxy().fingerprint(unit.pkg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the (old, new) location for the dep info file of a target.
|
/// Returns the (old, new) location for the dep info file of a target.
|
||||||
|
|
|
@ -49,9 +49,10 @@ use std::fs;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::{PathBuf, Path};
|
use std::path::{PathBuf, Path};
|
||||||
|
|
||||||
use core::{Package, Target, Workspace};
|
use core::{Package, Workspace};
|
||||||
use util::{Config, FileLock, CargoResult, Filesystem};
|
use util::{Config, FileLock, CargoResult, Filesystem};
|
||||||
use util::hex::short_hash;
|
use util::hex::short_hash;
|
||||||
|
use super::Unit;
|
||||||
|
|
||||||
pub struct Layout {
|
pub struct Layout {
|
||||||
root: PathBuf,
|
root: PathBuf,
|
||||||
|
@ -165,11 +166,13 @@ impl<'a> LayoutProxy<'a> {
|
||||||
|
|
||||||
pub fn proxy(&self) -> &'a Layout { self.root }
|
pub fn proxy(&self) -> &'a Layout { self.root }
|
||||||
|
|
||||||
pub fn out_dir(&self, pkg: &Package, target: &Target) -> PathBuf {
|
pub fn out_dir(&self, unit: &Unit) -> PathBuf {
|
||||||
if target.is_custom_build() {
|
if unit.target.is_custom_build() {
|
||||||
self.build(pkg)
|
self.build(unit.pkg)
|
||||||
} else if target.is_example() {
|
} else if unit.target.is_example() {
|
||||||
self.examples().to_path_buf()
|
self.examples().to_path_buf()
|
||||||
|
} else if unit.target.is_lib() {
|
||||||
|
self.deps().to_path_buf()
|
||||||
} else {
|
} else {
|
||||||
self.root().to_path_buf()
|
self.root().to_path_buf()
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>,
|
||||||
|
|
||||||
let mut queue = JobQueue::new(&cx);
|
let mut queue = JobQueue::new(&cx);
|
||||||
|
|
||||||
try!(cx.prepare(root));
|
try!(cx.prepare());
|
||||||
try!(cx.probe_target_info(&units));
|
try!(cx.probe_target_info(&units));
|
||||||
try!(custom_build::build_map(&mut cx, &units));
|
try!(custom_build::build_map(&mut cx, &units));
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>,
|
||||||
try!(queue.execute(&mut cx));
|
try!(queue.execute(&mut cx));
|
||||||
|
|
||||||
for unit in units.iter() {
|
for unit in units.iter() {
|
||||||
let out_dir = cx.layout(unit.pkg, unit.kind).build_out(unit.pkg)
|
let out_dir = cx.layout(unit).build_out(unit.pkg)
|
||||||
.display().to_string();
|
.display().to_string();
|
||||||
cx.compilation.extra_env.entry(unit.pkg.package_id().clone())
|
cx.compilation.extra_env.entry(unit.pkg.package_id().clone())
|
||||||
.or_insert(Vec::new())
|
.or_insert(Vec::new())
|
||||||
|
@ -228,6 +228,7 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult<Work> {
|
||||||
let do_rename = unit.target.allows_underscores() && !unit.profile.test;
|
let do_rename = unit.target.allows_underscores() && !unit.profile.test;
|
||||||
let real_name = unit.target.name().to_string();
|
let real_name = unit.target.name().to_string();
|
||||||
let crate_name = unit.target.crate_name();
|
let crate_name = unit.target.crate_name();
|
||||||
|
let move_outputs_up = unit.pkg.package_id() == cx.resolve.root();
|
||||||
|
|
||||||
let rustc_dep_info_loc = if do_rename {
|
let rustc_dep_info_loc = if do_rename {
|
||||||
root.join(&crate_name)
|
root.join(&crate_name)
|
||||||
|
@ -271,7 +272,7 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult<Work> {
|
||||||
let src = dst.with_file_name(dst.file_name().unwrap()
|
let src = dst.with_file_name(dst.file_name().unwrap()
|
||||||
.to_str().unwrap()
|
.to_str().unwrap()
|
||||||
.replace(&real_name, &crate_name));
|
.replace(&real_name, &crate_name));
|
||||||
if !has_custom_args || fs::metadata(&src).is_ok() {
|
if !has_custom_args || src.exists() {
|
||||||
try!(fs::rename(&src, &dst).chain_error(|| {
|
try!(fs::rename(&src, &dst).chain_error(|| {
|
||||||
internal(format!("could not rename crate {:?}", src))
|
internal(format!("could not rename crate {:?}", src))
|
||||||
}));
|
}));
|
||||||
|
@ -286,6 +287,40 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult<Work> {
|
||||||
try!(fingerprint::append_current_dir(&dep_info_loc, &cwd));
|
try!(fingerprint::append_current_dir(&dep_info_loc, &cwd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we're a "root crate", e.g. the target of this compilation, then we
|
||||||
|
// hard link our outputs out of the `deps` directory into the directory
|
||||||
|
// above. This means that `cargo build` will produce binaries in
|
||||||
|
// `target/debug` which one probably expects.
|
||||||
|
if move_outputs_up {
|
||||||
|
for &(ref filename, _linkable) in filenames.iter() {
|
||||||
|
let src = root.join(filename);
|
||||||
|
// This may have been a `cargo rustc` command which changes the
|
||||||
|
// output, so the source may not actually exist.
|
||||||
|
if !src.exists() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// We currently only lift files up from the `deps` directory. If
|
||||||
|
// it was compiled into something like `example/` or `doc/` then
|
||||||
|
// we don't want to link it up.
|
||||||
|
let src_dir = src.parent().unwrap();
|
||||||
|
if !src_dir.ends_with("deps") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
let dst = src_dir.parent().unwrap()
|
||||||
|
.join(src.file_name().unwrap());
|
||||||
|
if dst.exists() {
|
||||||
|
try!(fs::remove_file(&dst).chain_error(|| {
|
||||||
|
human(format!("failed to remove: {}", dst.display()))
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
try!(fs::hard_link(&src, &dst).chain_error(|| {
|
||||||
|
human(format!("failed to link `{}` to `{}`",
|
||||||
|
src.display(), dst.display()))
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -390,8 +425,7 @@ fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult<Work> {
|
||||||
try!(build_deps_args(&mut rustdoc, cx, unit));
|
try!(build_deps_args(&mut rustdoc, cx, unit));
|
||||||
|
|
||||||
if unit.pkg.has_custom_build() {
|
if unit.pkg.has_custom_build() {
|
||||||
rustdoc.env("OUT_DIR", &cx.layout(unit.pkg, unit.kind)
|
rustdoc.env("OUT_DIR", &cx.layout(unit).build_out(unit.pkg));
|
||||||
.build_out(unit.pkg));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rustdoc.args(&try!(cx.rustdocflags_args(unit)));
|
rustdoc.args(&try!(cx.rustdocflags_args(unit)));
|
||||||
|
@ -552,12 +586,7 @@ fn build_plugin_args(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit) {
|
||||||
|
|
||||||
fn build_deps_args(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit)
|
fn build_deps_args(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit)
|
||||||
-> CargoResult<()> {
|
-> CargoResult<()> {
|
||||||
let layout = cx.layout(unit.pkg, unit.kind);
|
let layout = cx.layout(unit);
|
||||||
cmd.arg("-L").arg(&{
|
|
||||||
let mut root = OsString::from("dependency=");
|
|
||||||
root.push(layout.root());
|
|
||||||
root
|
|
||||||
});
|
|
||||||
cmd.arg("-L").arg(&{
|
cmd.arg("-L").arg(&{
|
||||||
let mut deps = OsString::from("dependency=");
|
let mut deps = OsString::from("dependency=");
|
||||||
deps.push(layout.deps());
|
deps.push(layout.deps());
|
||||||
|
@ -569,7 +598,7 @@ fn build_deps_args(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
for unit in try!(cx.dep_targets(unit)).iter() {
|
for unit in try!(cx.dep_targets(unit)).iter() {
|
||||||
if unit.target.linkable() {
|
if unit.target.linkable() && !unit.profile.doc {
|
||||||
try!(link_to(cmd, cx, unit));
|
try!(link_to(cmd, cx, unit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -578,8 +607,6 @@ fn build_deps_args(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit)
|
||||||
|
|
||||||
fn link_to(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit)
|
fn link_to(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit)
|
||||||
-> CargoResult<()> {
|
-> CargoResult<()> {
|
||||||
let layout = cx.layout(unit.pkg, unit.kind);
|
|
||||||
|
|
||||||
for (filename, linkable) in try!(cx.target_filenames(unit)) {
|
for (filename, linkable) in try!(cx.target_filenames(unit)) {
|
||||||
if !linkable {
|
if !linkable {
|
||||||
continue
|
continue
|
||||||
|
@ -587,7 +614,7 @@ fn build_deps_args(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit)
|
||||||
let mut v = OsString::new();
|
let mut v = OsString::new();
|
||||||
v.push(&unit.target.crate_name());
|
v.push(&unit.target.crate_name());
|
||||||
v.push("=");
|
v.push("=");
|
||||||
v.push(layout.root());
|
v.push(cx.out_dir(unit));
|
||||||
v.push(&path::MAIN_SEPARATOR.to_string());
|
v.push(&path::MAIN_SEPARATOR.to_string());
|
||||||
v.push(&filename);
|
v.push(&filename);
|
||||||
cmd.arg("--extern").arg(&v);
|
cmd.arg("--extern").arg(&v);
|
||||||
|
@ -600,9 +627,8 @@ pub fn process(cmd: CommandType, pkg: &Package,
|
||||||
cx: &Context) -> CargoResult<CommandPrototype> {
|
cx: &Context) -> CargoResult<CommandPrototype> {
|
||||||
// When invoking a tool, we need the *host* deps directory in the dynamic
|
// When invoking a tool, we need the *host* deps directory in the dynamic
|
||||||
// library search path for plugins and such which have dynamic dependencies.
|
// library search path for plugins and such which have dynamic dependencies.
|
||||||
let layout = cx.layout(pkg, Kind::Host);
|
|
||||||
let mut search_path = util::dylib_path();
|
let mut search_path = util::dylib_path();
|
||||||
search_path.push(layout.deps().to_path_buf());
|
search_path.push(cx.host_dylib_path().to_path_buf());
|
||||||
|
|
||||||
// We want to use the same environment and such as normal processes, but we
|
// We want to use the same environment and such as normal processes, but we
|
||||||
// want to override the dylib search path with the one we just calculated.
|
// want to override the dylib search path with the one we just calculated.
|
||||||
|
|
|
@ -134,7 +134,7 @@ fn run_doc_tests(options: &TestOptions,
|
||||||
p.arg("--test").arg(lib)
|
p.arg("--test").arg(lib)
|
||||||
.arg("--crate-name").arg(&crate_name);
|
.arg("--crate-name").arg(&crate_name);
|
||||||
|
|
||||||
for &rust_dep in &[&compilation.deps_output, &compilation.root_output] {
|
for &rust_dep in &[&compilation.deps_output] {
|
||||||
let mut arg = OsString::from("dependency=");
|
let mut arg = OsString::from("dependency=");
|
||||||
arg.push(rust_dep);
|
arg.push(rust_dep);
|
||||||
p.arg("-L").arg(arg);
|
p.arg("-L").arg(arg);
|
||||||
|
|
|
@ -10,9 +10,8 @@ fn verbose_output_for_lib(p: &ProjectBuilder) -> String {
|
||||||
format!("\
|
format!("\
|
||||||
[COMPILING] {name} v{version} ({url})
|
[COMPILING] {name} v{version} ({url})
|
||||||
[RUNNING] `rustc src{sep}lib.rs --crate-name {name} --crate-type lib -g \
|
[RUNNING] `rustc src{sep}lib.rs --crate-name {name} --crate-type lib -g \
|
||||||
--out-dir {dir}{sep}target{sep}debug \
|
--out-dir [..] \
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
-L dependency={dir}{sep}target{sep}debug \
|
|
||||||
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
||||||
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
||||||
", sep = SEP,
|
", sep = SEP,
|
||||||
|
|
|
@ -766,19 +766,17 @@ fn build_cmd_with_a_build_cmd() {
|
||||||
[RUNNING] `rustc a[..]build.rs [..] --extern b=[..]`
|
[RUNNING] `rustc a[..]build.rs [..] --extern b=[..]`
|
||||||
[RUNNING] `[..]a-[..]build-script-build[..]`
|
[RUNNING] `[..]a-[..]build-script-build[..]`
|
||||||
[RUNNING] `rustc [..]lib.rs --crate-name a --crate-type lib -g \
|
[RUNNING] `rustc [..]lib.rs --crate-name a --crate-type lib -g \
|
||||||
-C metadata=[..] -C extra-filename=-[..] \
|
|
||||||
--out-dir [..]target[..]deps --emit=dep-info,link \
|
--out-dir [..]target[..]deps --emit=dep-info,link \
|
||||||
-L [..]target[..]deps -L [..]target[..]deps`
|
-L [..]target[..]deps`
|
||||||
[COMPILING] foo v0.5.0 (file://[..])
|
[COMPILING] foo v0.5.0 (file://[..])
|
||||||
[RUNNING] `rustc build.rs --crate-name build_script_build --crate-type bin \
|
[RUNNING] `rustc build.rs --crate-name build_script_build --crate-type bin \
|
||||||
-g \
|
-g --out-dir [..] --emit=dep-info,link \
|
||||||
--out-dir [..]build[..]foo-[..] --emit=dep-info,link \
|
-L [..]target[..]deps \
|
||||||
-L [..]target[..]debug -L [..]target[..]deps \
|
--extern a=[..]liba[..].rlib`
|
||||||
--extern a=[..]liba-[..].rlib`
|
|
||||||
[RUNNING] `[..]foo-[..]build-script-build[..]`
|
[RUNNING] `[..]foo-[..]build-script-build[..]`
|
||||||
[RUNNING] `rustc [..]lib.rs --crate-name foo --crate-type lib -g \
|
[RUNNING] `rustc [..]lib.rs --crate-name foo --crate-type lib -g \
|
||||||
--out-dir [..]target[..]debug --emit=dep-info,link \
|
--out-dir [..] --emit=dep-info,link \
|
||||||
-L [..]target[..]debug -L [..]target[..]deps`
|
-L [..]target[..]deps`
|
||||||
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
||||||
"));
|
"));
|
||||||
}
|
}
|
||||||
|
@ -1175,7 +1173,7 @@ fn build_script_with_dynamic_native_dependency() {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let src = PathBuf::from(env::var("SRC").unwrap());
|
let src = PathBuf::from(env::var("SRC").unwrap());
|
||||||
println!("cargo:rustc-link-search={}/target/debug",
|
println!("cargo:rustc-link-search={}/target/debug/deps",
|
||||||
src.display());
|
src.display());
|
||||||
}
|
}
|
||||||
"#)
|
"#)
|
||||||
|
|
|
@ -1026,7 +1026,6 @@ fn lto_build() {
|
||||||
-C lto \
|
-C lto \
|
||||||
--out-dir {dir}[..]target[..]release \
|
--out-dir {dir}[..]target[..]release \
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
-L dependency={dir}[..]target[..]release \
|
|
||||||
-L dependency={dir}[..]target[..]release[..]deps`
|
-L dependency={dir}[..]target[..]release[..]deps`
|
||||||
[FINISHED] release [optimized] target(s) in [..]
|
[FINISHED] release [optimized] target(s) in [..]
|
||||||
",
|
",
|
||||||
|
@ -1051,9 +1050,8 @@ fn verbose_build() {
|
||||||
execs().with_status(0).with_stderr(&format!("\
|
execs().with_status(0).with_stderr(&format!("\
|
||||||
[COMPILING] test v0.0.0 ({url})
|
[COMPILING] test v0.0.0 ({url})
|
||||||
[RUNNING] `rustc src[..]lib.rs --crate-name test --crate-type lib -g \
|
[RUNNING] `rustc src[..]lib.rs --crate-name test --crate-type lib -g \
|
||||||
--out-dir {dir}[..]target[..]debug \
|
--out-dir [..] \
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
-L dependency={dir}[..]target[..]debug \
|
|
||||||
-L dependency={dir}[..]target[..]debug[..]deps`
|
-L dependency={dir}[..]target[..]debug[..]deps`
|
||||||
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
||||||
",
|
",
|
||||||
|
@ -1079,9 +1077,8 @@ fn verbose_release_build() {
|
||||||
[COMPILING] test v0.0.0 ({url})
|
[COMPILING] test v0.0.0 ({url})
|
||||||
[RUNNING] `rustc src[..]lib.rs --crate-name test --crate-type lib \
|
[RUNNING] `rustc src[..]lib.rs --crate-name test --crate-type lib \
|
||||||
-C opt-level=3 \
|
-C opt-level=3 \
|
||||||
--out-dir {dir}[..]target[..]release \
|
--out-dir [..] \
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
-L dependency={dir}[..]target[..]release \
|
|
||||||
-L dependency={dir}[..]target[..]release[..]deps`
|
-L dependency={dir}[..]target[..]release[..]deps`
|
||||||
[FINISHED] release [optimized] target(s) in [..]
|
[FINISHED] release [optimized] target(s) in [..]
|
||||||
",
|
",
|
||||||
|
@ -1123,22 +1120,18 @@ fn verbose_release_build_deps() {
|
||||||
[RUNNING] `rustc foo[..]src[..]lib.rs --crate-name foo \
|
[RUNNING] `rustc foo[..]src[..]lib.rs --crate-name foo \
|
||||||
--crate-type dylib --crate-type rlib -C prefer-dynamic \
|
--crate-type dylib --crate-type rlib -C prefer-dynamic \
|
||||||
-C opt-level=3 \
|
-C opt-level=3 \
|
||||||
-C metadata=[..] \
|
--out-dir [..] \
|
||||||
-C extra-filename=-[..] \
|
|
||||||
--out-dir {dir}[..]target[..]release[..]deps \
|
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
-L dependency={dir}[..]target[..]release[..]deps \
|
|
||||||
-L dependency={dir}[..]target[..]release[..]deps`
|
-L dependency={dir}[..]target[..]release[..]deps`
|
||||||
[COMPILING] test v0.0.0 ({url})
|
[COMPILING] test v0.0.0 ({url})
|
||||||
[RUNNING] `rustc src[..]lib.rs --crate-name test --crate-type lib \
|
[RUNNING] `rustc src[..]lib.rs --crate-name test --crate-type lib \
|
||||||
-C opt-level=3 \
|
-C opt-level=3 \
|
||||||
--out-dir {dir}[..]target[..]release \
|
--out-dir [..] \
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
-L dependency={dir}[..]target[..]release \
|
|
||||||
-L dependency={dir}[..]target[..]release[..]deps \
|
-L dependency={dir}[..]target[..]release[..]deps \
|
||||||
--extern foo={dir}[..]target[..]release[..]deps[..]\
|
--extern foo={dir}[..]target[..]release[..]deps[..]\
|
||||||
{prefix}foo-[..]{suffix} \
|
{prefix}foo{suffix} \
|
||||||
--extern foo={dir}[..]target[..]release[..]deps[..]libfoo-[..].rlib`
|
--extern foo={dir}[..]target[..]release[..]deps[..]libfoo.rlib`
|
||||||
[FINISHED] release [optimized] target(s) in [..]
|
[FINISHED] release [optimized] target(s) in [..]
|
||||||
",
|
",
|
||||||
dir = p.root().display(),
|
dir = p.root().display(),
|
||||||
|
@ -1783,14 +1776,14 @@ fn compile_then_delete() {
|
||||||
"#)
|
"#)
|
||||||
.file("src/main.rs", "fn main() {}");
|
.file("src/main.rs", "fn main() {}");
|
||||||
|
|
||||||
assert_that(p.cargo_process("run"), execs().with_status(0));
|
assert_that(p.cargo_process("run").arg("-v"), execs().with_status(0));
|
||||||
assert_that(&p.bin("foo"), existing_file());
|
assert_that(&p.bin("foo"), existing_file());
|
||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
// On windows unlinking immediately after running often fails, so sleep
|
// On windows unlinking immediately after running often fails, so sleep
|
||||||
sleep_ms(100);
|
sleep_ms(100);
|
||||||
}
|
}
|
||||||
fs::remove_file(&p.bin("foo")).unwrap();
|
fs::remove_file(&p.bin("foo")).unwrap();
|
||||||
assert_that(p.cargo("run"),
|
assert_that(p.cargo("run").arg("-v"),
|
||||||
execs().with_status(0));
|
execs().with_status(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2243,11 +2236,7 @@ fn explicit_color_config_is_propagated_to_rustc() {
|
||||||
assert_that(p.cargo_process("build").arg("-v").arg("--color").arg("never"),
|
assert_that(p.cargo_process("build").arg("-v").arg("--color").arg("never"),
|
||||||
execs().with_status(0).with_stderr("\
|
execs().with_status(0).with_stderr("\
|
||||||
[COMPILING] test v0.0.0 ([..])
|
[COMPILING] test v0.0.0 ([..])
|
||||||
[RUNNING] `rustc src[..]lib.rs --color never --crate-name test --crate-type lib -g \
|
[RUNNING] `rustc [..] --color never [..]`
|
||||||
--out-dir [..]target[..]debug \
|
|
||||||
--emit=dep-info,link \
|
|
||||||
-L dependency=[..]target[..]debug \
|
|
||||||
-L dependency=[..]target[..]debug[..]deps`
|
|
||||||
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
||||||
"));
|
"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,7 @@ fn alias_config() {
|
||||||
execs().with_status(0).
|
execs().with_status(0).
|
||||||
with_stderr_contains("[COMPILING] foo v0.5.0 [..]
|
with_stderr_contains("[COMPILING] foo v0.5.0 [..]
|
||||||
[RUNNING] `rustc [..] --crate-name foo --crate-type \
|
[RUNNING] `rustc [..] --crate-name foo --crate-type \
|
||||||
bin -g --out-dir [..] --emit=dep-info,link -L dependency=[..]\
|
bin -g --out-dir [..] --emit=dep-info,link -L dependency=[..]"));
|
||||||
-L dependency=[..]"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -362,7 +362,6 @@ fn linker_and_ar() {
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
--target {target} \
|
--target {target} \
|
||||||
-C ar=my-ar-tool -C linker=my-linker-tool \
|
-C ar=my-ar-tool -C linker=my-linker-tool \
|
||||||
-L dependency={dir}[..]target[..]{target}[..]debug \
|
|
||||||
-L dependency={dir}[..]target[..]{target}[..]debug[..]deps`
|
-L dependency={dir}[..]target[..]{target}[..]debug[..]deps`
|
||||||
",
|
",
|
||||||
dir = p.root().display(),
|
dir = p.root().display(),
|
||||||
|
|
|
@ -147,7 +147,7 @@ fn plugin_with_dynamic_native_dependency() {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let src = PathBuf::from(env::var("SRC").unwrap());
|
let src = PathBuf::from(env::var("SRC").unwrap());
|
||||||
println!("cargo:rustc-flags=-L {}", src.parent().unwrap()
|
println!("cargo:rustc-flags=-L {}/deps", src.parent().unwrap()
|
||||||
.display());
|
.display());
|
||||||
}
|
}
|
||||||
"#)
|
"#)
|
||||||
|
|
|
@ -31,9 +31,8 @@ fn profile_overrides() {
|
||||||
-C opt-level=1 \
|
-C opt-level=1 \
|
||||||
-C debug-assertions=on \
|
-C debug-assertions=on \
|
||||||
-C rpath \
|
-C rpath \
|
||||||
--out-dir {dir}{sep}target{sep}debug \
|
--out-dir [..] \
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
-L dependency={dir}{sep}target{sep}debug \
|
|
||||||
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
||||||
[FINISHED] debug [optimized] target(s) in [..]
|
[FINISHED] debug [optimized] target(s) in [..]
|
||||||
", sep = SEP,
|
", sep = SEP,
|
||||||
|
@ -84,23 +83,19 @@ fn top_level_overrides_deps() {
|
||||||
--crate-type dylib --crate-type rlib -C prefer-dynamic \
|
--crate-type dylib --crate-type rlib -C prefer-dynamic \
|
||||||
-C opt-level=1 \
|
-C opt-level=1 \
|
||||||
-g \
|
-g \
|
||||||
-C metadata=[..] \
|
|
||||||
-C extra-filename=-[..] \
|
|
||||||
--out-dir {dir}{sep}target{sep}release{sep}deps \
|
--out-dir {dir}{sep}target{sep}release{sep}deps \
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
-L dependency={dir}{sep}target{sep}release{sep}deps \
|
|
||||||
-L dependency={dir}{sep}target{sep}release{sep}deps`
|
-L dependency={dir}{sep}target{sep}release{sep}deps`
|
||||||
[COMPILING] test v0.0.0 ({url})
|
[COMPILING] test v0.0.0 ({url})
|
||||||
[RUNNING] `rustc src{sep}lib.rs --crate-name test --crate-type lib \
|
[RUNNING] `rustc src{sep}lib.rs --crate-name test --crate-type lib \
|
||||||
-C opt-level=1 \
|
-C opt-level=1 \
|
||||||
-g \
|
-g \
|
||||||
--out-dir {dir}{sep}target{sep}release \
|
--out-dir [..] \
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
-L dependency={dir}{sep}target{sep}release \
|
|
||||||
-L dependency={dir}{sep}target{sep}release{sep}deps \
|
-L dependency={dir}{sep}target{sep}release{sep}deps \
|
||||||
--extern foo={dir}{sep}target{sep}release{sep}deps{sep}\
|
--extern foo={dir}{sep}target{sep}release{sep}deps{sep}\
|
||||||
{prefix}foo-[..]{suffix} \
|
{prefix}foo[..]{suffix} \
|
||||||
--extern foo={dir}{sep}target{sep}release{sep}deps{sep}libfoo-[..].rlib`
|
--extern foo={dir}{sep}target{sep}release{sep}deps{sep}libfoo.rlib`
|
||||||
[FINISHED] release [optimized + debuginfo] target(s) in [..]
|
[FINISHED] release [optimized + debuginfo] target(s) in [..]
|
||||||
",
|
",
|
||||||
dir = p.root().display(),
|
dir = p.root().display(),
|
||||||
|
|
12
tests/run.rs
12
tests/run.rs
|
@ -411,20 +411,16 @@ fn example_with_release_flag() {
|
||||||
[COMPILING] bar v0.0.1 ({url}/bar)
|
[COMPILING] bar v0.0.1 ({url}/bar)
|
||||||
[RUNNING] `rustc bar{sep}src{sep}bar.rs --crate-name bar --crate-type lib \
|
[RUNNING] `rustc bar{sep}src{sep}bar.rs --crate-name bar --crate-type lib \
|
||||||
-C opt-level=3 \
|
-C opt-level=3 \
|
||||||
-C metadata=[..] \
|
|
||||||
-C extra-filename=[..] \
|
|
||||||
--out-dir {dir}{sep}target{sep}release{sep}deps \
|
--out-dir {dir}{sep}target{sep}release{sep}deps \
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
-L dependency={dir}{sep}target{sep}release{sep}deps \
|
|
||||||
-L dependency={dir}{sep}target{sep}release{sep}deps`
|
-L dependency={dir}{sep}target{sep}release{sep}deps`
|
||||||
[COMPILING] foo v0.0.1 ({url})
|
[COMPILING] foo v0.0.1 ({url})
|
||||||
[RUNNING] `rustc examples{sep}a.rs --crate-name a --crate-type bin \
|
[RUNNING] `rustc examples{sep}a.rs --crate-name a --crate-type bin \
|
||||||
-C opt-level=3 \
|
-C opt-level=3 \
|
||||||
--out-dir {dir}{sep}target{sep}release{sep}examples \
|
--out-dir {dir}{sep}target{sep}release{sep}examples \
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
-L dependency={dir}{sep}target{sep}release \
|
|
||||||
-L dependency={dir}{sep}target{sep}release{sep}deps \
|
-L dependency={dir}{sep}target{sep}release{sep}deps \
|
||||||
--extern bar={dir}{sep}target{sep}release{sep}deps{sep}libbar-[..].rlib`
|
--extern bar={dir}{sep}target{sep}release{sep}deps{sep}libbar.rlib`
|
||||||
[FINISHED] release [optimized] target(s) in [..]
|
[FINISHED] release [optimized] target(s) in [..]
|
||||||
[RUNNING] `target{sep}release{sep}examples{sep}a[..]`
|
[RUNNING] `target{sep}release{sep}examples{sep}a[..]`
|
||||||
",
|
",
|
||||||
|
@ -441,20 +437,16 @@ fast2"));
|
||||||
[COMPILING] bar v0.0.1 ({url}/bar)
|
[COMPILING] bar v0.0.1 ({url}/bar)
|
||||||
[RUNNING] `rustc bar{sep}src{sep}bar.rs --crate-name bar --crate-type lib \
|
[RUNNING] `rustc bar{sep}src{sep}bar.rs --crate-name bar --crate-type lib \
|
||||||
-g \
|
-g \
|
||||||
-C metadata=[..] \
|
|
||||||
-C extra-filename=[..] \
|
|
||||||
--out-dir {dir}{sep}target{sep}debug{sep}deps \
|
--out-dir {dir}{sep}target{sep}debug{sep}deps \
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
-L dependency={dir}{sep}target{sep}debug{sep}deps \
|
|
||||||
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
||||||
[COMPILING] foo v0.0.1 ({url})
|
[COMPILING] foo v0.0.1 ({url})
|
||||||
[RUNNING] `rustc examples{sep}a.rs --crate-name a --crate-type bin \
|
[RUNNING] `rustc examples{sep}a.rs --crate-name a --crate-type bin \
|
||||||
-g \
|
-g \
|
||||||
--out-dir {dir}{sep}target{sep}debug{sep}examples \
|
--out-dir {dir}{sep}target{sep}debug{sep}examples \
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
-L dependency={dir}{sep}target{sep}debug \
|
|
||||||
-L dependency={dir}{sep}target{sep}debug{sep}deps \
|
-L dependency={dir}{sep}target{sep}debug{sep}deps \
|
||||||
--extern bar={dir}{sep}target{sep}debug{sep}deps{sep}libbar-[..].rlib`
|
--extern bar={dir}{sep}target{sep}debug{sep}deps{sep}libbar.rlib`
|
||||||
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
||||||
[RUNNING] `target{sep}debug{sep}examples{sep}a[..]`
|
[RUNNING] `target{sep}debug{sep}examples{sep}a[..]`
|
||||||
",
|
",
|
||||||
|
|
|
@ -30,9 +30,8 @@ fn build_lib_for_foo() {
|
||||||
.with_stderr(format!("\
|
.with_stderr(format!("\
|
||||||
[COMPILING] foo v0.0.1 ({url})
|
[COMPILING] foo v0.0.1 ({url})
|
||||||
[RUNNING] `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \
|
[RUNNING] `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \
|
||||||
--out-dir {dir}{sep}target{sep}debug \
|
--out-dir [..] \
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
-L dependency={dir}{sep}target{sep}debug \
|
|
||||||
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
||||||
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
||||||
", sep = SEP,
|
", sep = SEP,
|
||||||
|
@ -61,9 +60,8 @@ fn lib() {
|
||||||
[COMPILING] foo v0.0.1 ({url})
|
[COMPILING] foo v0.0.1 ({url})
|
||||||
[RUNNING] `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \
|
[RUNNING] `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \
|
||||||
-C debug-assertions=off \
|
-C debug-assertions=off \
|
||||||
--out-dir {dir}{sep}target{sep}debug \
|
--out-dir [..] \
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
-L dependency={dir}{sep}target{sep}debug \
|
|
||||||
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
||||||
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
||||||
", sep = SEP,
|
", sep = SEP,
|
||||||
|
@ -91,17 +89,15 @@ fn build_main_and_allow_unstable_options() {
|
||||||
.with_stderr(&format!("\
|
.with_stderr(&format!("\
|
||||||
[COMPILING] {name} v{version} ({url})
|
[COMPILING] {name} v{version} ({url})
|
||||||
[RUNNING] `rustc src{sep}lib.rs --crate-name {name} --crate-type lib -g \
|
[RUNNING] `rustc src{sep}lib.rs --crate-name {name} --crate-type lib -g \
|
||||||
--out-dir {dir}{sep}target{sep}debug \
|
--out-dir [..] \
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
-L dependency={dir}{sep}target{sep}debug \
|
|
||||||
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
||||||
[RUNNING] `rustc src{sep}main.rs --crate-name {name} --crate-type bin -g \
|
[RUNNING] `rustc src{sep}main.rs --crate-name {name} --crate-type bin -g \
|
||||||
-C debug-assertions \
|
-C debug-assertions \
|
||||||
--out-dir {dir}{sep}target{sep}debug \
|
--out-dir [..] \
|
||||||
--emit=dep-info,link \
|
--emit=dep-info,link \
|
||||||
-L dependency={dir}{sep}target{sep}debug \
|
|
||||||
-L dependency={dir}{sep}target{sep}debug{sep}deps \
|
-L dependency={dir}{sep}target{sep}debug{sep}deps \
|
||||||
--extern {name}={dir}{sep}target{sep}debug{sep}lib{name}.rlib`
|
--extern {name}={dir}{sep}target[..]lib{name}.rlib`
|
||||||
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
||||||
", sep = SEP,
|
", sep = SEP,
|
||||||
dir = p.root().display(), url = p.url(),
|
dir = p.root().display(), url = p.url(),
|
||||||
|
@ -156,12 +152,11 @@ fn build_with_args_to_one_of_multiple_binaries() {
|
||||||
.with_stderr(format!("\
|
.with_stderr(format!("\
|
||||||
[COMPILING] foo v0.0.1 ({url})
|
[COMPILING] foo v0.0.1 ({url})
|
||||||
[RUNNING] `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \
|
[RUNNING] `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \
|
||||||
--out-dir {dir}{sep}target{sep}debug [..]`
|
--out-dir [..]`
|
||||||
[RUNNING] `rustc src{sep}bin{sep}bar.rs --crate-name bar --crate-type bin -g \
|
[RUNNING] `rustc src{sep}bin{sep}bar.rs --crate-name bar --crate-type bin -g \
|
||||||
-C debug-assertions [..]`
|
-C debug-assertions [..]`
|
||||||
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
||||||
", sep = SEP,
|
", sep = SEP, url = p.url())));
|
||||||
dir = p.root().display(), url = p.url())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -212,12 +207,11 @@ fn build_with_args_to_one_of_multiple_tests() {
|
||||||
.with_stderr(format!("\
|
.with_stderr(format!("\
|
||||||
[COMPILING] foo v0.0.1 ({url})
|
[COMPILING] foo v0.0.1 ({url})
|
||||||
[RUNNING] `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \
|
[RUNNING] `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \
|
||||||
--out-dir {dir}{sep}target{sep}debug [..]`
|
--out-dir [..]`
|
||||||
[RUNNING] `rustc tests{sep}bar.rs --crate-name bar -g \
|
[RUNNING] `rustc tests{sep}bar.rs --crate-name bar -g \
|
||||||
-C debug-assertions [..]--test[..]`
|
-C debug-assertions [..]--test[..]`
|
||||||
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
||||||
", sep = SEP,
|
", sep = SEP, url = p.url())));
|
||||||
dir = p.root().display(), url = p.url())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -255,7 +249,7 @@ fn build_foo_with_bar_dependency() {
|
||||||
.with_status(0)
|
.with_status(0)
|
||||||
.with_stderr(format!("\
|
.with_stderr(format!("\
|
||||||
[COMPILING] bar v0.1.0 ([..])
|
[COMPILING] bar v0.1.0 ([..])
|
||||||
[RUNNING] `[..] -g -C [..]`
|
[RUNNING] `[..] -g [..]`
|
||||||
[COMPILING] foo v0.0.1 ({url})
|
[COMPILING] foo v0.0.1 ({url})
|
||||||
[RUNNING] `[..] -g -C debug-assertions [..]`
|
[RUNNING] `[..] -g -C debug-assertions [..]`
|
||||||
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
||||||
|
|
|
@ -24,7 +24,6 @@ fn rustdoc_simple() {
|
||||||
[DOCUMENTING] foo v0.0.1 ({url})
|
[DOCUMENTING] foo v0.0.1 ({url})
|
||||||
[RUNNING] `rustdoc src{sep}lib.rs --crate-name foo \
|
[RUNNING] `rustdoc src{sep}lib.rs --crate-name foo \
|
||||||
-o {dir}{sep}target{sep}doc \
|
-o {dir}{sep}target{sep}doc \
|
||||||
-L dependency={dir}{sep}target{sep}debug \
|
|
||||||
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
||||||
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
||||||
", sep = SEP,
|
", sep = SEP,
|
||||||
|
@ -50,7 +49,6 @@ fn rustdoc_args() {
|
||||||
[RUNNING] `rustdoc src{sep}lib.rs --crate-name foo \
|
[RUNNING] `rustdoc src{sep}lib.rs --crate-name foo \
|
||||||
-o {dir}{sep}target{sep}doc \
|
-o {dir}{sep}target{sep}doc \
|
||||||
--no-defaults \
|
--no-defaults \
|
||||||
-L dependency={dir}{sep}target{sep}debug \
|
|
||||||
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
||||||
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
||||||
", sep = SEP,
|
", sep = SEP,
|
||||||
|
@ -97,7 +95,6 @@ fn rustdoc_foo_with_bar_dependency() {
|
||||||
[RUNNING] `rustdoc src{sep}lib.rs --crate-name foo \
|
[RUNNING] `rustdoc src{sep}lib.rs --crate-name foo \
|
||||||
-o {dir}{sep}target{sep}doc \
|
-o {dir}{sep}target{sep}doc \
|
||||||
--no-defaults \
|
--no-defaults \
|
||||||
-L dependency={dir}{sep}target{sep}debug \
|
|
||||||
-L dependency={dir}{sep}target{sep}debug{sep}deps \
|
-L dependency={dir}{sep}target{sep}debug{sep}deps \
|
||||||
--extern [..]`
|
--extern [..]`
|
||||||
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
||||||
|
@ -144,7 +141,6 @@ fn rustdoc_only_bar_dependency() {
|
||||||
[RUNNING] `rustdoc [..]bar{sep}src{sep}lib.rs --crate-name bar \
|
[RUNNING] `rustdoc [..]bar{sep}src{sep}lib.rs --crate-name bar \
|
||||||
-o {dir}{sep}target{sep}doc \
|
-o {dir}{sep}target{sep}doc \
|
||||||
--no-defaults \
|
--no-defaults \
|
||||||
-L dependency={dir}{sep}target{sep}debug{sep}deps \
|
|
||||||
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
||||||
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
||||||
", sep = SEP,
|
", sep = SEP,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
extern crate cargotest;
|
extern crate cargotest;
|
||||||
extern crate hamcrest;
|
extern crate hamcrest;
|
||||||
|
|
||||||
use std::io::Read;
|
use std::io::{Read, Write};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|
||||||
use cargotest::support::{project, execs};
|
use cargotest::support::{project, execs};
|
||||||
|
@ -827,3 +827,49 @@ fn lock_doesnt_change_depending_on_crate() {
|
||||||
|
|
||||||
assert_eq!(lockfile, lockfile2);
|
assert_eq!(lockfile, lockfile2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn rebuild_please() {
|
||||||
|
let p = project("foo")
|
||||||
|
.file("Cargo.toml", r#"
|
||||||
|
[workspace]
|
||||||
|
members = ['lib', 'bin']
|
||||||
|
"#)
|
||||||
|
.file("lib/Cargo.toml", r#"
|
||||||
|
[package]
|
||||||
|
name = "lib"
|
||||||
|
version = "0.1.0"
|
||||||
|
"#)
|
||||||
|
.file("lib/src/lib.rs", r#"
|
||||||
|
pub fn foo() -> u32 { 0 }
|
||||||
|
"#)
|
||||||
|
.file("bin/Cargo.toml", r#"
|
||||||
|
[package]
|
||||||
|
name = "bin"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
lib = { path = "../lib" }
|
||||||
|
"#)
|
||||||
|
.file("bin/src/main.rs", r#"
|
||||||
|
extern crate lib;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
assert_eq!(lib::foo(), 0);
|
||||||
|
}
|
||||||
|
"#);
|
||||||
|
p.build();
|
||||||
|
|
||||||
|
assert_that(p.cargo("run").cwd(p.root().join("bin")),
|
||||||
|
execs().with_status(0));
|
||||||
|
|
||||||
|
t!(t!(File::create(p.root().join("lib/src/lib.rs"))).write_all(br#"
|
||||||
|
pub fn foo() -> u32 { 1 }
|
||||||
|
"#));
|
||||||
|
|
||||||
|
assert_that(p.cargo("build").cwd(p.root().join("lib")),
|
||||||
|
execs().with_status(0));
|
||||||
|
|
||||||
|
assert_that(p.cargo("run").cwd(p.root().join("bin")),
|
||||||
|
execs().with_status(101));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue