diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-09-02 17:07:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-02 17:07:11 -0400 |
commit | d43b43ca781b025b9a6a54827ea3ef193972ef24 (patch) | |
tree | 84173b6a653802a41c23145dd3b2048d9075e2a4 /core/snapshot_creator.rs | |
parent | 56508f113d9fe61ffcce4cbbb85e3d6961888e1d (diff) |
Refactor snapshot build (#2825)
Instead of using core/snapshot_creator.rs, instead two crates are
introduced which allow building the snapshot during build.rs.
Rollup is removed and replaced with our own bundler. This removes
the Node build dependency. Modules in //js now use Deno-style imports
with file extensions, rather than Node style extensionless imports.
This improves incremental build time when changes are made to //js files
by about 40 seconds.
Diffstat (limited to 'core/snapshot_creator.rs')
-rw-r--r-- | core/snapshot_creator.rs | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/core/snapshot_creator.rs b/core/snapshot_creator.rs deleted file mode 100644 index 1d43b9174..000000000 --- a/core/snapshot_creator.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Note: This is a nearly identical rewrite of core/libdeno/snapshot_creator.cc -// but in Rust. -// -// This snapshot program is considered "basic" because the code being -// snapshotted cannot call ops. - -extern crate deno; - -use deno::js_check; -use deno::Isolate; -use deno::StartupData; -use std::env; -use std::io::Write; - -fn main() { - let args: Vec<String> = env::args().collect(); - // NOTE: `--help` arg will display V8 help and exit - let args = deno::v8_set_flags(args); - - let (snapshot_out_bin, js_filename) = if args.len() == 3 { - (args[1].clone(), args[2].clone()) - } else { - eprintln!("Usage: snapshot_creator <out_filename> <js_filename>"); - std::process::exit(1); - }; - - let js_source = - std::fs::read(&js_filename).expect("couldn't read js_filename"); - let js_source_str = std::str::from_utf8(&js_source).unwrap(); - - let will_snapshot = true; - let mut isolate = Isolate::new(StartupData::None, will_snapshot); - - js_check(isolate.execute(&js_filename, js_source_str)); - - let snapshot = isolate.snapshot().expect("error snapshotting"); - - let mut out_file = std::fs::File::create(snapshot_out_bin).unwrap(); - let snapshot_slice = - unsafe { std::slice::from_raw_parts(snapshot.data_ptr, snapshot.data_len) }; - out_file - .write_all(snapshot_slice) - .expect("Failed to write snapshot file"); -} |