diff options
Diffstat (limited to 'build.rs')
-rw-r--r-- | build.rs | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -7,12 +7,31 @@ // TODO Combine DENO_BUILD_PATH and OUT_DIR. use std::env; +use std::path::PathBuf; use std::process::Command; fn main() { let mode = env::var("PROFILE").unwrap(); let deno_build_path = env::var("DENO_BUILD_PATH").unwrap(); + // Detect if we're being invoked by the rust language server (RLS). + // Unfortunately we can't detect whether we're being run by `cargo check`. + let check_only = env::var_os("CARGO") + .map(PathBuf::from) + .as_ref() + .and_then(|p| p.file_stem()) + .and_then(|f| f.to_str()) + .map(|s| s.starts_with("rls")) + .unwrap_or(false); + + // If we're being invoked by the RLS, build only the targets that are needed + // for `cargo check` to succeed. + let gn_target = if check_only { + "cargo_check_deps" + } else { + "deno_deps" + }; + let status = Command::new("python") .env("DENO_BUILD_PATH", &deno_build_path) .env("DENO_BUILD_MODE", &mode) @@ -31,7 +50,7 @@ fn main() { .env("DENO_BUILD_PATH", &deno_build_path) .env("DENO_BUILD_MODE", &mode) .arg("./tools/build.py") - .arg("deno_deps") + .arg(gn_target) .arg("-v") .status() .expect("build.py failed"); |