@@ -13,6 +13,7 @@ mod macros;
1313pub mod run;
1414pub mod rustc;
1515pub mod rustdoc;
16+ pub mod targets;
1617
1718use std:: env;
1819use std:: ffi:: OsString ;
@@ -37,6 +38,7 @@ pub use llvm::{
3738pub use run:: { cmd, run, run_fail, run_with_args} ;
3839pub use rustc:: { aux_build, bare_rustc, rustc, Rustc } ;
3940pub use rustdoc:: { bare_rustdoc, rustdoc, Rustdoc } ;
41+ pub use targets:: { is_darwin, is_msvc, is_windows, target, uname} ;
4042
4143use command:: { Command , CompletedProcess } ;
4244
@@ -58,28 +60,17 @@ pub fn env_var_os(name: &str) -> OsString {
5860 }
5961}
6062
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+ }
8374}
8475
8576#[ track_caller]
@@ -348,20 +339,11 @@ pub fn cygpath_windows<P: AsRef<Path>>(path: P) -> String {
348339 output. stdout_utf8 ( ) . trim ( ) . to_string ( )
349340}
350341
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+ ) -> ! {
365347 if output. status ( ) . success ( ) {
366348 eprintln ! ( "command unexpectedly succeeded at line {caller_line_number}" ) ;
367349 } else {
0 commit comments