deno/BUILD.gn

271 lines
5.7 KiB
Plaintext
Raw Normal View History

# Copyright 2018 the Deno authors. All rights reserved. MIT license.
2018-07-03 08:15:32 +00:00
import("//third_party/v8/gni/v8.gni")
import("//third_party/v8/snapshot_toolchain.gni")
import("//build_extra/flatbuffers/flatbuffer.gni")
import("//build_extra/flatbuffers/rust/rust_flatbuffer.gni")
import("//build_extra/deno.gni")
import("//build_extra/rust/rust.gni")
2018-07-12 22:37:06 +00:00
group("all") {
testonly = true
deps = [
":deno",
2018-07-17 04:41:25 +00:00
":deno_ns",
2018-07-12 22:37:06 +00:00
":test_cc",
":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" ]
if (is_debug) {
defines = [ "DEBUG" ]
}
# 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-06-19 10:54:24 +00:00
}
main_extern = [
"$rust_build:libc",
"$rust_build:log",
2018-07-24 05:45:23 +00:00
"$rust_build:sha1",
"$rust_build:tempfile",
"$rust_build:url",
"//build_extra/flatbuffers/rust:flatbuffers",
":msg_rs",
# Indirect rust depdendencies also need to be listed here:
# * Linking to `:handlers` or `:libdeno` isn't possible, because they
# already contain some symbols exported by `handlers.rs`. These duplicate
# symbols trip up the linker.
# * The `rust_test` and `rust_executable` templates only produce an object
# file, and then invoke an external linker. Transitive rust depencenies
# are not resolved in either step.
"$rust_build:idna",
"$rust_build:percent_encoding",
"$rust_build:unicode_bidi",
"$rust_build:unicode_normalization",
2018-07-24 05:45:23 +00:00
"$rust_build:rand",
"$rust_build:rand_core",
"$rust_build:remove_dir_all",
]
2018-06-23 07:42:06 +00:00
rust_executable("deno") {
source_root = "src/main.rs"
extern = main_extern
2018-07-12 22:38:00 +00: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 04:41:25 +00:00
# ns = no snapshot
rust_executable("deno_ns") {
source_root = "src/main.rs"
extern = main_extern
2018-07-12 22:38:00 +00:00
deps = [
":libdeno_nosnapshot",
]
2018-06-15 23:43:23 +00:00
}
rust_test("test_rs") {
source_root = "src/main.rs"
extern = main_extern
deps = [
":libdeno",
2018-07-10 18:56:12 +00:00
]
}
executable("test_cc") {
2018-06-10 12:24:39 +00:00
testonly = true
sources = [
"src/flatbuffer_builder_test.cc",
"src/test.cc",
2018-06-10 12:24:39 +00:00
]
deps = [
":deno_base_test",
":deno_flatbuffer_builder",
2018-06-10 12:24:39 +00:00
"//testing/gtest:gtest",
]
2018-06-19 10:54:24 +00:00
configs += [ ":deno_config" ]
2018-06-10 12:24:39 +00:00
}
static_library("libdeno") {
complete_static_lib = true
2018-06-11 15:01:35 +00:00
sources = [
"src/from_snapshot.cc",
2018-06-11 15:01:35 +00:00
]
2018-06-10 12:24:39 +00:00
deps = [
2018-06-11 15:01:35 +00:00
":create_snapshot_deno",
":deno_bindings",
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
}
# 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 12:24:39 +00:00
sources = [
"src/binding.cc",
2018-07-06 19:00:45 +00: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_flatbuffer_builder") {
sources = [
"src/flatbuffer_builder.cc",
"src/flatbuffer_builder.h",
2018-06-10 12:24:39 +00:00
]
deps = [
":deno_base",
2018-06-13 22:55:40 +00:00
]
public_deps = [
"build_extra/flatbuffers:flatbuffers",
]
2018-06-19 10:54:24 +00:00
configs = [ ":deno_config" ]
2018-06-10 12:24:39 +00:00
}
v8_source_set("deno_bindings") {
sources = [
"src/reply.cc",
"src/reply.h",
]
deps = [
":deno_base",
":deno_flatbuffer_builder",
":msg_cpp",
]
configs = [ ":deno_config" ]
}
2018-06-10 12:24:39 +00:00
executable("snapshot_creator") {
sources = [
"src/snapshot_creator.cc",
2018-06-10 12:24:39 +00:00
]
deps = [
":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-07-04 18:50:28 +00:00
flatbuffer("msg_cpp") {
sources = [
2018-07-04 18:50:28 +00:00
"src/msg.fbs",
]
}
2018-06-12 01:54:55 +00: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",
"js/os.ts",
"js/runtime.ts",
"js/types.ts",
"js/util.ts",
2018-07-22 01:14:52 +00:00
"rollup.config.js",
2018-07-26 15:01:17 +00:00
"src/msg.fbs",
2018-07-22 01:14:52 +00:00
"tsconfig.json",
]
outputs = [
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-07-26 03:07:50 +00:00
":msg_ts",
]
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",
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),
"--silent",
"--environment",
"BASEPATH:" + rebase_path(".", root_build_dir),
2018-06-12 01:54:55 +00: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\"" ]
}
2018-07-04 18:50:28 +00:00
ts_flatbuffer("msg_ts") {
sources = [
"src/msg.fbs",
]
}
rust_flatbuffer("msg_rs") {
sources = [
"src/msg.fbs",
]
}
2018-06-11 15:01:35 +00:00
# Generates $target_gen_dir/snapshot_deno.cc
create_snapshot("deno") {
2018-06-12 01:54:55 +00:00
js = "$target_gen_dir/bundle/main.js"
deps = [
2018-06-12 01:54:55 +00:00
":bundle",
]
}
2018-06-11 15:01:35 +00:00
# Generates $target_gen_dir/snapshot_mock_runtime.cc
create_snapshot("mock_runtime") {
testonly = true
js = "js/mock_runtime.js"
2018-06-11 15:01:35 +00:00
deps = []
}