1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

chore: improve build times for ext/ changes (#13927)

This commit is contained in:
Divy Srivastava 2022-03-14 09:08:54 +05:30 committed by GitHub
parent 6a635345ef
commit 4e3ed37037
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 29 additions and 131 deletions

View file

@ -244,7 +244,7 @@ jobs:
~/.cargo/registry/index ~/.cargo/registry/index
~/.cargo/registry/cache ~/.cargo/registry/cache
~/.cargo/git/db ~/.cargo/git/db
key: 5-cargo-home-${{ matrix.os }}-${{ hashFiles('Cargo.lock') }} key: 7-cargo-home-${{ matrix.os }}-${{ hashFiles('Cargo.lock') }}
# In main branch, always creates fresh cache # In main branch, always creates fresh cache
- name: Cache build output (main) - name: Cache build output (main)
@ -260,7 +260,7 @@ jobs:
!./target/*/*.zip !./target/*/*.zip
!./target/*/*.tar.gz !./target/*/*.tar.gz
key: | key: |
5-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ github.sha }} 7-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ github.sha }}
# Restore cache from the latest 'main' branch build. # Restore cache from the latest 'main' branch build.
- name: Cache build output (PR) - name: Cache build output (PR)
@ -276,7 +276,7 @@ jobs:
!./target/*/*.tar.gz !./target/*/*.tar.gz
key: never_saved key: never_saved
restore-keys: | restore-keys: |
5-cargo-target-${{ matrix.os }}-${{ matrix.profile }}- 7-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-
# Don't save cache after building PRs or branches other than 'main'. # Don't save cache after building PRs or branches other than 'main'.
- name: Skip save cache (PR) - name: Skip save cache (PR)

10
Cargo.lock generated
View file

