From 0bd141c78dd0b64cd965f7f39039b0cc1306c5fb Mon Sep 17 00:00:00 2001 From: Aaron O'Mullan Date: Wed, 22 Sep 2021 12:02:55 +0200 Subject: [PATCH] Default to linking against release v8 builds (#783) Unless $V8_FORCE_DEBUG=true to speedup CI for main deno repo --- README.md | 7 +++++++ build.rs | 22 ++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c8970d2d..d5bbb8cf 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,13 @@ from github to get the static lib. To disable this build using the When making changes to rusty_v8 itself, it should be tested by build from source. The CI always builds from source. +## The `V8_FORCE_DEBUG` environment variable + +By default `rusty_v8` will link against release builds of `v8`, if you want to +use a debug build of `v8` set `V8_FORCE_DEBUG=true`. + +We default to release builds of `v8` due to performance & CI reasons in `deno`. + ## The `RUSTY_V8_MIRROR` environment variable Tells the build script where to get binary builds from. Understands diff --git a/build.rs b/build.rs index 3dcd0a82..9b2d04ff 100644 --- a/build.rs +++ b/build.rs @@ -206,14 +206,24 @@ fn static_lib_url() -> String { env::var("RUSTY_V8_MIRROR").unwrap_or_else(|_| default_base.into()); let version = env::var("CARGO_PKG_VERSION").unwrap(); let target = env::var("TARGET").unwrap(); + + // Note: we always use the release build on windows. if cfg!(target_os = "windows") { - // Note: we always use the release build on windows. - format!("{}/v{}/rusty_v8_release_{}.lib", base, version, target) - } else { - let profile = env::var("PROFILE").unwrap(); - assert!(profile == "release" || profile == "debug"); - format!("{}/v{}/librusty_v8_{}_{}.a", base, version, profile, target) + return format!("{}/v{}/rusty_v8_release_{}.lib", base, version, target); } + // Use v8 in release mode unless $V8_FORCE_DEBUG=true + let profile = match env_bool("V8_FORCE_DEBUG") { + true => "debug", + _ => "release", + }; + format!("{}/v{}/librusty_v8_{}_{}.a", base, version, profile, target) +} + +fn env_bool(key: &str) -> bool { + matches!( + env::var(key).unwrap_or_default().as_str(), + "true" | "1" | "yes" + ) } fn static_lib_name() -> &'static str {