mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-15 06:33:58 +00:00
Auto merge of #17929 - Veykril:invocation-loc-docs, r=Veykril
minor: Improve documentation for `InvocationStrategy` cc https://github.com/rust-lang/rust-analyzer/pull/17888
This commit is contained in:
commit
c9955bf86b
5 changed files with 29 additions and 23 deletions
|
@ -82,17 +82,16 @@ impl WorkspaceBuildScripts {
|
||||||
config: &CargoConfig,
|
config: &CargoConfig,
|
||||||
workspaces: &[&CargoWorkspace],
|
workspaces: &[&CargoWorkspace],
|
||||||
progress: &dyn Fn(String),
|
progress: &dyn Fn(String),
|
||||||
workspace_root: &AbsPathBuf,
|
working_directory: &AbsPathBuf,
|
||||||
) -> io::Result<Vec<WorkspaceBuildScripts>> {
|
) -> io::Result<Vec<WorkspaceBuildScripts>> {
|
||||||
assert_eq!(config.invocation_strategy, InvocationStrategy::Once);
|
assert_eq!(config.invocation_strategy, InvocationStrategy::Once);
|
||||||
|
|
||||||
let current_dir = workspace_root;
|
|
||||||
let cmd = Self::build_command(
|
let cmd = Self::build_command(
|
||||||
config,
|
config,
|
||||||
&Default::default(),
|
&Default::default(),
|
||||||
// This is not gonna be used anyways, so just construct a dummy here
|
// This is not gonna be used anyways, so just construct a dummy here
|
||||||
&ManifestPath::try_from(workspace_root.clone()).unwrap(),
|
&ManifestPath::try_from(working_directory.clone()).unwrap(),
|
||||||
current_dir,
|
working_directory,
|
||||||
&Sysroot::empty(),
|
&Sysroot::empty(),
|
||||||
)?;
|
)?;
|
||||||
// NB: Cargo.toml could have been modified between `cargo metadata` and
|
// NB: Cargo.toml could have been modified between `cargo metadata` and
|
||||||
|
|
|
@ -459,7 +459,7 @@ impl ProjectWorkspace {
|
||||||
workspaces: &[ProjectWorkspace],
|
workspaces: &[ProjectWorkspace],
|
||||||
config: &CargoConfig,
|
config: &CargoConfig,
|
||||||
progress: &dyn Fn(String),
|
progress: &dyn Fn(String),
|
||||||
workspace_root: &AbsPathBuf,
|
working_directory: &AbsPathBuf,
|
||||||
) -> Vec<anyhow::Result<WorkspaceBuildScripts>> {
|
) -> Vec<anyhow::Result<WorkspaceBuildScripts>> {
|
||||||
if matches!(config.invocation_strategy, InvocationStrategy::PerWorkspace)
|
if matches!(config.invocation_strategy, InvocationStrategy::PerWorkspace)
|
||||||
|| config.run_build_script_command.is_none()
|
|| config.run_build_script_command.is_none()
|
||||||
|
@ -474,9 +474,12 @@ impl ProjectWorkspace {
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let outputs =
|
let outputs = &mut match WorkspaceBuildScripts::run_once(
|
||||||
&mut match WorkspaceBuildScripts::run_once(config, &cargo_ws, progress, workspace_root)
|
config,
|
||||||
{
|
&cargo_ws,
|
||||||
|
progress,
|
||||||
|
working_directory,
|
||||||
|
) {
|
||||||
Ok(it) => Ok(it.into_iter()),
|
Ok(it) => Ok(it.into_iter()),
|
||||||
// io::Error is not Clone?
|
// io::Error is not Clone?
|
||||||
Err(e) => Err(sync::Arc::new(e)),
|
Err(e) => Err(sync::Arc::new(e)),
|
||||||
|
|
|
@ -81,8 +81,10 @@ config_data! {
|
||||||
/// Run build scripts (`build.rs`) for more precise code analysis.
|
/// Run build scripts (`build.rs`) for more precise code analysis.
|
||||||
cargo_buildScripts_enable: bool = true,
|
cargo_buildScripts_enable: bool = true,
|
||||||
/// Specifies the invocation strategy to use when running the build scripts command.
|
/// Specifies the invocation strategy to use when running the build scripts command.
|
||||||
/// If `per_workspace` is set, the command will be executed for each workspace.
|
/// If `per_workspace` is set, the command will be executed for each Rust workspace with the
|
||||||
/// If `once` is set, the command will be executed once.
|
/// workspace as the working directory.
|
||||||
|
/// If `once` is set, the command will be executed once with the opened project as the
|
||||||
|
/// working directory.
|
||||||
/// This config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`
|
/// This config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`
|
||||||
/// is set.
|
/// is set.
|
||||||
cargo_buildScripts_invocationStrategy: InvocationStrategy = InvocationStrategy::PerWorkspace,
|
cargo_buildScripts_invocationStrategy: InvocationStrategy = InvocationStrategy::PerWorkspace,
|
||||||
|
@ -3154,8 +3156,8 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["per_workspace", "once"],
|
"enum": ["per_workspace", "once"],
|
||||||
"enumDescriptions": [
|
"enumDescriptions": [
|
||||||
"The command will be executed for each workspace.",
|
"The command will be executed for each Rust workspace with the workspace as the working directory.",
|
||||||
"The command will be executed once."
|
"The command will be executed once with the opened project as the working directory."
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"Option<CheckOnSaveTargets>" => set! {
|
"Option<CheckOnSaveTargets>" => set! {
|
||||||
|
|
|
@ -49,8 +49,10 @@ Run build scripts (`build.rs`) for more precise code analysis.
|
||||||
+
|
+
|
||||||
--
|
--
|
||||||
Specifies the invocation strategy to use when running the build scripts command.
|
Specifies the invocation strategy to use when running the build scripts command.
|
||||||
If `per_workspace` is set, the command will be executed for each workspace.
|
If `per_workspace` is set, the command will be executed for each Rust workspace with the
|
||||||
If `once` is set, the command will be executed once.
|
workspace as the working directory.
|
||||||
|
If `once` is set, the command will be executed once with the opened project as the
|
||||||
|
working directory.
|
||||||
This config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`
|
This config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`
|
||||||
is set.
|
is set.
|
||||||
--
|
--
|
||||||
|
|
|
@ -667,7 +667,7 @@
|
||||||
"title": "cargo",
|
"title": "cargo",
|
||||||
"properties": {
|
"properties": {
|
||||||
"rust-analyzer.cargo.buildScripts.invocationStrategy": {
|
"rust-analyzer.cargo.buildScripts.invocationStrategy": {
|
||||||
"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.",
|
"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.",
|
||||||
"default": "per_workspace",
|
"default": "per_workspace",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
|
@ -675,8 +675,8 @@
|
||||||
"once"
|
"once"
|
||||||
],
|
],
|
||||||
"enumDescriptions": [
|
"enumDescriptions": [
|
||||||
"The command will be executed for each workspace.",
|
"The command will be executed for each Rust workspace with the workspace as the working directory.",
|
||||||
"The command will be executed once."
|
"The command will be executed once with the opened project as the working directory."
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -959,8 +959,8 @@
|
||||||
"once"
|
"once"
|
||||||
],
|
],
|
||||||
"enumDescriptions": [
|
"enumDescriptions": [
|
||||||
"The command will be executed for each workspace.",
|
"The command will be executed for each Rust workspace with the workspace as the working directory.",
|
||||||
"The command will be executed once."
|
"The command will be executed once with the opened project as the working directory."
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue