@@ -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,12 +60,6 @@ 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
63
/// `AR`
68
64
#[ track_caller]
69
65
pub fn ar ( inputs : & [ impl AsRef < Path > ] , output_path : impl AsRef < Path > ) {
@@ -77,24 +73,6 @@ pub fn ar(inputs: &[impl AsRef<Path>], output_path: impl AsRef<Path>) {
77
73
}
78
74
}
79
75
80
- /// Check if target is windows-like.
81
- #[ must_use]
82
- pub fn is_windows ( ) -> bool {
83
- target ( ) . contains ( "windows" )
84
- }
85
-
86
- /// Check if target uses msvc.
87
- #[ must_use]
88
- pub fn is_msvc ( ) -> bool {
89
- target ( ) . contains ( "msvc" )
90
- }
91
-
92
- /// Check if target uses macOS.
93
- #[ must_use]
94
- pub fn is_darwin ( ) -> bool {
95
- target ( ) . contains ( "darwin" )
96
- }
97
-
98
76
#[ track_caller]
99
77
#[ must_use]
100
78
pub fn python_command ( ) -> Command {
@@ -341,20 +319,11 @@ pub fn cygpath_windows<P: AsRef<Path>>(path: P) -> String {
341
319
output. stdout_utf8 ( ) . trim ( ) . to_string ( )
342
320
}
343
321
344
- /// Run `uname`. This assumes that `uname` is available on the platform!
345
- #[ track_caller]
346
- #[ must_use]
347
- pub fn uname ( ) -> String {
348
- let caller = panic:: Location :: caller ( ) ;
349
- let mut uname = Command :: new ( "uname" ) ;
350
- let output = uname. run ( ) ;
351
- if !output. status ( ) . success ( ) {
352
- handle_failed_output ( & uname, output, caller. line ( ) ) ;
353
- }
354
- output. stdout_utf8 ( )
355
- }
356
-
357
- fn handle_failed_output ( cmd : & Command , output : CompletedProcess , caller_line_number : u32 ) -> ! {
322
+ pub ( crate ) fn handle_failed_output (
323
+ cmd : & Command ,
324
+ output : CompletedProcess ,
325
+ caller_line_number : u32 ,
326
+ ) -> ! {
358
327
if output. status ( ) . success ( ) {
359
328
eprintln ! ( "command unexpectedly succeeded at line {caller_line_number}" ) ;
360
329
} else {
0 commit comments