Skip to content

Commit c9955bf

Browse files
committed
Auto merge of #17929 - Veykril:invocation-loc-docs, r=Veykril
minor: Improve documentation for `InvocationStrategy` cc #17888
2 parents 0c395dc + 3c4cdbb commit c9955bf

File tree

5 files changed

+29
-23
lines changed

5 files changed

+29
-23
lines changed

crates/project-model/src/build_dependencies.rs

+3-4
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

+11-8
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

+6-4
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! {

docs/user/generated_config.adoc

+4-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ Run build scripts (`build.rs`) for more precise code analysis.
4949
+
5050
--
5151
Specifies the invocation strategy to use when running the build scripts command.
52-
If `per_workspace` is set, the command will be executed for each workspace.
53-
If `once` is set, the command will be executed once.
52+
If `per_workspace` is set, the command will be executed for each Rust workspace with the
53+
workspace as the working directory.
54+
If `once` is set, the command will be executed once with the opened project as the
55+
working directory.
5456
This config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`
5557
is set.
5658
--

editors/code/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -667,16 +667,16 @@
667667
"title": "cargo",
668668
"properties": {
669669
"rust-analyzer.cargo.buildScripts.invocationStrategy": {
670-
"markdownDescription": "Specifies the invocation strategy to use when running the build scripts command.\nIf `per_workspace` is set, the command will be executed for each workspace.\nIf `once` is set, the command will be executed once.\nThis config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`\nis set.",
670+
"markdownDescription": "Specifies the invocation strategy to use when running the build scripts command.\nIf `per_workspace` is set, the command will be executed for each Rust workspace with the\nworkspace as the working directory.\nIf `once` is set, the command will be executed once with the opened project as the\nworking directory.\nThis config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`\nis set.",
671671
"default": "per_workspace",
672672
"type": "string",
673673
"enum": [
674674
"per_workspace",
675675
"once"
676676
],
677677
"enumDescriptions": [
678-
"The command will be executed for each workspace.",
679-
"The command will be executed once."
678+
"The command will be executed for each Rust workspace with the workspace as the working directory.",
679+
"The command will be executed once with the opened project as the working directory."
680680
]
681681
}
682682
}
@@ -959,8 +959,8 @@
959959
"once"
960960
],
961961
"enumDescriptions": [
962-
"The command will be executed for each workspace.",
963-
"The command will be executed once."
962+
"The command will be executed for each Rust workspace with the workspace as the working directory.",
963+
"The command will be executed once with the opened project as the working directory."
964964
]
965965
}
966966
}

0 commit comments

Comments
 (0)