1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-14 16:33:45 -05:00
denoland-deno/BUILD.gn

237 lines
5.2 KiB
Text
Raw Normal View History

# Copyright 2018 the Deno authors. All rights reserved. MIT license.
import("//build/toolchain/cc_wrapper.gni")
import("//build_extra/flatbuffers/flatbuffer.gni")
import("//build_extra/flatbuffers/rust/rust_flatbuffer.gni")
import("//build_extra/rust/rust.gni")
import("//third_party/v8/gni/v8.gni")
import("//third_party/v8/snapshot_toolchain.gni")
import("libdeno/deno.gni")
2018-08-17 18:23:14 -04:00
group("default") {
2018-07-12 18:37:06 -04:00
testonly = true
deps = [
":deno",
":hyper_hello",
":test_rs",
"libdeno:test_cc",
2018-07-12 18:37:06 -04:00
]
}
main_extern = [
"$rust_build:atty",
"$rust_build:dirs",
2018-12-23 12:39:40 -05:00
"$rust_build:flatbuffers",
"$rust_build:futures",
"$rust_build:getopts",
"$rust_build:http",
2018-08-05 18:50:15 -04:00
"$rust_build:hyper",
"$rust_build:hyper_rustls",
2018-12-23 12:39:40 -05:00
"$rust_build:kernel32",
"$rust_build:lazy_static",
"$rust_build:libc",
"$rust_build:log",
"$rust_build:rand",
"$rust_build:remove_dir_all",
"$rust_build:ring",
"$rust_build:rustyline",
"$rust_build:serde_json",
"$rust_build:source_map_mappings",
2018-07-24 01:45:23 -04:00
"$rust_build:tempfile",
"$rust_build:tokio",
"$rust_build:tokio_executor",
"$rust_build:tokio_fs",
"$rust_build:tokio_io",
"$rust_build:tokio_process",
2018-09-22 04:42:07 -04:00
"$rust_build:tokio_threadpool",
"$rust_build:url",
2018-12-22 23:53:29 -05:00
"$rust_build:winapi",
]
2018-09-12 10:33:30 -04:00
ts_sources = [
"js/assets.ts",
2018-09-14 08:45:50 -04:00
"js/blob.ts",
"js/buffer.ts",
"js/chmod.ts",
2018-09-12 10:33:30 -04:00
"js/compiler.ts",
"js/console.ts",
"js/copy_file.ts",
2018-09-12 10:33:30 -04:00
"js/deno.ts",
2018-10-13 16:03:27 -04:00
"js/dir.ts",
2018-09-12 10:33:30 -04:00
"js/dispatch.ts",
2018-09-16 02:46:12 -04:00
"js/dom_types.ts",
2018-09-12 10:33:30 -04:00
"js/errors.ts",
2019-01-05 10:02:44 -05:00
"js/event.ts",
"js/event_target.ts",
2018-09-12 10:33:30 -04:00
"js/fetch.ts",
2018-12-27 04:45:58 -05:00
"js/dom_file.ts",
2018-10-03 21:41:59 -04:00
"js/file_info.ts",
"js/files.ts",
"js/flatbuffers.ts",
"js/form_data.ts",
2018-10-03 21:41:59 -04:00
"js/global_eval.ts",
2018-09-12 10:33:30 -04:00
"js/globals.ts",
"js/headers.ts",
"js/io.ts",
2018-09-12 10:33:30 -04:00
"js/libdeno.ts",
"js/main.ts",
2018-09-12 22:04:45 -04:00
"js/make_temp_dir.ts",
2018-10-05 13:21:15 -04:00
"js/metrics.ts",
"js/mkdir.ts",
2018-09-12 10:33:30 -04:00
"js/mock_builtin.js",
"js/net.ts",
2018-09-12 10:33:30 -04:00
"js/os.ts",
2018-09-20 02:13:59 -04:00
"js/platform.ts",
2018-09-12 10:33:30 -04:00
"js/plugins.d.ts",
"js/process.ts",
2018-10-03 17:56:56 -04:00
"js/read_dir.ts",
"js/read_file.ts",
"js/read_link.ts",
2018-09-12 10:33:30 -04:00
"js/remove.ts",
"js/rename.ts",
"js/repl.ts",
"js/resources.ts",
2018-09-12 10:33:30 -04:00
"js/stat.ts",
2018-09-19 00:38:24 -04:00
"js/symlink.ts",
2018-09-12 10:33:30 -04:00
"js/text_encoding.ts",
"js/timers.ts",
2018-09-30 15:06:20 -04:00
"js/truncate.ts",
2018-09-12 10:33:30 -04:00
"js/types.ts",
2018-12-17 20:07:47 -05:00
"js/url.ts",
2018-10-21 11:07:29 -04:00
"js/url_search_params.ts",
2018-09-12 10:33:30 -04:00
"js/util.ts",
"js/write_file.ts",
"tsconfig.json",
# Listing package.json and yarn.lock as sources ensures the bundle is rebuilt
# when npm packages are added/removed or their contents changes.
"package.json",
"third_party/yarn.lock",
2018-09-12 10:33:30 -04:00
]
2018-12-13 16:19:17 -05:00
# When Cargo is driving the build, GN/Ninja are used to produce these non-Rust
# targets. Cargo handles all Rust source files and the final linking step.
group("deno_deps") {
deps = [
":msg_rs",
":snapshot_deno",
2018-12-19 20:11:58 -05:00
"libdeno:libdeno_static_lib",
]
}
2018-12-13 16:16:58 -05:00
# Reads the cargo info from Cargo.toml
deno_cargo_info = exec_script("build_extra/rust/get_cargo_info.py",
[ rebase_path("Cargo.toml", root_build_dir) ],
"json")
2018-06-23 03:42:06 -04:00
rust_executable("deno") {
source_root = "src/main.rs"
extern = main_extern
2018-07-12 18:38:00 -04:00
deps = [
":deno_deps",
2018-07-12 18:38:00 -04:00
]
2018-12-13 16:16:58 -05:00
# Extract version from Cargo.toml
# TODO integrate this into rust.gni by allowing the rust_executable template
# to specify a cargo.toml from which it will extract a version.
crate_version = deno_cargo_info.version
inputs = [
"Cargo.toml",
]
}
rust_test("test_rs") {
source_root = "src/main.rs"
extern = main_extern
2018-06-10 08:24:39 -04:00
deps = [
":deno_deps",
2018-06-10 08:24:39 -04:00
]
2018-12-13 16:16:58 -05:00
# Extract version from Cargo.toml
crate_version = deno_cargo_info.version
inputs = [
"Cargo.toml",
]
2018-06-10 08:24:39 -04:00
}
rust_executable("hyper_hello") {
source_root = "tools/hyper_hello.rs"
extern = [
"$rust_build:hyper",
"$rust_build:ring",
]
}
# Generates the core TypeScript type library for deno that will be
# included in the runtime bundle
run_node("deno_runtime_declaration") {
2018-08-07 16:27:31 -04:00
out_dir = target_gen_dir
2018-09-12 10:33:30 -04:00
sources = ts_sources
2018-08-07 16:27:31 -04:00
outputs = [
"$out_dir/lib/lib.deno_runtime.d.ts",
2018-08-07 16:27:31 -04:00
]
deps = [
":msg_ts",
]
args = [
rebase_path("node_modules/ts-node/dist/bin.js", root_build_dir),
"--project",
rebase_path("tools/ts_library_builder/tsconfig.json"),
rebase_path("tools/ts_library_builder/main.ts", root_build_dir),
"--basePath",
rebase_path(".", root_build_dir),
"--buildPath",
rebase_path(root_build_dir, root_build_dir),
"--outFile",
rebase_path("$out_dir/lib/lib.deno_runtime.d.ts", root_build_dir),
"--silent",
2018-08-07 16:27:31 -04:00
]
if (is_debug) {
args += [ "--debug" ]
}
2018-08-07 16:27:31 -04:00
}
2018-06-11 21:54:55 -04:00
run_node("bundle") {
out_dir = "$target_gen_dir/bundle/"
outputs = [
out_dir + "main.js",
2018-07-21 21:14:52 -04:00
out_dir + "main.js.map",
2018-06-11 21:54:55 -04:00
]
depfile = out_dir + "main.d"
2018-06-11 21:54:55 -04:00
deps = [
":deno_runtime_declaration",
2018-07-25 23:07:50 -04:00
":msg_ts",
]
2018-06-11 21:54:55 -04:00
args = [
rebase_path("third_party/node_modules/rollup/bin/rollup", root_build_dir),
2018-07-21 21:14:52 -04:00
"-c",
rebase_path("rollup.config.js", root_build_dir),
"-i",
rebase_path("js/main.ts", root_build_dir),
2018-07-21 21:14:52 -04:00
"-o",
rebase_path(out_dir + "main.js", root_build_dir),
"--sourcemapFile",
rebase_path("."),
2018-07-21 21:14:52 -04:00
"--silent",
2018-06-11 21:54:55 -04:00
]
}
2018-07-04 14:50:28 -04:00
ts_flatbuffer("msg_ts") {
sources = [
"src/msg.fbs",
]
}
rust_flatbuffer("msg_rs") {
sources = [
"src/msg.fbs",
]
}
# Generates $target_gen_dir/snapshot_deno.bin
snapshot("snapshot_deno") {
source_root = "$target_gen_dir/bundle/main.js"
deps = [
2018-06-11 21:54:55 -04:00
":bundle",
]
}