2019-01-21 14:03:30 -05:00
|
|
|
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2018-08-29 02:42:30 -04:00
|
|
|
import("//build/toolchain/cc_wrapper.gni")
|
2018-07-07 10:37:56 -04:00
|
|
|
import("//build_extra/flatbuffers/flatbuffer.gni")
|
2018-07-23 14:13:12 -04:00
|
|
|
import("//build_extra/flatbuffers/rust/rust_flatbuffer.gni")
|
2018-07-06 00:58:09 -04:00
|
|
|
import("//build_extra/rust/rust.gni")
|
2018-11-25 16:56:04 -05:00
|
|
|
import("//third_party/v8/gni/v8.gni")
|
|
|
|
import("//third_party/v8/snapshot_toolchain.gni")
|
|
|
|
import("libdeno/deno.gni")
|
2018-06-09 18:32:04 -04:00
|
|
|
|
2018-08-17 18:23:14 -04:00
|
|
|
group("default") {
|
2018-07-12 18:37:06 -04:00
|
|
|
testonly = true
|
|
|
|
deps = [
|
|
|
|
":deno",
|
2018-10-20 22:56:16 -04:00
|
|
|
":hyper_hello",
|
2018-07-23 14:13:12 -04:00
|
|
|
":test_rs",
|
2018-11-25 16:56:04 -05:00
|
|
|
"libdeno:test_cc",
|
2018-07-12 18:37:06 -04:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-07-23 14:13:12 -04:00
|
|
|
main_extern = [
|
2019-02-07 16:19:50 -05:00
|
|
|
"$rust_build:ansi_term",
|
2018-10-27 09:11:39 -04:00
|
|
|
"$rust_build:atty",
|
|
|
|
"$rust_build:dirs",
|
2018-12-23 12:39:40 -05:00
|
|
|
"$rust_build:flatbuffers",
|
2018-10-27 09:11:39 -04:00
|
|
|
"$rust_build:futures",
|
|
|
|
"$rust_build:getopts",
|
2018-11-14 20:36:34 -05:00
|
|
|
"$rust_build:http",
|
2018-08-05 18:50:15 -04:00
|
|
|
"$rust_build:hyper",
|
2018-08-28 13:49:19 -04:00
|
|
|
"$rust_build:hyper_rustls",
|
2018-09-24 19:51:37 -04:00
|
|
|
"$rust_build:lazy_static",
|
2018-07-23 14:13:12 -04:00
|
|
|
"$rust_build:libc",
|
|
|
|
"$rust_build:log",
|
2018-10-27 09:11:39 -04:00
|
|
|
"$rust_build:rand",
|
2019-02-07 20:07:20 -05:00
|
|
|
"$rust_build:regex",
|
2018-10-27 09:11:39 -04:00
|
|
|
"$rust_build:remove_dir_all",
|
2018-08-28 13:49:19 -04:00
|
|
|
"$rust_build:ring",
|
2018-11-05 12:55:59 -05:00
|
|
|
"$rust_build:rustyline",
|
2018-12-06 23:05:36 -05:00
|
|
|
"$rust_build:serde_json",
|
|
|
|
"$rust_build:source_map_mappings",
|
2018-07-24 01:45:23 -04:00
|
|
|
"$rust_build:tempfile",
|
2018-07-28 20:46:27 -04:00
|
|
|
"$rust_build:tokio",
|
2018-09-18 14:53:16 -04:00
|
|
|
"$rust_build:tokio_executor",
|
2018-10-27 09:11:39 -04:00
|
|
|
"$rust_build:tokio_fs",
|
|
|
|
"$rust_build:tokio_io",
|
2018-11-03 01:58:30 -04:00
|
|
|
"$rust_build:tokio_process",
|
2018-09-22 04:42:07 -04:00
|
|
|
"$rust_build:tokio_threadpool",
|
2018-07-23 14:13:12 -04:00
|
|
|
"$rust_build:url",
|
|
|
|
]
|
2019-01-13 17:43:00 -05:00
|
|
|
if (is_win) {
|
|
|
|
main_extern += [ "$rust_build:winapi" ]
|
|
|
|
}
|
2018-07-23 14:13:12 -04:00
|
|
|
|
2018-09-12 10:33:30 -04:00
|
|
|
ts_sources = [
|
|
|
|
"js/assets.ts",
|
2018-09-14 08:45:50 -04:00
|
|
|
"js/blob.ts",
|
2018-11-04 18:36:46 -05:00
|
|
|
"js/buffer.ts",
|
2018-10-26 16:01:45 -04:00
|
|
|
"js/chmod.ts",
|
2019-01-28 16:41:29 -05:00
|
|
|
"js/console_table.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"js/compiler.ts",
|
|
|
|
"js/console.ts",
|
2018-10-03 23:58:29 -04:00
|
|
|
"js/copy_file.ts",
|
2019-01-23 07:20:53 -05:00
|
|
|
"js/custom_event.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"js/deno.ts",
|
2018-10-13 16:03:27 -04:00
|
|
|
"js/dir.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"js/dispatch.ts",
|
2018-09-16 02:46:12 -04:00
|
|
|
"js/dom_types.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"js/errors.ts",
|
2019-01-05 10:02:44 -05:00
|
|
|
"js/event.ts",
|
|
|
|
"js/event_target.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"js/fetch.ts",
|
2019-02-09 16:55:40 -05:00
|
|
|
"js/format_error.ts",
|
2018-12-27 04:45:58 -05:00
|
|
|
"js/dom_file.ts",
|
2018-10-03 21:41:59 -04:00
|
|
|
"js/file_info.ts",
|
2018-09-27 00:56:39 -04:00
|
|
|
"js/files.ts",
|
2018-10-17 13:04:28 -04:00
|
|
|
"js/flatbuffers.ts",
|
2018-11-04 13:05:02 -05:00
|
|
|
"js/form_data.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"js/globals.ts",
|
2018-11-15 23:07:40 -05:00
|
|
|
"js/headers.ts",
|
2018-10-03 23:58:29 -04:00
|
|
|
"js/io.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"js/libdeno.ts",
|
2019-02-05 08:12:58 -05:00
|
|
|
"js/lib.web_assembly.d.ts",
|
2019-02-12 21:14:02 -05:00
|
|
|
"js/location.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"js/main.ts",
|
2018-09-12 22:04:45 -04:00
|
|
|
"js/make_temp_dir.ts",
|
2018-10-05 13:21:15 -04:00
|
|
|
"js/metrics.ts",
|
2018-10-03 23:58:29 -04:00
|
|
|
"js/mkdir.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"js/mock_builtin.js",
|
2018-10-03 23:58:29 -04:00
|
|
|
"js/net.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"js/os.ts",
|
2018-09-20 02:13:59 -04:00
|
|
|
"js/platform.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"js/plugins.d.ts",
|
2018-11-15 23:07:40 -05:00
|
|
|
"js/process.ts",
|
2018-10-03 17:56:56 -04:00
|
|
|
"js/read_dir.ts",
|
2018-10-03 23:58:29 -04:00
|
|
|
"js/read_file.ts",
|
|
|
|
"js/read_link.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"js/remove.ts",
|
|
|
|
"js/rename.ts",
|
2018-11-05 12:55:59 -05:00
|
|
|
"js/repl.ts",
|
2018-11-15 23:07:40 -05:00
|
|
|
"js/resources.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"js/stat.ts",
|
2018-09-19 00:38:24 -04:00
|
|
|
"js/symlink.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"js/text_encoding.ts",
|
|
|
|
"js/timers.ts",
|
2018-09-30 15:06:20 -04:00
|
|
|
"js/truncate.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"js/types.ts",
|
2018-12-17 20:07:47 -05:00
|
|
|
"js/url.ts",
|
2018-10-21 11:07:29 -04:00
|
|
|
"js/url_search_params.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"js/util.ts",
|
2019-02-19 21:42:19 -05:00
|
|
|
"js/window.ts",
|
2019-01-08 14:44:06 -05:00
|
|
|
"js/workers.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"js/write_file.ts",
|
2019-02-02 01:27:42 -05:00
|
|
|
"js/performance.ts",
|
2019-02-18 18:43:02 -05:00
|
|
|
"js/version.ts",
|
2018-09-12 10:33:30 -04:00
|
|
|
"tsconfig.json",
|
2018-09-13 00:25:43 -04:00
|
|
|
|
|
|
|
# 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",
|
2018-09-12 10:33:30 -04:00
|
|
|
]
|
|
|
|
|
2018-12-13 16:19:17 -05:00
|
|
|
# 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.
|
2018-11-12 20:17:30 -05:00
|
|
|
group("deno_deps") {
|
|
|
|
deps = [
|
|
|
|
":msg_rs",
|
2019-01-28 20:41:28 -05:00
|
|
|
":snapshot_compiler",
|
2018-12-01 01:53:37 -05:00
|
|
|
":snapshot_deno",
|
2018-12-19 20:11:58 -05:00
|
|
|
"libdeno:libdeno_static_lib",
|
2018-11-12 20:17:30 -05:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-12-13 16:16:58 -05:00
|
|
|
# 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")
|
|
|
|
|
2018-06-23 03:42:06 -04:00
|
|
|
rust_executable("deno") {
|
2018-07-01 07:47:28 -04:00
|
|
|
source_root = "src/main.rs"
|
2018-07-23 14:13:12 -04:00
|
|
|
extern = main_extern
|
2018-07-12 18:38:00 -04:00
|
|
|
deps = [
|
2018-10-31 14:11:10 -04:00
|
|
|
":deno_deps",
|
2018-07-12 18:38:00 -04:00
|
|
|
]
|
2018-12-13 16:16:58 -05:00
|
|
|
|
|
|
|
# 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.
|
|
|
|
crate_version = deno_cargo_info.version
|
|
|
|
inputs = [
|
|
|
|
"Cargo.toml",
|
|
|
|
]
|
2018-07-12 15:06:36 -04:00
|
|
|
}
|
|
|
|
|
2018-11-12 20:17:30 -05:00
|
|
|
rust_test("test_rs") {
|
|
|
|
source_root = "src/main.rs"
|
|
|
|
extern = main_extern
|
2018-06-10 08:24:39 -04:00
|
|
|
deps = [
|
2018-11-12 20:17:30 -05:00
|
|
|
":deno_deps",
|
2018-06-10 08:24:39 -04:00
|
|
|
]
|
2018-12-13 16:16:58 -05:00
|
|
|
|
|
|
|
# Extract version from Cargo.toml
|
|
|
|
crate_version = deno_cargo_info.version
|
|
|
|
inputs = [
|
|
|
|
"Cargo.toml",
|
|
|
|
]
|
2018-06-10 08:24:39 -04:00
|
|
|
}
|
|
|
|
|
2018-10-23 19:39:31 -04:00
|
|
|
rust_executable("hyper_hello") {
|
|
|
|
source_root = "tools/hyper_hello.rs"
|
|
|
|
extern = [
|
|
|
|
"$rust_build:hyper",
|
|
|
|
"$rust_build:ring",
|
2018-07-16 21:33:57 -04:00
|
|
|
]
|
2018-10-23 19:39:31 -04:00
|
|
|
}
|
|
|
|
|
2018-10-11 17:23:13 -04:00
|
|
|
# Generates the core TypeScript type library for deno that will be
|
|
|
|
# included in the runtime bundle
|
|
|
|
run_node("deno_runtime_declaration") {
|
2018-08-07 16:27:31 -04:00
|
|
|
out_dir = target_gen_dir
|
2018-09-12 10:33:30 -04:00
|
|
|
sources = ts_sources
|
2018-08-07 16:27:31 -04:00
|
|
|
outputs = [
|
2018-10-11 17:23:13 -04:00
|
|
|
"$out_dir/lib/lib.deno_runtime.d.ts",
|
2018-08-07 16:27:31 -04:00
|
|
|
]
|
|
|
|
deps = [
|
|
|
|
":msg_ts",
|
|
|
|
]
|
2019-02-13 13:26:30 -05:00
|
|
|
inputs = ts_sources + [
|
|
|
|
"tools/ts_library_builder/tsconfig.json",
|
|
|
|
"tools/ts_library_builder/main.ts",
|
|
|
|
"tools/ts_library_builder/build_library.ts",
|
|
|
|
"tools/ts_library_builder/ast_util.ts",
|
|
|
|
]
|
2018-08-07 16:27:31 -04:00
|
|
|
args = [
|
2018-10-20 13:06:57 -04:00
|
|
|
rebase_path("node_modules/ts-node/dist/bin.js", root_build_dir),
|
2018-10-11 17:23:13 -04:00
|
|
|
"--project",
|
|
|
|
rebase_path("tools/ts_library_builder/tsconfig.json"),
|
2019-01-20 21:25:01 -05:00
|
|
|
"--skip-ignore",
|
2018-10-11 17:23:13 -04:00
|
|
|
rebase_path("tools/ts_library_builder/main.ts", root_build_dir),
|
|
|
|
"--basePath",
|
|
|
|
rebase_path(".", root_build_dir),
|
2019-02-05 08:12:58 -05:00
|
|
|
"--inline",
|
|
|
|
rebase_path("js/lib.web_assembly.d.ts", root_build_dir),
|
2018-10-11 17:23:13 -04:00
|
|
|
"--buildPath",
|
2018-08-25 13:04:30 -04:00
|
|
|
rebase_path(root_build_dir, root_build_dir),
|
2018-09-01 10:45:26 -04:00
|
|
|
"--outFile",
|
2019-02-13 13:26:30 -05:00
|
|
|
rebase_path(outputs[0], root_build_dir),
|
2018-10-11 17:23:13 -04:00
|
|
|
"--silent",
|
2018-08-07 16:27:31 -04:00
|
|
|
]
|
2018-10-11 17:23:13 -04:00
|
|
|
if (is_debug) {
|
|
|
|
args += [ "--debug" ]
|
|
|
|
}
|
2018-08-07 16:27:31 -04:00
|
|
|
}
|
|
|
|
|
2019-01-28 20:41:28 -05:00
|
|
|
bundle("main_bundle") {
|
2018-06-13 08:58:06 -04:00
|
|
|
out_dir = "$target_gen_dir/bundle/"
|
2019-01-28 20:41:28 -05:00
|
|
|
out_name = "main"
|
2018-06-11 21:54:55 -04:00
|
|
|
deps = [
|
2018-10-11 17:23:13 -04:00
|
|
|
":deno_runtime_declaration",
|
2018-07-25 23:07:50 -04:00
|
|
|
":msg_ts",
|
2018-06-09 18:32:04 -04:00
|
|
|
]
|
2019-01-28 20:41:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bundle("compiler_bundle") {
|
|
|
|
out_dir = "$target_gen_dir/bundle/"
|
|
|
|
out_name = "compiler"
|
|
|
|
deps = [
|
|
|
|
":deno_runtime_declaration",
|
|
|
|
":msg_ts",
|
2018-06-11 21:54:55 -04:00
|
|
|
]
|
|
|
|
}
|
2018-06-09 18:32:04 -04:00
|
|
|
|
2018-07-04 14:50:28 -04:00
|
|
|
ts_flatbuffer("msg_ts") {
|
|
|
|
sources = [
|
|
|
|
"src/msg.fbs",
|
|
|
|
]
|
2018-06-09 18:32:04 -04:00
|
|
|
}
|
|
|
|
|
2018-07-23 14:13:12 -04:00
|
|
|
rust_flatbuffer("msg_rs") {
|
|
|
|
sources = [
|
|
|
|
"src/msg.fbs",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-08-10 15:09:28 -04:00
|
|
|
# Generates $target_gen_dir/snapshot_deno.bin
|
2018-12-01 01:53:37 -05:00
|
|
|
snapshot("snapshot_deno") {
|
2018-12-11 13:07:31 -05:00
|
|
|
source_root = "$target_gen_dir/bundle/main.js"
|
2018-06-09 18:32:04 -04:00
|
|
|
deps = [
|
2019-01-28 20:41:28 -05:00
|
|
|
":main_bundle",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
# Generates $target_gen_dir/snapshot_compiler.bin
|
|
|
|
snapshot("snapshot_compiler") {
|
|
|
|
source_root = "$target_gen_dir/bundle/compiler.js"
|
|
|
|
deps = [
|
|
|
|
":compiler_bundle",
|
2018-06-09 18:32:04 -04:00
|
|
|
]
|
|
|
|
}
|