1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-10 16:11:13 -05:00

fix snapshots in gn build (#1886)

Bug introduced in 75fe80d5a4
This commit is contained in:
andy finch 2019-03-05 17:26:59 -05:00 committed by Ryan Dahl
parent ee29ed79a7
commit da004fb6c8
2 changed files with 59 additions and 63 deletions

View file

@ -76,11 +76,15 @@ fn main() {
} }
} }
// Enable snapshots for x64 builds // If target_arch != host_arch disable snapshots since we are cross compiling.
if env::var("CARGO_CFG_TARGET_ARCH").unwrap() == "x86_64" { if env::var("CARGO_CFG_TARGET_ARCH").unwrap().as_str() != env::var("HOST")
// Not related to v8_use_snapshot .unwrap()
// This only enables using pregenerated snapshots for isolate init .as_str()
println!("cargo:rustc-cfg=feature=\"use-snapshot-init\""); .split("-")
.collect::<Vec<&str>>()[0]
{
// no-snapshot-init is not related to v8_use_snapshots
println!("cargo:rustc-cfg=feature=\"no-snapshot-init\"");
} }
if !gn_out_path.join("build.ninja").exists() { if !gn_out_path.join("build.ninja").exists() {

View file

@ -12,22 +12,11 @@ pub struct IsolateInit {
} }
pub fn deno_isolate_init() -> IsolateInit { pub fn deno_isolate_init() -> IsolateInit {
if cfg!(not(feature = "check-only")) { if cfg!(feature = "no-snapshot-init") {
if cfg!(feature = "use-snapshot-init") { debug!("Deno isolate init without snapshots.");
let data =
include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/snapshot_deno.bin"));
unsafe {
IsolateInit {
snapshot: Some(deno_buf::from_raw_parts(data.as_ptr(), data.len())),
init_script: None,
}
}
} else {
#[cfg(not(feature = "check-only"))] #[cfg(not(feature = "check-only"))]
let source_bytes = let source_bytes =
include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/bundle/main.js")); include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/bundle/main.js"));
#[cfg(feature = "check-only")] #[cfg(feature = "check-only")]
let source_bytes = vec![]; let source_bytes = vec![];
@ -38,22 +27,13 @@ pub fn deno_isolate_init() -> IsolateInit {
source: std::str::from_utf8(source_bytes).unwrap().to_string(), source: std::str::from_utf8(source_bytes).unwrap().to_string(),
}), }),
} }
}
} else { } else {
IsolateInit { debug!("Deno isolate init with snapshots.");
snapshot: None, #[cfg(not(feature = "check-only"))]
init_script: None, let data =
} include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/snapshot_deno.bin"));
} #[cfg(feature = "check-only")]
} let data = vec![];
pub fn compiler_isolate_init() -> IsolateInit {
if cfg!(not(feature = "check-only")) {
if cfg!(feature = "use-snapshot-init") {
let data = include_bytes!(concat!(
env!("GN_OUT_DIR"),
"/gen/snapshot_compiler.bin"
));
unsafe { unsafe {
IsolateInit { IsolateInit {
@ -61,11 +41,15 @@ pub fn compiler_isolate_init() -> IsolateInit {
init_script: None, init_script: None,
} }
} }
} else { }
}
pub fn compiler_isolate_init() -> IsolateInit {
if cfg!(feature = "no-snapshot-init") {
debug!("Deno isolate init without snapshots.");
#[cfg(not(feature = "check-only"))] #[cfg(not(feature = "check-only"))]
let source_bytes = let source_bytes =
include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/bundle/compiler.js")); include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/bundle/compiler.js"));
#[cfg(feature = "check-only")] #[cfg(feature = "check-only")]
let source_bytes = vec![]; let source_bytes = vec![];
@ -76,11 +60,19 @@ pub fn compiler_isolate_init() -> IsolateInit {
source: std::str::from_utf8(source_bytes).unwrap().to_string(), source: std::str::from_utf8(source_bytes).unwrap().to_string(),
}), }),
} }
}
} else { } else {
debug!("Deno isolate init with snapshots.");
#[cfg(not(feature = "check-only"))]
let data =
include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/snapshot_compiler.bin"));
#[cfg(feature = "check-only")]
let data = vec![];
unsafe {
IsolateInit { IsolateInit {
snapshot: None, snapshot: Some(deno_buf::from_raw_parts(data.as_ptr(), data.len())),
init_script: None, init_script: None,
} }
} }
}
} }