-
Notifications
You must be signed in to change notification settings - Fork 18
/
BUILD.gn
129 lines (111 loc) · 2.94 KB
/
BUILD.gn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
# Based on https://github.com/denoland/rusty_v8/blob/main/BUILD.gn
import("//build/config/host_byteorder.gni")
import("//build/toolchain/gcc_toolchain.gni")
import("//build/config/c++/c++.gni")
static_library("c_v8") {
complete_static_lib = true
sources = [ "../../src/binding.cpp" ]
deps = [
"//build/config:shared_library_deps",
"//:v8",
"//:v8_libbase",
"//:v8_libplatform",
]
configs -= [
"//build/config/compiler:default_init_stack_vars",
"//build/config/compiler:thin_archive",
]
configs += [ ":c_v8_config" ]
}
config("c_v8_config") {
configs = [
"//:external_config",
"//:toolchain",
"//:features",
]
cflags = []
# We need these directories in the search path to be able to include some
# internal V8 headers.
include_dirs = [
"v8",
"$target_gen_dir/v8",
]
if (is_debug) {
defines = [ "DEBUG" ]
}
if (is_clang) {
cflags += [
"-fcolor-diagnostics",
"-fansi-escape-codes",
]
}
if (is_debug && is_clang && !is_win) {
cflags += [ "-glldb" ]
}
}
# Based on template("clang_toolchain") in build/toolchain/gcc_toolchain.gni
template("zig_toolchain") {
gcc_toolchain(target_name) {
prefix = rebase_path("$clang_base_path/bin", root_build_dir)
readelf = "${prefix}/llvm-readelf"
# Is this even used?
nm = "${prefix}/llvm-nm"
if (current_cpu == "x64" && current_os == "linux") {
# From //build/toolchain/linux:clang_x64
# Output linker map files for binary size analysis.
enable_linker_map = true
}
forward_variables_from(invoker,
[
"strip",
"default_shlib_subdir",
"dwp",
"enable_linker_map",
"loadable_module_extension",
"use_unstripped_as_runtime_outputs",
"cc",
"cxx",
"ld",
"ar",
"extra_cppflags",
])
toolchain_args = {
if (defined(invoker.toolchain_args)) {
forward_variables_from(invoker.toolchain_args, "*")
}
is_clang = true
}
}
}
# Used to compile the v8 library.
zig_toolchain("main_zig_toolchain") {
cc = zig_cc
cxx = zig_cxx
# ld commands in v8 use cxx with -fuse-ld
ld = cxx
#ar = "${prefix}/llvm-ar"
ar = "zig ar"
extra_cppflags = "-Wno-unused-but-set-variable"
toolchain_args = {
current_cpu = target_cpu
current_os = target_os
}
}
# Used to compile v8 snapshots/generators to run locally.
# v8_current_cpu indicates that we are still targeting a different arch but must compile tools to run on host machine.
# See gni/snapshot_toolchain.gni
zig_toolchain("v8_zig_toolchain") {
cc = host_zig_cc
cxx = host_zig_cxx
# ld commands in v8 use cxx with -fuse-ld
ld = cxx
#ar = "${prefix}/llvm-ar"
ar = "zig ar"
extra_cppflags = "-Wno-unused-but-set-variable"
toolchain_args = {
current_os = host_os
current_cpu = host_cpu
v8_current_cpu = target_cpu
}
}