@@ -21,6 +21,7 @@ use error::Result;
21
21
/// all-features = true
22
22
/// no-default-features = true
23
23
/// default-target = "x86_64-unknown-linux-gnu"
24
+ /// rustc-args = [ "--example-rustc-arg" ]
24
25
/// rustdoc-args = [ "--example-rustdoc-arg" ]
25
26
/// dependencies = [ "example-system-dependency" ]
26
27
/// ```
@@ -44,6 +45,9 @@ pub struct Metadata {
44
45
/// is always built on this target. You can change default target by setting this.
45
46
pub default_target : Option < String > ,
46
47
48
+ /// List of command line arguments for `rustc`.
49
+ pub rustc_args : Option < Vec < String > > ,
50
+
47
51
/// List of command line arguments for `rustdoc`.
48
52
pub rustdoc_args : Option < Vec < String > > ,
49
53
@@ -89,6 +93,7 @@ impl Metadata {
89
93
all_features : false ,
90
94
no_default_features : false ,
91
95
default_target : None ,
96
+ rustc_args : None ,
92
97
rustdoc_args : None ,
93
98
dependencies : None ,
94
99
}
@@ -115,6 +120,8 @@ impl Metadata {
115
120
. and_then ( |v| v. as_bool ( ) ) . unwrap_or ( metadata. all_features ) ;
116
121
metadata. default_target = table. get ( "default-target" )
117
122
. and_then ( |v| v. as_str ( ) ) . map ( |v| v. to_owned ( ) ) ;
123
+ metadata. rustc_args = table. get ( "rustc-args" ) . and_then ( |f| f. as_array ( ) )
124
+ . and_then ( |f| f. iter ( ) . map ( |v| v. as_str ( ) . map ( |v| v. to_owned ( ) ) ) . collect ( ) ) ;
118
125
metadata. rustdoc_args = table. get ( "rustdoc-args" ) . and_then ( |f| f. as_array ( ) )
119
126
. and_then ( |f| f. iter ( ) . map ( |v| v. as_str ( ) . map ( |v| v. to_owned ( ) ) ) . collect ( ) ) ;
120
127
metadata. dependencies = table. get ( "dependencies" ) . and_then ( |f| f. as_array ( ) )
@@ -164,6 +171,10 @@ mod test {
164
171
165
172
assert_eq ! ( metadata. default_target. unwrap( ) , "x86_64-unknown-linux-gnu" . to_owned( ) ) ;
166
173
174
+ let rustc_args = metadata. rustc_args . unwrap ( ) ;
175
+ assert_eq ! ( rustc_args. len( ) , 1 ) ;
176
+ assert_eq ! ( rustc_args[ 0 ] , "--example-rustc-arg" . to_owned( ) ) ;
177
+
167
178
let rustdoc_args = metadata. rustdoc_args . unwrap ( ) ;
168
179
assert_eq ! ( rustdoc_args. len( ) , 1 ) ;
169
180
assert_eq ! ( rustdoc_args[ 0 ] , "--example-rustdoc-arg" . to_owned( ) ) ;
0 commit comments