diff options
-rw-r--r-- | BUILD.gn | 7 | ||||
-rw-r--r-- | build.rs | 21 |
2 files changed, 27 insertions, 1 deletions
@@ -18,6 +18,13 @@ group("default") { ] } +# Set of targets that need to be built for `cargo check` to succeed. +group("cargo_check_deps") { + deps = [ + ":msg_rs", + ] +} + config("deno_config") { include_dirs = [ "third_party/v8" ] # This allows us to v8/src/base/ libraries. configs = [ "third_party/v8:external_config" ] @@ -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"); |