@ -749,22 +749,12 @@ dependencies = [
"data-url", "data-url",
"deno_ast", "deno_ast",
"deno_bench_util", "deno_bench_util",
"deno_broadcast_channel",
"deno_console",
"deno_core", "deno_core",
"deno_crypto",
"deno_doc", "deno_doc",
"deno_fetch",
"deno_graph", "deno_graph",
"deno_lint", "deno_lint",
"deno_net",
"deno_runtime", "deno_runtime",
"deno_task_shell", "deno_task_shell",
"deno_url",
"deno_web",
"deno_webgpu",
"deno_websocket",
"deno_webstorage",
"dissimilar", "dissimilar",
"dprint-plugin-json", "dprint-plugin-json",
"dprint-plugin-markdown", "dprint-plugin-markdown",

View file

@ -25,20 +25,10 @@ harness = false
path = "./bench/lsp_bench_standalone.rs" path = "./bench/lsp_bench_standalone.rs"
[build-dependencies] [build-dependencies]
deno_broadcast_channel = { version = "0.34.0", path = "../ext/broadcast_channel" }
deno_console = { version = "0.40.0", path = "../ext/console" }
deno_core = { version = "0.122.0", path = "../core" } deno_core = { version = "0.122.0", path = "../core" }
deno_crypto = { version = "0.54.0", path = "../ext/crypto" }
deno_fetch = { version = "0.63.0", path = "../ext/fetch" }
deno_net = { version = "0.32.0", path = "../ext/net" }
deno_url = { version = "0.40.0", path = "../ext/url" }
deno_web = { version = "0.71.0", path = "../ext/web" }
deno_webgpu = { version = "0.41.0", path = "../ext/webgpu" }
deno_websocket = { version = "0.45.0", path = "../ext/websocket" }
deno_webstorage = { version = "0.35.0", path = "../ext/webstorage" }
regex = "=1.5.5" regex = "=1.5.5"
serde = { version = "=1.0.133", features = ["derive"] } serde = { version = "=1.0.133", features = ["derive"] }
zstd = '=0.9.2' zstd = { version = '=0.9.2', default-features = false }
[target.'cfg(windows)'.build-dependencies] [target.'cfg(windows)'.build-dependencies]
winapi = "=0.3.9" winapi = "=0.3.9"
@ -98,7 +88,7 @@ tokio-util = "=0.6.9"
typed-arena = "2.0.1" typed-arena = "2.0.1"
uuid = { version = "=0.8.2", features = ["v4", "serde"] } uuid = { version = "=0.8.2", features = ["v4", "serde"] }
walkdir = "=2.3.2" walkdir = "=2.3.2"
zstd = '=0.9.2' zstd = { version = '=0.9.2', default-features = false }
[target.'cfg(windows)'.dependencies] [target.'cfg(windows)'.dependencies]
fwdansi = "=1.1.0" fwdansi = "=1.1.0"

View file

@ -78,22 +78,33 @@ fn create_compiler_snapshot(
) { ) {
// libs that are being provided by op crates. // libs that are being provided by op crates.
let mut op_crate_libs = HashMap::new(); let mut op_crate_libs = HashMap::new();
op_crate_libs.insert("deno.console", deno_console::get_declaration()); op_crate_libs.insert("deno.console", "../ext/console/lib.deno_console.d.ts");
op_crate_libs.insert("deno.url", deno_url::get_declaration()); op_crate_libs.insert("deno.url", "../ext/url/lib.deno_url.d.ts");
op_crate_libs.insert("deno.web", deno_web::get_declaration()); op_crate_libs.insert("deno.web", "../ext/web/lib.deno_web.d.ts");
op_crate_libs.insert("deno.fetch", deno_fetch::get_declaration()); op_crate_libs.insert("deno.fetch", "../ext/fetch/lib.deno_fetch.d.ts");
op_crate_libs.insert("deno.webgpu", deno_webgpu_get_declaration()); op_crate_libs.insert("deno.webgpu", "./dts/lib.deno_webgpu.d.ts");
op_crate_libs.insert("deno.websocket", deno_websocket::get_declaration()); op_crate_libs
op_crate_libs.insert("deno.webstorage", deno_webstorage::get_declaration()); .insert("deno.websocket", "../ext/websocket/lib.deno_websocket.d.ts");
op_crate_libs.insert("deno.crypto", deno_crypto::get_declaration()); op_crate_libs.insert(
"deno.webstorage",
"../ext/webstorage/lib.deno_webstorage.d.ts",
);
op_crate_libs.insert("deno.crypto", "../ext/crypto/lib.deno_crypto.d.ts");
op_crate_libs.insert( op_crate_libs.insert(
"deno.broadcast_channel", "deno.broadcast_channel",
deno_broadcast_channel::get_declaration(), "../ext/broadcast_channel/lib.deno_broadcast_channel.d.ts",
); );
op_crate_libs.insert("deno.net", deno_net::get_declaration()); op_crate_libs.insert("deno.net", "../ext/net/lib.deno_net.d.ts");
// ensure we invalidate the build properly. // ensure we invalidate the build properly.
for (_, path) in op_crate_libs.iter() { for (name, path) in op_crate_libs.iter() {
let path = std::fs::canonicalize(path)
.map_err(|e| format!("{}: {}", path, e))
.unwrap();
println!(
"cargo:rustc-env={}_LIB_PATH={}",
name.replace('.', "_").to_uppercase(),
path.display()
);
println!("cargo:rerun-if-changed={}", path.display()); println!("cargo:rerun-if-changed={}", path.display());
} }
@ -220,7 +231,7 @@ fn create_compiler_snapshot(
// if it comes from an op crate, we were supplied with the path to the // if it comes from an op crate, we were supplied with the path to the
// file. // file.
let path = if let Some(op_crate_lib) = op_crate_libs.get(lib) { let path = if let Some(op_crate_lib) = op_crate_libs.get(lib) {
op_crate_lib.clone() PathBuf::from(op_crate_lib).canonicalize().unwrap()
// otherwise we are will generate the path ourself // otherwise we are will generate the path ourself
} else { } else {
path_dts.join(format!("lib.{}.d.ts", lib)) path_dts.join(format!("lib.{}.d.ts", lib))
@ -247,7 +258,6 @@ fn create_compiler_snapshot(
}), }),
); );
js_runtime.sync_ops_cache(); js_runtime.sync_ops_cache();
create_snapshot(js_runtime, snapshot_path, files); create_snapshot(js_runtime, snapshot_path, files);
} }
@ -300,54 +310,12 @@ fn main() {
println!("cargo:rustc-env=DENO_CANARY={}", c); println!("cargo:rustc-env=DENO_CANARY={}", c);
} }
println!("cargo:rerun-if-env-changed=DENO_CANARY"); println!("cargo:rerun-if-env-changed=DENO_CANARY");
println!("cargo:rustc-env=GIT_COMMIT_HASH={}", git_commit_hash()); println!("cargo:rustc-env=GIT_COMMIT_HASH={}", git_commit_hash());
println!("cargo:rerun-if-env-changed=GIT_COMMIT_HASH"); println!("cargo:rerun-if-env-changed=GIT_COMMIT_HASH");
println!("cargo:rustc-env=TS_VERSION={}", ts_version()); println!("cargo:rustc-env=TS_VERSION={}", ts_version());
println!("cargo:rerun-if-env-changed=TS_VERSION"); println!("cargo:rerun-if-env-changed=TS_VERSION");
println!(
"cargo:rustc-env=DENO_CONSOLE_LIB_PATH={}",
deno_console::get_declaration().display()
);
println!(
"cargo:rustc-env=DENO_URL_LIB_PATH={}",
deno_url::get_declaration().display()
);
println!(
"cargo:rustc-env=DENO_WEB_LIB_PATH={}",
deno_web::get_declaration().display()
);
println!(
"cargo:rustc-env=DENO_FETCH_LIB_PATH={}",
deno_fetch::get_declaration().display()
);
println!(
"cargo:rustc-env=DENO_WEBGPU_LIB_PATH={}",
deno_webgpu_get_declaration().display()
);
println!(
"cargo:rustc-env=DENO_WEBSOCKET_LIB_PATH={}",
deno_websocket::get_declaration().display()
);
println!(
"cargo:rustc-env=DENO_WEBSTORAGE_LIB_PATH={}",
deno_webstorage::get_declaration().display()
);
println!(
"cargo:rustc-env=DENO_CRYPTO_LIB_PATH={}",
deno_crypto::get_declaration().display()
);
println!(
"cargo:rustc-env=DENO_BROADCAST_CHANNEL_LIB_PATH={}",
deno_broadcast_channel::get_declaration().display()
);
println!(
"cargo:rustc-env=DENO_NET_LIB_PATH={}",
deno_net::get_declaration().display()
);
println!("cargo:rustc-env=TARGET={}", env::var("TARGET").unwrap()); println!("cargo:rustc-env=TARGET={}", env::var("TARGET").unwrap());
println!("cargo:rustc-env=PROFILE={}", env::var("PROFILE").unwrap()); println!("cargo:rustc-env=PROFILE={}", env::var("PROFILE").unwrap());
@ -372,11 +340,6 @@ fn main() {
} }
} }
fn deno_webgpu_get_declaration() -> PathBuf {
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
manifest_dir.join("dts").join("lib.deno_webgpu.d.ts")
}
fn get_js_files(d: &str) -> Vec<PathBuf> { fn get_js_files(d: &str) -> Vec<PathBuf> {
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
let mut js_files = std::fs::read_dir(d) let mut js_files = std::fs::read_dir(d)

View file

@ -16,7 +16,6 @@ use deno_core::Resource;
use deno_core::ResourceId; use deno_core::ResourceId;
use deno_core::ZeroCopyBuf; use deno_core::ZeroCopyBuf;
use std::cell::RefCell; use std::cell::RefCell;
use std::path::PathBuf;
use std::rc::Rc; use std::rc::Rc;
#[async_trait] #[async_trait]
@ -121,8 +120,3 @@ pub fn init<BC: BroadcastChannel + 'static>(
}) })
.build() .build()
} }
pub fn get_declaration() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("lib.deno_broadcast_channel.d.ts")
}

