Remove infrastructure for the old custom build command

This aspect of the manifest has been deprecated for quite some time now, and
this commit purges the support entirely.
This commit is contained in:
Alex Crichton 2015-01-19 14:27:51 -08:00
parent 73b904c05e
commit 0fdaf507a1
14 changed files with 58 additions and 644 deletions

View file

@ -15,7 +15,6 @@ pub struct Manifest {
targets: Vec<Target>,
target_dir: Path,
doc_dir: Path,
build: Vec<String>, // TODO: deprecated, remove
links: Option<String>,
warnings: Vec<String>,
exclude: Vec<String>,
@ -52,7 +51,6 @@ pub struct SerializedManifest {
targets: Vec<Target>,
target_dir: String,
doc_dir: String,
build: Option<Vec<String>>, // TODO: deprecated, remove
}
impl Encodable for Manifest {
@ -66,8 +64,6 @@ impl Encodable for Manifest {
targets: self.targets.clone(),
target_dir: self.target_dir.display().to_string(),
doc_dir: self.doc_dir.display().to_string(),
// TODO: deprecated, remove
build: if self.build.len() == 0 { None } else { Some(self.build.clone()) },
}.encode(s)
}
}
@ -388,7 +384,6 @@ impl Encodable for Target {
impl Manifest {
pub fn new(summary: Summary, targets: Vec<Target>,
target_dir: Path, doc_dir: Path,
build: Vec<String>,
exclude: Vec<String>,
include: Vec<String>,
links: Option<String>,
@ -398,7 +393,6 @@ impl Manifest {
targets: targets,
target_dir: target_dir,
doc_dir: doc_dir,
build: build, // TODO: deprecated, remove
warnings: Vec::new(),
exclude: exclude,
include: include,
@ -439,10 +433,6 @@ impl Manifest {
&self.doc_dir
}
pub fn get_build(&self) -> &[String] {
self.build.as_slice()
}
pub fn get_links(&self) -> Option<&str> {
self.links.as_ref().map(|s| s.as_slice())
}

View file

@ -179,7 +179,7 @@ pub fn prepare(pkg: &Package, target: &Target, req: Platform,
//
// Also note that a fresh build command needs to
let (freshness, dirty, fresh) =
try!(fingerprint::prepare_build_cmd(cx, pkg, Some(target)));
try!(fingerprint::prepare_build_cmd(cx, pkg, kind, Some(target)));
let dirty = Work::new(move |tx| {
try!(work(tx.clone()));
dirty.call(tx)

View file

@ -124,17 +124,14 @@ pub fn prepare_target(cx: &mut Context, pkg: &Package, target: &Target,
///
/// The currently implemented solution is option (1), although it is planned to
/// migrate to option (2) in the near future.
pub fn prepare_build_cmd(cx: &mut Context, pkg: &Package,
pub fn prepare_build_cmd(cx: &mut Context, pkg: &Package, kind: Kind,
target: Option<&Target>) -> CargoResult<Preparation> {
let _p = profile::start(format!("fingerprint build cmd: {}",
pkg.get_package_id()));
// TODO: this should not explicitly pass Kind::Target
let kind = Kind::Target;
if pkg.get_manifest().get_build().len() == 0 && target.is_none() {
if target.is_none() {
return Ok((Fresh, Work::noop(), Work::noop()));
}
let _p = profile::start(format!("fingerprint build cmd: {}",
pkg.get_package_id()));
let new = dir(cx, pkg, kind);
let loc = new.join("build");
cx.layout(pkg, kind).proxy().whitelist(&loc);

View file

@ -1,14 +1,12 @@
use std::collections::{HashSet, HashMap};
use std::dynamic_lib::DynamicLibrary;
use std::ffi::CString;
use std::io::USER_RWX;
use std::io::fs::{self, PathExtensions};
use std::path;
use std::sync::Arc;
use core::{SourceMap, Package, PackageId, PackageSet, Target, Resolve};
use util::{self, CargoResult, human, caused_human};
use util::{Config, internal, ChainError, Fresh, profile, join_paths, Human};
use util::{Config, internal, ChainError, Fresh, profile, join_paths};
use self::job::{Job, Work};
use self::job_queue::{JobQueue, Stage};
@ -320,39 +318,8 @@ fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package,
}
}
if targets.iter().any(|t| t.get_profile().is_custom_build()) {
// New custom build system
jobs.enqueue(pkg, Stage::BuildCustomBuild, build_custom);
jobs.enqueue(pkg, Stage::RunCustomBuild, run_custom);
} else {
// Old custom build system
// OLD-BUILD: to-remove
let mut build_cmds = Vec::new();
for (i, build_cmd) in pkg.get_manifest().get_build().iter().enumerate() {
let work = try!(compile_custom_old(pkg, build_cmd.as_slice(), cx, i == 0));
build_cmds.push(work);
}
let (freshness, dirty, fresh) =
try!(fingerprint::prepare_build_cmd(cx, pkg, None));
let desc = match build_cmds.len() {
0 => String::new(),
1 => pkg.get_manifest().get_build()[0].to_string(),
_ => format!("custom build commands"),
};
let dirty = Work::new(move |desc_tx| {
if desc.len() > 0 {
desc_tx.send(desc).ok();
}
for cmd in build_cmds.into_iter() {
try!(cmd.call(desc_tx.clone()))
}
dirty.call(desc_tx)
});
jobs.enqueue(pkg, Stage::BuildCustomBuild, vec![]);
jobs.enqueue(pkg, Stage::RunCustomBuild, vec![(job(dirty, fresh), freshness)]);
}
jobs.enqueue(pkg, Stage::BuildCustomBuild, build_custom);
jobs.enqueue(pkg, Stage::RunCustomBuild, run_custom);
jobs.enqueue(pkg, Stage::Libraries, libs);
jobs.enqueue(pkg, Stage::Binaries, bins);
jobs.enqueue(pkg, Stage::BinaryTests, bin_tests);
@ -360,81 +327,6 @@ fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package,
Ok(())
}
// OLD-BUILD: to-remove
fn compile_custom_old(pkg: &Package, cmd: &str,
cx: &Context, first: bool) -> CargoResult<Work> {
let root = cx.get_package(cx.resolve.root());
let profile = root.get_manifest().get_targets().iter()
.find(|target| target.get_profile().get_env() == cx.env())
.map(|target| target.get_profile());
let profile = match profile {
Some(profile) => profile,
None => return Err(internal(format!("no profile for {}", cx.env())))
};
// Just need a target which isn't a custom build command
let target = &pkg.get_targets()[0];
assert!(!target.get_profile().is_custom_build());
// TODO: this needs to be smarter about splitting
let mut cmd = cmd.split(' ');
// TODO: this shouldn't explicitly pass `Kind::Target` for dest/deps_dir, we
// may be building a C lib for a plugin
let layout = cx.layout(pkg, Kind::Target);
let output = layout.native(pkg);
let exe = CString::from_slice(cmd.next().unwrap().as_bytes());
let mut p = try!(process(CommandType::Host(exe), pkg, target, cx))
.env("OUT_DIR", Some(&output))
.env("DEPS_DIR", Some(&output))
.env("TARGET", Some(cx.target_triple()))
.env("DEBUG", Some(profile.get_debug().to_string()))
.env("OPT_LEVEL", Some(profile.get_opt_level().to_string()))
.env("LTO", Some(profile.get_lto().to_string()))
.env("PROFILE", Some(profile.get_env()));
for arg in cmd {
p = p.arg(arg);
}
match cx.resolve.features(pkg.get_package_id()) {
Some(features) => {
for feat in features.iter() {
p = p.env(format!("CARGO_FEATURE_{}",
envify(feat.as_slice())).as_slice(),
Some("1"));
}
}
None => {}
}
for &(pkg, _) in cx.dep_targets(pkg, target).iter() {
let name: String = pkg.get_name().chars().map(|c| {
match c {
'-' => '_',
c => c.to_uppercase(),
}
}).collect();
p = p.env(format!("DEP_{}_OUT_DIR", name).as_slice(),
Some(&layout.native(pkg)));
}
let pkg = pkg.to_string();
let exec_engine = cx.exec_engine.clone();
Ok(Work::new(move |desc_tx| {
desc_tx.send(p.to_string()).ok();
if first && !output.exists() {
try!(fs::mkdir(&output, USER_RWX).chain_error(|| {
internal("failed to create output directory for build command")
}))
}
try!(exec_engine.exec_with_output(p).map(|_| ()).map_err(|mut e| {
e.desc = format!("Failed to run custom build command for `{}`\n{}",
pkg, e.desc);
Human(e)
}));
Ok(())
}))
}
fn rustc(package: &Package, target: &Target,
cx: &mut Context, req: Platform)
-> CargoResult<Vec<(Work, Kind)> >{
@ -766,19 +658,6 @@ fn build_deps_args(mut cmd: CommandPrototype, target: &Target, package: &Package
None
});
// Traverse the entire dependency graph looking for -L paths to pass for
// native dependencies.
// OLD-BUILD: to-remove
let mut dirs = Vec::new();
each_dep(package, cx, |pkg| {
if pkg.get_manifest().get_build().len() > 0 {
dirs.push(layout.native(pkg));
}
});
for dir in dirs.into_iter() {
cmd = cmd.arg("-L").arg(format!("native={}", dir.display()));
}
for &(pkg, target) in cx.dep_targets(package, target).iter() {
cmd = try!(link_to(cmd, pkg, target, cx, kind));
}
@ -821,7 +700,7 @@ fn build_deps_args(mut cmd: CommandPrototype, target: &Target, package: &Package
}
}
pub fn process(cmd: CommandType, pkg: &Package, target: &Target,
pub fn process(cmd: CommandType, pkg: &Package, _target: &Target,
cx: &Context) -> CargoResult<CommandPrototype> {
// When invoking a tool, we need the *host* deps directory in the dynamic
// library search path for plugins and such which have dynamic dependencies.
@ -829,20 +708,6 @@ pub fn process(cmd: CommandType, pkg: &Package, target: &Target,
let mut search_path = DynamicLibrary::search_path();
search_path.push(layout.deps().clone());
// OLD-BUILD: to-remove
// Also be sure to pick up any native build directories required by plugins
// or their dependencies
let mut native_search_paths = HashSet::new();
for &(dep, target) in cx.dep_targets(pkg, target).iter() {
if !target.get_profile().is_for_host() { continue }
each_dep(dep, cx, |dep| {
if dep.get_manifest().get_build().len() > 0 {
native_search_paths.insert(layout.native(dep));
}
});
}
search_path.extend(native_search_paths.into_iter());
// 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.
let search_path = try!(join_paths(search_path.as_slice(),

View file

@ -253,7 +253,7 @@ pub struct TomlProject {
name: String,
version: TomlVersion,
authors: Vec<String>,
build: Option<BuildCommand>, // TODO: `String` instead
build: Option<String>,
links: Option<String>,
exclude: Option<Vec<String>>,
include: Option<Vec<String>>,
@ -269,13 +269,6 @@ pub struct TomlProject {
repository: Option<String>,
}
// TODO: deprecated, remove
#[derive(RustcDecodable)]
pub enum BuildCommand {
Single(String),
Multiple(Vec<String>)
}
pub struct TomlVersion {
version: semver::Version,
}
@ -449,17 +442,7 @@ impl TomlManifest {
};
// processing the custom build script
let (new_build, old_build) = match project.build {
Some(BuildCommand::Single(ref cmd)) => {
if cmd.as_slice().ends_with(".rs") && layout.root.join(cmd.as_slice()).exists() {
(Some(Path::new(cmd.as_slice())), Vec::new())
} else {
(None, vec!(cmd.clone()))
}
},
Some(BuildCommand::Multiple(ref cmd)) => (None, cmd.clone()),
None => (None, Vec::new())
};
let new_build = project.build.clone().map(Path::new);
// Get targets
let profiles = self.profile.clone().unwrap_or(Default::default());
@ -509,8 +492,6 @@ impl TomlManifest {
let exclude = project.exclude.clone().unwrap_or(Vec::new());
let include = project.include.clone().unwrap_or(Vec::new());
let has_old_build = old_build.len() >= 1;
let summary = try!(Summary::new(pkgid, deps,
self.features.clone()
.unwrap_or(HashMap::new())));
@ -529,7 +510,6 @@ impl TomlManifest {
targets,
layout.root.join("target"),
layout.root.join("doc"),
old_build,
exclude,
include,
project.links.clone(),
@ -538,14 +518,6 @@ impl TomlManifest {
manifest.add_warning(format!("the [[lib]] section has been \
deprecated in favor of [lib]"));
}
if has_old_build {
manifest.add_warning(format!("warning: an arbitrary build command \
has now been deprecated."));
manifest.add_warning(format!(" It has been replaced by custom \
build scripts."));
manifest.add_warning(format!(" For more information, see \
http://doc.crates.io/build-script.html"));
}
if project.license_file.is_some() && project.license.is_some() {
manifest.add_warning(format!("warning: only one of `license` or \
`license-file` is necessary"));

View file

@ -750,8 +750,9 @@ test!(bench_twice_with_build_cmd {
name = "foo"
version = "0.0.1"
authors = []
build = 'true'
build = "build.rs"
"#)
.file("build.rs", "fn main() {}")
.file("src/lib.rs", "
extern crate test;
#[bench]

View file

@ -1252,9 +1252,10 @@ test!(freshness_ignores_excluded {
name = "foo"
version = "0.0.0"
authors = []
build = "true"
build = "build.rs"
exclude = ["src/b*.rs"]
"#)
.file("build.rs", "fn main() {}")
.file("src/lib.rs", "pub fn bar() -> int { 1 }");
foo.build();
foo.root().move_into_the_past().unwrap();
@ -1280,37 +1281,27 @@ test!(freshness_ignores_excluded {
});
test!(rebuild_preserves_out_dir {
let mut build = project("builder");
build = build
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
name = "builder"
version = "0.5.0"
authors = ["wycats@example.com"]
name = "foo"
version = "0.0.0"
authors = []
build = 'build.rs'
"#)
.file("src/main.rs", r#"
.file("build.rs", r#"
use std::os;
use std::io::File;
fn main() {{
fn main() {
let path = Path::new(os::getenv("OUT_DIR").unwrap()).join("foo");
if os::getenv("FIRST").is_some() {
File::create(&path).unwrap();
} else {
File::create(&path).unwrap();
}
}}
"#);
assert_that(build.cargo_process("build"), execs().with_status(0));
let foo = project("foo")
.file("Cargo.toml", format!(r#"
[package]
name = "foo"
version = "0.0.0"
authors = []
build = '{}'
"#, build.bin("builder").display()).as_slice())
}
"#)
.file("src/lib.rs", "pub fn bar() -> int { 1 }");
foo.build();
foo.root().move_into_the_past().unwrap();

View file

@ -1087,8 +1087,9 @@ test!(git_build_cmd_freshness {
name = "foo"
version = "0.0.0"
authors = []
build = "true"
build = "build.rs"
"#)
.file("build.rs", "fn main() {}")
.file("src/lib.rs", "pub fn bar() -> int { 1 }")
.file(".gitignore", "
src/bar.rs
@ -1175,11 +1176,12 @@ test!(git_repo_changing_no_rebuild {
name = "p1"
version = "0.5.0"
authors = []
build = 'true'
build = 'build.rs'
[dependencies.bar]
git = '{}'
"#, bar.url()).as_slice())
.file("src/main.rs", "fn main() {}");
.file("src/main.rs", "fn main() {}")
.file("build.rs", "fn main() {}");
p1.build();
p1.root().move_into_the_past().unwrap();
assert_that(p1.process(cargo_dir().join("cargo")).arg("build"),
@ -1247,7 +1249,7 @@ test!(git_dep_build_cmd {
name = "bar"
version = "0.5.0"
authors = ["wycats@example.com"]
build = "cp src/bar.rs.in src/bar.rs"
build = "build.rs"
[lib]
@ -1256,6 +1258,13 @@ test!(git_dep_build_cmd {
.file("bar/src/bar.rs.in", r#"
pub fn gimme() -> int { 0 }
"#)
.file("bar/build.rs", r#"
use std::io::fs;
fn main() {
fs::copy(&Path::new("src/bar.rs.in"),
&Path::new("src/bar.rs")).unwrap();
}
"#)
}).unwrap();
p.root().join("bar").move_into_the_past().unwrap();

View file

@ -1,408 +0,0 @@
use std::path;
use support::{project, execs, cargo_dir};
use hamcrest::{assert_that};
fn setup() {
}
test!(old_custom_build {
let mut build = project("builder");
build = build
.file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.5.0"
authors = ["wycats@example.com"]
[[bin]] name = "foo"
"#)
.file("src/foo.rs", r#"
fn main() { println!("Hello!"); }
"#);
assert_that(build.cargo_process("build"),
execs().with_status(0));
let mut p = project("foo");
p = p
.file("Cargo.toml", format!(r#"
[project]
name = "foo"
version = "0.5.0"
authors = ["wycats@example.com"]
build = '{}'
[[bin]] name = "foo"
"#, build.bin("foo").display()))
.file("src/foo.rs", r#"
fn main() {}
"#);
assert_that(p.cargo_process("build"),
execs().with_status(0)
.with_stdout(format!(" Compiling foo v0.5.0 ({})\n",
p.url()))
.with_stderr("warning: [..] deprecated.\n\
[..]\n\
[..]"));
});
test!(old_custom_multiple_build {
let mut build1 = project("builder1");
build1 = build1
.file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.5.0"
authors = ["wycats@example.com"]
[[bin]] name = "foo"
"#)
.file("src/foo.rs", r#"
fn main() {
let args = ::std::os::args();
assert_eq!(args[1], "hello".to_string());
assert_eq!(args[2], "world".to_string());
}
"#);
assert_that(build1.cargo_process("build"),
execs().with_status(0));
let mut build2 = project("builder2");
build2 = build2
.file("Cargo.toml", r#"
[project]
name = "bar"
version = "0.5.0"
authors = ["wycats@example.com"]
[[bin]] name = "bar"
"#)
.file("src/bar.rs", r#"
fn main() {
let args = ::std::os::args();
assert_eq!(args[1], "cargo".to_string());
}
"#);
assert_that(build2.cargo_process("build"),
execs().with_status(0));
let mut p = project("foo");
p = p
.file("Cargo.toml", format!(r#"
[project]
name = "foo"
version = "0.5.0"
authors = ["wycats@example.com"]
build = [ '{} hello world', '{} cargo' ]
[[bin]] name = "foo"
"#, build1.bin("foo").display(), build2.bin("bar").display()))
.file("src/foo.rs", r#"
fn main() {}
"#);
assert_that(p.cargo_process("build"),
execs().with_status(0)
.with_stdout(format!(" Compiling foo v0.5.0 ({})\n",
p.url())));
});
test!(old_custom_build_failure {
let mut build = project("builder");
build = build
.file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.5.0"
authors = ["wycats@example.com"]
[[bin]]
name = "foo"
"#)
.file("src/foo.rs", r#"
fn main() { panic!("nope") }
"#);
assert_that(build.cargo_process("build"), execs().with_status(0));
let mut p = project("foo");
p = p
.file("Cargo.toml", format!(r#"
[project]
name = "foo"
version = "0.5.0"
authors = ["wycats@example.com"]
build = '{}'
[[bin]]
name = "foo"
"#, build.bin("foo").display()))
.file("src/foo.rs", r#"
fn main() {}
"#);
assert_that(p.cargo_process("build"),
execs().with_status(101).with_stderr(format!("\
warning: an arbitrary build command has now been deprecated.
[..]
[..]
Failed to run custom build command for `foo v0.5.0 ({dir})`
Process didn't exit successfully: `{}` (status=101)\n\
--- stderr\n\
thread '<main>' panicked at 'nope', {filename}:2\n\
\n\
", build.bin("foo").display(), filename = format!("src{}foo.rs", path::SEP),
dir = p.url())));
});
test!(old_custom_second_build_failure {
let mut build1 = project("builder1");
build1 = build1
.file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.5.0"
authors = ["wycats@example.com"]
[[bin]] name = "foo"
"#)
.file("src/foo.rs", r#"
fn main() { println!("Hello!"); }
"#);
assert_that(build1.cargo_process("build"),
execs().with_status(0));
let mut build2 = project("builder2");
build2 = build2
.file("Cargo.toml", r#"
[project]
name = "bar"
version = "0.5.0"
authors = ["wycats@example.com"]
[[bin]]
name = "bar"
"#)
.file("src/bar.rs", r#"
fn main() { panic!("nope") }
"#);
assert_that(build2.cargo_process("build"), execs().with_status(0));
let mut p = project("foo");
p = p
.file("Cargo.toml", format!(r#"
[project]
name = "foo"
version = "0.5.0"
authors = ["wycats@example.com"]
build = [ '{}', '{}' ]
[[bin]]
name = "foo"
"#, build1.bin("foo").display(), build2.bin("bar").display()))
.file("src/foo.rs", r#"
fn main() {}
"#);
assert_that(p.cargo_process("build"),
execs().with_status(101).with_stderr(format!("\
warning: an arbitrary build command has now been deprecated.
[..]
[..]
Failed to run custom build command for `foo v0.5.0 ({dir})`
Process didn't exit successfully: `{}` (status=101)\n\
--- stderr\n\
thread '<main>' panicked at 'nope', {filename}:2\n\
\n\
", build2.bin("bar").display(), filename = format!("src{}bar.rs", path::SEP),
dir = p.url())));
});
test!(old_custom_build_env_vars {
let bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar-bar"
version = "0.0.1"
authors = []
build = "true"
"#)
.file("src/lib.rs", "");
bar.build();
let mut p = project("foo");
let mut build = project("builder");
build = build
.file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.5.0"
authors = ["wycats@example.com"]
[features]
foo = []
[[bin]]
name = "foo"
"#)
.file("src/foo.rs", format!(r#"
use std::os;
use std::io::fs::PathExtensions;
fn main() {{
let _ncpus = os::getenv("NUM_JOBS").unwrap();
let _feat = os::getenv("CARGO_FEATURE_FOO").unwrap();
let debug = os::getenv("DEBUG").unwrap();
assert_eq!(debug.as_slice(), "true");
let opt = os::getenv("OPT_LEVEL").unwrap();
assert_eq!(opt.as_slice(), "0");
let opt = os::getenv("PROFILE").unwrap();
assert_eq!(opt.as_slice(), "compile");
let out = os::getenv("OUT_DIR").unwrap();
assert!(out.as_slice().starts_with(r"{0}"));
assert!(Path::new(out).is_dir());
let out = os::getenv("DEP_BAR_BAR_OUT_DIR").unwrap();
assert!(out.as_slice().starts_with(r"{0}"));
assert!(Path::new(out).is_dir());
let out = os::getenv("CARGO_MANIFEST_DIR").unwrap();
let p1 = Path::new(out);
let p2 = os::make_absolute(&Path::new(file!()).dir_path().dir_path()).unwrap();
assert!(p1 == p2, "{{}} != {{}}", p1.display(), p2.display());
}}
"#,
p.root().join("target").join("native").display()));
assert_that(build.cargo_process("build").arg("--features").arg("foo"),
execs().with_status(0));
p = p
.file("Cargo.toml", format!(r#"
[project]
name = "foo"
version = "0.5.0"
authors = ["wycats@example.com"]
build = '{}'
[features]
foo = []
[[bin]]
name = "foo"
[dependencies.bar-bar]
path = '{}'
"#, build.bin("foo").display(), bar.root().display()))
.file("src/foo.rs", r#"
fn main() {}
"#);
assert_that(p.cargo_process("build").arg("--features").arg("foo"),
execs().with_status(0));
});
test!(old_custom_build_in_dependency {
let mut p = project("foo");
let mut build = project("builder");
build = build
.file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.5.0"
authors = ["wycats@example.com"]
[[bin]]
name = "foo"
"#)
.file("src/foo.rs", format!(r#"
use std::os;
fn main() {{
assert!(os::getenv("OUT_DIR").unwrap().as_slice()
.starts_with(r"{}"));
}}
"#,
p.root().join("target/native/bar-").display()));
assert_that(build.cargo_process("build"), execs().with_status(0));
p = p
.file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.5.0"
authors = ["wycats@example.com"]
[[bin]]
name = "foo"
[dependencies.bar]
path = "bar"
"#)
.file("src/foo.rs", r#"
extern crate bar;
fn main() { bar::bar() }
"#)
.file("bar/Cargo.toml", format!(r#"
[project]
name = "bar"
version = "0.5.0"
authors = ["wycats@example.com"]
build = '{}'
"#, build.bin("foo").display()))
.file("bar/src/lib.rs", r#"
pub fn bar() {}
"#);
assert_that(p.cargo_process("build"),
execs().with_status(0));
});
// tests that custom build in dep can be built twice in a row - issue 227
test!(old_custom_build_in_dependency_twice {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.5.0"
authors = ["wycats@example.com"]
[[bin]]
name = "foo"
[dependencies.bar]
path = "./bar"
"#)
.file("src/foo.rs", r#"
extern crate bar;
fn main() { bar::bar() }
"#)
.file("bar/Cargo.toml", format!(r#"
[project]
name = "bar"
version = "0.0.1"
authors = ["wycats@example.com"]
build = '{}'
"#, "echo test"))
.file("bar/src/lib.rs", r#"
pub fn bar() {}
"#);
assert_that(p.cargo_process("build"),
execs().with_status(0));
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
execs().with_status(0));
});

View file

@ -658,12 +658,19 @@ test!(path_dep_build_cmd {
name = "bar"
version = "0.5.0"
authors = ["wycats@example.com"]
build = "cp src/bar.rs.in src/bar.rs"
build = "build.rs"
[lib]
name = "bar"
"#)
.file("bar/build.rs", r#"
use std::io::fs;
fn main() {
fs::copy(&Path::new("src/bar.rs.in"),
&Path::new("src/bar.rs")).unwrap();
}
"#)
.file("bar/src/bar.rs.in", r#"
pub fn gimme() -> int { 0 }
"#);

View file

@ -34,30 +34,19 @@ fn alternate() -> &'static str {
test!(simple_cross {
if disabled() { return }
let mut build = project("builder");
build = build
.file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.5.0"
authors = ["wycats@example.com"]
"#)
.file("src/main.rs", format!(r#"
fn main() {{
assert_eq!(std::os::getenv("TARGET").unwrap().as_slice(), "{}");
}}
"#, alternate()).as_slice());
assert_that(build.cargo_process("build"),
execs().with_status(0));
let p = project("foo")
.file("Cargo.toml", format!(r#"
.file("Cargo.toml", r#"
[package]
name = "foo"
version = "0.0.0"
authors = []
build = '{}'
"#, build.bin("foo").display()))
build = "build.rs"
"#)
.file("build.rs", format!(r#"
fn main() {{
assert_eq!(std::os::getenv("TARGET").unwrap().as_slice(), "{}");
}}
"#, alternate()).as_slice())
.file("src/main.rs", r#"
use std::os;
fn main() {

View file

@ -12,8 +12,9 @@ test!(simple {
name = "foo"
version = "0.0.1"
authors = []
build = 'true'
build = "build.rs"
"#)
.file("build.rs", "fn main() {}")
.file("src/lib.rs", r#"
pub fn foo() {}
"#);

View file

@ -755,8 +755,9 @@ test!(test_twice_with_build_cmd {
name = "foo"
version = "0.0.1"
authors = []
build = 'true'
build = "build.rs"
"#)
.file("build.rs", "fn main() {}")
.file("src/lib.rs", "
#[test]
fn foo() {}

View file

@ -34,7 +34,6 @@ mod test_cargo_clean;
mod test_cargo_compile;
mod test_cargo_compile_custom_build;
mod test_cargo_compile_git_deps;
mod test_cargo_compile_old_custom_build;
mod test_cargo_compile_path_deps;
mod test_cargo_compile_plugins;
mod test_cargo_cross_compile;