From c1c8eb3d558bedf6588179ae93737bd6afe5a368 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Sun, 6 Aug 2023 00:47:15 +0100 Subject: build: allow disabling snapshots for dev (#20048) Closes #19399 (running without snapshots at all was suggested as an alternative solution). Adds a `__runtime_js_sources` pseudo-private feature to load extension JS sources at runtime for faster development, instead of building and loading snapshots or embedding sources in the binary. Will only work in a development environment obviously. Try running `cargo test --features __runtime_js_sources integration::node_unit_tests::os_test`. Then break some behaviour in `ext/node/polyfills/os.ts` e.g. make `function cpus() {}` return an empty array, and run it again. Fix and then run again. No more build time in between. --- ext/node/build.rs | 7 +++++++ ext/node/lib.rs | 7 +------ 2 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 ext/node/build.rs (limited to 'ext') diff --git a/ext/node/build.rs b/ext/node/build.rs new file mode 100644 index 000000000..778f2da17 --- /dev/null +++ b/ext/node/build.rs @@ -0,0 +1,7 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. + +use std::env; + +fn main() { + println!("cargo:rustc-env=TARGET={}", env::var("TARGET").unwrap()); +} diff --git a/ext/node/lib.rs b/ext/node/lib.rs index 40330dc5b..e2643a84f 100644 --- a/ext/node/lib.rs +++ b/ext/node/lib.rs @@ -132,12 +132,7 @@ pub static NODE_ENV_VAR_ALLOWLIST: Lazy> = Lazy::new(|| { #[op] fn op_node_build_os() -> String { - std::env::var("TARGET") - .unwrap() - .split('-') - .nth(2) - .unwrap() - .to_string() + env!("TARGET").split('-').nth(2).unwrap().to_string() } #[op(fast)] -- cgit v1.2.3