mirror of
https://github.com/denoland/deno.git
synced 2024-12-21 23:04:45 -05:00
Separate deno.gni and rust.gni and clean up.
Put rust depfile in target_out_dir because the depfile isn't in the outputs, the gen directory doesn't get created. Prefix rlib files with lib.
This commit is contained in:
parent
693e43e421
commit
15d6541d4d
5 changed files with 139 additions and 139 deletions
|
@ -43,8 +43,7 @@ install:
|
|||
- gn args $BUILD_PATH --list
|
||||
- ccache -s
|
||||
# Travis hangs without -j2 argument to ninja.
|
||||
- ninja -j2 -C $BUILD_PATH mock_runtime_test mock_main
|
||||
- ninja -j2 -C $BUILD_PATH deno
|
||||
- ninja -j2 -C $BUILD_PATH mock_runtime_test mock_main deno
|
||||
script:
|
||||
- $BUILD_PATH/mock_runtime_test
|
||||
- $BUILD_PATH/mock_main foo bar
|
||||
|
|
1
BUILD.gn
1
BUILD.gn
|
@ -2,6 +2,7 @@ import("//third_party/protobuf/proto_library.gni")
|
|||
import("//third_party/v8/gni/v8.gni")
|
||||
import("//third_party/v8/snapshot_toolchain.gni")
|
||||
import("deno.gni")
|
||||
import("rust.gni")
|
||||
|
||||
config("deno_config") {
|
||||
include_dirs = [ "third_party/v8" ] # This allows us to v8/src/base/ libraries.
|
||||
|
|
137
deno.gni
137
deno.gni
|
@ -50,140 +50,3 @@ template("create_snapshot") {
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
template("rust_crate") {
|
||||
action(target_name) {
|
||||
forward_variables_from(invoker,
|
||||
[
|
||||
"cfg",
|
||||
"crate_type",
|
||||
"source_root",
|
||||
"deps",
|
||||
"rust_deps",
|
||||
])
|
||||
sources = [
|
||||
source_root,
|
||||
]
|
||||
outputs = []
|
||||
depfile = "$target_gen_dir/$target_name.d"
|
||||
script = "//third_party/v8/tools/run.py"
|
||||
|
||||
args = [
|
||||
"rustc",
|
||||
rebase_path(source_root, root_build_dir),
|
||||
"--crate-name=$target_name",
|
||||
"--crate-type=$crate_type",
|
||||
"--emit=dep-info=" + rebase_path(depfile, root_build_dir),
|
||||
]
|
||||
|
||||
# We only use staticlib for the special "empty" lib.
|
||||
if (crate_type == "staticlib") {
|
||||
staticlib = "$target_out_dir/$target_name.a"
|
||||
outputs += [ staticlib ]
|
||||
args += [ "--emit=link=" + rebase_path(staticlib, root_build_dir) ]
|
||||
}
|
||||
|
||||
if (crate_type == "rlib" || crate_type == "bin") {
|
||||
obj = "$target_out_dir/$target_name.o"
|
||||
outputs += [ obj ]
|
||||
args += [ "--emit=obj=" + rebase_path(obj, root_build_dir) ]
|
||||
}
|
||||
|
||||
if (crate_type == "rlib") {
|
||||
rlib = "$target_out_dir/$target_name.rlib"
|
||||
outputs += [ rlib ]
|
||||
args += [ "--emit=link=" + rebase_path(rlib, root_build_dir) ]
|
||||
}
|
||||
|
||||
if (is_debug) {
|
||||
args += [ "-g" ]
|
||||
}
|
||||
|
||||
if (is_official_build) {
|
||||
args += [ "-O" ]
|
||||
}
|
||||
|
||||
if (defined(cfg)) {
|
||||
foreach(c, cfg) {
|
||||
args += [
|
||||
"--cfg",
|
||||
c,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined(deps)) {
|
||||
deps = []
|
||||
}
|
||||
|
||||
if (defined(rust_deps)) {
|
||||
deps += rust_deps
|
||||
foreach(dep_label, rust_deps) {
|
||||
dep_name = get_label_info(dep_label, "name")
|
||||
dep_dir = get_label_info(dep_label, "target_out_dir")
|
||||
dep_rlib = "$dep_dir/$dep_name.rlib"
|
||||
args += [
|
||||
"--extern",
|
||||
"$dep_name=" + rebase_path(dep_rlib, root_build_dir),
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template("rust_library") {
|
||||
rust_crate(target_name) {
|
||||
crate_type = "rlib"
|
||||
forward_variables_from(invoker, "*")
|
||||
}
|
||||
}
|
||||
|
||||
template("rust_executable") {
|
||||
bin_target = target_name + "_bin"
|
||||
rust_crate(bin_target) {
|
||||
crate_type = "bin"
|
||||
forward_variables_from(invoker, "*")
|
||||
}
|
||||
|
||||
# By compiling an empty file as crate-type=staticlib we get all the code
|
||||
# for the rust stdlib, which are not included in the object file outputs
|
||||
# of other libs.
|
||||
stdlib_target = target_name + "_stdlib"
|
||||
rust_crate(stdlib_target) {
|
||||
crate_type = "staticlib"
|
||||
source_root = "src/empty.rs"
|
||||
}
|
||||
|
||||
executable(target_name) {
|
||||
forward_variables_from(invoker, "*")
|
||||
|
||||
if (!defined(deps)) {
|
||||
deps = []
|
||||
}
|
||||
|
||||
deps += [
|
||||
":" + bin_target,
|
||||
":" + stdlib_target,
|
||||
]
|
||||
|
||||
libs = get_target_outputs(":" + bin_target) +
|
||||
get_target_outputs(":" + stdlib_target)
|
||||
|
||||
if (defined(rust_deps)) {
|
||||
deps += rust_deps
|
||||
foreach(dep_label, rust_deps) {
|
||||
dep_name = get_label_info(dep_label, "name")
|
||||
dep_dir = get_label_info(dep_label, "target_out_dir")
|
||||
dep_obj = "$dep_dir/$dep_name.o"
|
||||
libs += [ dep_obj ]
|
||||
}
|
||||
}
|
||||
|
||||
if (current_os == "mac") {
|
||||
libs += [ "resolv" ]
|
||||
}
|
||||
if (current_os == "win") {
|
||||
libs += [ "userenv.lib" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
136
rust.gni
Normal file
136
rust.gni
Normal file
|
@ -0,0 +1,136 @@
|
|||
template("rust_crate") {
|
||||
action(target_name) {
|
||||
forward_variables_from(invoker,
|
||||
[
|
||||
"cfg",
|
||||
"crate_type",
|
||||
"source_root",
|
||||
"deps",
|
||||
"rust_deps",
|
||||
])
|
||||
sources = [
|
||||
source_root,
|
||||
]
|
||||
outputs = []
|
||||
depfile = "$target_out_dir/$target_name.d"
|
||||
script = "//third_party/v8/tools/run.py"
|
||||
|
||||
args = [
|
||||
"rustc",
|
||||
rebase_path(source_root, root_build_dir),
|
||||
"--crate-name=$target_name",
|
||||
"--crate-type=$crate_type",
|
||||
"--emit=dep-info=" + rebase_path(depfile, root_build_dir),
|
||||
]
|
||||
|
||||
# We only use staticlib for the special "empty" lib.
|
||||
if (crate_type == "staticlib") {
|
||||
staticlib = "$target_out_dir/$target_name.a"
|
||||
outputs += [ staticlib ]
|
||||
args += [ "--emit=link=" + rebase_path(staticlib, root_build_dir) ]
|
||||
}
|
||||
|
||||
if (crate_type == "rlib" || crate_type == "bin") {
|
||||
obj = "$target_out_dir/$target_name.o"
|
||||
outputs += [ obj ]
|
||||
args += [ "--emit=obj=" + rebase_path(obj, root_build_dir) ]
|
||||
}
|
||||
|
||||
if (crate_type == "rlib") {
|
||||
rlib = "$target_out_dir/lib$target_name.rlib"
|
||||
outputs += [ rlib ]
|
||||
args += [ "--emit=link=" + rebase_path(rlib, root_build_dir) ]
|
||||
}
|
||||
|
||||
if (is_debug) {
|
||||
args += [ "-g" ]
|
||||
}
|
||||
|
||||
if (is_official_build) {
|
||||
args += [ "-O" ]
|
||||
}
|
||||
|
||||
if (defined(cfg)) {
|
||||
foreach(c, cfg) {
|
||||
args += [
|
||||
"--cfg",
|
||||
c,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined(deps)) {
|
||||
deps = []
|
||||
}
|
||||
|
||||
if (defined(rust_deps)) {
|
||||
deps += rust_deps
|
||||
foreach(dep_label, rust_deps) {
|
||||
dep_name = get_label_info(dep_label, "name")
|
||||
dep_dir = get_label_info(dep_label, "target_out_dir")
|
||||
dep_rlib = "$dep_dir/lib$dep_name.rlib"
|
||||
args += [
|
||||
"--extern",
|
||||
"$dep_name=" + rebase_path(dep_rlib, root_build_dir),
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template("rust_library") {
|
||||
rust_crate(target_name) {
|
||||
crate_type = "rlib"
|
||||
forward_variables_from(invoker, "*")
|
||||
}
|
||||
}
|
||||
|
||||
template("rust_executable") {
|
||||
bin_target = target_name + "_bin"
|
||||
rust_crate(bin_target) {
|
||||
crate_type = "bin"
|
||||
forward_variables_from(invoker, "*")
|
||||
}
|
||||
|
||||
# By compiling an empty file as crate-type=staticlib we get all the code
|
||||
# for the rust stdlib, which are not included in the object file outputs
|
||||
# of other libs.
|
||||
stdlib_target = target_name + "_stdlib"
|
||||
rust_crate(stdlib_target) {
|
||||
crate_type = "staticlib"
|
||||
source_root = "src/empty.rs"
|
||||
}
|
||||
|
||||
executable(target_name) {
|
||||
forward_variables_from(invoker, "*")
|
||||
|
||||
if (!defined(deps)) {
|
||||
deps = []
|
||||
}
|
||||
|
||||
deps += [
|
||||
":" + bin_target,
|
||||
":" + stdlib_target,
|
||||
]
|
||||
|
||||
libs = get_target_outputs(":" + bin_target) +
|
||||
get_target_outputs(":" + stdlib_target)
|
||||
|
||||
if (defined(rust_deps)) {
|
||||
deps += rust_deps
|
||||
foreach(dep_label, rust_deps) {
|
||||
dep_name = get_label_info(dep_label, "name")
|
||||
dep_dir = get_label_info(dep_label, "target_out_dir")
|
||||
dep_obj = "$dep_dir/$dep_name.o"
|
||||
libs += [ dep_obj ]
|
||||
}
|
||||
}
|
||||
|
||||
if (current_os == "mac") {
|
||||
libs += [ "resolv" ]
|
||||
}
|
||||
if (current_os == "win") {
|
||||
libs += [ "userenv.lib" ]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ clang-format -i -style Google src/*.cc src/*.h src/include/*.h
|
|||
|
||||
gn format BUILD.gn
|
||||
gn format deno.gni
|
||||
gn format rust.gni
|
||||
gn format .gn
|
||||
|
||||
yapf -i js/*.py
|
||||
|
|
Loading…
Reference in a new issue