@@ -73,8 +73,14 @@ pub struct Compilation<'cfg> {
73
73
pub target : String ,
74
74
75
75
config : & ' cfg Config ,
76
+
77
+ /// Rustc process to be used by default
76
78
rustc_process : ProcessBuilder ,
77
- primary_unit_rustc_process : Option < ProcessBuilder > ,
79
+ /// Rustc process to be used for workspace crates instead of rustc_process
80
+ rustc_workspace_wrapper_process : ProcessBuilder ,
81
+ /// Optional rustc process to be used for primary crates instead of either rustc_process or
82
+ /// rustc_workspace_wrapper_process
83
+ primary_rustc_process : Option < ProcessBuilder > ,
78
84
79
85
target_runner : Option < ( PathBuf , Vec < String > ) > ,
80
86
}
@@ -85,13 +91,14 @@ impl<'cfg> Compilation<'cfg> {
85
91
default_kind : CompileKind ,
86
92
) -> CargoResult < Compilation < ' cfg > > {
87
93
let mut rustc = bcx. rustc ( ) . process ( ) ;
88
-
89
- let mut primary_unit_rustc_process = bcx. build_config . primary_unit_rustc . clone ( ) ;
94
+ let mut primary_rustc_process = bcx . build_config . primary_unit_rustc . clone ( ) ;
95
+ let mut rustc_workspace_wrapper_process = bcx. rustc ( ) . workspace_process ( ) ;
90
96
91
97
if bcx. config . extra_verbose ( ) {
92
98
rustc. display_env_vars ( ) ;
99
+ rustc_workspace_wrapper_process. display_env_vars ( ) ;
93
100
94
- if let Some ( rustc) = primary_unit_rustc_process . as_mut ( ) {
101
+ if let Some ( rustc) = primary_rustc_process . as_mut ( ) {
95
102
rustc. display_env_vars ( ) ;
96
103
}
97
104
}
@@ -120,19 +127,25 @@ impl<'cfg> Compilation<'cfg> {
120
127
rustdocflags : HashMap :: new ( ) ,
121
128
config : bcx. config ,
122
129
rustc_process : rustc,
123
- primary_unit_rustc_process,
130
+ rustc_workspace_wrapper_process,
131
+ primary_rustc_process,
124
132
host : bcx. host_triple ( ) . to_string ( ) ,
125
133
target : bcx. target_data . short_name ( & default_kind) . to_string ( ) ,
126
134
target_runner : target_runner ( bcx, default_kind) ?,
127
135
} )
128
136
}
129
137
130
138
/// See `process`.
131
- pub fn rustc_process ( & self , pkg : & Package , is_primary : bool ) -> CargoResult < ProcessBuilder > {
132
- let rustc = if is_primary {
133
- self . primary_unit_rustc_process
134
- . clone ( )
135
- . unwrap_or_else ( || self . rustc_process . clone ( ) )
139
+ pub fn rustc_process (
140
+ & self ,
141
+ pkg : & Package ,
142
+ is_primary : bool ,
143
+ is_workspace : bool ,
144
+ ) -> CargoResult < ProcessBuilder > {
145
+ let rustc = if is_primary && self . primary_rustc_process . is_some ( ) {
146
+ self . primary_rustc_process . clone ( ) . unwrap ( )
147
+ } else if is_workspace {
148
+ self . rustc_workspace_wrapper_process . clone ( )
136
149
} else {
137
150
self . rustc_process . clone ( )
138
151
} ;
0 commit comments