1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
# 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 = [
{
label = "../core:deno"
crate_name = "deno"
crate_type = "rlib"
},
{
label = "$rust_build:serde_derive"
crate_name = "serde_derive"
crate_type = "proc_macro"
},
]
main_extern_rlib = [
"ansi_term",
"atty",
"clap",
"dirs",
"futures",
"http",
"hyper",
"hyper_rustls",
"indexmap",
"lazy_static",
"libc",
"log",
"rand",
"regex",
"remove_dir_all",
"reqwest",
"ring",
"rustyline",
"serde",
"serde_json",
"source_map_mappings",
"tempfile",
"termcolor",
"tokio",
"tokio_executor",
"tokio_fs",
"tokio_io",
"tokio_process",
"tokio_rustls",
"tokio_threadpool",
"url",
"utime",
]
if (is_win) {
main_extern_rlib += [
"fwdansi",
"winapi",
]
}
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) ],
"json")
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
# to specify a cargo.toml from which it will extract a version.
inputs = [
"Cargo.toml",
]
env = [ "CARGO_PKG_VERSION=${deno_cargo_info.version}" ]
}
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 = [
"Cargo.toml",
]
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",
]
}
|