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

197 lines
4.1 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")
2018-07-04 14:50:28 -04:00
import("//third_party/flatbuffers/flatbuffer.gni")
import("//third_party/flatbuffers/ts_flatbuffer.gni")
import("//build_extra/deno.gni")
import("//build_extra/rust/rust.gni")
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-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-06 05:33:32 -04:00
extern = [ ":libc" ]
2018-06-15 19:43:23 -04:00
deps = [
":libdeno",
]
}
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-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-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
}
2018-06-11 11:01:35 -04:00
executable("mock_runtime_test") {
2018-06-10 08:24:39 -04:00
testonly = true
sources = [
"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
}
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_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 = [
"src/binding.cc",
"src/internal.h",
"src/file_util.cc",
"src/file_util.h",
"src/deno.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 = [
"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") {
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/main.ts",
2018-07-04 14:50:28 -04:00
"js/msg_generated.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",
"--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
]
}
# 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 = "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),
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 = []
}