0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-30 09:08:00 -04:00
denoland-deno/BUILD.gn

286 lines
5.9 KiB
Text
Raw Normal View History

2018-07-03 04:15:32 -04:00
import("//third_party/v8/gni/v8.gni")
import("//third_party/v8/snapshot_toolchain.gni")
import("//build_extra/flatbuffers/flatbuffer.gni")
import("//build_extra/deno.gni")
import("//build_extra/rust/rust.gni")
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
":handlers_test",
":test_cc",
]
}
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" ]
if (is_debug) {
defines = [ "DEBUG" ]
}
2018-06-19 06:54:24 -04:00
}
2018-06-23 03:42:06 -04:00
rust_executable("deno") {
source_root = "src/main.rs"
2018-07-16 23:25:50 -04:00
extern = [
"$rust_build:libc",
"$rust_build:log",
]
2018-07-12 18:38:00 -04:00
deps = [
":libdeno",
]
}
# 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") {
source_root = "src/main.rs"
2018-07-16 23:25:50 -04:00
extern = [
"$rust_build:libc",
"$rust_build:log",
]
2018-07-12 18:38:00 -04:00
deps = [
":libdeno_nosnapshot",
]
2018-06-15 19:43:23 -04:00
}
2018-07-10 14:56:12 -04:00
rust_staticlib("handlers") {
source_root = "src/handlers.rs"
2018-07-10 14:56:12 -04:00
extern = [
"$rust_build:libc",
"$rust_build:url",
2018-07-16 21:27:37 -04:00
"$rust_build:log",
2018-07-10 14:56:12 -04:00
]
}
rust_test("handlers_test") {
source_root = "src/handlers.rs"
2018-07-10 14:56:12 -04:00
extern = [
"$rust_build:libc",
"$rust_build:url",
2018-07-16 21:27:37 -04:00
"$rust_build:log",
2018-07-10 14:56:12 -04:00
]
}
executable("test_cc") {
2018-06-10 08:24:39 -04:00
testonly = true
sources = [
"src/flatbuffer_builder_test.cc",
"src/test.cc",
2018-06-10 08:24:39 -04:00
]
deps = [
":deno_base_test",
":deno_bindings",
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
}
static_library("libdeno") {
complete_static_lib = true
2018-06-11 11:01:35 -04:00
sources = [
"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_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
}
# 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 = [
"src/binding.cc",
2018-07-06 15:00:45 -04:00
"src/deno.h",
"src/file_util.cc",
"src/file_util.h",
"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",
]
deps = [
":create_snapshot_mock_runtime",
":deno_base",
"//testing/gtest:gtest",
]
defines = [ "DENO_MOCK_RUNTIME" ]
configs = [ ":deno_config" ]
}
v8_source_set("deno_bindings") {
sources = [
"src/flatbuffer_builder.cc",
"src/flatbuffer_builder.h",
"src/reply.cc",
"src/reply.h",
2018-06-10 08:24:39 -04:00
]
deps = [
":deno_base",
":handlers",
":msg_cpp",
2018-06-13 18:55:40 -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
}
executable("snapshot_creator") {
sources = [
"src/snapshot_creator.cc",
2018-06-10 08:24:39 -04:00
]
deps = [
":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") {
sources = [
2018-07-04 14:50:28 -04:00
"src/msg.fbs",
]
}
2018-06-11 21:54:55 -04:00
run_node("bundle") {
out_dir = "$target_gen_dir/bundle/"
sources = [
"js/assets.ts",
"js/console.ts",
"js/deno.d.ts",
"js/dispatch.ts",
"js/globals.ts",
"js/main.ts",
2018-07-04 14:50:28 -04:00
"js/msg_generated.ts",
"js/os.ts",
"js/runtime.ts",
"js/types.ts",
"js/util.ts",
"package.json", # The `browserslist` field controls Babel behavior.
]
outputs = [
out_dir + "main.js",
out_dir + "main.map",
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-11 21:54:55 -04:00
args = [
"./node_modules/parcel-bundler/bin/cli.js",
"build",
2018-07-16 22:40:42 -04:00
"--log-level=1", # Only disply errors.
"--no-minify",
"--out-dir",
rebase_path(out_dir, root_build_dir),
rebase_path("js/main.ts", root_build_dir),
2018-06-11 21:54:55 -04:00
]
}
source_set("libdeno_nosnapshot") {
sources = [
"src/from_filesystem.cc",
]
deps = [
":bundle",
":deno_bindings",
]
configs += [ ":deno_config" ]
bundle_outputs = get_target_outputs(":bundle")
bundle_location = rebase_path(bundle_outputs[0])
defines = [ "BUNDLE_LOCATION=\"$bundle_location\"" ]
}
# 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") {
main = "js/main.ts"
tsconfig = "tsconfig.json"
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",
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",
"--project",
rebase_path(tsconfig, root_build_dir),
2018-06-11 21:54:55 -04:00
"--outDir",
rebase_path(out_dir, root_build_dir),
]
}
2018-07-04 14:50:28 -04:00
# Generates flatbuffer TypeScript code.
# TODO(ry) Ideally flatc output files should be written into
# 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
# generated JS files. The stamp file is just to make gn work.
2018-07-04 14:50:28 -04:00
action("flatbufferjs") {
script = "//tools/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),
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-11 11:01:35 -04:00
# Generates $target_gen_dir/snapshot_deno.cc
create_snapshot("deno") {
2018-06-11 21:54:55 -04:00
js = "$target_gen_dir/bundle/main.js"
deps = [
2018-06-11 21:54:55 -04:00
":bundle",
]
}
2018-06-11 11:01:35 -04:00
# Generates $target_gen_dir/snapshot_mock_runtime.cc
create_snapshot("mock_runtime") {
testonly = true
js = "js/mock_runtime.js"
2018-06-11 11:01:35 -04:00
deps = []
}