Open joepio opened 1 month ago
Skipping the check in build.rs
works, lowers refresh time from 7 seconds to about 2 seconds.
// Check if we're likely running in a check-like context
let opt_level = std::env::var("OPT_LEVEL").unwrap_or_else(|_| "0".to_string());
let profile = std::env::var("PROFILE").unwrap_or_else(|_| "release".to_string());
let is_check_like = profile == "debug" && opt_level == "0";
if is_check_like {
println!("cargo:rerun-if-changed=build.rs");
// Skip the heavy logic
println!("Skipping build.rs logic for cargo check/clippy.");
} else {
const BROWSER_ROOT: &str = "../browser/";
EDIT: No, this does not a good solutions, it too often maps to true
(e.g. when running cargo run
the first time and there are no assets). I still need a different solution.
New solution:
println!("cargo:rerun-if-changed=build.rs");
// Env is set in .vscode/settings.json when rust-analyzer runs
let is_rust_analyzer = !std::env::var("IS_RUST_ANALYZER")
.unwrap_or_default()
.is_empty();
if is_rust_analyzer {
p!("Skipping build.rs logic to keep cargo check/clippy fast. If you see this message in some other context: the JS build not run!");
} else {
const BROWSER_ROOT: &str = "../browser/";
Running
build.rs
has some steps that are sometimes unnecessarily slow. This is particularly annoying because rust-analyzer seems to be slowed down due to this.