Skip to content
This repository was archived by the owner on Nov 8, 2018. It is now read-only.

Commit e29cad5

Browse files
committedDec 15, 2015
Merge pull request #5 from mcoffin/merge-upgrade#4
build: Ensure unzipped rust is clean
2 parents 60ad525 + de743f9 commit e29cad5

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed
 

‎Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "core"
3-
version = "0.0.1"
3+
version = "0.0.2"
44
authors = ["The Rust Developers Team"]
55
build = "./build.rs"
66
description = "Libcore wrapped into cargo package, suitable for cross-builds"

‎build.rs

+29-10
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@ fn ensure_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
1515
}
1616

1717
fn main() {
18-
// Ensure the rust directory exists
19-
if let Err(e) = ensure_dir(RUST_DIR) {
20-
panic!(e);
21-
}
22-
23-
// cd to the rust directory
24-
if let Err(e) = env::set_current_dir(RUST_DIR) {
25-
panic!(e);
26-
}
27-
2818
// Run rustc to get the version
2919
let rustc_output = Command::new("rustc").arg("--version")
3020
.output().unwrap_or_else(|e| {
@@ -36,6 +26,28 @@ fn main() {
3626
Err(e) => panic!(e),
3727
}.trim_left_matches("(");
3828

29+
match fs::metadata(Path::new(RUST_DIR).join(version)) {
30+
Ok(meta) => {
31+
if !meta.is_file() {
32+
match fs::remove_dir_all(RUST_DIR) {
33+
Err(e) => panic!(e),
34+
_ => {},
35+
}
36+
}
37+
},
38+
Err(..) => {}, // Ok to ignore since this just means that the version file doesn't exist
39+
}
40+
41+
// Ensure the rust directory exists
42+
if let Err(e) = ensure_dir(RUST_DIR) {
43+
panic!(e);
44+
}
45+
46+
// cd to the rust directory
47+
if let Err(e) = env::set_current_dir(RUST_DIR) {
48+
panic!(e);
49+
}
50+
3951
// Shell out to perform the build. In the future, the logic
4052
// to grab libcore could be done in rust in order to support
4153
// platforms without a posix shell
@@ -46,4 +58,11 @@ fn main() {
4658
.status().unwrap_or_else(|e| {
4759
panic!("failed to execute process: {}", e);
4860
});
61+
62+
// Now that we've successfully unzipped, write the version
63+
// file as a success tag.
64+
match fs::File::create(version) {
65+
Err(e) => panic!(e),
66+
_ => {},
67+
}
4968
}

0 commit comments

Comments
 (0)
This repository has been archived.