|
1 | 1 | // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. |
2 | | -use deno::{Script, StartupData}; |
| 2 | +#[cfg(feature = "no-snapshot-init")] |
| 3 | +use deno::Script; |
3 | 4 |
|
| 5 | +use deno::StartupData; |
| 6 | + |
| 7 | +#[cfg(feature = "no-snapshot-init")] |
| 8 | +pub fn deno_isolate_init() -> StartupData<'static> { |
| 9 | + debug!("Deno isolate init without snapshots."); |
| 10 | + #[cfg(not(feature = "check-only"))] |
| 11 | + let source = |
| 12 | + include_str!(concat!(env!("GN_OUT_DIR"), "/gen/cli/bundle/main.js")); |
| 13 | + #[cfg(feature = "check-only")] |
| 14 | + let source = ""; |
| 15 | + |
| 16 | + StartupData::Script(Script { |
| 17 | + filename: "gen/cli/bundle/main.js", |
| 18 | + source, |
| 19 | + }) |
| 20 | +} |
| 21 | + |
| 22 | +#[cfg(not(feature = "no-snapshot-init"))] |
4 | 23 | pub fn deno_isolate_init() -> StartupData<'static> { |
5 | | - if cfg!(feature = "no-snapshot-init") { |
6 | | - debug!("Deno isolate init without snapshots."); |
7 | | - #[cfg(not(feature = "check-only"))] |
8 | | - let source_bytes = |
9 | | - include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/cli/bundle/main.js")); |
10 | | - #[cfg(feature = "check-only")] |
11 | | - let source_bytes = b""; |
12 | | - |
13 | | - StartupData::Script(Script { |
14 | | - filename: "gen/cli/bundle/main.js", |
15 | | - source: std::str::from_utf8(&source_bytes[..]).unwrap(), |
16 | | - }) |
17 | | - } else { |
18 | | - debug!("Deno isolate init with snapshots."); |
19 | | - #[cfg(not(any(feature = "check-only", feature = "no-snapshot-init")))] |
20 | | - let data = |
21 | | - include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/cli/snapshot_deno.bin")); |
22 | | - #[cfg(any(feature = "check-only", feature = "no-snapshot-init"))] |
23 | | - let data = b""; |
24 | | - |
25 | | - StartupData::Snapshot(data) |
26 | | - } |
| 24 | + debug!("Deno isolate init with snapshots."); |
| 25 | + #[cfg(not(feature = "check-only"))] |
| 26 | + let data = |
| 27 | + include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/cli/snapshot_deno.bin")); |
| 28 | + #[cfg(feature = "check-only")] |
| 29 | + let data = b""; |
| 30 | + |
| 31 | + StartupData::Snapshot(data) |
27 | 32 | } |
28 | 33 |
|
| 34 | +#[cfg(feature = "no-snapshot-init")] |
29 | 35 | pub fn compiler_isolate_init() -> StartupData<'static> { |
30 | | - if cfg!(feature = "no-snapshot-init") { |
31 | | - debug!("Compiler isolate init without snapshots."); |
32 | | - #[cfg(not(feature = "check-only"))] |
33 | | - let source_bytes = include_bytes!(concat!( |
34 | | - env!("GN_OUT_DIR"), |
35 | | - "/gen/cli/bundle/compiler.js" |
36 | | - )); |
37 | | - #[cfg(feature = "check-only")] |
38 | | - let source_bytes = b""; |
39 | | - |
40 | | - StartupData::Script(Script { |
41 | | - filename: "gen/cli/bundle/compiler.js", |
42 | | - source: std::str::from_utf8(&source_bytes[..]).unwrap(), |
43 | | - }) |
44 | | - } else { |
45 | | - debug!("Deno isolate init with snapshots."); |
46 | | - #[cfg(not(any(feature = "check-only", feature = "no-snapshot-init")))] |
47 | | - let data = include_bytes!(concat!( |
48 | | - env!("GN_OUT_DIR"), |
49 | | - "/gen/cli/snapshot_compiler.bin" |
50 | | - )); |
51 | | - #[cfg(any(feature = "check-only", feature = "no-snapshot-init"))] |
52 | | - let data = b""; |
53 | | - |
54 | | - StartupData::Snapshot(data) |
55 | | - } |
| 36 | + debug!("Compiler isolate init without snapshots."); |
| 37 | + #[cfg(not(feature = "check-only"))] |
| 38 | + let source = |
| 39 | + include_str!(concat!(env!("GN_OUT_DIR"), "/gen/cli/bundle/compiler.js")); |
| 40 | + #[cfg(feature = "check-only")] |
| 41 | + let source = ""; |
| 42 | + |
| 43 | + StartupData::Script(Script { |
| 44 | + filename: "gen/cli/bundle/compiler.js", |
| 45 | + source, |
| 46 | + }) |
| 47 | +} |
| 48 | + |
| 49 | +#[cfg(not(feature = "no-snapshot-init"))] |
| 50 | +pub fn compiler_isolate_init() -> StartupData<'static> { |
| 51 | + debug!("Deno isolate init with snapshots."); |
| 52 | + #[cfg(not(feature = "check-only"))] |
| 53 | + let data = include_bytes!(concat!( |
| 54 | + env!("GN_OUT_DIR"), |
| 55 | + "/gen/cli/snapshot_compiler.bin" |
| 56 | + )); |
| 57 | + #[cfg(feature = "check-only")] |
| 58 | + let data = b""; |
| 59 | + |
| 60 | + StartupData::Snapshot(data) |
56 | 61 | } |
0 commit comments