2018-07-23 18:46:30 +00:00
|
|
|
# Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
2018-08-29 06:42:30 +00:00
|
|
|
import("//build/toolchain/cc_wrapper.gni")
|
2018-07-03 08:15:32 +00:00
|
|
|
import("//third_party/v8/gni/v8.gni")
|
|
|
|
import("//third_party/v8/snapshot_toolchain.gni")
|
2018-07-07 14:37:56 +00:00
|
|
|
import("//build_extra/flatbuffers/flatbuffer.gni")
|
2018-07-23 18:13:12 +00:00
|
|
|
import("//build_extra/flatbuffers/rust/rust_flatbuffer.gni")
|
2018-07-06 04:58:09 +00:00
|
|
|
import("//build_extra/deno.gni")
|
|
|
|
import("//build_extra/rust/rust.gni")
|
2018-08-25 11:30:58 +00:00
|
|
|
import("//build_extra/toolchain/validate.gni")
|
2018-06-09 22:32:04 +00:00
|
|
|
|
2018-08-17 22:23:14 +00:00
|
|
|
group("default") {
|
2018-07-12 22:37:06 +00:00
|
|
|
testonly = true
|
|
|
|
deps = [
|
|
|
|
":deno",
|
2018-07-17 04:41:25 +00:00
|
|
|
":deno_ns",
|
2018-07-12 22:37:06 +00:00
|
|
|
":test_cc",
|
2018-07-23 18:13:12 +00:00
|
|
|
":test_rs",
|
2018-07-12 22:37:06 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-06-19 10:54:24 +00:00
|
|
|
config("deno_config") {
|
2018-07-03 08:15:32 +00:00
|
|
|
include_dirs = [ "third_party/v8" ] # This allows us to v8/src/base/ libraries.
|
|
|
|
configs = [ "third_party/v8:external_config" ]
|
2018-07-06 15:27:36 +00:00
|
|
|
if (is_debug) {
|
|
|
|
defines = [ "DEBUG" ]
|
|
|
|
}
|
2018-07-17 20:36:11 +00: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-09-24 19:20:00 +00:00
|
|
|
|
|
|
|
if (is_clang) {
|
|
|
|
cflags = [
|
|
|
|
"-fcolor-diagnostics",
|
|
|
|
"-fansi-escape-codes",
|
|
|
|
]
|
|
|
|
}
|
2018-06-19 10:54:24 +00:00
|
|
|
}
|
|
|
|
|
2018-07-23 18:13:12 +00:00
|
|
|
main_extern = [
|
2018-08-05 22:50:15 +00:00
|
|
|
"$rust_build:hyper",
|
2018-08-28 17:49:19 +00:00
|
|
|
"$rust_build:hyper_rustls",
|
2018-08-11 20:55:37 +00:00
|
|
|
"$rust_build:futures",
|
2018-09-24 23:51:37 +00:00
|
|
|
"$rust_build:lazy_static",
|
2018-07-23 18:13:12 +00:00
|
|
|
"$rust_build:libc",
|
|
|
|
"$rust_build:log",
|
2018-08-28 17:49:19 +00:00
|
|
|
"$rust_build:ring",
|
2018-07-24 05:45:23 +00:00
|
|
|
"$rust_build:tempfile",
|
2018-08-23 22:36:45 +00:00
|
|
|
"$rust_build:rand",
|
2018-07-29 00:46:27 +00:00
|
|
|
"$rust_build:tokio",
|
2018-09-27 04:56:39 +00:00
|
|
|
"$rust_build:tokio_io",
|
|
|
|
"$rust_build:tokio_fs",
|
2018-09-18 18:53:16 +00:00
|
|
|
"$rust_build:tokio_executor",
|
2018-09-22 08:42:07 +00:00
|
|
|
"$rust_build:tokio_threadpool",
|
2018-07-23 18:13:12 +00:00
|
|
|
"$rust_build:url",
|
2018-09-11 03:40:03 +00:00
|
|
|
"$rust_build:remove_dir_all",
|
2018-09-17 01:09:02 +00:00
|
|
|
"$rust_build:dirs",
|
2018-07-23 18:13:12 +00:00
|
|
|
"//build_extra/flatbuffers/rust:flatbuffers",
|
|
|
|
":msg_rs",
|
|
|
|
]
|
|
|
|
|
2018-09-12 14:33:30 +00:00
|
|
|
ts_sources = [
|
|
|
|
"js/assets.ts",
|
2018-09-14 12:45:50 +00:00
|
|
|
"js/blob.ts",
|
2018-09-12 14:33:30 +00:00
|
|
|
"js/compiler.ts",
|
|
|
|
"js/console.ts",
|
2018-10-04 03:58:29 +00:00
|
|
|
"js/copy_file.ts",
|
2018-09-12 14:33:30 +00:00
|
|
|
"js/deno.ts",
|
|
|
|
"js/dispatch.ts",
|
2018-09-16 06:46:12 +00:00
|
|
|
"js/dom_types.ts",
|
2018-09-12 14:33:30 +00:00
|
|
|
"js/errors.ts",
|
|
|
|
"js/fetch.ts",
|
2018-10-03 21:56:56 +00:00
|
|
|
"js/fileinfo.ts",
|
2018-09-27 04:56:39 +00:00
|
|
|
"js/files.ts",
|
2018-09-12 14:33:30 +00:00
|
|
|
"js/global-eval.ts",
|
|
|
|
"js/globals.ts",
|
2018-10-04 03:58:29 +00:00
|
|
|
"js/io.ts",
|
2018-09-12 14:33:30 +00:00
|
|
|
"js/libdeno.ts",
|
|
|
|
"js/main.ts",
|
2018-09-13 02:04:45 +00:00
|
|
|
"js/make_temp_dir.ts",
|
2018-10-04 03:58:29 +00:00
|
|
|
"js/mkdir.ts",
|
2018-09-12 14:33:30 +00:00
|
|
|
"js/mock_builtin.js",
|
2018-10-04 03:58:29 +00:00
|
|
|
"js/net.ts",
|
2018-09-12 14:33:30 +00:00
|
|
|
"js/os.ts",
|
2018-09-20 06:13:59 +00:00
|
|
|
"js/platform.ts",
|
2018-09-12 14:33:30 +00:00
|
|
|
"js/plugins.d.ts",
|
2018-10-03 21:56:56 +00:00
|
|
|
"js/read_dir.ts",
|
2018-10-04 03:58:29 +00:00
|
|
|
"js/read_file.ts",
|
|
|
|
"js/read_link.ts",
|
2018-09-12 14:33:30 +00:00
|
|
|
"js/remove.ts",
|
|
|
|
"js/rename.ts",
|
|
|
|
"js/stat.ts",
|
2018-09-19 04:38:24 +00:00
|
|
|
"js/symlink.ts",
|
2018-09-12 14:33:30 +00:00
|
|
|
"js/text_encoding.ts",
|
|
|
|
"js/timers.ts",
|
2018-09-22 07:59:26 +00:00
|
|
|
"js/trace.ts",
|
2018-09-30 19:06:20 +00:00
|
|
|
"js/truncate.ts",
|
2018-09-12 14:33:30 +00:00
|
|
|
"js/types.ts",
|
|
|
|
"js/util.ts",
|
|
|
|
"js/v8_source_maps.ts",
|
|
|
|
"js/write_file.ts",
|
2018-10-04 03:58:29 +00:00
|
|
|
|
2018-10-02 16:32:02 +00:00
|
|
|
"js/tsconfig.declarations.json",
|
2018-09-12 14:33:30 +00:00
|
|
|
"tsconfig.json",
|
2018-09-13 04:25:43 +00: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 14:33:30 +00:00
|
|
|
]
|
|
|
|
|
2018-06-23 07:42:06 +00:00
|
|
|
rust_executable("deno") {
|
2018-07-01 11:47:28 +00:00
|
|
|
source_root = "src/main.rs"
|
2018-07-23 18:13:12 +00:00
|
|
|
extern = main_extern
|
2018-07-12 22:38:00 +00:00
|
|
|
deps = [
|
|
|
|
":libdeno",
|
|
|
|
]
|
2018-07-12 19:06:36 +00: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 04:41:25 +00:00
|
|
|
# ns = no snapshot
|
|
|
|
rust_executable("deno_ns") {
|
2018-07-12 19:06:36 +00:00
|
|
|
source_root = "src/main.rs"
|
2018-07-23 18:13:12 +00:00
|
|
|
extern = main_extern
|
2018-07-12 22:38:00 +00:00
|
|
|
deps = [
|
|
|
|
":libdeno_nosnapshot",
|
|
|
|
]
|
2018-06-15 23:43:23 +00:00
|
|
|
}
|
|
|
|
|
2018-07-23 18:13:12 +00:00
|
|
|
rust_test("test_rs") {
|
|
|
|
source_root = "src/main.rs"
|
|
|
|
extern = main_extern
|
2018-07-17 20:36:11 +00:00
|
|
|
deps = [
|
2018-07-26 21:47:42 +00:00
|
|
|
":libdeno",
|
2018-07-10 18:56:12 +00:00
|
|
|
]
|
2018-07-07 20:50:35 +00:00
|
|
|
}
|
|
|
|
|
2018-08-14 03:03:32 +00:00
|
|
|
v8_executable("test_cc") {
|
2018-06-10 12:24:39 +00:00
|
|
|
testonly = true
|
|
|
|
sources = [
|
2018-08-19 07:44:10 +00:00
|
|
|
"libdeno/test.cc",
|
2018-06-10 12:24:39 +00:00
|
|
|
]
|
|
|
|
deps = [
|
2018-07-17 01:33:57 +00:00
|
|
|
":deno_base_test",
|
2018-06-10 12:24:39 +00:00
|
|
|
"//testing/gtest:gtest",
|
|
|
|
]
|
2018-08-14 03:03:32 +00:00
|
|
|
configs = [ ":deno_config" ]
|
2018-06-10 12:24:39 +00:00
|
|
|
}
|
|
|
|
|
2018-06-15 17:58:33 +00:00
|
|
|
static_library("libdeno") {
|
|
|
|
complete_static_lib = true
|
2018-06-11 15:01:35 +00:00
|
|
|
sources = [
|
2018-08-19 07:44:10 +00:00
|
|
|
"libdeno/from_snapshot.cc",
|
2018-06-11 15:01:35 +00:00
|
|
|
]
|
2018-08-02 01:33:52 +00:00
|
|
|
inputs = [
|
2018-07-27 03:21:10 +00:00
|
|
|
"$target_gen_dir/snapshot_deno.bin",
|
|
|
|
]
|
2018-06-10 12:24:39 +00:00
|
|
|
deps = [
|
2018-06-11 15:01:35 +00:00
|
|
|
":create_snapshot_deno",
|
2018-07-12 19:06:36 +00:00
|
|
|
":deno_bindings",
|
2018-06-10 12:24:39 +00:00
|
|
|
]
|
2018-06-19 10:54:24 +00:00
|
|
|
configs += [ ":deno_config" ]
|
2018-08-29 06:42:30 +00:00
|
|
|
|
|
|
|
# from_snapshot.cc uses an assembly '.incbin' directive to embed the snapshot.
|
|
|
|
# This causes trouble when using sccache: since the snapshot file is not
|
|
|
|
# inlined by the c preprocessor, sccache doesn't take its contents into
|
|
|
|
# consideration, leading to false-positive cache hits.
|
|
|
|
# Maybe other caching tools have this issue too, but ccache is unaffected.
|
|
|
|
# Therefore, if a cc_wrapper is used that isn't ccache, include a generated
|
|
|
|
# header file that contains the the sha256 hash of the snapshot.
|
|
|
|
if (cc_wrapper != "" && cc_wrapper != "ccache") {
|
|
|
|
hash_h = "$target_gen_dir/bundle/hash.h"
|
|
|
|
inputs += [ hash_h ]
|
|
|
|
deps += [ ":bundle_hash_h" ]
|
|
|
|
if (is_win) {
|
|
|
|
cflags = [ "/FI" + rebase_path(hash_h, target_out_dir) ]
|
|
|
|
} else {
|
|
|
|
cflags = [
|
|
|
|
"-include",
|
|
|
|
rebase_path(hash_h, target_out_dir),
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
2018-06-10 12:24:39 +00:00
|
|
|
}
|
|
|
|
|
2018-08-10 19:09:28 +00:00
|
|
|
# Only functionality needed for libdeno_test and snapshot_creator
|
2018-07-17 01:33:57 +00:00
|
|
|
# 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 12:24:39 +00:00
|
|
|
sources = [
|
2018-08-19 07:44:10 +00:00
|
|
|
"libdeno/binding.cc",
|
|
|
|
"libdeno/deno.h",
|
|
|
|
"libdeno/file_util.cc",
|
|
|
|
"libdeno/file_util.h",
|
|
|
|
"libdeno/internal.h",
|
2018-07-17 01:33:57 +00:00
|
|
|
]
|
|
|
|
public_deps = [
|
|
|
|
"third_party/v8:v8_monolith",
|
|
|
|
]
|
|
|
|
configs = [ ":deno_config" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
v8_source_set("deno_base_test") {
|
|
|
|
testonly = true
|
|
|
|
sources = [
|
2018-08-19 07:44:10 +00:00
|
|
|
"libdeno/file_util_test.cc",
|
|
|
|
"libdeno/from_snapshot.cc",
|
|
|
|
"libdeno/libdeno_test.cc",
|
2018-07-17 01:33:57 +00:00
|
|
|
]
|
2018-08-06 23:40:04 +00:00
|
|
|
inputs = [
|
2018-08-10 19:09:28 +00:00
|
|
|
"$target_gen_dir/snapshot_libdeno_test.bin",
|
2018-07-27 03:21:10 +00:00
|
|
|
]
|
2018-07-17 01:33:57 +00:00
|
|
|
deps = [
|
2018-08-10 19:09:28 +00:00
|
|
|
":create_snapshot_libdeno_test",
|
2018-07-17 01:33:57 +00:00
|
|
|
":deno_base",
|
|
|
|
"//testing/gtest:gtest",
|
|
|
|
]
|
2018-08-10 19:09:28 +00:00
|
|
|
defines = [ "LIBDENO_TEST" ]
|
2018-07-17 01:33:57 +00:00
|
|
|
configs = [ ":deno_config" ]
|
|
|
|
}
|
|
|
|
|
2018-07-23 18:13:12 +00:00
|
|
|
v8_source_set("deno_bindings") {
|
|
|
|
deps = [
|
|
|
|
":deno_base",
|
|
|
|
]
|
|
|
|
configs = [ ":deno_config" ]
|
|
|
|
}
|
|
|
|
|
2018-06-10 12:24:39 +00:00
|
|
|
executable("snapshot_creator") {
|
|
|
|
sources = [
|
2018-08-19 07:44:10 +00:00
|
|
|
"libdeno/snapshot_creator.cc",
|
2018-06-10 12:24:39 +00:00
|
|
|
]
|
|
|
|
deps = [
|
2018-07-17 01:33:57 +00:00
|
|
|
":deno_base",
|
2018-06-10 12:24:39 +00:00
|
|
|
]
|
2018-06-19 10:54:24 +00:00
|
|
|
configs += [ ":deno_config" ]
|
2018-06-10 12:24:39 +00:00
|
|
|
}
|
|
|
|
|
2018-08-07 20:27:31 +00:00
|
|
|
# Generates type declarations for files that need to be included
|
|
|
|
# in the runtime bundle
|
|
|
|
run_node("gen_declarations") {
|
|
|
|
out_dir = target_gen_dir
|
2018-09-12 14:33:30 +00:00
|
|
|
sources = ts_sources
|
2018-08-07 20:27:31 +00:00
|
|
|
outputs = [
|
2018-09-01 14:45:26 +00:00
|
|
|
"$out_dir/types/globals.d.ts",
|
2018-08-07 20:27:31 +00:00
|
|
|
]
|
|
|
|
deps = [
|
|
|
|
":msg_ts",
|
|
|
|
]
|
|
|
|
args = [
|
|
|
|
"./node_modules/typescript/bin/tsc",
|
|
|
|
"-p",
|
2018-10-02 16:32:02 +00:00
|
|
|
rebase_path("js/tsconfig.declarations.json", root_build_dir),
|
2018-08-07 20:27:31 +00:00
|
|
|
"--baseUrl",
|
2018-08-25 17:04:30 +00:00
|
|
|
rebase_path(root_build_dir, root_build_dir),
|
2018-09-01 14:45:26 +00:00
|
|
|
"--outFile",
|
|
|
|
rebase_path("$out_dir/types/globals.js", root_build_dir),
|
2018-08-07 20:27:31 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-06-12 01:54:55 +00:00
|
|
|
run_node("bundle") {
|
2018-06-13 12:58:06 +00:00
|
|
|
out_dir = "$target_gen_dir/bundle/"
|
2018-09-13 04:25:43 +00:00
|
|
|
sources = ts_sources + [ "rollup.config.js" ]
|
2018-06-09 22:32:04 +00:00
|
|
|
outputs = [
|
2018-06-13 12:58:06 +00:00
|
|
|
out_dir + "main.js",
|
2018-07-22 01:14:52 +00:00
|
|
|
out_dir + "main.js.map",
|
2018-06-12 01:54:55 +00:00
|
|
|
]
|
|
|
|
deps = [
|
2018-08-07 20:27:31 +00:00
|
|
|
":gen_declarations",
|
2018-07-26 03:07:50 +00:00
|
|
|
":msg_ts",
|
2018-06-09 22:32:04 +00:00
|
|
|
]
|
2018-06-12 01:54:55 +00:00
|
|
|
args = [
|
2018-07-22 01:14:52 +00:00
|
|
|
"./node_modules/rollup/bin/rollup",
|
|
|
|
"-c",
|
|
|
|
rebase_path("rollup.config.js", root_build_dir),
|
|
|
|
"-i",
|
2018-07-01 14:37:10 +00:00
|
|
|
rebase_path("js/main.ts", root_build_dir),
|
2018-07-22 01:14:52 +00:00
|
|
|
"-o",
|
|
|
|
rebase_path(out_dir + "main.js", root_build_dir),
|
2018-08-08 17:44:46 +00:00
|
|
|
"--sourcemapFile",
|
|
|
|
rebase_path("."),
|
2018-07-22 01:14:52 +00:00
|
|
|
"--silent",
|
|
|
|
"--environment",
|
|
|
|
"BASEPATH:" + rebase_path(".", root_build_dir),
|
2018-06-12 01:54:55 +00:00
|
|
|
]
|
|
|
|
}
|
2018-06-09 22:32:04 +00:00
|
|
|
|
2018-08-29 06:42:30 +00:00
|
|
|
action("bundle_hash_h") {
|
|
|
|
script = "//tools/sha256sum.py"
|
|
|
|
inputs = get_target_outputs(":bundle")
|
|
|
|
outputs = [
|
|
|
|
"$target_gen_dir/bundle/hash.h",
|
|
|
|
]
|
|
|
|
deps = [
|
|
|
|
":bundle",
|
|
|
|
]
|
|
|
|
args = [
|
|
|
|
"--format",
|
|
|
|
"__attribute__((__unused__)) static const int dummy_%s = 0;",
|
|
|
|
"--outfile",
|
|
|
|
rebase_path(outputs[0], root_build_dir),
|
|
|
|
]
|
|
|
|
foreach(input, inputs) {
|
|
|
|
args += [
|
|
|
|
"--infile",
|
|
|
|
rebase_path(input, root_build_dir),
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-12 19:06:36 +00:00
|
|
|
source_set("libdeno_nosnapshot") {
|
2018-08-10 17:41:12 +00:00
|
|
|
bundle_outputs = get_target_outputs(":bundle")
|
2018-08-25 23:38:23 +00:00
|
|
|
bundle_location = rebase_path(bundle_outputs[0], root_build_dir)
|
|
|
|
bundle_map_location = rebase_path(bundle_outputs[1], root_build_dir)
|
2018-08-10 17:41:12 +00:00
|
|
|
inputs = bundle_outputs
|
2018-07-12 19:06:36 +00:00
|
|
|
sources = [
|
2018-08-19 07:44:10 +00:00
|
|
|
"libdeno/from_filesystem.cc",
|
2018-07-12 19:06:36 +00:00
|
|
|
]
|
|
|
|
deps = [
|
|
|
|
":bundle",
|
|
|
|
":deno_bindings",
|
|
|
|
]
|
|
|
|
configs += [ ":deno_config" ]
|
2018-08-10 17:41:12 +00:00
|
|
|
defines = [
|
|
|
|
"BUNDLE_LOCATION=\"$bundle_location\"",
|
|
|
|
"BUNDLE_MAP_LOCATION=\"$bundle_map_location\"",
|
|
|
|
]
|
2018-07-12 19:06:36 +00:00
|
|
|
}
|
|
|
|
|
2018-07-04 18:50:28 +00:00
|
|
|
ts_flatbuffer("msg_ts") {
|
|
|
|
sources = [
|
|
|
|
"src/msg.fbs",
|
|
|
|
]
|
2018-06-09 22:32:04 +00:00
|
|
|
}
|
|
|
|
|
2018-07-23 18:13:12 +00:00
|
|
|
rust_flatbuffer("msg_rs") {
|
|
|
|
sources = [
|
|
|
|
"src/msg.fbs",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-08-10 19:09:28 +00:00
|
|
|
# Generates $target_gen_dir/snapshot_deno.bin
|
2018-06-09 22:32:04 +00:00
|
|
|
create_snapshot("deno") {
|
2018-06-12 01:54:55 +00:00
|
|
|
js = "$target_gen_dir/bundle/main.js"
|
2018-08-02 17:13:32 +00:00
|
|
|
source_map = "$target_gen_dir/bundle/main.js.map"
|
2018-06-09 22:32:04 +00:00
|
|
|
deps = [
|
2018-06-12 01:54:55 +00:00
|
|
|
":bundle",
|
2018-06-09 22:32:04 +00:00
|
|
|
]
|
|
|
|
}
|
2018-06-11 15:01:35 +00:00
|
|
|
|
2018-08-10 19:09:28 +00:00
|
|
|
# Generates $target_gen_dir/snapshot_libdeno_test.bin
|
|
|
|
create_snapshot("libdeno_test") {
|
2018-06-11 15:01:35 +00:00
|
|
|
testonly = true
|
2018-08-19 07:44:10 +00:00
|
|
|
js = "libdeno/libdeno_test.js"
|
2018-06-11 15:01:35 +00:00
|
|
|
}
|