From 7f3902b41f68edddbc50b01ea52c697827d8516f Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Wed, 15 Nov 2023 04:25:55 -0800 Subject: perf: static bootstrap options in snapshot (#21213) Closes https://github.com/denoland/deno/issues/21133 --- cli/build.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'cli/build.rs') diff --git a/cli/build.rs b/cli/build.rs index 6260c1c61..1480bb5c7 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -352,9 +352,18 @@ fn create_cli_snapshot(snapshot_path: PathBuf) -> CreateSnapshotOutput { use deno_runtime::deno_cron::local::LocalCronHandler; use deno_runtime::deno_http::DefaultHttpPropertyExtractor; use deno_runtime::deno_kv::sqlite::SqliteDbHandler; + use deno_runtime::ops::bootstrap::SnapshotOptions; use deno_runtime::permissions::PermissionsContainer; use std::sync::Arc; + fn deno_version() -> String { + if env::var("DENO_CANARY").is_ok() { + format!("{}+{}", env!("CARGO_PKG_VERSION"), git_commit_hash()) + } else { + env!("CARGO_PKG_VERSION").to_string() + } + } + // NOTE(bartlomieju): ordering is important here, keep it in sync with // `runtime/worker.rs`, `runtime/web_worker.rs` and `runtime/build.rs`! let fs = Arc::new(deno_fs::RealFs); @@ -405,7 +414,14 @@ fn create_cli_snapshot(snapshot_path: PathBuf) -> CreateSnapshotOutput { deno_runtime::ops::signal::deno_signal::init_ops(), deno_runtime::ops::tty::deno_tty::init_ops(), deno_runtime::ops::http::deno_http_runtime::init_ops(), - deno_runtime::ops::bootstrap::deno_bootstrap::init_ops(), + deno_runtime::ops::bootstrap::deno_bootstrap::init_ops(Some( + SnapshotOptions { + deno_version: deno_version(), + ts_version: ts::version(), + v8_version: deno_core::v8_version(), + target: std::env::var("TARGET").unwrap(), + }, + )), cli::init_ops_and_esm(), // NOTE: This needs to be init_ops_and_esm! ]; -- cgit v1.2.3