File tree 3 files changed +36
-0
lines changed
3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,7 @@ pub enum PrintRequest {
163
163
FileNames ,
164
164
Sysroot ,
165
165
CrateName ,
166
+ Cfg ,
166
167
}
167
168
168
169
pub enum Input {
@@ -1105,6 +1106,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1105
1106
"crate-name" => PrintRequest :: CrateName ,
1106
1107
"file-names" => PrintRequest :: FileNames ,
1107
1108
"sysroot" => PrintRequest :: Sysroot ,
1109
+ "cfg" => PrintRequest :: Cfg ,
1108
1110
req => {
1109
1111
early_error ( error_format, & format ! ( "unknown print request `{}`" , req) )
1110
1112
}
Original file line number Diff line number Diff line change @@ -518,6 +518,25 @@ impl RustcDefaultCalls {
518
518
. to_string_lossy( ) ) ;
519
519
}
520
520
}
521
+ PrintRequest :: Cfg => {
522
+ for cfg in config:: build_configuration ( sess) {
523
+ match cfg. node {
524
+ ast:: MetaWord ( ref word) => println ! ( "{}" , word) ,
525
+ ast:: MetaNameValue ( ref name, ref value) => {
526
+ println ! ( "{}=\" {}\" " , name, match value. node {
527
+ ast:: LitStr ( ref s, _) => s,
528
+ _ => continue ,
529
+ } ) ;
530
+ }
531
+ // Right now there are not and should not be any
532
+ // MetaList items in the configuration returned by
533
+ // `build_configuration`.
534
+ ast:: MetaList ( ..) => {
535
+ panic ! ( "MetaList encountered in default cfg" )
536
+ }
537
+ }
538
+ }
539
+ }
521
540
}
522
541
}
523
542
return Compilation :: Stop ;
Original file line number Diff line number Diff line change
1
+ -include ../tools.mk
2
+
3
+ all : default
4
+ rustc --target x86_64-pc-windows-gnu --print cfg | grep windows
5
+ rustc --target x86_64-pc-windows-gnu --print cfg | grep x86_64
6
+ rustc --target i686-pc-windows-msvc --print cfg | grep msvc
7
+ rustc --target i686-apple-darwin --print cfg | grep macos
8
+
9
+ ifdef IS_WINDOWS
10
+ default :
11
+ rustc --print cfg | grep windows
12
+ else
13
+ default :
14
+ rustc --print cfg | grep unix
15
+ endif
You can’t perform that action at this time.
0 commit comments