Skip to content

Commit

Permalink
refactor: deno_runtime crate (denoland#8640)
Browse files Browse the repository at this point in the history
This commit moves Deno JS runtime, ops, permissions and
inspector implementation to new "deno_runtime" crate located
in "runtime/" directory.

Details in "runtime/README.md".

Co-authored-by: Ryan Dahl <[email protected]>
  • Loading branch information
bartlomieju and ry committed Dec 13, 2020
1 parent 84ef9bd commit 2e74f16
Show file tree
Hide file tree
Showing 99 changed files with 1,127 additions and 458 deletions.
48 changes: 43 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
members = [
"cli",
"core",
"runtime",
"test_plugin",
"test_util",
"op_crates/fetch",
Expand Down
11 changes: 2 additions & 9 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ harness = false
path = "./bench/main.rs"

[build-dependencies]
deno_crypto = { path = "../op_crates/crypto", version = "0.4.0" }
deno_core = { path = "../core", version = "0.70.0" }
deno_web = { path = "../op_crates/web", version = "0.21.0" }
deno_fetch = { path = "../op_crates/fetch", version = "0.13.0" }
deno_web = { path = "../op_crates/web", version = "0.21.0" }
regex = "1.3.9"
serde = { version = "1.0.116", features = ["derive"] }

Expand All @@ -33,11 +32,9 @@ winapi = "0.3.9"

[dependencies]
deno_core = { path = "../core", version = "0.70.0" }
deno_crypto = { path = "../op_crates/crypto", version = "0.4.0" }
deno_doc = "0.1.18"
deno_fetch = { path = "../op_crates/fetch", version = "0.13.0" }
deno_lint = "0.2.13"
deno_web = { path = "../op_crates/web", version = "0.21.0" }
deno_runtime = { path = "../runtime", version = "0.1.0" }

atty = "0.2.14"
base64 = "0.12.3"
Expand All @@ -46,7 +43,6 @@ byteorder = "1.3.4"
clap = "2.33.3"
crossbeam-channel = "0.5.0"
dissimilar = "1.0.2"
dlopen = "0.1.8"
dprint-plugin-typescript = "0.35.1"
encoding_rs = "0.8.24"
env_logger = "0.7.1"
Expand All @@ -72,7 +68,6 @@ sourcemap = "6.0.1"
swc_bundler = "0.17.6"
swc_common = { version = "0.10.7", features = ["sourcemap"] }
swc_ecmascript = { version = "0.15.0", features = ["codegen", "dep_graph", "parser", "react", "transforms", "visit"] }
sys-info = "0.7.0"
tempfile = "3.1.0"
termcolor = "1.1.0"
tokio = { version = "0.2.22", features = ["full"] }
Expand All @@ -82,8 +77,6 @@ tokio-tungstenite = "0.11.0"
uuid = { version = "0.8.1", features = ["v4"] }
walkdir = "2.3.1"
warp = { version = "0.2.5", features = ["tls"] }
webpki = "0.21.3"
webpki-roots = "=0.19.0" # Pinned to v0.19.0 to match 'reqwest'.

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.9", features = ["knownfolders", "mswsock", "objbase", "shlobj", "tlhelp32", "winbase", "winerror", "winsock2"] }
Expand Down
17 changes: 2 additions & 15 deletions cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ use std::env;
use std::path::Path;
use std::path::PathBuf;

// TODO(bartlomieju): this module contains a lot of duplicated
// logic with `runtime/build.rs`, factor out to `deno_core`.
fn create_snapshot(
mut js_runtime: JsRuntime,
snapshot_path: &Path,
files: Vec<PathBuf>,
) {
deno_web::init(&mut js_runtime);
deno_fetch::init(&mut js_runtime);
deno_crypto::init(&mut js_runtime);
// 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();
Expand All @@ -43,14 +42,6 @@ fn create_snapshot(
println!("Snapshot written to: {} ", snapshot_path.display());
}

fn create_runtime_snapshot(snapshot_path: &Path, files: Vec<PathBuf>) {
let js_runtime = JsRuntime::new(RuntimeOptions {
will_snapshot: true,
..Default::default()
});
create_snapshot(js_runtime, snapshot_path, files);
}

#[derive(Debug, Deserialize)]
struct LoadArgs {
/// The fully qualified specifier that should be loaded.
Expand Down Expand Up @@ -265,12 +256,8 @@ fn main() {
let o = PathBuf::from(env::var_os("OUT_DIR").unwrap());

// Main snapshot
let runtime_snapshot_path = o.join("CLI_SNAPSHOT.bin");
let compiler_snapshot_path = o.join("COMPILER_SNAPSHOT.bin");

let js_files = get_js_files("rt");
create_runtime_snapshot(&runtime_snapshot_path, js_files);

let js_files = get_js_files("tsc");
create_compiler_snapshot(&compiler_snapshot_path, js_files, &c);

Expand Down
Loading

0 comments on commit 2e74f16

Please sign in to comment.