@@ -292,7 +292,7 @@ fn rustc(cx: &mut Context<'_, '_>, unit: &Unit, exec: &Arc<dyn Executor>) -> Car
292
292
) ?;
293
293
add_plugin_deps ( & mut rustc, & script_outputs, & build_scripts, & root_output) ?;
294
294
}
295
- add_custom_env ( & mut rustc, & script_outputs, script_metadata) ;
295
+ add_custom_flags ( & mut rustc, & script_outputs, script_metadata) ? ;
296
296
}
297
297
298
298
for output in outputs. iter ( ) {
@@ -408,15 +408,6 @@ fn rustc(cx: &mut Context<'_, '_>, unit: &Unit, exec: &Arc<dyn Executor>) -> Car
408
408
}
409
409
410
410
if key. 0 == current_id {
411
- for cfg in & output. cfgs {
412
- rustc. arg ( "--cfg" ) . arg ( cfg) ;
413
- }
414
- if !output. check_cfgs . is_empty ( ) {
415
- rustc. arg ( "-Zunstable-options" ) ;
416
- for check_cfg in & output. check_cfgs {
417
- rustc. arg ( "--check-cfg" ) . arg ( check_cfg) ;
418
- }
419
- }
420
411
if pass_l_flag {
421
412
for name in output. library_links . iter ( ) {
422
413
rustc. arg ( "-l" ) . arg ( name) ;
@@ -437,22 +428,6 @@ fn rustc(cx: &mut Context<'_, '_>, unit: &Unit, exec: &Arc<dyn Executor>) -> Car
437
428
}
438
429
Ok ( ( ) )
439
430
}
440
-
441
- // Add all custom environment variables present in `state` (after they've
442
- // been put there by one of the `build_scripts`) to the command provided.
443
- fn add_custom_env (
444
- rustc : & mut ProcessBuilder ,
445
- build_script_outputs : & BuildScriptOutputs ,
446
- metadata : Option < Metadata > ,
447
- ) {
448
- if let Some ( metadata) = metadata {
449
- if let Some ( output) = build_script_outputs. get ( metadata) {
450
- for & ( ref name, ref value) in output. env . iter ( ) {
451
- rustc. env ( name, value) ;
452
- }
453
- }
454
- }
455
- }
456
431
}
457
432
458
433
/// Link the compiled target (often of form `foo-{metadata_hash}`) to the
@@ -719,22 +694,11 @@ fn rustdoc(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Work> {
719
694
let mut output_options = OutputOptions :: new ( cx, unit) ;
720
695
let script_metadata = cx. find_build_script_metadata ( unit) ;
721
696
Ok ( Work :: new ( move |state| {
722
- if let Some ( script_metadata) = script_metadata {
723
- if let Some ( output) = build_script_outputs. lock ( ) . unwrap ( ) . get ( script_metadata) {
724
- for cfg in output. cfgs . iter ( ) {
725
- rustdoc. arg ( "--cfg" ) . arg ( cfg) ;
726
- }
727
- if !output. check_cfgs . is_empty ( ) {
728
- rustdoc. arg ( "-Zunstable-options" ) ;
729
- for check_cfg in & output. check_cfgs {
730
- rustdoc. arg ( "--check-cfg" ) . arg ( check_cfg) ;
731
- }
732
- }
733
- for & ( ref name, ref value) in output. env . iter ( ) {
734
- rustdoc. env ( name, value) ;
735
- }
736
- }
737
- }
697
+ add_custom_flags (
698
+ & mut rustdoc,
699
+ & build_script_outputs. lock ( ) . unwrap ( ) ,
700
+ script_metadata,
701
+ ) ?;
738
702
let crate_dir = doc_dir. join ( & crate_name) ;
739
703
if crate_dir. exists ( ) {
740
704
// Remove output from a previous build. This ensures that stale
@@ -1196,6 +1160,32 @@ fn build_deps_args(
1196
1160
Ok ( ( ) )
1197
1161
}
1198
1162
1163
+ /// Add custom flags from the output a of build-script to a `ProcessBuilder`
1164
+ fn add_custom_flags (
1165
+ cmd : & mut ProcessBuilder ,
1166
+ build_script_outputs : & BuildScriptOutputs ,
1167
+ metadata : Option < Metadata > ,
1168
+ ) -> CargoResult < ( ) > {
1169
+ if let Some ( metadata) = metadata {
1170
+ if let Some ( output) = build_script_outputs. get ( metadata) {
1171
+ for cfg in output. cfgs . iter ( ) {
1172
+ cmd. arg ( "--cfg" ) . arg ( cfg) ;
1173
+ }
1174
+ if !output. check_cfgs . is_empty ( ) {
1175
+ cmd. arg ( "-Zunstable-options" ) ;
1176
+ for check_cfg in & output. check_cfgs {
1177
+ cmd. arg ( "--check-cfg" ) . arg ( check_cfg) ;
1178
+ }
1179
+ }
1180
+ for & ( ref name, ref value) in output. env . iter ( ) {
1181
+ cmd. env ( name, value) ;
1182
+ }
1183
+ }
1184
+ }
1185
+
1186
+ Ok ( ( ) )
1187
+ }
1188
+
1199
1189
/// Generates a list of `--extern` arguments.
1200
1190
pub fn extern_args (
1201
1191
cx : & Context < ' _ , ' _ > ,
0 commit comments