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

277 lines
5.8 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",
":deno_cc",
":deno_cc_nosnapshot",
":deno_nosnapshot",
":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"
extern = [ "$rust_build:libc" ]
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.
rust_executable("deno_nosnapshot") {
source_root = "src/main.rs"
extern = [ "$rust_build:libc" ]
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",
]
}
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-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",
":handlers",
2018-06-10 08:24:39 -04:00
":libdeno",
2018-07-04 14:50:28 -04:00
":msg_cpp",
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
}
# 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.
executable("deno_cc_nosnapshot") {
sources = [
"src/main.cc",
]
deps = [
":flatbufferjs",
":handlers",
":libdeno_nosnapshot",
":msg_cpp",
]
configs += [ ":deno_config" ]
}
executable("test_cc") {
2018-06-10 08:24:39 -04:00
testonly = true
sources = [
"src/file_util_test.cc",
"src/flatbuffer_builder_test.cc",
"src/from_snapshot.cc",
"src/mock_runtime_test.cc",
"src/test.cc",
2018-06-10 08:24:39 -04:00
]
deps = [
2018-06-11 11:01:35 -04:00
":create_snapshot_mock_runtime",
":deno_bindings",
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
}
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
}
v8_source_set("deno_bindings") {
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/flatbuffer_builder.cc",
"src/flatbuffer_builder.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
]
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_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-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/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",
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 = []
}