View file

@ -2,7 +2,6 @@
use deno_core::include_js_files; use deno_core::include_js_files;
use deno_core::Extension; use deno_core::Extension;
use std::path::PathBuf;
pub fn init() -> Extension { pub fn init() -> Extension {
Extension::builder() Extension::builder()
@ -13,7 +12,3 @@ pub fn init() -> Extension {
)) ))
.build() .build()
} }
pub fn get_declaration() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_console.d.ts")
}

View file

@ -53,7 +53,6 @@ use sha2::Sha256;
use sha2::Sha384; use sha2::Sha384;
use sha2::Sha512; use sha2::Sha512;
use std::convert::TryFrom; use std::convert::TryFrom;
use std::path::PathBuf;
pub use rand; // Re-export rand pub use rand; // Re-export rand
@ -890,7 +889,3 @@ pub fn op_crypto_unwrap_key(
_ => Err(type_error("Unsupported algorithm")), _ => Err(type_error("Unsupported algorithm")),
} }
} }
pub fn get_declaration() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_crypto.d.ts")
}

View file

@ -45,7 +45,6 @@ use std::borrow::Cow;
use std::cell::RefCell; use std::cell::RefCell;
use std::convert::From; use std::convert::From;
use std::path::Path; use std::path::Path;
use std::path::PathBuf;
use std::pin::Pin; use std::pin::Pin;
use std::rc::Rc; use std::rc::Rc;
use tokio::io::AsyncReadExt; use tokio::io::AsyncReadExt;
@ -174,10 +173,6 @@ pub trait FetchPermissions {
fn check_read(&mut self, _p: &Path) -> Result<(), AnyError>; fn check_read(&mut self, _p: &Path) -> Result<(), AnyError>;
} }
pub fn get_declaration() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_fetch.d.ts")
}
#[derive(Deserialize)] #[derive(Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct FetchArgs { pub struct FetchArgs {

