Over time this functionality has become obsolete through other means. Due to the
usage of `-L dependency=foo` it's not possible to pick up stale dependencies by
accident, and due to `--extern` you can only pick up a dependency. All of the
cases that auto-cleaning was fixing are now fixed through other methods, so
there's not much use ensuring a "clean build directory" any more.
This has the benefit of fixing issues like #961 where the downside of long
compiles outweighs the benefits of a "let's pretend we started from scratch"
build.
Closes #961
pkg.get_package_id(), target));
let new = dir(cx, pkg, kind);
let loc = new.join(filename(target));
- cx.layout(pkg, kind).proxy().whitelist(&loc);
info!("fingerprint at: {}", loc.display());
if !target.get_profile().is_doc() {
for filename in try!(cx.target_filenames(target)).iter() {
let dst = root.join(filename);
- cx.layout(pkg, kind).proxy().whitelist(&dst);
missing_outputs |= !dst.exists();
if target.get_profile().is_test() {
pkg.get_package_id()));
let new = dir(cx, pkg, kind);
let loc = new.join("build");
- cx.layout(pkg, kind).proxy().whitelist(&loc);
info!("fingerprint at: {}", loc.display());
/// Returns the (old, new) location for the dep info file of a target.
pub fn dep_info_loc(cx: &Context, pkg: &Package, target: &Target,
kind: Kind) -> Path {
- let ret = dir(cx, pkg, kind).join(format!("dep-{}", filename(target)));
- cx.layout(pkg, kind).proxy().whitelist(&ret);
- return ret;
+ dir(cx, pkg, kind).join(format!("dep-{}", filename(target)))
}
fn is_fresh(loc: &Path, new_fingerprint: &Fingerprint) -> CargoResult<bool> {
//! .fingerprint/
//! ```
-use std::cell::RefCell;
-use std::collections::HashSet;
use std::old_io::fs::PathExtensions;
use std::old_io::{self, fs, IoResult};
-use std::mem;
use core::Package;
use util::hex::short_hash;
build: Path,
fingerprint: Path,
examples: Path,
- to_delete: RefCell<HashSet<Path>>,
}
pub struct LayoutProxy<'a> {
fingerprint: root.join(".fingerprint"),
examples: root.join("examples"),
root: root,
- to_delete: RefCell::new(HashSet::new()),
}
}
try!(fs::mkdir_recursive(&self.root, old_io::USER_RWX));
}
- try!(mkdir(self, &self.deps, false));
- try!(mkdir(self, &self.native, false));
- try!(mkdir(self, &self.fingerprint, true));
- try!(mkdir(self, &self.examples, false));
- try!(mkdir(self, &self.build, false));
-
- for file in try!(fs::readdir(&self.root)).into_iter() {
- if !file.is_file() { continue }
-
- self.to_delete.borrow_mut().insert(file);
- }
+ try!(mkdir(&self.deps));
+ try!(mkdir(&self.native));
+ try!(mkdir(&self.fingerprint));
+ try!(mkdir(&self.examples));
+ try!(mkdir(&self.build));
return Ok(());
- fn mkdir(layout: &Layout, dir: &Path, deep: bool) -> IoResult<()> {
- if dir.exists() {
- if deep {
- for file in try!(fs::walk_dir(dir)) {
- if !file.is_dir() {
- layout.to_delete.borrow_mut().insert(file);
- }
- }
- } else {
- for file in try!(fs::readdir(dir)).into_iter() {
- layout.to_delete.borrow_mut().insert(file);
- }
- }
- } else {
+ fn mkdir(dir: &Path) -> IoResult<()> {
+ if !dir.exists() {
try!(fs::mkdir(dir, old_io::USER_DIR));
}
Ok(())
// TODO: deprecated, remove
pub fn native(&self, package: &Package) -> Path {
- let ret = self.native.join(self.pkg_dir(package));
- self.whitelist(&ret);
- ret
+ self.native.join(self.pkg_dir(package))
}
pub fn fingerprint(&self, package: &Package) -> Path {
- let ret = self.fingerprint.join(self.pkg_dir(package));
- self.whitelist(&ret);
- ret
+ self.fingerprint.join(self.pkg_dir(package))
}
pub fn build(&self, package: &Package) -> Path {
- let ret = self.build.join(self.pkg_dir(package));
- self.whitelist(&ret);
- ret
+ self.build.join(self.pkg_dir(package))
}
pub fn build_out(&self, package: &Package) -> Path {
self.build(package).join("out")
}
- pub fn clean(&self) -> IoResult<()> {
- let set = mem::replace(&mut *self.to_delete.borrow_mut(),
- HashSet::new());
- for file in set.iter() {
- info!("dirty: {}", file.display());
- if file.is_dir() {
- try!(fs::rmdir_recursive(file));
- } else {
- try!(fs::unlink(file));
- }
- }
- Ok(())
- }
-
- pub fn whitelist(&self, p: &Path) {
- self.to_delete.borrow_mut().remove(p);
- }
-
fn pkg_dir(&self, pkg: &Package) -> String {
format!("{}-{}", pkg.get_name(), short_hash(pkg.get_package_id()))
}
try!(compile(targets, pkg, true, &mut cx, &mut queue));
- // Clean out any old files sticking around in directories.
- try!(cx.layout(pkg, Kind::Host).proxy().clean());
- try!(cx.layout(pkg, Kind::Target).proxy().clean());
-
// Now that we've figured out everything that we're going to do, do it!
try!(queue.execute(cx.config));
-use std::old_io::{fs, File, USER_RWX};
+use std::old_io::{fs, File, USER_RWX, timer};
+use std::time::Duration;
use support::{project, execs, main_file, cargo_dir};
use support::{COMPILING, RUNNING};
//
// We base recompilation off mtime, so sleep for at least a second to ensure
// that this write will change the mtime.
- p.root().move_into_the_past().unwrap();
+ timer::sleep(Duration::seconds(1));
File::create(&p.root().join("baz/src/baz.rs")).write_str(r#"
pub fn baz() { println!("hello!"); }
"#).unwrap();
COMPILING, p.url())));
// Make sure an update to bar doesn't trigger baz
- p.root().move_into_the_past().unwrap();
+ timer::sleep(Duration::seconds(1));
File::create(&p.root().join("bar/src/bar.rs")).write_str(r#"
extern crate baz;
pub fn bar() { println!("hello!"); baz::baz(); }
{running} `rustc [..] --crate-name ex [..] --extern a=[..]`
", running = RUNNING).as_slice()));
});
+
+test!(bin_is_preserved {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("src/lib.rs", "")
+ .file("src/main.rs", "fn main() {}");
+
+ assert_that(p.cargo_process("build").arg("-v"),
+ execs().with_status(0));
+ assert_that(&p.bin("foo"), existing_file());
+
+ println!("testing");
+ assert_that(p.process(cargo_dir().join("cargo")).arg("test").arg("-v"),
+ execs().with_status(0));
+ assert_that(&p.bin("foo"), existing_file());
+});