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-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-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-06-19 06:54:24 -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-06 05:33:32 -04:00
|
|
|
extern = [ ":libc" ]
|
2018-06-15 19:43:23 -04:00
|
|
|
deps = [
|
|
|
|
":libdeno",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-07-06 00:58:09 -04:00
|
|
|
rust_component("libc") {
|
2018-06-15 19:43:23 -04:00
|
|
|
source_root = "third_party/rust_crates/libc/src/lib.rs"
|
|
|
|
cfg = [
|
|
|
|
"feature=\"default\"",
|
|
|
|
"feature=\"use_std\"",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-07-06 11:27:36 -04:00
|
|
|
rust_component("handlers") {
|
|
|
|
source_root = "src/handlers.rs"
|
|
|
|
extern = [ ":libc" ]
|
|
|
|
}
|
|
|
|
|
2018-07-07 16:50:35 -04:00
|
|
|
rust_test("handlers_test") {
|
|
|
|
source_root = "src/handlers.rs"
|
|
|
|
extern = [ ":libc" ]
|
|
|
|
}
|
|
|
|
|
2018-07-04 16:45:56 -04:00
|
|
|
executable("deno_cc") {
|
2018-06-10 08:24:39 -04:00
|
|
|
sources = [
|
2018-07-04 16:45:56 -04:00
|
|
|
"src/main.cc",
|
2018-06-10 08:24:39 -04:00
|
|
|
]
|
|
|
|
deps = [
|
2018-07-04 14:50:28 -04:00
|
|
|
":flatbufferjs",
|
2018-07-06 11:27:36 -04:00
|
|
|
":handlers",
|
2018-06-10 08:24:39 -04:00
|
|
|
":libdeno",
|
2018-07-04 14:50:28 -04:00
|
|
|
":msg_cpp",
|
2018-07-06 11:27:36 -04:00
|
|
|
"//build_extra/rust:stdlib",
|
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-06-11 11:01:35 -04:00
|
|
|
executable("mock_runtime_test") {
|
2018-06-10 08:24:39 -04:00
|
|
|
testonly = true
|
|
|
|
sources = [
|
2018-07-01 07:47:28 -04:00
|
|
|
"src/file_util_test.cc",
|
|
|
|
"src/from_snapshot.cc",
|
|
|
|
"src/mock_runtime_test.cc",
|
2018-06-10 08:24:39 -04:00
|
|
|
]
|
|
|
|
deps = [
|
2018-06-11 11:01:35 -04:00
|
|
|
":create_snapshot_mock_runtime",
|
|
|
|
":deno_nosnapshot",
|
2018-06-10 08:24:39 -04:00
|
|
|
"//testing/gtest:gtest",
|
|
|
|
]
|
2018-06-11 11:01:35 -04:00
|
|
|
defines = [ "DENO_MOCK_RUNTIME" ]
|
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-06-10 08:24:39 -04:00
|
|
|
deps = [
|
2018-06-11 11:01:35 -04:00
|
|
|
":create_snapshot_deno",
|
|
|
|
":deno_nosnapshot",
|
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-06-19 06:54:24 -04:00
|
|
|
v8_source_set("deno_nosnapshot") {
|
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-06 15:00:45 -04:00
|
|
|
"src/internal.h",
|
2018-06-10 08:24:39 -04:00
|
|
|
]
|
|
|
|
deps = [
|
2018-07-03 04:15:32 -04:00
|
|
|
"third_party/v8:v8_monolith",
|
2018-06-13 18:55:40 -04:00
|
|
|
]
|
2018-06-19 06:54:24 -04:00
|
|
|
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 = [
|
|
|
|
":deno_nosnapshot",
|
|
|
|
]
|
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-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-06 11:27:36 -04:00
|
|
|
"js/console.ts",
|
|
|
|
"js/deno.d.ts",
|
|
|
|
"js/dispatch.ts",
|
|
|
|
"js/globals.ts",
|
2018-07-01 10:37:10 -04:00
|
|
|
"js/main.ts",
|
2018-07-04 14:50:28 -04:00
|
|
|
"js/msg_generated.ts",
|
2018-07-06 11:27:36 -04:00
|
|
|
"js/os.ts",
|
|
|
|
"js/runtime.ts",
|
|
|
|
"js/types.ts",
|
|
|
|
"js/util.ts",
|
2018-07-06 01:11:15 -04:00
|
|
|
"package.json", # The `browserslist` field controls Babel behavior.
|
2018-06-09 18:32:04 -04:00
|
|
|
]
|
|
|
|
outputs = [
|
2018-06-13 08:58:06 -04:00
|
|
|
out_dir + "main.js",
|
2018-06-11 21:54:55 -04:00
|
|
|
]
|
|
|
|
deps = [
|
2018-07-04 14:50:28 -04:00
|
|
|
":flatbufferjs",
|
2018-06-11 21:54:55 -04:00
|
|
|
":run_tsc",
|
2018-06-09 18:32:04 -04:00
|
|
|
]
|
2018-06-11 21:54:55 -04:00
|
|
|
args = [
|
2018-06-13 08:58:06 -04:00
|
|
|
"./node_modules/parcel-bundler/bin/cli.js",
|
|
|
|
"build",
|
|
|
|
"--no-minify",
|
|
|
|
"--out-dir",
|
|
|
|
rebase_path(out_dir, root_build_dir),
|
2018-07-01 10:37:10 -04:00
|
|
|
rebase_path("js/main.ts", root_build_dir),
|
2018-06-11 21:54:55 -04:00
|
|
|
]
|
|
|
|
}
|
2018-06-09 18:32:04 -04:00
|
|
|
|
2018-06-13 08:58:06 -04:00
|
|
|
# Due to bugs in Parcel we must run TSC independently in order to catch errors.
|
|
|
|
# https://github.com/parcel-bundler/parcel/issues/954
|
2018-06-11 21:54:55 -04:00
|
|
|
run_node("run_tsc") {
|
2018-07-01 10:37:10 -04:00
|
|
|
main = "js/main.ts"
|
|
|
|
tsconfig = "tsconfig.json"
|
2018-06-13 08:58:06 -04:00
|
|
|
out_dir = "$target_gen_dir/tsc_dist/"
|
2018-06-11 21:54:55 -04:00
|
|
|
sources = [
|
2018-07-04 14:50:28 -04:00
|
|
|
"js/msg_generated.ts",
|
2018-06-13 08:58:06 -04:00
|
|
|
main,
|
|
|
|
tsconfig,
|
2018-06-11 21:54:55 -04:00
|
|
|
]
|
|
|
|
outputs = [
|
|
|
|
out_dir + "/main.js",
|
|
|
|
]
|
|
|
|
deps = [
|
2018-07-04 14:50:28 -04:00
|
|
|
":flatbufferjs",
|
2018-06-11 21:54:55 -04:00
|
|
|
]
|
|
|
|
args = [
|
2018-06-12 16:05:49 -04:00
|
|
|
"./node_modules/typescript/bin/tsc",
|
2018-06-13 08:58:06 -04:00
|
|
|
"--project",
|
|
|
|
rebase_path(tsconfig, root_build_dir),
|
2018-06-11 21:54:55 -04:00
|
|
|
"--outDir",
|
|
|
|
rebase_path(out_dir, root_build_dir),
|
|
|
|
]
|
|
|
|
}
|
2018-06-09 18:32:04 -04:00
|
|
|
|
2018-07-04 14:50:28 -04:00
|
|
|
# Generates flatbuffer TypeScript code.
|
|
|
|
# TODO(ry) Ideally flatc output files should be written into
|
2018-06-13 08:58:06 -04:00
|
|
|
# target_gen_dir, but its difficult to get this working in a way that the
|
|
|
|
# bundler can resolve their location. (The bundler does not support NODE_PATH?)
|
2018-07-04 14:50:28 -04:00
|
|
|
# Therefore this hack: write the msg_generated.ts output
|
|
|
|
# into the js/ folder, and we check it into the repo. Hopefully this hack can
|
|
|
|
# be removed at some point. If msg.fps is changed, commit changes to the
|
2018-06-13 08:58:06 -04:00
|
|
|
# generated JS files. The stamp file is just to make gn work.
|
2018-07-04 14:50:28 -04:00
|
|
|
action("flatbufferjs") {
|
|
|
|
script = "js/flatbufferjs_hack.py"
|
2018-06-11 21:54:55 -04:00
|
|
|
sources = [
|
2018-07-04 14:50:28 -04:00
|
|
|
"src/msg.fbs",
|
2018-06-11 21:54:55 -04:00
|
|
|
]
|
|
|
|
outputs = [
|
2018-07-04 14:50:28 -04:00
|
|
|
"$target_gen_dir/flatbufferjs_hack.stamp",
|
2018-06-11 21:54:55 -04:00
|
|
|
]
|
2018-07-04 14:50:28 -04:00
|
|
|
|
2018-06-11 21:54:55 -04:00
|
|
|
args = [
|
2018-07-04 14:50:28 -04:00
|
|
|
rebase_path("$target_gen_dir/msg_generated.ts", root_build_dir),
|
|
|
|
rebase_path("js/msg_generated.ts", root_build_dir),
|
2018-06-11 23:16:41 -04:00
|
|
|
rebase_path(outputs[0], root_build_dir),
|
2018-06-11 21:54:55 -04:00
|
|
|
]
|
2018-07-04 14:50:28 -04:00
|
|
|
|
|
|
|
deps = [
|
|
|
|
":msg_ts",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
ts_flatbuffer("msg_ts") {
|
|
|
|
sources = [
|
|
|
|
"src/msg.fbs",
|
|
|
|
]
|
2018-06-09 18:32:04 -04:00
|
|
|
}
|
|
|
|
|
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-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
|
|
|
deps = []
|
|
|
|
}
|