2019-03-04 18:09:35 -05:00
|
|
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2019-03-14 19:17:52 -04:00
|
|
|
use deno_core::deno_buf;
|
2019-03-25 17:43:31 -04:00
|
|
|
use deno_core::{Script, StartupData};
|
2019-03-04 18:09:35 -05:00
|
|
|
|
2019-03-18 20:03:37 -04:00
|
|
|
pub fn deno_isolate_init() -> StartupData {
|
2019-03-05 17:26:59 -05:00
|
|
|
if cfg!(feature = "no-snapshot-init") {
|
|
|
|
debug!("Deno isolate init without snapshots.");
|
|
|
|
#[cfg(not(feature = "check-only"))]
|
|
|
|
let source_bytes =
|
2019-03-30 14:45:36 -04:00
|
|
|
include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/cli/bundle/main.js"));
|
2019-03-05 17:26:59 -05:00
|
|
|
#[cfg(feature = "check-only")]
|
|
|
|
let source_bytes = vec![];
|
2019-03-04 18:09:35 -05:00
|
|
|
|
2019-03-25 17:43:31 -04:00
|
|
|
StartupData::Script(Script {
|
2019-03-30 14:45:36 -04:00
|
|
|
filename: "gen/cli/bundle/main.js".to_string(),
|
2019-03-28 08:09:19 -04:00
|
|
|
source: std::str::from_utf8(&source_bytes[..]).unwrap().to_string(),
|
2019-03-18 20:03:37 -04:00
|
|
|
})
|
2019-03-05 17:26:59 -05:00
|
|
|
} else {
|
|
|
|
debug!("Deno isolate init with snapshots.");
|
2019-03-08 13:11:05 -05:00
|
|
|
#[cfg(not(any(feature = "check-only", feature = "no-snapshot-init")))]
|
2019-03-05 17:26:59 -05:00
|
|
|
let data =
|
2019-03-30 14:45:36 -04:00
|
|
|
include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/cli/snapshot_deno.bin"));
|
2019-03-08 13:11:05 -05:00
|
|
|
#[cfg(any(feature = "check-only", feature = "no-snapshot-init"))]
|
2019-03-05 17:26:59 -05:00
|
|
|
let data = vec![];
|
2019-03-04 18:09:35 -05:00
|
|
|
|
2019-03-05 17:26:59 -05:00
|
|
|
unsafe {
|
2019-03-18 20:03:37 -04:00
|
|
|
StartupData::Snapshot(deno_buf::from_raw_parts(data.as_ptr(), data.len()))
|
2019-03-04 18:09:35 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-18 20:03:37 -04:00
|
|
|
pub fn compiler_isolate_init() -> StartupData {
|
2019-03-05 17:26:59 -05:00
|
|
|
if cfg!(feature = "no-snapshot-init") {
|
|
|
|
debug!("Deno isolate init without snapshots.");
|
|
|
|
#[cfg(not(feature = "check-only"))]
|
2019-03-30 14:45:36 -04:00
|
|
|
let source_bytes = include_bytes!(concat!(
|
|
|
|
env!("GN_OUT_DIR"),
|
|
|
|
"/gen/cli/bundle/compiler.js"
|
|
|
|
));
|
2019-03-05 17:26:59 -05:00
|
|
|
#[cfg(feature = "check-only")]
|
|
|
|
let source_bytes = vec![];
|
2019-03-04 18:09:35 -05:00
|
|
|
|
2019-03-25 17:43:31 -04:00
|
|
|
StartupData::Script(Script {
|
2019-03-30 14:45:36 -04:00
|
|
|
filename: "gen/cli/bundle/compiler.js".to_string(),
|
2019-03-28 08:09:19 -04:00
|
|
|
source: std::str::from_utf8(&source_bytes[..]).unwrap().to_string(),
|
2019-03-18 20:03:37 -04:00
|
|
|
})
|
2019-03-05 17:26:59 -05:00
|
|
|
} else {
|
|
|
|
debug!("Deno isolate init with snapshots.");
|
2019-03-08 13:11:05 -05:00
|
|
|
#[cfg(not(any(feature = "check-only", feature = "no-snapshot-init")))]
|
2019-03-30 14:45:36 -04:00
|
|
|
let data = include_bytes!(concat!(
|
|
|
|
env!("GN_OUT_DIR"),
|
|
|
|
"/gen/cli/snapshot_compiler.bin"
|
|
|
|
));
|
2019-03-08 13:11:05 -05:00
|
|
|
#[cfg(any(feature = "check-only", feature = "no-snapshot-init"))]
|
2019-03-05 17:26:59 -05:00
|
|
|
let data = vec![];
|
2019-03-04 18:09:35 -05:00
|
|
|
|
2019-03-05 17:26:59 -05:00
|
|
|
unsafe {
|
2019-03-18 20:03:37 -04:00
|
|
|
StartupData::Snapshot(deno_buf::from_raw_parts(data.as_ptr(), data.len()))
|
2019-03-04 18:09:35 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|