feat: add proc-macro rebuild on save option

Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
This commit is contained in:
ClSlaid 2023-12-04 21:08:29 +08:00
parent e402c494b7
commit b21d68cd2a
No known key found for this signature in database
GPG Key ID: E0A5F564C51C056E
2 changed files with 11 additions and 0 deletions

View File

@ -105,6 +105,9 @@ config_data! {
/// ```
/// .
cargo_buildScripts_overrideCommand: Option<Vec<String>> = "null",
/// rerun proc-macros building/build-scripts running when proc-macro
/// or build-script sources change and are saved.
cargo_buildScripts_rebuildOnSave: bool = "false",
/// Use `RUSTC_WRAPPER=rust-analyzer` when running build scripts to
/// avoid checking unnecessary things.
cargo_buildScripts_useRustcWrapper: bool = "true",
@ -1368,6 +1371,10 @@ impl Config {
self.data.checkOnSave
}
pub fn script_rebuild_on_save(&self) -> bool {
self.data.cargo_buildScripts_rebuildOnSave
}
pub fn runnables(&self) -> RunnablesConfig {
RunnablesConfig {
override_cargo: self.data.runnables_command.clone(),

View File

@ -351,6 +351,10 @@ impl GlobalState {
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