View file

@ -14,7 +14,6 @@ use deno_core::OpState;
use deno_tls::rustls::RootCertStore; use deno_tls::rustls::RootCertStore;
use std::cell::RefCell; use std::cell::RefCell;
use std::path::Path; use std::path::Path;
use std::path::PathBuf;
use std::rc::Rc; use std::rc::Rc;
pub trait NetPermissions { pub trait NetPermissions {
@ -61,10 +60,6 @@ pub fn check_unstable2(state: &Rc<RefCell<OpState>>, api_name: &str) {
state.borrow::<UnstableChecker>().check_unstable(api_name) state.borrow::<UnstableChecker>().check_unstable(api_name)
} }
pub fn get_declaration() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_net.d.ts")
}
#[derive(Clone)] #[derive(Clone)]
pub struct DefaultTlsOptions { pub struct DefaultTlsOptions {
pub root_cert_store: Option<RootCertStore>, pub root_cert_store: Option<RootCertStore>,

View file

@ -14,7 +14,6 @@ use deno_core::url::Url;
use deno_core::Extension; use deno_core::Extension;
use deno_core::ZeroCopyBuf; use deno_core::ZeroCopyBuf;
use std::panic::catch_unwind; use std::panic::catch_unwind;
use std::path::PathBuf;
use crate::urlpattern::op_urlpattern_parse; use crate::urlpattern::op_urlpattern_parse;
use crate::urlpattern::op_urlpattern_process_match_input; use crate::urlpattern::op_urlpattern_process_match_input;
@ -197,7 +196,3 @@ pub fn op_url_stringify_search_params(
.finish(); .finish();
Ok(search) Ok(search)
} }
pub fn get_declaration() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_url.d.ts")
}

View file

@ -27,7 +27,6 @@ use serde::Serialize;
use std::borrow::Cow; use std::borrow::Cow;
use std::cell::RefCell; use std::cell::RefCell;
use std::fmt; use std::fmt;
use std::path::PathBuf;
use std::usize; use std::usize;
use crate::blob::op_blob_create_object_url; use crate::blob::op_blob_create_object_url;
@ -393,10 +392,6 @@ fn op_encoding_encode_into(
}) })
} }
pub fn get_declaration() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_web.d.ts")
}
#[derive(Debug)] #[derive(Debug)]
pub struct DomExceptionQuotaExceededError { pub struct DomExceptionQuotaExceededError {
pub msg: String, pub msg: String,

View file

@ -33,7 +33,6 @@ use std::borrow::Cow;
use std::cell::RefCell; use std::cell::RefCell;
use std::convert::TryFrom; use std::convert::TryFrom;
use std::fmt; use std::fmt;
use std::path::PathBuf;
use std::rc::Rc; use std::rc::Rc;
use std::sync::Arc; use std::sync::Arc;
use tokio::net::TcpStream; use tokio::net::TcpStream;
@ -507,10 +506,6 @@ pub fn init<P: WebSocketPermissions + 'static>(
.build() .build()
} }
pub fn get_declaration() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_websocket.d.ts")
}
#[derive(Debug)] #[derive(Debug)]
pub struct DomExceptionNetworkError { pub struct DomExceptionNetworkError {
pub msg: String, pub msg: String,

View file

@ -46,10 +46,6 @@ pub fn init(origin_storage_dir: Option<PathBuf>) -> Extension {
.build() .build()
} }
pub fn get_declaration() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_webstorage.d.ts")
}
struct LocalStorage(Connection); struct LocalStorage(Connection);
struct SessionStorage(Connection); struct SessionStorage(Connection);