forked from denoland/deno
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Separate Snapshot and Script StartupData functions based on cfg "no-snapshot-init" 2. Replace deprecated Once::ONCE_INIT with Once::new (rust-lang/rust#61757) 3. Elide lifetime 4. Fix typos
- Loading branch information
Showing
2 changed files
with
60 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,61 @@ | ||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. | ||
use deno::{Script, StartupData}; | ||
#[cfg(feature = "no-snapshot-init")] | ||
use deno::Script; | ||
|
||
use deno::StartupData; | ||
|
||
#[cfg(feature = "no-snapshot-init")] | ||
pub fn deno_isolate_init() -> StartupData<'static> { | ||
debug!("Deno isolate init without snapshots."); | ||
#[cfg(not(feature = "check-only"))] | ||
let source = | ||
include_str!(concat!(env!("GN_OUT_DIR"), "/gen/cli/bundle/main.js")); | ||
#[cfg(feature = "check-only")] | ||
let source = ""; | ||
|
||
StartupData::Script(Script { | ||
filename: "gen/cli/bundle/main.js", | ||
source, | ||
}) | ||
} | ||
|
||
#[cfg(not(feature = "no-snapshot-init"))] | ||
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."); | ||
#[cfg(not(any(feature = "check-only", feature = "no-snapshot-init")))] | ||
let data = | ||
include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/cli/snapshot_deno.bin")); | ||
#[cfg(any(feature = "check-only", feature = "no-snapshot-init"))] | ||
let data = b""; | ||
|
||
StartupData::Snapshot(data) | ||
} | ||
debug!("Deno isolate init with snapshots."); | ||
#[cfg(not(feature = "check-only"))] | ||
let data = | ||
include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/cli/snapshot_deno.bin")); | ||
#[cfg(feature = "check-only")] | ||
let data = b""; | ||
|
||
StartupData::Snapshot(data) | ||
} | ||
|
||
#[cfg(feature = "no-snapshot-init")] | ||
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."); | ||
#[cfg(not(any(feature = "check-only", feature = "no-snapshot-init")))] | ||
let data = include_bytes!(concat!( | ||
env!("GN_OUT_DIR"), | ||
"/gen/cli/snapshot_compiler.bin" | ||
)); | ||
#[cfg(any(feature = "check-only", feature = "no-snapshot-init"))] | ||
let data = b""; | ||
|
||
StartupData::Snapshot(data) | ||
} | ||
debug!("Compiler isolate init without snapshots."); | ||
#[cfg(not(feature = "check-only"))] | ||
let source = | ||
include_str!(concat!(env!("GN_OUT_DIR"), "/gen/cli/bundle/compiler.js")); | ||
#[cfg(feature = "check-only")] | ||
let source = ""; | ||
|
||
StartupData::Script(Script { | ||
filename: "gen/cli/bundle/compiler.js", | ||
source, | ||
}) | ||
} | ||
|
||
#[cfg(not(feature = "no-snapshot-init"))] | ||
pub fn compiler_isolate_init() -> StartupData<'static> { | ||
debug!("Deno isolate init with snapshots."); | ||
#[cfg(not(feature = "check-only"))] | ||
let data = include_bytes!(concat!( | ||
env!("GN_OUT_DIR"), | ||
"/gen/cli/snapshot_compiler.bin" | ||
)); | ||
#[cfg(feature = "check-only")] | ||
let data = b""; | ||
|
||
StartupData::Snapshot(data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters