@@ -13,6 +13,7 @@ mod macros;
13
13
pub mod run;
14
14
pub mod rustc;
15
15
pub mod rustdoc;
16
+ pub mod targets;
16
17
17
18
use std:: env;
18
19
use std:: ffi:: OsString ;
@@ -37,6 +38,7 @@ pub use llvm::{
37
38
pub use run:: { cmd, run, run_fail, run_with_args} ;
38
39
pub use rustc:: { aux_build, bare_rustc, rustc, Rustc } ;
39
40
pub use rustdoc:: { bare_rustdoc, rustdoc, Rustdoc } ;
41
+ pub use targets:: { is_darwin, is_msvc, is_windows, target, uname} ;
40
42
41
43
use command:: { Command , CompletedProcess } ;
42
44
@@ -58,28 +60,17 @@ pub fn env_var_os(name: &str) -> OsString {
58
60
}
59
61
}
60
62
61
- /// `TARGET`
62
- #[ must_use]
63
- pub fn target ( ) -> String {
64
- env_var ( "TARGET" )
65
- }
66
-
67
- /// Check if target is windows-like.
68
- #[ must_use]
69
- pub fn is_windows ( ) -> bool {
70
- target ( ) . contains ( "windows" )
71
- }
72
-
73
- /// Check if target uses msvc.
74
- #[ must_use]
75
- pub fn is_msvc ( ) -> bool {
76
- target ( ) . contains ( "msvc" )
77
- }
78
-
79
- /// Check if target uses macOS.
80
- #[ must_use]
81
- pub fn is_darwin ( ) -> bool {
82
- target ( ) . contains ( "darwin" )
63
+ /// `AR`
64
+ #[ track_caller]
65
+ pub fn ar ( inputs : & [ impl AsRef < Path > ] , output_path : impl AsRef < Path > ) {
66
+ let output = fs:: File :: create ( & output_path) . expect ( & format ! (
67
+ "the file in path \" {}\" could not be created" ,
68
+ output_path. as_ref( ) . display( )
69
+ ) ) ;
70
+ let mut builder = ar:: Builder :: new ( output) ;
71
+ for input in inputs {
72
+ builder. append_path ( input) . unwrap ( ) ;
73
+ }
83
74
}
84
75
85
76
#[ track_caller]
@@ -348,20 +339,11 @@ pub fn cygpath_windows<P: AsRef<Path>>(path: P) -> String {
348
339
output. stdout_utf8 ( ) . trim ( ) . to_string ( )
349
340
}
350
341
351
- /// Run `uname`. This assumes that `uname` is available on the platform!
352
- #[ track_caller]
353
- #[ must_use]
354
- pub fn uname ( ) -> String {
355
- let caller = panic:: Location :: caller ( ) ;
356
- let mut uname = Command :: new ( "uname" ) ;
357
- let output = uname. run ( ) ;
358
- if !output. status ( ) . success ( ) {
359
- handle_failed_output ( & uname, output, caller. line ( ) ) ;
360
- }
361
- output. stdout_utf8 ( )
362
- }
363
-
364
- fn handle_failed_output ( cmd : & Command , output : CompletedProcess , caller_line_number : u32 ) -> ! {
342
+ pub ( crate ) fn handle_failed_output (
343
+ cmd : & Command ,
344
+ output : CompletedProcess ,
345
+ caller_line_number : u32 ,
346
+ ) -> ! {
365
347
if output. status ( ) . success ( ) {
366
348
eprintln ! ( "command unexpectedly succeeded at line {caller_line_number}" ) ;
367
349
} else {
0 commit comments