From a19fea918f12249d2c248eb013b3b8baf2eacb84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 14 Dec 2020 18:42:40 +0100 Subject: Revert "build: Factor out common code into core/build_util.rs (#8756)" (#8763) This reverts commit 502c77aad969fe8557aaf6d56432f94450c26a2a. --- core/build_util.rs | 44 -------------------------------------------- core/lib.rs | 1 - 2 files changed, 45 deletions(-) delete mode 100644 core/build_util.rs (limited to 'core') diff --git a/core/build_util.rs b/core/build_util.rs deleted file mode 100644 index 04a0f870b..000000000 --- a/core/build_util.rs +++ /dev/null @@ -1,44 +0,0 @@ -//! Helper module used in cli/build.rs and runtime/build.rs -use crate::JsRuntime; -use std::path::Path; -use std::path::PathBuf; - -pub fn create_snapshot( - mut js_runtime: JsRuntime, - snapshot_path: &Path, - files: Vec, -) { - // TODO(nayeemrmn): https://github.com/rust-lang/cargo/issues/3946 to get the - // workspace root. - let display_root = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap(); - for file in files { - println!("cargo:rerun-if-changed={}", file.display()); - let display_path = file.strip_prefix(display_root).unwrap(); - let display_path_str = display_path.display().to_string(); - js_runtime - .execute( - &("deno:".to_string() + &display_path_str.replace('\\', "/")), - &std::fs::read_to_string(&file).unwrap(), - ) - .unwrap(); - } - - let snapshot = js_runtime.snapshot(); - let snapshot_slice: &[u8] = &*snapshot; - println!("Snapshot size: {}", snapshot_slice.len()); - std::fs::write(&snapshot_path, snapshot_slice).unwrap(); - println!("Snapshot written to: {} ", snapshot_path.display()); -} - -pub fn get_js_files(d: &Path) -> Vec { - let mut js_files = std::fs::read_dir(d) - .unwrap() - .map(|dir_entry| { - let file = dir_entry.unwrap(); - d.join(file.path()) - }) - .filter(|path| path.extension().unwrap_or_default() == "js") - .collect::>(); - js_files.sort(); - js_files -} diff --git a/core/lib.rs b/core/lib.rs index 0f7c23c26..5846ad99d 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -8,7 +8,6 @@ extern crate log; mod async_cancel; mod async_cell; mod bindings; -pub mod build_util; pub mod error; mod flags; mod gotham_state; -- cgit v1.2.3