mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
cargo: build only necessary Ninja targets when invoked by RLS
This commit is contained in:
parent
b73b651612
commit
67944f298c
2 changed files with 27 additions and 1 deletions
7
BUILD.gn
7
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" ]
|
||||
|
|
21
build.rs
21
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");
|
||||
|
|
Loading…
Add table
Reference in a new issue