File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
src/tools/run-make-support/src Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ pub mod rustc;
1212pub mod rustdoc;
1313
1414use std:: env;
15+ use std:: fs;
16+ use std:: io;
1517use std:: path:: { Path , PathBuf } ;
1618use std:: process:: { Command , Output } ;
1719
@@ -201,6 +203,24 @@ pub fn set_host_rpath(cmd: &mut Command) {
201203 } ) ;
202204}
203205
206+ /// Copy a directory into another.
207+ pub fn copy_dir_all ( src : impl AsRef < Path > , dst : impl AsRef < Path > ) -> io:: Result < ( ) > {
208+ let dst = dst. as_ref ( ) ;
209+ if !dst. is_dir ( ) {
210+ fs:: create_dir_all ( & dst) ?;
211+ }
212+ for entry in fs:: read_dir ( src) ? {
213+ let entry = entry?;
214+ let ty = entry. file_type ( ) ?;
215+ if ty. is_dir ( ) {
216+ copy_dir_all ( entry. path ( ) , dst. join ( entry. file_name ( ) ) ) ?;
217+ } else {
218+ fs:: copy ( entry. path ( ) , dst. join ( entry. file_name ( ) ) ) ?;
219+ }
220+ }
221+ Ok ( ( ) )
222+ }
223+
204224/// Implement common helpers for command wrappers. This assumes that the command wrapper is a struct
205225/// containing a `cmd: Command` field and a `output` function. The provided helpers are:
206226///
You can’t perform that action at this time.
0 commit comments