1
1
use crate :: config:: { Channel , ConfigInfo } ;
2
- use crate :: utils:: { run_command, run_command_with_output_and_env, walk_dir} ;
2
+ use crate :: utils:: { create_dir , run_command, run_command_with_output_and_env, walk_dir} ;
3
3
use std:: collections:: HashMap ;
4
4
use std:: ffi:: OsStr ;
5
5
use std:: fs;
@@ -103,6 +103,7 @@ fn cleanup_sysroot_previous_build(start_dir: &Path) {
103
103
104
104
pub fn build_sysroot ( env : & HashMap < String , String > , config : & ConfigInfo ) -> Result < ( ) , String > {
105
105
let start_dir = Path :: new ( "build_sysroot" ) ;
106
+
106
107
cleanup_sysroot_previous_build ( & start_dir) ;
107
108
108
109
// Builds libs
@@ -136,13 +137,7 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
136
137
137
138
// Copy files to sysroot
138
139
let sysroot_path = start_dir. join ( format ! ( "sysroot/lib/rustlib/{}/lib/" , config. target_triple) ) ;
139
- fs:: create_dir_all ( & sysroot_path) . map_err ( |error| {
140
- format ! (
141
- "Failed to create directory `{}`: {:?}" ,
142
- sysroot_path. display( ) ,
143
- error
144
- )
145
- } ) ?;
140
+ create_dir ( & sysroot_path) ?;
146
141
let copier = |dir_to_copy : & Path | {
147
142
// FIXME: should not use shell command!
148
143
run_command ( & [ & "cp" , & "-r" , & dir_to_copy, & sysroot_path] , None ) . map ( |_| ( ) )
@@ -155,13 +150,7 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
155
150
156
151
// Copy the source files to the sysroot (Rust for Linux needs this).
157
152
let sysroot_src_path = start_dir. join ( "sysroot/lib/rustlib/src/rust" ) ;
158
- fs:: create_dir_all ( & sysroot_src_path) . map_err ( |error| {
159
- format ! (
160
- "Failed to create directory `{}`: {:?}" ,
161
- sysroot_src_path. display( ) ,
162
- error
163
- )
164
- } ) ?;
153
+ create_dir ( & sysroot_src_path) ?;
165
154
run_command (
166
155
& [
167
156
& "cp" ,
@@ -216,12 +205,7 @@ fn build_codegen(args: &mut BuildArg) -> Result<(), String> {
216
205
// We voluntarily ignore the error.
217
206
let _ = fs:: remove_dir_all ( "target/out" ) ;
218
207
let gccjit_target = "target/out/gccjit" ;
219
- fs:: create_dir_all ( gccjit_target) . map_err ( |error| {
220
- format ! (
221
- "Failed to create directory `{}`: {:?}" ,
222
- gccjit_target, error
223
- )
224
- } ) ?;
208
+ create_dir ( gccjit_target) ?;
225
209
226
210
println ! ( "[BUILD] sysroot" ) ;
227
211
build_sysroot ( & env, & args. config_info ) ?;
0 commit comments