@@ -114,6 +114,8 @@ pub struct CommandBuilder {
114114 pub rustc : Option < PathBuf > ,
115115 // -C flags
116116 pub rust_flags : Option < Vec < String > > ,
117+ // --cfg configs
118+ pub rust_cfgs : Option < Vec < String > > ,
117119 // -Z flags
118120 pub z_flags : Option < Vec < String > > ,
119121 // riscv32im gcc
@@ -163,6 +165,7 @@ impl CommandBuilder {
163165 rustc : CommandBuilder :: get_path_buf ( "rustc" , toolchain) ,
164166 sanitized_env : Vec :: new ( ) ,
165167 rust_flags : None ,
168+ rust_cfgs : None ,
166169 z_flags : None ,
167170 cc_compiler : None ,
168171 c_flags : None ,
@@ -189,6 +192,11 @@ impl CommandBuilder {
189192 self
190193 }
191194
195+ pub fn rust_cfgs ( mut self , flags : & [ & str ] ) -> Self {
196+ self . rust_cfgs = Some ( to_strings ( flags) ) ;
197+ self
198+ }
199+
192200 pub fn z_flags ( mut self , flags : & [ & str ] ) -> Self {
193201 self . z_flags = Some ( to_strings ( flags) ) ;
194202 self
@@ -321,6 +329,7 @@ impl CommandBuilder {
321329 cargo,
322330 rustc,
323331 rust_flags,
332+ rust_cfgs,
324333 z_flags,
325334 cc_compiler,
326335 c_flags,
@@ -373,12 +382,15 @@ impl CommandBuilder {
373382 } ) ,
374383 ) ;
375384
385+ let mut encoded_flags: Vec < String > = vec ! [ ] ;
376386 if let Some ( rust_flags) = rust_flags {
377- cmd. env (
378- "CARGO_ENCODED_RUSTFLAGS" ,
379- format_flags ( "-C" , & rust_flags) . join ( "\x1f " ) ,
380- ) ;
387+ encoded_flags = format_flags ( "-C" , & rust_flags) ;
388+ }
389+
390+ if let Some ( cfgs) = rust_cfgs {
391+ encoded_flags. extend ( format_flags ( "--cfg" , & cfgs) ) ;
381392 }
393+ cmd. env ( "CARGO_ENCODED_RUSTFLAGS" , encoded_flags. join ( "\x1f " ) ) ;
382394
383395 // Set C compiler path and flags
384396 if let Some ( cc_compiler) = cc_compiler {
0 commit comments