2019-03-30 14:45:36 -04:00
|
|
|
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
|
|
|
import("//build/toolchain/cc_wrapper.gni")
|
|
|
|
import("//build_extra/flatbuffers/flatbuffer.gni")
|
|
|
|
import("//build_extra/flatbuffers/rust/rust_flatbuffer.gni")
|
|
|
|
import("//build_extra/rust/rust.gni")
|
|
|
|
import("//third_party/v8/gni/v8.gni")
|
|
|
|
import("//third_party/v8/snapshot_toolchain.gni")
|
|
|
|
import("../deno.gni")
|
|
|
|
|
|
|
|
main_extern = [
|
2019-05-14 17:30:56 -04:00
|
|
|
{
|
|
|
|
label = "../core:deno"
|
|
|
|
crate_name = "deno"
|
|
|
|
crate_type = "rlib"
|
|
|
|
},
|
|
|
|
]
|
|
|
|
main_extern_rlib = [
|
|
|
|
"ansi_term",
|
|
|
|
"atty",
|
|
|
|
"clap",
|
|
|
|
"dirs",
|
|
|
|
"flatbuffers",
|
|
|
|
"futures",
|
|
|
|
"http",
|
|
|
|
"hyper",
|
|
|
|
"hyper_rustls",
|
|
|
|
"lazy_static",
|
|
|
|
"libc",
|
|
|
|
"log",
|
|
|
|
"rand",
|
|
|
|
"regex",
|
|
|
|
"remove_dir_all",
|
|
|
|
"ring",
|
|
|
|
"rustyline",
|
|
|
|
"serde_json",
|
|
|
|
"source_map_mappings",
|
|
|
|
"tempfile",
|
|
|
|
"tokio",
|
|
|
|
"tokio_executor",
|
|
|
|
"tokio_fs",
|
|
|
|
"tokio_io",
|
|
|
|
"tokio_process",
|
|
|
|
"tokio_rustls",
|
|
|
|
"tokio_threadpool",
|
|
|
|
"url",
|
|
|
|
"utime",
|
2019-03-30 14:45:36 -04:00
|
|
|
]
|
|
|
|
if (is_win) {
|
2019-05-14 17:30:56 -04:00
|
|
|
main_extern_rlib += [ "winapi" ]
|
2019-03-30 14:45:36 -04:00
|
|
|
}
|
2019-04-21 21:26:56 -04:00
|
|
|
if (is_posix) {
|
2019-05-14 17:30:56 -04:00
|
|
|
main_extern_rlib += [ "nix" ]
|
2019-04-21 21:26:56 -04:00
|
|
|
}
|
2019-03-30 14:45:36 -04:00
|
|
|
|
|
|
|
ts_sources = [
|
|
|
|
"../js/assets.ts",
|
|
|
|
"../js/blob.ts",
|
2019-05-01 23:56:42 -04:00
|
|
|
"../js/body.ts",
|
2019-03-30 14:45:36 -04:00
|
|
|
"../js/buffer.ts",
|
|
|
|
"../js/build.ts",
|
|
|
|
"../js/chmod.ts",
|
2019-05-07 21:58:58 -04:00
|
|
|
"../js/chown.ts",
|
2019-04-29 10:58:31 -04:00
|
|
|
"../js/colors.ts",
|
2019-03-30 14:45:36 -04:00
|
|
|
"../js/compiler.ts",
|
|
|
|
"../js/console.ts",
|
2019-04-29 10:58:31 -04:00
|
|
|
"../js/console_table.ts",
|
2019-03-30 14:45:36 -04:00
|
|
|
"../js/copy_file.ts",
|
|
|
|
"../js/core.ts",
|
|
|
|
"../js/custom_event.ts",
|
|
|
|
"../js/deno.ts",
|
|
|
|
"../js/dir.ts",
|
|
|
|
"../js/dispatch.ts",
|
2019-05-03 00:06:43 -04:00
|
|
|
"../js/dispatch_minimal.ts",
|
2019-03-30 14:45:36 -04:00
|
|
|
"../js/dom_types.ts",
|
|
|
|
"../js/errors.ts",
|
|
|
|
"../js/event.ts",
|
|
|
|
"../js/event_target.ts",
|
|
|
|
"../js/fetch.ts",
|
|
|
|
"../js/format_error.ts",
|
|
|
|
"../js/dom_file.ts",
|
|
|
|
"../js/file_info.ts",
|
|
|
|
"../js/files.ts",
|
|
|
|
"../js/flatbuffers.ts",
|
|
|
|
"../js/form_data.ts",
|
|
|
|
"../js/globals.ts",
|
|
|
|
"../js/headers.ts",
|
|
|
|
"../js/io.ts",
|
|
|
|
"../js/lib.web_assembly.d.ts",
|
2019-04-08 09:11:32 -04:00
|
|
|
"../js/link.ts",
|
2019-03-30 14:45:36 -04:00
|
|
|
"../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/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",
|
2019-05-01 23:56:42 -04:00
|
|
|
"../js/request.ts",
|
2019-03-30 14:45:36 -04:00
|
|
|
"../js/resources.ts",
|
|
|
|
"../js/stat.ts",
|
|
|
|
"../js/symlink.ts",
|
|
|
|
"../js/text_encoding.ts",
|
|
|
|
"../js/timers.ts",
|
|
|
|
"../js/truncate.ts",
|
|
|
|
"../js/types.ts",
|
|
|
|
"../js/url.ts",
|
|
|
|
"../js/url_search_params.ts",
|
|
|
|
"../js/util.ts",
|
2019-05-01 05:08:12 -04:00
|
|
|
"../js/utime.ts",
|
2019-03-30 14:45:36 -04:00
|
|
|
"../js/window.ts",
|
|
|
|
"../js/workers.ts",
|
|
|
|
"../js/write_file.ts",
|
|
|
|
"../js/performance.ts",
|
|
|
|
"../js/version.ts",
|
2019-05-03 16:24:09 -04:00
|
|
|
"../js/xeval.ts",
|
2019-03-30 14:45:36 -04:00
|
|
|
"../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 = [
|
|
|
|
":msg_rs",
|
|
|
|
":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",
|
|
|
|
":msg_rs",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
# Reads the cargo info from Cargo.toml
|
2019-05-14 17:30:56 -04:00
|
|
|
deno_cargo_info = exec_script("../build_extra/rust/get_cargo_info.py",
|
|
|
|
[ rebase_path("Cargo.toml", root_build_dir) ],
|
|
|
|
"json")
|
2019-03-30 14:45:36 -04:00
|
|
|
|
|
|
|
rust_executable("deno") {
|
|
|
|
source_root = "main.rs"
|
|
|
|
extern = main_extern
|
2019-05-14 17:30:56 -04:00
|
|
|
extern_rlib = main_extern_rlib
|
2019-03-30 14:45:36 -04:00
|
|
|
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.
|
|
|
|
crate_version = deno_cargo_info.version
|
|
|
|
inputs = [
|
|
|
|
"Cargo.toml",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2019-05-01 09:48:56 -04:00
|
|
|
rust_test("cli_test") {
|
2019-03-30 14:45:36 -04:00
|
|
|
source_root = "main.rs"
|
|
|
|
extern = main_extern
|
2019-05-14 17:30:56 -04:00
|
|
|
extern_rlib = main_extern_rlib
|
2019-03-30 14:45:36 -04:00
|
|
|
deps = [
|
|
|
|
":deno_deps",
|
|
|
|
]
|
|
|
|
|
|
|
|
# Extract version from Cargo.toml
|
|
|
|
crate_version = deno_cargo_info.version
|
|
|
|
inputs = [
|
|
|
|
"Cargo.toml",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
# Generates the core TypeScript type library for deno that will be
|
|
|
|
# included in the runtime bundle
|
|
|
|
run_node("deno_runtime_declaration") {
|
|
|
|
out_dir = target_gen_dir
|
|
|
|
sources = ts_sources
|
|
|
|
outputs = [
|
|
|
|
"$out_dir/lib/lib.deno_runtime.d.ts",
|
|
|
|
]
|
|
|
|
deps = [
|
|
|
|
":msg_ts",
|
|
|
|
]
|
|
|
|
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",
|
|
|
|
]
|
|
|
|
args = [
|
|
|
|
rebase_path("//node_modules/ts-node/dist/bin.js", root_build_dir),
|
|
|
|
"--project",
|
|
|
|
rebase_path("//tools/ts_library_builder/tsconfig.json"),
|
|
|
|
"--skip-ignore",
|
|
|
|
rebase_path("//tools/ts_library_builder/main.ts", root_build_dir),
|
|
|
|
"--basePath",
|
|
|
|
rebase_path("//", root_build_dir),
|
|
|
|
"--inline",
|
|
|
|
rebase_path("//js/lib.web_assembly.d.ts", root_build_dir),
|
|
|
|
"--buildPath",
|
|
|
|
rebase_path(root_build_dir, root_build_dir),
|
|
|
|
"--outFile",
|
|
|
|
rebase_path(outputs[0], root_build_dir),
|
|
|
|
"--silent",
|
|
|
|
]
|
|
|
|
if (is_debug) {
|
|
|
|
args += [ "--debug" ]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bundle("main_bundle") {
|
|
|
|
out_dir = "$target_gen_dir/bundle/"
|
|
|
|
out_name = "main"
|
|
|
|
deps = [
|
|
|
|
":deno_runtime_declaration",
|
|
|
|
":msg_ts",
|
|
|
|
":write_gn_args",
|
|
|
|
]
|
|
|
|
data = [
|
|
|
|
"$target_gen_dir/gn_args.txt",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
bundle("compiler_bundle") {
|
|
|
|
out_dir = "$target_gen_dir/bundle/"
|
|
|
|
out_name = "compiler"
|
|
|
|
deps = [
|
|
|
|
":deno_runtime_declaration",
|
|
|
|
":msg_ts",
|
|
|
|
":write_gn_args",
|
|
|
|
]
|
|
|
|
data = [
|
|
|
|
"$target_gen_dir/gn_args.txt",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
ts_flatbuffer("msg_ts") {
|
|
|
|
sources = [
|
|
|
|
"msg.fbs",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
rust_flatbuffer("msg_rs") {
|
|
|
|
sources = [
|
|
|
|
"msg.fbs",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
# 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",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
action("write_gn_args") {
|
|
|
|
script = "//tools/write_gn_args.py"
|
|
|
|
outputs = [
|
|
|
|
"$target_gen_dir/gn_args.txt",
|
|
|
|
]
|
|
|
|
args = [ rebase_path(outputs[0], root_build_dir) ]
|
|
|
|
}
|