diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/BUILD.gn | 150 | ||||
-rw-r--r-- | cli/Cargo.toml | 2 | ||||
-rw-r--r-- | cli/assets.rs | 53 | ||||
-rw-r--r-- | cli/build.rs | 15 | ||||
-rw-r--r-- | cli/deno.gni | 65 | ||||
-rw-r--r-- | cli/main.rs | 1 | ||||
-rw-r--r-- | cli/source_maps.rs | 26 | ||||
-rw-r--r-- | cli/startup_data.rs | 10 |
8 files changed, 26 insertions, 296 deletions
diff --git a/cli/BUILD.gn b/cli/BUILD.gn index fd89d1941..ce18eb297 100644 --- a/cli/BUILD.gn +++ b/cli/BUILD.gn @@ -1,9 +1,6 @@ # Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import("//build/toolchain/cc_wrapper.gni") import("//build_extra/rust/rust.gni") -import("//third_party/v8/gni/snapshot_toolchain.gni") -import("//third_party/v8/gni/v8.gni") -import("deno.gni") main_extern = [ { @@ -12,6 +9,16 @@ main_extern = [ crate_type = "rlib" }, { + label = "../cli_snapshots:deno_cli_snapshots" + crate_name = "deno_cli_snapshots" + crate_type = "rlib" + }, + { + label = "../deno_typescript:deno_typescript" + crate_name = "deno_typescript" + crate_type = "rlib" + }, + { label = "$rust_build:serde_derive" crate_name = "serde_derive" crate_type = "proc_macro" @@ -61,109 +68,6 @@ if (is_posix) { main_extern_rlib += [ "nix" ] } -ts_sources = [ - "../js/base64.ts", - "../js/blob.ts", - "../js/body.ts", - "../js/buffer.ts", - "../js/build.ts", - "../js/chmod.ts", - "../js/chown.ts", - "../js/colors.ts", - "../js/compiler.ts", - "../js/console.ts", - "../js/console_table.ts", - "../js/copy_file.ts", - "../js/core.ts", - "../js/custom_event.ts", - "../js/deno.ts", - "../js/diagnostics.ts", - "../js/dir.ts", - "../js/dispatch.ts", - "../js/dispatch_json.ts", - "../js/dispatch_minimal.ts", - "../js/dom_file.ts", - "../js/dom_types.ts", - "../js/dom_util.ts", - "../js/error_stack.ts", - "../js/errors.ts", - "../js/event.ts", - "../js/event_target.ts", - "../js/fetch.ts", - "../js/file_info.ts", - "../js/files.ts", - "../js/form_data.ts", - "../js/format_error.ts", - "../js/get_random_values.ts", - "../js/globals.ts", - "../js/headers.ts", - "../js/io.ts", - "../js/lib.deno_runtime.d.ts", - "../js/lib.web_assembly.d.ts", - "../js/link.ts", - "../js/location.ts", - "../js/main.ts", - "../js/make_temp_dir.ts", - "../js/metrics.ts", - "../js/mkdir.ts", - "../js/mock_builtin.js", - "../js/net.ts", - "../js/os.ts", - "../js/performance.ts", - "../js/permissions.ts", - "../js/plugins.d.ts", - "../js/process.ts", - "../js/read_dir.ts", - "../js/read_file.ts", - "../js/read_link.ts", - "../js/remove.ts", - "../js/rename.ts", - "../js/repl.ts", - "../js/request.ts", - "../js/resources.ts", - "../js/stat.ts", - "../js/symlink.ts", - "../js/text_encoding.ts", - "../js/timers.ts", - "../js/truncate.ts", - "../js/type_directives.ts", - "../js/types.ts", - "../js/url.ts", - "../js/url_search_params.ts", - "../js/util.ts", - "../js/utime.ts", - "../js/version.ts", - "../js/window.ts", - "../js/workers.ts", - "../js/write_file.ts", - "../js/xeval.ts", - "../tsconfig.json", - - # Listing package.json and yarn.lock as sources ensures the bundle is rebuilt - # when npm packages are added/removed or their contents changes. - "../package.json", - "../third_party/yarn.lock", -] - -# When Cargo is driving the build, GN/Ninja are used to produce these non-Rust -# targets. Cargo handles all Rust source files and the final linking step. -group("deno_deps") { - deps = [ - ":snapshot_compiler", - ":snapshot_deno", - ] -} - -# Optimized dependencies for cross compiled builds. -# This can be removed once we get snapshots into cross compiled builds. -group("deno_deps_cross") { - testonly = true - deps = [ - ":compiler_bundle", - ":main_bundle", - ] -} - # Reads the cargo info from Cargo.toml deno_cargo_info = exec_script("../build_extra/rust/get_cargo_info.py", [ rebase_path("Cargo.toml", root_build_dir) ], @@ -173,9 +77,6 @@ rust_executable("deno") { source_root = "main.rs" extern = main_extern extern_rlib = main_extern_rlib - deps = [ - ":deno_deps", - ] # Extract version from Cargo.toml # TODO integrate this into rust.gni by allowing the rust_executable template @@ -190,9 +91,6 @@ rust_test("cli_test") { source_root = "main.rs" extern = main_extern extern_rlib = main_extern_rlib - deps = [ - ":deno_deps", - ] # Extract version from Cargo.toml inputs = [ @@ -200,31 +98,3 @@ rust_test("cli_test") { ] env = [ "CARGO_PKG_VERSION=${deno_cargo_info.version}" ] } - -bundle("main_bundle") { - sources = ts_sources - out_dir = "$target_gen_dir/bundle/" - out_name = "main" -} - -bundle("compiler_bundle") { - sources = ts_sources - out_dir = "$target_gen_dir/bundle/" - out_name = "compiler" -} - -# Generates $target_gen_dir/snapshot_deno.bin -snapshot("snapshot_deno") { - source_root = "$target_gen_dir/bundle/main.js" - deps = [ - ":main_bundle", - ] -} - -# Generates $target_gen_dir/snapshot_compiler.bin -snapshot("snapshot_compiler") { - source_root = "$target_gen_dir/bundle/compiler.js" - deps = [ - ":compiler_bundle", - ] -} diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 6fac49e3d..02d241003 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -52,6 +52,8 @@ tokio-rustls = "0.10.0" tokio-threadpool = "0.1.15" url = "1.7.2" utime = "0.2.1" +deno_cli_snapshots = { path = "../cli_snapshots" } +deno_typescript = { path = "../deno_typescript" } [target.'cfg(windows)'.dependencies] winapi = "0.3.7" diff --git a/cli/assets.rs b/cli/assets.rs index c7bfc484d..a0abca115 100644 --- a/cli/assets.rs +++ b/cli/assets.rs @@ -1,59 +1,8 @@ static DENO_RUNTIME: &str = include_str!("../js/lib.deno_runtime.d.ts"); -macro_rules! inc { - ($e:expr) => { - Some(include_str!(concat!( - "../third_party/node_modules/typescript/lib/", - $e - ))) - }; -} - pub fn get_source_code(name: &str) -> Option<&'static str> { match name { "lib.deno_runtime.d.ts" => Some(DENO_RUNTIME), - "lib.es2015.collection.d.ts" => inc!("lib.es2015.collection.d.ts"), - "lib.es2015.core.d.ts" => inc!("lib.es2015.core.d.ts"), - "lib.es2015.d.ts" => inc!("lib.es2015.d.ts"), - "lib.es2015.generator.d.ts" => inc!("lib.es2015.generator.d.ts"), - "lib.es2015.iterable.d.ts" => inc!("lib.es2015.iterable.d.ts"), - "lib.es2015.promise.d.ts" => inc!("lib.es2015.promise.d.ts"), - "lib.es2015.proxy.d.ts" => inc!("lib.es2015.proxy.d.ts"), - "lib.es2015.reflect.d.ts" => inc!("lib.es2015.reflect.d.ts"), - "lib.es2015.symbol.d.ts" => inc!("lib.es2015.symbol.d.ts"), - "lib.es2015.symbol.wellknown.d.ts" => { - inc!("lib.es2015.symbol.wellknown.d.ts") - } - "lib.es2016.array.include.d.ts" => inc!("lib.es2016.array.include.d.ts"), - "lib.es2016.d.ts" => inc!("lib.es2016.d.ts"), - "lib.es2017.d.ts" => inc!("lib.es2017.d.ts"), - "lib.es2017.intl.d.ts" => inc!("lib.es2017.intl.d.ts"), - "lib.es2017.object.d.ts" => inc!("lib.es2017.object.d.ts"), - "lib.es2017.sharedmemory.d.ts" => inc!("lib.es2017.sharedmemory.d.ts"), - "lib.es2017.string.d.ts" => inc!("lib.es2017.string.d.ts"), - "lib.es2017.typedarrays.d.ts" => inc!("lib.es2017.typedarrays.d.ts"), - "lib.es2018.d.ts" => inc!("lib.es2018.d.ts"), - "lib.es2018.asynciterable.d.ts" => inc!("lib.es2018.asynciterable.d.ts"), - "lib.es2018.intl.d.ts" => inc!("lib.es2018.intl.d.ts"), - "lib.es2018.promise.d.ts" => inc!("lib.es2018.promise.d.ts"), - "lib.es2018.regexp.d.ts" => inc!("lib.es2018.regexp.d.ts"), - "lib.es2019.d.ts" => inc!("lib.es2019.d.ts"), - "lib.es2019.array.d.ts" => inc!("lib.es2019.array.d.ts"), - "lib.es2019.object.d.ts" => inc!("lib.es2019.object.d.ts"), - "lib.es2019.string.d.ts" => inc!("lib.es2019.string.d.ts"), - "lib.es2019.symbol.d.ts" => inc!("lib.es2019.symbol.d.ts"), - "lib.es2020.d.ts" => inc!("lib.es2020.d.ts"), - "lib.es2020.string.d.ts" => inc!("lib.es2020.string.d.ts"), - "lib.es2020.symbol.wellknown.d.ts" => { - inc!("lib.es2020.symbol.wellknown.d.ts") - } - "lib.es5.d.ts" => inc!("lib.es5.d.ts"), - "lib.esnext.d.ts" => inc!("lib.esnext.d.ts"), - "lib.esnext.array.d.ts" => inc!("lib.esnext.array.d.ts"), - "lib.esnext.asynciterable.d.ts" => inc!("lib.esnext.asynciterable.d.ts"), - "lib.esnext.bigint.d.ts" => inc!("lib.esnext.bigint.d.ts"), - "lib.esnext.intl.d.ts" => inc!("lib.esnext.intl.d.ts"), - "lib.esnext.symbol.d.ts" => inc!("lib.esnext.symbol.d.ts"), - _ => None, + _ => deno_typescript::get_asset(name), } } diff --git a/cli/build.rs b/cli/build.rs deleted file mode 100644 index 55451e6b7..000000000 --- a/cli/build.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -// Run "cargo build -vv" if you want to see gn output. -mod gn { - include!("../tools/gn.rs"); -} - -fn main() { - let build = gn::Build::setup(); - // When RLS is running "cargo check" to analyze the source code, we're not - // trying to build a working executable, rather we're just compiling all - // rust code. - if !build.check_only { - build.run("cli:deno_deps"); - } -} diff --git a/cli/deno.gni b/cli/deno.gni deleted file mode 100644 index dabcd43ca..000000000 --- a/cli/deno.gni +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import("//build/compiled_action.gni") - -# Tempalte to generate a Rollup bundle of code. -template("bundle") { - action(target_name) { - forward_variables_from(invoker, "*") - script = "//tools/run_node.py" - outputs = [ - out_dir + out_name + ".js", - out_dir + out_name + ".js.map", - ] - inputs = [ - "//js/" + out_name + ".ts", - "//rollup.config.js", - ] - depfile = out_dir + out_name + ".d" - args = [ - rebase_path("//third_party/node_modules/rollup/bin/rollup", - root_build_dir), - "-c", - rebase_path("//rollup.config.js", root_build_dir), - "-i", - rebase_path(inputs[0], root_build_dir), - "-o", - rebase_path(outputs[0], root_build_dir), - "--sourcemapFile", - rebase_path("."), - "--silent", - ] - } -} - -template("run_node") { - action(target_name) { - forward_variables_from(invoker, "*") - script = "//tools/run_node.py" - } -} - -# Template to generate different V8 snapshots based on different runtime flags. -template("snapshot") { - compiled_action(target_name) { - forward_variables_from(invoker, - [ - "testonly", - "deps", - ]) - tool = "//core:snapshot_creator" - visibility = [ ":*" ] # Only targets in this file can depend on this. - snapshot_out_bin = "$target_gen_dir/$target_name.bin" - inputs = [ - invoker.source_root, - ] - - outputs = [ - snapshot_out_bin, - ] - args = rebase_path(outputs, root_build_dir) + - rebase_path(inputs, root_build_dir) - - # To debug snapshotting problems: - # args += ["--trace-serializer"] - } -} diff --git a/cli/main.rs b/cli/main.rs index 1f2451567..682d1055f 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -9,6 +9,7 @@ extern crate futures; extern crate serde_json; extern crate clap; extern crate deno; +extern crate deno_typescript; extern crate indexmap; #[cfg(unix)] extern crate nix; diff --git a/cli/source_maps.rs b/cli/source_maps.rs index 5a34041c5..b3b8d7e56 100644 --- a/cli/source_maps.rs +++ b/cli/source_maps.rs @@ -73,22 +73,12 @@ fn builtin_source_map(_: &str) -> Option<Vec<u8>> { #[cfg(not(feature = "check-only"))] fn builtin_source_map(script_name: &str) -> Option<Vec<u8>> { - match script_name { - "gen/cli/bundle/main.js" => Some( - include_bytes!(concat!( - env!("GN_OUT_DIR"), - "/gen/cli/bundle/main.js.map" - )) - .to_vec(), - ), - "gen/cli/bundle/compiler.js" => Some( - include_bytes!(concat!( - env!("GN_OUT_DIR"), - "/gen/cli/bundle/compiler.js.map" - )) - .to_vec(), - ), - _ => None, + if script_name.ends_with("CLI_SNAPSHOT.js") { + Some(deno_cli_snapshots::CLI_SNAPSHOT_MAP.to_vec()) + } else if script_name.ends_with("COMPILER_SNAPSHOT.js") { + Some(deno_cli_snapshots::COMPILER_SNAPSHOT_MAP.to_vec()) + } else { + None } } @@ -405,7 +395,7 @@ mod tests { frames: vec![StackFrame { line: 11, column: 12, - script_name: "gen/cli/bundle/main.js".to_string(), + script_name: "CLI_SNAPSHOT.js".to_string(), function_name: "setLogDebug".to_string(), is_eval: false, is_constructor: false, @@ -417,7 +407,7 @@ mod tests { assert_eq!(actual.message, "TypeError: baz"); // Because this is accessing the live bundle, this test might be more fragile assert_eq!(actual.frames.len(), 1); - assert!(actual.frames[0].script_name.ends_with("js/util.ts")); + assert!(actual.frames[0].script_name.ends_with("js/window.ts")); } #[test] diff --git a/cli/startup_data.rs b/cli/startup_data.rs index e7d0a08a8..593859be7 100644 --- a/cli/startup_data.rs +++ b/cli/startup_data.rs @@ -3,6 +3,8 @@ use deno::Script; use deno::StartupData; +use deno_cli_snapshots::CLI_SNAPSHOT; +use deno_cli_snapshots::COMPILER_SNAPSHOT; #[cfg(feature = "no-snapshot-init")] pub fn deno_isolate_init() -> StartupData<'static> { @@ -23,8 +25,7 @@ pub fn deno_isolate_init() -> StartupData<'static> { pub fn deno_isolate_init() -> StartupData<'static> { debug!("Deno isolate init with snapshots."); #[cfg(not(feature = "check-only"))] - let data = - include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/cli/snapshot_deno.bin")); + let data = CLI_SNAPSHOT; #[cfg(feature = "check-only")] let data = b""; @@ -50,10 +51,7 @@ pub fn compiler_isolate_init() -> StartupData<'static> { pub fn compiler_isolate_init() -> StartupData<'static> { debug!("Deno isolate init with snapshots."); #[cfg(not(feature = "check-only"))] - let data = include_bytes!(concat!( - env!("GN_OUT_DIR"), - "/gen/cli/snapshot_compiler.bin" - )); + let data = COMPILER_SNAPSHOT; #[cfg(feature = "check-only")] let data = b""; |