Skip to content

Commit 554d736

Browse files
committed
Improve documentation for InvocationStrategy
1 parent 0c395dc commit 554d736

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

crates/project-model/src/build_dependencies.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,16 @@ impl WorkspaceBuildScripts {
8282
config: &CargoConfig,
8383
workspaces: &[&CargoWorkspace],
8484
progress: &dyn Fn(String),
85-
workspace_root: &AbsPathBuf,
85+
working_directory: &AbsPathBuf,
8686
) -> io::Result<Vec<WorkspaceBuildScripts>> {
8787
assert_eq!(config.invocation_strategy, InvocationStrategy::Once);
8888

89-
let current_dir = workspace_root;
9089
let cmd = Self::build_command(
9190
config,
9291
&Default::default(),
9392
// This is not gonna be used anyways, so just construct a dummy here
94-
&ManifestPath::try_from(workspace_root.clone()).unwrap(),
95-
current_dir,
93+
&ManifestPath::try_from(working_directory.clone()).unwrap(),
94+
working_directory,
9695
&Sysroot::empty(),
9796
)?;
9897
// NB: Cargo.toml could have been modified between `cargo metadata` and

crates/project-model/src/workspace.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ impl ProjectWorkspace {
459459
workspaces: &[ProjectWorkspace],
460460
config: &CargoConfig,
461461
progress: &dyn Fn(String),
462-
workspace_root: &AbsPathBuf,
462+
working_directory: &AbsPathBuf,
463463
) -> Vec<anyhow::Result<WorkspaceBuildScripts>> {
464464
if matches!(config.invocation_strategy, InvocationStrategy::PerWorkspace)
465465
|| config.run_build_script_command.is_none()
@@ -474,13 +474,16 @@ impl ProjectWorkspace {
474474
_ => None,
475475
})
476476
.collect();
477-
let outputs =
478-
&mut match WorkspaceBuildScripts::run_once(config, &cargo_ws, progress, workspace_root)
479-
{
480-
Ok(it) => Ok(it.into_iter()),
481-
// io::Error is not Clone?
482-
Err(e) => Err(sync::Arc::new(e)),
483-
};
477+
let outputs = &mut match WorkspaceBuildScripts::run_once(
478+
config,
479+
&cargo_ws,
480+
progress,
481+
working_directory,
482+
) {
483+
Ok(it) => Ok(it.into_iter()),
484+
// io::Error is not Clone?
485+
Err(e) => Err(sync::Arc::new(e)),
486+
};
484487

485488
workspaces
486489
.iter()

crates/rust-analyzer/src/config.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ config_data! {
8181
/// Run build scripts (`build.rs`) for more precise code analysis.
8282
cargo_buildScripts_enable: bool = true,
8383
/// Specifies the invocation strategy to use when running the build scripts command.
84-
/// If `per_workspace` is set, the command will be executed for each workspace.
85-
/// If `once` is set, the command will be executed once.
84+
/// If `per_workspace` is set, the command will be executed for each Rust workspace with the
85+
/// workspace as the working directory.
86+
/// If `once` is set, the command will be executed once with the opened project as the
87+
/// working directory.
8688
/// This config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`
8789
/// is set.
8890
cargo_buildScripts_invocationStrategy: InvocationStrategy = InvocationStrategy::PerWorkspace,
@@ -3154,8 +3156,8 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
31543156
"type": "string",
31553157
"enum": ["per_workspace", "once"],
31563158
"enumDescriptions": [
3157-
"The command will be executed for each workspace.",
3158-
"The command will be executed once."
3159+
"The command will be executed for each Rust workspace with the workspace as the working directory.",
3160+
"The command will be executed once with the opened project as the working directory."
31593161
],
31603162
},
31613163
"Option<CheckOnSaveTargets>" => set! {

0 commit comments

Comments
 (0)