Skip to content

Commit 473c07f

Browse files
committed
Refactor snapshots
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 improve incremental build time when changes are made //js files by about 40 seconds.
1 parent 65fa2b8 commit 473c07f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1612
-760
lines changed

Cargo.lock

Lines changed: 81 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ members = [
33
"cli",
44
"core",
55
"tools/hyper_hello",
6+
"deno_typescript",
7+
"cli_snapshots",
68
]

build_extra/rust/run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
# When building with Cargo this variable is set by build.rs.
2929
env["GN_OUT_DIR"] = os.path.abspath(".")
3030
assert os.path.isdir(env["GN_OUT_DIR"])
31+
env["OUT_DIR"] = os.path.abspath(".")
3132

3233
# Environment variables can be specified on the command line using
3334
# '--env=variable=value' flags. These flags are not passed through to rustc.

cli/BUILD.gn

Lines changed: 5 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
22
import("//build/toolchain/cc_wrapper.gni")
33
import("//build_extra/rust/rust.gni")
4-
import("//third_party/v8/gni/snapshot_toolchain.gni")
5-
import("//third_party/v8/gni/v8.gni")
6-
import("deno.gni")
74

85
main_extern = [
96
{
107
label = "../core:deno"
118
crate_name = "deno"
129
crate_type = "rlib"
1310
},
11+
{
12+
label = "../cli_snapshots:deno_cli_snapshots"
13+
crate_name = "deno_cli_snapshots"
14+
crate_type = "rlib"
15+
},
1416
{
1517
label = "$rust_build:serde_derive"
1618
crate_name = "serde_derive"
@@ -60,109 +62,6 @@ if (is_posix) {
6062
main_extern_rlib += [ "nix" ]
6163
}
6264

63-
ts_sources = [
64-
"../js/base64.ts",
65-
"../js/blob.ts",
66-
"../js/body.ts",
67-
"../js/buffer.ts",
68-
"../js/build.ts",
69-
"../js/chmod.ts",
70-
"../js/chown.ts",
71-
"../js/colors.ts",
72-
"../js/compiler.ts",
73-
"../js/console.ts",
74-
"../js/console_table.ts",
75-
"../js/copy_file.ts",
76-
"../js/core.ts",
77-
"../js/custom_event.ts",
78-
"../js/deno.ts",
79-
"../js/diagnostics.ts",
80-
"../js/dir.ts",
81-
"../js/dispatch.ts",
82-
"../js/dispatch_json.ts",
83-
"../js/dispatch_minimal.ts",
84-
"../js/dom_file.ts",
85-
"../js/dom_types.ts",
86-
"../js/dom_util.ts",
87-
"../js/error_stack.ts",
88-
"../js/errors.ts",
89-
"../js/event.ts",
90-
"../js/event_target.ts",
91-
"../js/fetch.ts",
92-
"../js/file_info.ts",
93-
"../js/files.ts",
94-
"../js/form_data.ts",
95-
"../js/format_error.ts",
96-
"../js/get_random_values.ts",
97-
"../js/globals.ts",
98-
"../js/headers.ts",
99-
"../js/io.ts",
100-
"../js/lib.deno_runtime.d.ts",
101-
"../js/lib.web_assembly.d.ts",
102-
"../js/link.ts",
103-
"../js/location.ts",
104-
"../js/main.ts",
105-
"../js/make_temp_dir.ts",
106-
"../js/metrics.ts",
107-
"../js/mkdir.ts",
108-
"../js/mock_builtin.js",
109-
"../js/net.ts",
110-
"../js/os.ts",
111-
"../js/performance.ts",
112-
"../js/permissions.ts",
113-
"../js/plugins.d.ts",
114-
"../js/process.ts",
115-
"../js/read_dir.ts",
116-
"../js/read_file.ts",
117-
"../js/read_link.ts",
118-
"../js/remove.ts",
119-
"../js/rename.ts",
120-
"../js/repl.ts",
121-
"../js/request.ts",
122-
"../js/resources.ts",
123-
"../js/stat.ts",
124-
"../js/symlink.ts",
125-
"../js/text_encoding.ts",
126-
"../js/timers.ts",
127-
"../js/truncate.ts",
128-
"../js/type_directives.ts",
129-
"../js/types.ts",
130-
"../js/url.ts",
131-
"../js/url_search_params.ts",
132-
"../js/util.ts",
133-
"../js/utime.ts",
134-
"../js/version.ts",
135-
"../js/window.ts",
136-
"../js/workers.ts",
137-
"../js/write_file.ts",
138-
"../js/xeval.ts",
139-
"../tsconfig.json",
140-
141-
# Listing package.json and yarn.lock as sources ensures the bundle is rebuilt
142-
# when npm packages are added/removed or their contents changes.
143-
"../package.json",
144-
"../third_party/yarn.lock",
145-
]
146-
147-
# When Cargo is driving the build, GN/Ninja are used to produce these non-Rust
148-
# targets. Cargo handles all Rust source files and the final linking step.
149-
group("deno_deps") {
150-
deps = [
151-
":snapshot_compiler",
152-
":snapshot_deno",
153-
]
154-
}
155-
156-
# Optimized dependencies for cross compiled builds.
157-
# This can be removed once we get snapshots into cross compiled builds.
158-
group("deno_deps_cross") {
159-
testonly = true
160-
deps = [
161-
":compiler_bundle",
162-
":main_bundle",
163-
]
164-
}
165-
16665
# Reads the cargo info from Cargo.toml
16766
deno_cargo_info = exec_script("../build_extra/rust/get_cargo_info.py",
16867
[ rebase_path("Cargo.toml", root_build_dir) ],
@@ -172,9 +71,6 @@ rust_executable("deno") {
17271
source_root = "main.rs"
17372
extern = main_extern
17473
extern_rlib = main_extern_rlib
175-
deps = [
176-
":deno_deps",
177-
]
17874

17975
# Extract version from Cargo.toml
18076
# TODO integrate this into rust.gni by allowing the rust_executable template
@@ -189,41 +85,10 @@ rust_test("cli_test") {
18985
source_root = "main.rs"
19086
extern = main_extern
19187
extern_rlib = main_extern_rlib
192-
deps = [
193-
":deno_deps",
194-
]
19588

19689
# Extract version from Cargo.toml
19790
inputs = [
19891
"Cargo.toml",
19992
]
20093
env = [ "CARGO_PKG_VERSION=${deno_cargo_info.version}" ]
20194
}
202-
203-
bundle("main_bundle") {
204-
sources = ts_sources
205-
out_dir = "$target_gen_dir/bundle/"
206-
out_name = "main"
207-
}
208-
209-
bundle("compiler_bundle") {
210-
sources = ts_sources
211-
out_dir = "$target_gen_dir/bundle/"
212-
out_name = "compiler"
213-
}
214-
215-
# Generates $target_gen_dir/snapshot_deno.bin
216-
snapshot("snapshot_deno") {
217-
source_root = "$target_gen_dir/bundle/main.js"
218-
deps = [
219-
":main_bundle",
220-
]
221-
}
222-
223-
# Generates $target_gen_dir/snapshot_compiler.bin
224-
snapshot("snapshot_compiler") {
225-
source_root = "$target_gen_dir/bundle/compiler.js"
226-
deps = [
227-
":compiler_bundle",
228-
]
229-
}

cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ tokio-rustls = "0.10.0"
5151
tokio-threadpool = "0.1.15"
5252
url = "1.7.2"
5353
utime = "0.2.1"
54+
deno_cli_snapshots = { path = "../cli_snapshots" }
5455

5556
[target.'cfg(windows)'.dependencies]
5657
winapi = "0.3.7"

cli/build.rs

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)