summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD.gn7
-rw-r--r--build.rs21
2 files changed, 27 insertions, 1 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 039909893..9e6c7abd0 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -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" ]
diff --git a/build.rs b/build.rs
index 489f9f9d2..351a00cf7 100644
--- a/build.rs
+++ b/build.rs
@@ -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");