1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00
denoland-deno/cli/startup_data.rs

57 lines
1.8 KiB
Rust
Raw Normal View History

// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
2019-03-30 19:30:40 -04:00
use deno::{Script, StartupData};
pub fn deno_isolate_init() -> StartupData<'static> {
if cfg!(feature = "no-snapshot-init") {
debug!("Deno isolate init without snapshots.");
#[cfg(not(feature = "check-only"))]
let source_bytes =
include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/cli/bundle/main.js"));
#[cfg(feature = "check-only")]
let source_bytes = b"";
StartupData::Script(Script {
filename: "gen/cli/bundle/main.js",
source: std::str::from_utf8(&source_bytes[..]).unwrap(),
})
} 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")))]
let data =
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"))]
let data = b"";
StartupData::Snapshot(data)
}
}
pub fn compiler_isolate_init() -> StartupData<'static> {
if cfg!(feature = "no-snapshot-init") {
debug!("Compiler isolate init without snapshots.");
#[cfg(not(feature = "check-only"))]
let source_bytes = include_bytes!(concat!(
env!("GN_OUT_DIR"),
"/gen/cli/bundle/compiler.js"
));
#[cfg(feature = "check-only")]
let source_bytes = b"";
StartupData::Script(Script {
filename: "gen/cli/bundle/compiler.js",
source: std::str::from_utf8(&source_bytes[..]).unwrap(),
})
} 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")))]
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"))]
let data = b"";
StartupData::Snapshot(data)
}
}