summaryrefslogtreecommitdiff
path: root/src/startup_data.rs
diff options
context:
space:
mode:
authorandy finch <andyfinch7@gmail.com>2019-03-18 20:03:37 -0400
committerRyan Dahl <ry@tinyclouds.org>2019-03-18 20:03:37 -0400
commitcdfd32dd74d6286afe99fb5400e3dc0e9f2cec49 (patch)
treee8daa342c70ee472de28158d5448ed2078d0d9e9 /src/startup_data.rs
parent34a2aa4de6cfe334cf0d26620d244d5c66a976a4 (diff)
Re-implement init scripts in core (#1958)
Re-enables arm64 CI test
Diffstat (limited to 'src/startup_data.rs')
-rw-r--r--src/startup_data.rs57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/startup_data.rs b/src/startup_data.rs
new file mode 100644
index 000000000..29ae4db7d
--- /dev/null
+++ b/src/startup_data.rs
@@ -0,0 +1,57 @@
+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
+use deno_core::deno_buf;
+use deno_core::{StartupData, StartupScript};
+
+pub fn deno_isolate_init() -> StartupData {
+ 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/bundle/main.js"));
+ #[cfg(feature = "check-only")]
+ let source_bytes = vec![];
+
+ StartupData::Script(StartupScript {
+ filename: "gen/bundle/main.js".to_string(),
+ source: std::str::from_utf8(source_bytes).unwrap().to_string(),
+ })
+ } 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/snapshot_deno.bin"));
+ #[cfg(any(feature = "check-only", feature = "no-snapshot-init"))]
+ let data = vec![];
+
+ unsafe {
+ StartupData::Snapshot(deno_buf::from_raw_parts(data.as_ptr(), data.len()))
+ }
+ }
+}
+
+pub fn compiler_isolate_init() -> StartupData {
+ 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/bundle/compiler.js"));
+ #[cfg(feature = "check-only")]
+ let source_bytes = vec![];
+
+ StartupData::Script(StartupScript {
+ filename: "gen/bundle/compiler.js".to_string(),
+ source: std::str::from_utf8(source_bytes).unwrap().to_string(),
+ })
+ } 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/snapshot_compiler.bin"));
+ #[cfg(any(feature = "check-only", feature = "no-snapshot-init"))]
+ let data = vec![];
+
+ unsafe {
+ StartupData::Snapshot(deno_buf::from_raw_parts(data.as_ptr(), data.len()))
+ }
+ }
+}