@@ -60,6 +60,7 @@ impl WorkspaceBuildScripts {
60
60
fn build_command (
61
61
config : & CargoConfig ,
62
62
allowed_features : & FxHashSet < String > ,
63
+ workspace_root : & AbsPathBuf ,
63
64
) -> io:: Result < Command > {
64
65
let mut cmd = match config. run_build_script_command . as_deref ( ) {
65
66
Some ( [ program, args @ ..] ) => {
@@ -73,6 +74,9 @@ impl WorkspaceBuildScripts {
73
74
cmd. args ( [ "check" , "--quiet" , "--workspace" , "--message-format=json" ] ) ;
74
75
cmd. args ( & config. extra_args ) ;
75
76
77
+ cmd. arg ( "--manifest-path" ) ;
78
+ cmd. arg ( workspace_root. join ( "Cargo.toml" ) . as_os_str ( ) ) ;
79
+
76
80
if let Some ( target_dir) = & config. target_dir {
77
81
cmd. arg ( "--target-dir" ) . arg ( target_dir) ;
78
82
}
@@ -143,7 +147,11 @@ impl WorkspaceBuildScripts {
143
147
let allowed_features = workspace. workspace_features ( ) ;
144
148
145
149
match Self :: run_per_ws (
146
- Self :: build_command ( config, & allowed_features) ?,
150
+ Self :: build_command (
151
+ config,
152
+ & allowed_features,
153
+ & workspace. workspace_root ( ) . to_path_buf ( ) ,
154
+ ) ?,
147
155
workspace,
148
156
current_dir,
149
157
progress,
@@ -153,7 +161,11 @@ impl WorkspaceBuildScripts {
153
161
{
154
162
// building build scripts failed, attempt to build with --keep-going so
155
163
// that we potentially get more build data
156
- let mut cmd = Self :: build_command ( config, & allowed_features) ?;
164
+ let mut cmd = Self :: build_command (
165
+ config,
166
+ & allowed_features,
167
+ & workspace. workspace_root ( ) . to_path_buf ( ) ,
168
+ ) ?;
157
169
cmd. args ( [ "-Z" , "unstable-options" , "--keep-going" ] ) . env ( "RUSTC_BOOTSTRAP" , "1" ) ;
158
170
let mut res = Self :: run_per_ws ( cmd, workspace, current_dir, progress) ?;
159
171
res. error = Some ( error) ;
@@ -169,6 +181,7 @@ impl WorkspaceBuildScripts {
169
181
config : & CargoConfig ,
170
182
workspaces : & [ & CargoWorkspace ] ,
171
183
progress : & dyn Fn ( String ) ,
184
+ workspace_root : & AbsPathBuf ,
172
185
) -> io:: Result < Vec < WorkspaceBuildScripts > > {
173
186
assert_eq ! ( config. invocation_strategy, InvocationStrategy :: Once ) ;
174
187
@@ -181,7 +194,7 @@ impl WorkspaceBuildScripts {
181
194
) )
182
195
}
183
196
} ;
184
- let cmd = Self :: build_command ( config, & Default :: default ( ) ) ?;
197
+ let cmd = Self :: build_command ( config, & Default :: default ( ) , workspace_root ) ?;
185
198
// NB: Cargo.toml could have been modified between `cargo metadata` and
186
199
// `cargo check`. We shouldn't assume that package ids we see here are
187
200
// exactly those from `config`.
0 commit comments