use deno_core::snapshot_util;
use deno_runtime::{permissions::Permissions, *};
use std::{env, path::PathBuf};
fn main() {
if env::var("HOST").unwrap() != env::var("TARGET").unwrap() {
panic!("Cross-compiling is not supported");
}
let evo_snapshot_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("EVO_SNAPSHOT.bin");
create_evo_snapshot(evo_snapshot_path.clone());
println!(
"cargo:rustc-env=EVO_SNAPSHOT_PATH={}",
evo_snapshot_path.to_str().unwrap()
);
}
fn create_evo_snapshot(snapshot_path: PathBuf) {
// from github.com/denoland/deno/blob/master/cli/build.rs (formatted + comments removed)
let extensions = vec![
deno_webidl::init(),
deno_console::init(),
deno_url::init(),
deno_tls::init(),
deno_web::init::<Permissions>(deno_web::BlobStore::default(), Default::default()),
deno_fetch::init::<Permissions>(Default::default()),
deno_cache::init::<deno_cache::SqliteBackedCache>(None),
deno_websocket::init::<Permissions>("".to_owned(), None, None),
deno_webstorage::init(None),
deno_crypto::init(None),
deno_webgpu::init(false),
deno_broadcast_channel::init(
deno_broadcast_channel::InMemoryBroadcastChannel::default(),
false,
),
deno_node::init::<Permissions>(None),
deno_ffi::init::<Permissions>(false),
deno_net::init::<Permissions>(None, false, None),
deno_napi::init::<Permissions>(false),
deno_http::init(),
deno_flash::init::<Permissions>(false),
];
snapshot_util::create_snapshot(snapshot_util::CreateSnapshotOptions {
cargo_manifest_dir: env!("CARGO_MANIFEST_DIR"),
snapshot_path,
startup_snapshot: Some(js::deno_isolate_init()),
extensions,
extensions_with_js: vec![],
additional_files: vec![js::get_99_main()],
compression_cb: None,
});
}