patch: only rerun build scripts when saved.
Signed-off-by: 蔡略 <cailue@bupt.edu.cn>
This commit is contained in:
parent
b21d68cd2a
commit
ad27b6e053
@ -105,7 +105,7 @@ config_data! {
|
|||||||
/// ```
|
/// ```
|
||||||
/// .
|
/// .
|
||||||
cargo_buildScripts_overrideCommand: Option<Vec<String>> = "null",
|
cargo_buildScripts_overrideCommand: Option<Vec<String>> = "null",
|
||||||
/// rerun proc-macros building/build-scripts running when proc-macro
|
/// Rerun proc-macros building/build-scripts running when proc-macro
|
||||||
/// or build-script sources change and are saved.
|
/// or build-script sources change and are saved.
|
||||||
cargo_buildScripts_rebuildOnSave: bool = "false",
|
cargo_buildScripts_rebuildOnSave: bool = "false",
|
||||||
/// Use `RUSTC_WRAPPER=rust-analyzer` when running build scripts to
|
/// Use `RUSTC_WRAPPER=rust-analyzer` when running build scripts to
|
||||||
|
@ -351,10 +351,6 @@ impl GlobalState {
|
|||||||
|
|
||||||
crates.iter().any(|&krate| crate_graph[krate].is_proc_macro)
|
crates.iter().any(|&krate| crate_graph[krate].is_proc_macro)
|
||||||
});
|
});
|
||||||
if self.proc_macro_changed && self.config.script_rebuild_on_save() {
|
|
||||||
self.fetch_build_data_queue
|
|
||||||
.request_op(format!("proc-macro or build script source changed"), ())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
true
|
true
|
||||||
|
@ -130,6 +130,13 @@ pub(crate) fn handle_did_save_text_document(
|
|||||||
state: &mut GlobalState,
|
state: &mut GlobalState,
|
||||||
params: DidSaveTextDocumentParams,
|
params: DidSaveTextDocumentParams,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
|
if state.config.script_rebuild_on_save() && state.proc_macro_changed {
|
||||||
|
// reset the flag
|
||||||
|
state.proc_macro_changed = false;
|
||||||
|
// rebuild the proc macros
|
||||||
|
state.fetch_build_data_queue.request_op(format!("ScriptRebuildOnSave"), ());
|
||||||
|
}
|
||||||
|
|
||||||
if let Ok(vfs_path) = from_proto::vfs_path(¶ms.text_document.uri) {
|
if let Ok(vfs_path) = from_proto::vfs_path(¶ms.text_document.uri) {
|
||||||
// Re-fetch workspaces if a workspace related file has changed
|
// Re-fetch workspaces if a workspace related file has changed
|
||||||
if let Some(abs_path) = vfs_path.as_path() {
|
if let Some(abs_path) = vfs_path.as_path() {
|
||||||
|
@ -71,6 +71,12 @@ cargo check --quiet --workspace --message-format=json --all-targets
|
|||||||
```
|
```
|
||||||
.
|
.
|
||||||
--
|
--
|
||||||
|
[[rust-analyzer.cargo.buildScripts.rebuildOnSave]]rust-analyzer.cargo.buildScripts.rebuildOnSave (default: `false`)::
|
||||||
|
+
|
||||||
|
--
|
||||||
|
Rerun proc-macros building/build-scripts running when proc-macro
|
||||||
|
or build-script sources change and are saved.
|
||||||
|
--
|
||||||
[[rust-analyzer.cargo.buildScripts.useRustcWrapper]]rust-analyzer.cargo.buildScripts.useRustcWrapper (default: `true`)::
|
[[rust-analyzer.cargo.buildScripts.useRustcWrapper]]rust-analyzer.cargo.buildScripts.useRustcWrapper (default: `true`)::
|
||||||
+
|
+
|
||||||
--
|
--
|
||||||
|
@ -586,6 +586,11 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"rust-analyzer.cargo.buildScripts.rebuildOnSave": {
|
||||||
|
"markdownDescription": "Rerun proc-macros building/build-scripts running when proc-macro\nor build-script sources change and are saved.",
|
||||||
|
"default": false,
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
"rust-analyzer.cargo.buildScripts.useRustcWrapper": {
|
"rust-analyzer.cargo.buildScripts.useRustcWrapper": {
|
||||||
"markdownDescription": "Use `RUSTC_WRAPPER=rust-analyzer` when running build scripts to\navoid checking unnecessary things.",
|
"markdownDescription": "Use `RUSTC_WRAPPER=rust-analyzer` when running build scripts to\navoid checking unnecessary things.",
|
||||||
"default": true,
|
"default": true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user