@@ -24,7 +24,7 @@ use toolchain::Tool;
24
24
25
25
use crate :: {
26
26
cfg:: CfgFlag , utf8_stdout, CargoConfig , CargoFeatures , CargoWorkspace , InvocationLocation ,
27
- InvocationStrategy , Package , Sysroot , TargetKind ,
27
+ InvocationStrategy , ManifestPath , Package , Sysroot , TargetKind ,
28
28
} ;
29
29
30
30
/// Output of the build script and proc-macro building steps for a workspace.
@@ -63,7 +63,7 @@ impl WorkspaceBuildScripts {
63
63
fn build_command (
64
64
config : & CargoConfig ,
65
65
allowed_features : & FxHashSet < String > ,
66
- workspace_root : & AbsPathBuf ,
66
+ manifest_path : & ManifestPath ,
67
67
sysroot : Option < & Sysroot > ,
68
68
) -> io:: Result < Command > {
69
69
let mut cmd = match config. run_build_script_command . as_deref ( ) {
@@ -79,7 +79,7 @@ impl WorkspaceBuildScripts {
79
79
cmd. args ( & config. extra_args ) ;
80
80
81
81
cmd. arg ( "--manifest-path" ) ;
82
- cmd. arg ( workspace_root . join ( "Cargo.toml" ) ) ;
82
+ cmd. arg ( manifest_path . as_ref ( ) ) ;
83
83
84
84
if let Some ( target_dir) = & config. target_dir {
85
85
cmd. arg ( "--target-dir" ) . arg ( target_dir) ;
@@ -116,6 +116,10 @@ impl WorkspaceBuildScripts {
116
116
}
117
117
}
118
118
119
+ if manifest_path. extension ( ) . map_or ( false , |ext| ext == "rs" ) {
120
+ cmd. arg ( "-Zscript" ) ;
121
+ }
122
+
119
123
cmd
120
124
}
121
125
} ;
@@ -152,37 +156,12 @@ impl WorkspaceBuildScripts {
152
156
. as_ref ( ) ;
153
157
154
158
let allowed_features = workspace. workspace_features ( ) ;
155
-
156
- match Self :: run_per_ws (
157
- Self :: build_command (
158
- config,
159
- & allowed_features,
160
- & workspace. workspace_root ( ) . to_path_buf ( ) ,
161
- sysroot,
162
- ) ?,
163
- workspace,
164
- current_dir,
165
- progress,
166
- ) {
167
- Ok ( WorkspaceBuildScripts { error : Some ( error) , .. } )
168
- if toolchain. as_ref ( ) . map_or ( false , |it| * it >= RUST_1_75 ) =>
169
- {
170
- // building build scripts failed, attempt to build with --keep-going so
171
- // that we potentially get more build data
172
- let mut cmd = Self :: build_command (
173
- config,
174
- & allowed_features,
175
- & workspace. workspace_root ( ) . to_path_buf ( ) ,
176
- sysroot,
177
- ) ?;
178
-
179
- cmd. args ( [ "--keep-going" ] ) ;
180
- let mut res = Self :: run_per_ws ( cmd, workspace, current_dir, progress) ?;
181
- res. error = Some ( error) ;
182
- Ok ( res)
183
- }
184
- res => res,
159
+ let mut cmd =
160
+ Self :: build_command ( config, & allowed_features, workspace. manifest_path ( ) , sysroot) ?;
161
+ if toolchain. as_ref ( ) . map_or ( false , |it| * it >= RUST_1_75 ) {
162
+ cmd. args ( [ "--keep-going" ] ) ;
185
163
}
164
+ Self :: run_per_ws ( cmd, workspace, current_dir, progress)
186
165
}
187
166
188
167
/// Runs the build scripts by invoking the configured command *once*.
@@ -204,7 +183,13 @@ impl WorkspaceBuildScripts {
204
183
) )
205
184
}
206
185
} ;
207
- let cmd = Self :: build_command ( config, & Default :: default ( ) , workspace_root, None ) ?;
186
+ let cmd = Self :: build_command (
187
+ config,
188
+ & Default :: default ( ) ,
189
+ // This is not gonna be used anyways, so just construct a dummy here
190
+ & ManifestPath :: try_from ( workspace_root. clone ( ) ) . unwrap ( ) ,
191
+ None ,
192
+ ) ?;
208
193
// NB: Cargo.toml could have been modified between `cargo metadata` and
209
194
// `cargo check`. We shouldn't assume that package ids we see here are
210
195
// exactly those from `config`.
0 commit comments