2018-07-23 14:46:30 -04:00
|
|
|
# Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
2018-07-03 04:15:32 -04:00
|
|
|
import("//third_party/v8/gni/v8.gni")
|
|
|
|
import("//third_party/v8/snapshot_toolchain.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/deno.gni")
|
|
|
|
import("//build_extra/rust/rust.gni")
|
2018-06-09 18:32:04 -04:00
|
|
|
|
2018-07-12 18:37:06 -04:00
|
|
|
group("all") {
|
|
|
|
testonly = true
|
|
|
|
deps = [
|
|
|
|
":deno",
|
2018-07-17 00:41:25 -04:00
|
|
|
":deno_ns",
|
2018-07-12 18:37:06 -04:00
|
|
|
":test_cc",
|
2018-07-23 14:13:12 -04:00
|
|
|
":test_rs",
|
2018-07-12 18:37:06 -04:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-06-19 06:54:24 -04:00
|
|
|
config("deno_config") {
|
2018-07-03 04:15:32 -04:00
|
|
|
include_dirs = [ "third_party/v8" ] # This allows us to v8/src/base/ libraries.
|
|
|
|
configs = [ "third_party/v8:external_config" ]
|
2018-07-06 11:27:36 -04:00
|
|
|
if (is_debug) {
|
|
|
|
defines = [ "DEBUG" ]
|
|
|
|
}
|
2018-07-17 16:36:11 -04:00
|
|
|
|
|
|
|
# Targets built with the `rust_executable()` template automatically pick up
|
|
|
|
# these dependencies, but those built with `executable()` need them when they
|
|
|
|
# have Rust inputs. Currently, there's only one such target, `test_cc`.
|
|
|
|
if (is_mac) {
|
|
|
|
libs = [ "resolv" ]
|
|
|
|
}
|
|
|
|
if (is_win) {
|
|
|
|
libs = [ "userenv.lib" ]
|
|
|
|
}
|
2018-06-19 06:54:24 -04:00
|
|
|
}
|
|
|
|
|
2018-07-23 14:13:12 -04:00
|
|
|
main_extern = [
|
|
|
|
"$rust_build:libc",
|
|
|
|
"$rust_build:log",
|
2018-07-24 01:45:23 -04:00
|
|
|
"$rust_build:sha1",
|
|
|
|
"$rust_build:tempfile",
|
2018-07-28 20:46:27 -04:00
|
|
|
"$rust_build:tokio",
|
2018-07-23 14:13:12 -04:00
|
|
|
"$rust_build:url",
|
|
|
|
"//build_extra/flatbuffers/rust:flatbuffers",
|
|
|
|
":msg_rs",
|
|
|
|
|
|
|
|
# Indirect rust depdendencies also need to be listed here:
|
|
|
|
# * Linking to `:handlers` or `:libdeno` isn't possible, because they
|
|
|
|
# already contain some symbols exported by `handlers.rs`. These duplicate
|
|
|
|
# symbols trip up the linker.
|
|
|
|
# * The `rust_test` and `rust_executable` templates only produce an object
|
|
|
|
# file, and then invoke an external linker. Transitive rust depencenies
|
|
|
|
# are not resolved in either step.
|
2018-07-28 20:46:27 -04:00
|
|
|
"$rust_build:arrayvec",
|
|
|
|
"$rust_build:byteorder",
|
|
|
|
"$rust_build:bytes",
|
|
|
|
"$rust_build:crossbeam_deque",
|
|
|
|
"$rust_build:crossbeam_epoch",
|
|
|
|
"$rust_build:crossbeam_utils",
|
|
|
|
"$rust_build:futures",
|
2018-07-23 14:13:12 -04:00
|
|
|
"$rust_build:idna",
|
2018-07-28 20:46:27 -04:00
|
|
|
"$rust_build:iovec",
|
2018-08-08 05:48:56 -04:00
|
|
|
"$rust_build:kernel32",
|
2018-07-28 20:46:27 -04:00
|
|
|
"$rust_build:lazy_static",
|
|
|
|
"$rust_build:lazycell",
|
|
|
|
"$rust_build:memoffset",
|
|
|
|
"$rust_build:mio",
|
2018-08-08 05:48:56 -04:00
|
|
|
"$rust_build:miow",
|
2018-07-28 20:46:27 -04:00
|
|
|
"$rust_build:net2",
|
|
|
|
"$rust_build:nodrop",
|
|
|
|
"$rust_build:num_cpus",
|
2018-07-23 14:13:12 -04:00
|
|
|
"$rust_build:percent_encoding",
|
2018-07-24 01:45:23 -04:00
|
|
|
"$rust_build:rand",
|
|
|
|
"$rust_build:rand_core",
|
|
|
|
"$rust_build:remove_dir_all",
|
2018-07-28 20:46:27 -04:00
|
|
|
"$rust_build:scopeguard",
|
|
|
|
"$rust_build:slab",
|
|
|
|
"$rust_build:tokio_executor",
|
|
|
|
"$rust_build:tokio_fs",
|
|
|
|
"$rust_build:tokio_io",
|
|
|
|
"$rust_build:tokio_reactor",
|
|
|
|
"$rust_build:tokio_tcp",
|
|
|
|
"$rust_build:tokio_threadpool",
|
|
|
|
"$rust_build:tokio_current_thread",
|
|
|
|
"$rust_build:tokio_timer",
|
|
|
|
"$rust_build:tokio_udp",
|
|
|
|
"$rust_build:unicode_bidi",
|
|
|
|
"$rust_build:unicode_normalization",
|
2018-07-28 11:10:43 -04:00
|
|
|
"$rust_build:winapi",
|
2018-08-08 05:48:56 -04:00
|
|
|
"$rust_build:ws2_32",
|
|
|
|
]
|
|
|
|
|
|
|
|
# Old version of the 'winapi' crate, required by 'mio', 'miow', and 'iovec'.
|
|
|
|
# This exceptional! Generally we don't allow multiple versions of a crate.
|
|
|
|
# TODO: Remove this dependency. https://github.com/denoland/deno/issues/484
|
|
|
|
main_extern_version = [
|
|
|
|
{
|
|
|
|
label = "$rust_build:winapi-0.2"
|
|
|
|
crate_name = "winapi"
|
|
|
|
crate_version = "0.2"
|
|
|
|
},
|
2018-07-23 14:13:12 -04:00
|
|
|
]
|
|
|
|
|
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-08-08 05:48:56 -04:00
|
|
|
extern_version = main_extern_version
|
2018-07-12 18:38:00 -04:00
|
|
|
deps = [
|
|
|
|
":libdeno",
|
|
|
|
]
|
2018-07-12 15:06:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
# This target is for fast incremental development.
|
|
|
|
# When modifying the javascript runtime, this target will not go through the
|
|
|
|
# extra process of building a snapshot and instead load the bundle from disk.
|
2018-07-17 00:41:25 -04:00
|
|
|
# ns = no snapshot
|
|
|
|
rust_executable("deno_ns") {
|
2018-07-12 15:06:36 -04:00
|
|
|
source_root = "src/main.rs"
|
2018-07-23 14:13:12 -04:00
|
|
|
extern = main_extern
|
2018-08-08 05:48:56 -04:00
|
|
|
extern_version = main_extern_version
|
2018-07-12 18:38:00 -04:00
|
|
|
deps = [
|
|
|
|
":libdeno_nosnapshot",
|
|
|
|
]
|
2018-06-15 19:43:23 -04:00
|
|
|
}
|
|
|
|
|
2018-07-23 14:13:12 -04:00
|
|
|
rust_test("test_rs") {
|
|
|
|
source_root = "src/main.rs"
|
|
|
|
extern = main_extern
|
2018-08-08 05:48:56 -04:00
|
|
|
extern_version = main_extern_version
|
2018-07-17 16:36:11 -04:00
|
|
|
deps = [
|
2018-07-26 17:47:42 -04:00
|
|
|
":libdeno",
|
2018-07-10 14:56:12 -04:00
|
|
|
]
|
2018-07-07 16:50:35 -04:00
|
|
|
}
|
|
|
|
|
2018-07-12 13:41:19 -04:00
|
|
|
executable("test_cc") {
|
2018-06-10 08:24:39 -04:00
|
|
|
testonly = true
|
|
|
|
sources = [
|
2018-07-08 21:35:34 -04:00
|
|
|
"src/flatbuffer_builder_test.cc",
|
2018-07-12 13:41:19 -04:00
|
|
|
"src/test.cc",
|
2018-06-10 08:24:39 -04:00
|
|
|
]
|
|
|
|
deps = [
|
2018-07-16 21:33:57 -04:00
|
|
|
":deno_base_test",
|
2018-07-23 14:13:12 -04:00
|
|
|
":deno_flatbuffer_builder",
|
2018-06-10 08:24:39 -04:00
|
|
|
"//testing/gtest:gtest",
|
|
|
|
]
|
2018-06-19 06:54:24 -04:00
|
|
|
configs += [ ":deno_config" ]
|
2018-06-10 08:24:39 -04:00
|
|
|
}
|
|
|
|
|
2018-06-15 13:58:33 -04:00
|
|
|
static_library("libdeno") {
|
|
|
|
complete_static_lib = true
|
2018-06-11 11:01:35 -04:00
|
|
|
sources = [
|
2018-07-01 07:47:28 -04:00
|
|
|
"src/from_snapshot.cc",
|
2018-06-11 11:01:35 -04:00
|
|
|
]
|
2018-08-01 21:33:52 -04:00
|
|
|
inputs = [
|
2018-07-26 23:21:10 -04:00
|
|
|
"$target_gen_dir/snapshot_deno.bin",
|
|
|
|
]
|
2018-06-10 08:24:39 -04:00
|
|
|
deps = [
|
2018-06-11 11:01:35 -04:00
|
|
|
":create_snapshot_deno",
|
2018-07-12 15:06:36 -04:00
|
|
|
":deno_bindings",
|
2018-06-10 08:24:39 -04:00
|
|
|
]
|
2018-06-19 06:54:24 -04:00
|
|
|
configs += [ ":deno_config" ]
|
2018-06-10 08:24:39 -04:00
|
|
|
}
|
|
|
|
|
2018-07-16 21:33:57 -04:00
|
|
|
# Only functionality needed for mock_runtime_test and snapshot_creator
|
|
|
|
# In particular no flatbuffers, no assets, no rust, no msg handlers.
|
|
|
|
# Because snapshots are slow, it's important that snapshot_creator's
|
|
|
|
# dependencies are minimal.
|
|
|
|
v8_source_set("deno_base") {
|
2018-06-10 08:24:39 -04:00
|
|
|
sources = [
|
2018-07-06 03:19:19 -04:00
|
|
|
"src/binding.cc",
|
2018-07-06 15:00:45 -04:00
|
|
|
"src/deno.h",
|
2018-07-01 07:47:28 -04:00
|
|
|
"src/file_util.cc",
|
|
|
|
"src/file_util.h",
|
2018-07-16 21:33:57 -04:00
|
|
|
"src/internal.h",
|
|
|
|
]
|
|
|
|
public_deps = [
|
|
|
|
"third_party/v8:v8_monolith",
|
|
|
|
]
|
|
|
|
configs = [ ":deno_config" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
v8_source_set("deno_base_test") {
|
|
|
|
testonly = true
|
|
|
|
sources = [
|
|
|
|
"src/file_util_test.cc",
|
|
|
|
"src/from_snapshot.cc",
|
|
|
|
"src/mock_runtime_test.cc",
|
|
|
|
]
|
2018-08-06 19:40:04 -04:00
|
|
|
inputs = [
|
2018-07-26 23:21:10 -04:00
|
|
|
"$target_gen_dir/snapshot_mock_runtime.bin",
|
|
|
|
]
|
2018-07-16 21:33:57 -04:00
|
|
|
deps = [
|
|
|
|
":create_snapshot_mock_runtime",
|
|
|
|
":deno_base",
|
|
|
|
"//testing/gtest:gtest",
|
|
|
|
]
|
|
|
|
defines = [ "DENO_MOCK_RUNTIME" ]
|
|
|
|
configs = [ ":deno_config" ]
|
|
|
|
}
|
|
|
|
|
2018-07-23 14:13:12 -04:00
|
|
|
v8_source_set("deno_flatbuffer_builder") {
|
2018-07-16 21:33:57 -04:00
|
|
|
sources = [
|
2018-07-08 21:35:34 -04:00
|
|
|
"src/flatbuffer_builder.cc",
|
|
|
|
"src/flatbuffer_builder.h",
|
2018-06-10 08:24:39 -04:00
|
|
|
]
|
|
|
|
deps = [
|
2018-07-16 21:33:57 -04:00
|
|
|
":deno_base",
|
2018-06-13 18:55:40 -04:00
|
|
|
]
|
2018-07-08 21:35:34 -04:00
|
|
|
public_deps = [
|
|
|
|
"build_extra/flatbuffers:flatbuffers",
|
|
|
|
]
|
2018-06-19 06:54:24 -04:00
|
|
|
configs = [ ":deno_config" ]
|
2018-06-10 08:24:39 -04:00
|
|
|
}
|
|
|
|
|
2018-07-23 14:13:12 -04:00
|
|
|
v8_source_set("deno_bindings") {
|
|
|
|
sources = [
|
|
|
|
"src/reply.cc",
|
|
|
|
"src/reply.h",
|
|
|
|
]
|
|
|
|
deps = [
|
|
|
|
":deno_base",
|
|
|
|
":deno_flatbuffer_builder",
|
|
|
|
":msg_cpp",
|
|
|
|
]
|
|
|
|
configs = [ ":deno_config" ]
|
|
|
|
}
|
|
|
|
|
2018-06-10 08:24:39 -04:00
|
|
|
executable("snapshot_creator") {
|
|
|
|
sources = [
|
2018-07-01 07:47:28 -04:00
|
|
|
"src/snapshot_creator.cc",
|
2018-06-10 08:24:39 -04:00
|
|
|
]
|
|
|
|
deps = [
|
2018-07-16 21:33:57 -04:00
|
|
|
":deno_base",
|
2018-06-10 08:24:39 -04:00
|
|
|
]
|
2018-06-19 06:54:24 -04:00
|
|
|
configs += [ ":deno_config" ]
|
2018-06-10 08:24:39 -04:00
|
|
|
}
|
|
|
|
|
2018-07-04 14:50:28 -04:00
|
|
|
flatbuffer("msg_cpp") {
|
2018-06-09 18:32:04 -04:00
|
|
|
sources = [
|
2018-07-04 14:50:28 -04:00
|
|
|
"src/msg.fbs",
|
2018-06-09 18:32:04 -04:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-08-07 16:27:31 -04:00
|
|
|
# Generates type declarations for files that need to be included
|
|
|
|
# in the runtime bundle
|
|
|
|
run_node("gen_declarations") {
|
|
|
|
out_dir = target_gen_dir
|
|
|
|
sources = [
|
|
|
|
"js/console.ts",
|
|
|
|
"js/deno.ts",
|
|
|
|
"js/globals.ts",
|
|
|
|
"js/os.ts",
|
2018-08-09 15:17:08 -04:00
|
|
|
"js/timers.ts",
|
2018-08-07 16:27:31 -04:00
|
|
|
"js/tsconfig.generated.json",
|
|
|
|
"js/util.ts",
|
|
|
|
]
|
|
|
|
outputs = [
|
|
|
|
out_dir + "/js/console.d.ts",
|
|
|
|
out_dir + "/js/deno.d.ts",
|
|
|
|
out_dir + "/js/globals.d.ts",
|
|
|
|
out_dir + "/js/os.d.ts",
|
2018-08-09 15:17:08 -04:00
|
|
|
out_dir + "/js/timers.d.ts",
|
2018-08-07 16:27:31 -04:00
|
|
|
out_dir + "/js/util.d.ts",
|
|
|
|
]
|
|
|
|
deps = [
|
|
|
|
":msg_ts",
|
|
|
|
]
|
|
|
|
args = [
|
|
|
|
"./node_modules/typescript/bin/tsc",
|
|
|
|
"-p",
|
|
|
|
rebase_path("js/tsconfig.generated.json", root_build_dir),
|
|
|
|
"--baseUrl",
|
|
|
|
rebase_path(root_build_dir),
|
|
|
|
"--outDir",
|
|
|
|
rebase_path(out_dir),
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-06-11 21:54:55 -04:00
|
|
|
run_node("bundle") {
|
2018-06-13 08:58:06 -04:00
|
|
|
out_dir = "$target_gen_dir/bundle/"
|
2018-06-09 18:32:04 -04:00
|
|
|
sources = [
|
2018-07-13 03:24:07 -04:00
|
|
|
"js/assets.ts",
|
2018-07-06 11:27:36 -04:00
|
|
|
"js/console.ts",
|
|
|
|
"js/globals.ts",
|
2018-08-07 16:10:18 -04:00
|
|
|
"js/lib.globals.d.ts",
|
2018-07-01 10:37:10 -04:00
|
|
|
"js/main.ts",
|
2018-07-06 11:27:36 -04:00
|
|
|
"js/os.ts",
|
2018-08-07 16:27:31 -04:00
|
|
|
"js/plugins.d.ts",
|
2018-07-06 11:27:36 -04:00
|
|
|
"js/runtime.ts",
|
2018-08-09 13:24:03 -04:00
|
|
|
"js/text_encoding.ts",
|
2018-08-09 15:17:08 -04:00
|
|
|
"js/timers.ts",
|
2018-08-07 16:27:31 -04:00
|
|
|
"js/types.d.ts",
|
2018-07-06 11:27:36 -04:00
|
|
|
"js/util.ts",
|
2018-08-07 16:27:31 -04:00
|
|
|
"js/v8_source_maps.ts",
|
2018-07-21 21:14:52 -04:00
|
|
|
"rollup.config.js",
|
2018-07-26 11:01:17 -04:00
|
|
|
"src/msg.fbs",
|
2018-07-21 21:14:52 -04:00
|
|
|
"tsconfig.json",
|
2018-06-09 18:32:04 -04:00
|
|
|
]
|
|
|
|
outputs = [
|
2018-06-13 08:58:06 -04:00
|
|
|
out_dir + "main.js",
|
2018-07-21 21:14:52 -04:00
|
|
|
out_dir + "main.js.map",
|
2018-06-11 21:54:55 -04:00
|
|
|
]
|
|
|
|
deps = [
|
2018-08-07 16:27:31 -04:00
|
|
|
":gen_declarations",
|
2018-07-25 23:07:50 -04:00
|
|
|
":msg_ts",
|
2018-06-09 18:32:04 -04:00
|
|
|
]
|
2018-06-11 21:54:55 -04:00
|
|
|
args = [
|
2018-07-21 21:14:52 -04:00
|
|
|
"./node_modules/rollup/bin/rollup",
|
|
|
|
"-c",
|
|
|
|
rebase_path("rollup.config.js", root_build_dir),
|
|
|
|
"-i",
|
2018-07-01 10:37:10 -04:00
|
|
|
rebase_path("js/main.ts", root_build_dir),
|
2018-07-21 21:14:52 -04:00
|
|
|
"-o",
|
|
|
|
rebase_path(out_dir + "main.js", root_build_dir),
|
2018-08-08 13:44:46 -04:00
|
|
|
"--sourcemapFile",
|
|
|
|
rebase_path("."),
|
2018-07-21 21:14:52 -04:00
|
|
|
"--silent",
|
|
|
|
"--environment",
|
|
|
|
"BASEPATH:" + rebase_path(".", root_build_dir),
|
2018-06-11 21:54:55 -04:00
|
|
|
]
|
|
|
|
}
|
2018-06-09 18:32:04 -04:00
|
|
|
|
2018-07-12 15:06:36 -04:00
|
|
|
source_set("libdeno_nosnapshot") {
|
2018-08-10 13:41:12 -04:00
|
|
|
bundle_outputs = get_target_outputs(":bundle")
|
|
|
|
bundle_location = rebase_path(bundle_outputs[0])
|
|
|
|
bundle_rel_location = rebase_path(bundle_outputs[0], root_build_dir)
|
|
|
|
bundle_map_location = rebase_path(bundle_outputs[1])
|
|
|
|
inputs = bundle_outputs
|
2018-07-12 15:06:36 -04:00
|
|
|
sources = [
|
|
|
|
"src/from_filesystem.cc",
|
|
|
|
]
|
|
|
|
deps = [
|
|
|
|
":bundle",
|
|
|
|
":deno_bindings",
|
|
|
|
]
|
|
|
|
configs += [ ":deno_config" ]
|
2018-08-10 13:41:12 -04:00
|
|
|
defines = [
|
|
|
|
"BUNDLE_LOCATION=\"$bundle_location\"",
|
|
|
|
"BUNDLE_REL_LOCATION=\"$bundle_rel_location\"",
|
|
|
|
"BUNDLE_MAP_LOCATION=\"$bundle_map_location\"",
|
|
|
|
]
|
2018-07-12 15:06:36 -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-06-11 11:01:35 -04:00
|
|
|
# Generates $target_gen_dir/snapshot_deno.cc
|
2018-06-09 18:32:04 -04:00
|
|
|
create_snapshot("deno") {
|
2018-06-11 21:54:55 -04:00
|
|
|
js = "$target_gen_dir/bundle/main.js"
|
2018-08-02 13:13:32 -04:00
|
|
|
source_map = "$target_gen_dir/bundle/main.js.map"
|
2018-06-09 18:32:04 -04:00
|
|
|
deps = [
|
2018-06-11 21:54:55 -04:00
|
|
|
":bundle",
|
2018-06-09 18:32:04 -04:00
|
|
|
]
|
|
|
|
}
|
2018-06-11 11:01:35 -04:00
|
|
|
|
|
|
|
# Generates $target_gen_dir/snapshot_mock_runtime.cc
|
|
|
|
create_snapshot("mock_runtime") {
|
|
|
|
testonly = true
|
2018-07-01 10:37:10 -04:00
|
|
|
js = "js/mock_runtime.js"
|
2018-06-11 11:01:35 -04:00
|
|
|
}
|