@@ -15,16 +15,6 @@ fn ensure_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
15
15
}
16
16
17
17
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
-
28
18
// Run rustc to get the version
29
19
let rustc_output = Command :: new ( "rustc" ) . arg ( "--version" )
30
20
. output ( ) . unwrap_or_else ( |e| {
@@ -36,6 +26,28 @@ fn main() {
36
26
Err ( e) => panic ! ( e) ,
37
27
} . trim_left_matches ( "(" ) ;
38
28
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
+
39
51
// Shell out to perform the build. In the future, the logic
40
52
// to grab libcore could be done in rust in order to support
41
53
// platforms without a posix shell
@@ -46,4 +58,11 @@ fn main() {
46
58
. status ( ) . unwrap_or_else ( |e| {
47
59
panic ! ( "failed to execute process: {}" , e) ;
48
60
} ) ;
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
+ }
49
68
}
0 commit comments