Debian Codegraph @

llvm/utils/gn/secondary/lldb/test/BUILD.gn

raw
1 import("//llvm/triples.gni")
2
3 import("//llvm/utils/gn/build/buildflags.gni")
4 #import("//llvm/utils/gn/build/libs/xar/enable.gni")
5 import("//llvm/utils/gn/build/libs/xml/enable.gni")
6 import("//llvm/utils/gn/build/libs/zlib/enable.gni")
7 import("//llvm/utils/gn/build/write_cmake_config.gni")
8 import("lldb_lit_site_cfg_files.gni")
9
10 # The bits common to writing lit.site.cfg.py.in, API/lit.site.cfg.py,
11 # Shell/lit.site.cfg.py, and Unit/lit.site.cfg.py.in.
12 template("write_lit_cfg") {
13 write_cmake_config(target_name) {
14 input = invoker.input
15 output = invoker.output
16 values = [
17 "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
18 "LLDB_BINARY_DIR=" +
19 rebase_path(get_label_info("//lldb", "target_out_dir")),
20 "LLDB_SOURCE_DIR=" + rebase_path("//lldb"),
21 "LLVM_BINARY_DIR=" +
22 rebase_path(get_label_info("//llvm", "target_out_dir")),
23 "LLVM_LIBS_DIR=", # needed only for shared builds
24 "LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build.
25 "LLVM_SOURCE_DIR=" + rebase_path("//llvm"),
26 "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
27 "LLVM_TARGET_TRIPLE=$llvm_target_triple",
28 ]
29 values += invoker.extra_values
30 }
31 }
32
33 write_cmake_config("lit-lldb-init") {
34 input = "//lldb/test/Shell/lit-lldb-init.in"
35
36 # XXX nicer way to get this path
37 output = "$root_out_dir/obj/lldb/test/Shell/lit-lldb-init"
38 values = [ "LLDB_TEST_MODULE_CACHE_LLDB=" +
39 rebase_path(
40 "$target_gen_dir/lldb-test-build.noindex/module-cache-lldb") ]
41 }
42
43 write_lit_cfg("lit_site_cfg") {
44 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
45 input = "//lldb/test/lit.site.cfg.py.in"
46 output = lldb_lit_site_cfg_file
47 extra_values = [
48 "LLVM_BUILD_MODE=.",
49 "Python3_EXECUTABLE=$python_path",
50 ]
51 }
52
53 write_lit_cfg("lit_api_site_cfg") {
54 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
55 input = "//lldb/test/API/lit.site.cfg.py.in"
56 output = lldb_lit_api_site_cfg_file
57 extra_values = [
58 "DEFAULT_SYSROOT=",
59 "LIBCXX_LIBRARY_DIR=" + rebase_path("$root_build_dir/lib"),
60 "LIBCXX_GENERATED_INCLUDE_DIR=" +
61 rebase_path("$root_build_dir/include/c++/v1"),
62 "LIBCXX_GENERATED_INCLUDE_TARGET_DIR=",
63 "LLDB_BUILD_INTEL_PT=0",
64 "LLDB_TEST_COMMON_ARGS=",
65 "LLDB_TEST_USER_ARGS=",
66 "LLDB_ENABLE_PYTHON=0",
67 "LLDB_HAS_LIBCXX=False", # FIXME: support this (?)
68 "LLDB_LIBS_DIR=", # FIXME: for shared builds only (?)
69 "LLDB_PYTHON_API_TEST_EXECUTABLE=$python_path",
70 "LLDB_TEST_ARCH=$current_cpu",
71 "LLDB_TEST_COMPILER=" + rebase_path("$root_build_dir/bin/clang"),
72 "LLDB_TEST_BUILD_DIRECTORY=" + rebase_path("$target_gen_dir/test_build"),
73 "LLDB_TEST_DSYMUTIL=" + rebase_path("$root_build_dir/bin/dsymutil"),
74 "LLDB_TEST_EXECUTABLE=" + rebase_path("$root_build_dir/bin/lldb"),
75 "LLDB_TEST_MAKE=make",
76 "LLDB_TEST_MODULE_CACHE_CLANG=" +
77 rebase_path(
78 "$target_gen_dir/lldb-test-build.noindex/module-cache-clang"),
79 "LLDB_TEST_MODULE_CACHE_LLDB=" +
80 rebase_path(
81 "$target_gen_dir/lldb-test-build.noindex/module-cache-lldb"),
82 "LLDB_TEST_PLATFORM_URL=",
83 "LLDB_TEST_PLATFORM_WORKING_DIR=",
84 "LLDB_TEST_SYSROOT=",
85 "LLVM_BUILD_MODE=.",
86 "LLVM_ENABLE_SHARED_LIBS=0",
87 "LLVM_HOST_TRIPLE=$llvm_current_triple",
88 "LLVM_INCLUDE_DIR=" + rebase_path("$root_out_dir/include"),
89 "LLVM_USE_SANITIZER=",
90 "LUA_EXECUTABLE=",
91 "LLDB_LUA_CPATH=",
92 "LLDB_FRAMEWORK_DIR=XXX_framework_dir",
93 "CMAKE_CXX_COMPILER=c++", # XXX use bin/clang++ instead?
94 "HOST_OS=$host_os", # XXX
95 "Python3_ROOT_DIR=", # FIXME
96 ]
97
98 if (is_debug) {
99 extra_values += [ "CMAKE_BUILD_TYPE=Debug" ]
100 } else {
101 extra_values += [ "CMAKE_BUILD_TYPE=Releas" ]
102 }
103
104 dir = get_path_info(output, "dir")
105 if (host_os == "win") {
106 # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
107 extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin", dir) ]
108 } else {
109 extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib", dir) ]
110 }
111 }
112
113 write_lit_cfg("lit_shell_site_cfg") {
114 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
115 input = "//lldb/test/Shell/lit.site.cfg.py.in"
116 output = lldb_lit_shell_site_cfg_file
117 extra_values = [
118 "CLANG_RESOURCE_DIR=",
119 "DEFAULT_SYSROOT=",
120 "LIBCXX_LIBRARY_DIR=" + rebase_path("$root_build_dir/lib"),
121 "LLDB_ENABLE_LUA=0", # FIXME: gn arg, use in Config.h
122 "LLDB_ENABLE_LZMA=0", # FIXME: gn arg, use in Config.h
123 "LLDB_ENABLE_PYTHON=0", # FIXME: gn arg, use in Config.h
124 "LLDB_HAS_LIBCXX=False", # FIXME: support this (?)
125 "LLDB_IS_64_BITS=1",
126 "LLDB_LIBS_DIR=", # FIXME: for shared builds only (?)
127 "LLDB_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build.
128 "LLDB_TEST_BUILD_DIRECTORY=" + rebase_path("$target_gen_dir/test_build"),
129 "LLDB_TEST_MODULE_CACHE_CLANG=" +
130 rebase_path(
131 "$target_gen_dir/lldb-test-build.noindex/module-cache-clang"),
132 "LLDB_TEST_MODULE_CACHE_LLDB=" +
133 rebase_path(
134 "$target_gen_dir/lldb-test-build.noindex/module-cache-lldb"),
135 "LLDB_TEST_OBJC_GNUSTEP_DIR=",
136 "LLDB_TEST_PLATFORM_URL=",
137 "LLDB_TEST_PLATFORM_WORKING_DIR=",
138 "LLDB_TEST_SHELL_DISABLE_REMOTE=True",
139 "LLDB_TEST_SYSROOT=",
140 "LLDB_TOOL_LLDB_SERVER_BUILD=1",
141 "LLDB_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
142 "LLDB_USE_SYSTEM_DEBUGSERVER=1", # XXX port //lldb/tools/debugserver (?)
143 "LLVM_HOST_TRIPLE=$llvm_current_triple",
144 "LLVM_USE_SANITIZER=",
145 "Python3_EXECUTABLE=$python_path",
146 "Python3_ROOT_DIR=", # FIXME
147 ]
148
149 if (llvm_enable_zlib) {
150 extra_values += [ "LLVM_ENABLE_ZLIB=1" ]
151 } else {
152 extra_values += [ "LLVM_ENABLE_ZLIB=0" ] # Must be 0.
153 }
154
155 dir = get_path_info(output, "dir")
156 if (host_os == "win") {
157 # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
158 extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin", dir) ]
159 } else {
160 extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib", dir) ]
161 }
162 }
163
164 write_lit_cfg("lit_unit_site_cfg") {
165 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
166 input = "//lldb/test/Unit/lit.site.cfg.py.in"
167 output = lldb_lit_unit_site_cfg_file
168 extra_values = [
169 "LLVM_BUILD_MODE=.",
170 "LLVM_USE_SANITIZER=",
171 "Python3_EXECUTABLE=$python_path",
172 "Python3_ROOT_DIR=", # FIXME
173 ]
174 }
175
176 action("lit-lldb-init-quiet") {
177 script = "//llvm/utils/gn/build/write_file.py"
178 outputs = [ "$root_out_dir/obj/lldb/test/Shell/lit-lldb-init-quiet" ]
179 args = [
180 rebase_path(outputs[0], root_build_dir),
181 "command source -C --silent-run true lit-lldb-init",
182 ]
183 }
184
185 # This target should contain all dependencies of check-lldb.
186 # //:default depends on it, so that ninja's default target builds all
187 # prerequisites for check-lldb but doesn't run check-lldb itself.
188 group("test") {
189 deps = [
190 ":lit-lldb-init",
191 ":lit-lldb-init-quiet",
192 ":lit_api_site_cfg",
193 ":lit_shell_site_cfg",
194 ":lit_site_cfg",
195 ":lit_unit_site_cfg",
196 "//clang/tools/driver:symlinks",
197 "//lld/tools/lld:symlinks",
198 "//lldb/tools/driver:lldb",
199 "//lldb/tools/lldb-dap/tool:lldb-dap",
200
201 # XXX lldb-instr, darwin-debug, etc
202 "//lldb/tools/lldb-server",
203 "//lldb/tools/lldb-test",
204 "//lldb/utils/lit-cpuid",
205
206 #"//lldb/unittests",
207 "//llvm/tools/dsymutil",
208 "//llvm/tools/llc",
209 "//llvm/tools/lli",
210 "//llvm/tools/llvm-config",
211 "//llvm/tools/llvm-dwarfdump",
212 "//llvm/tools/llvm-dwp",
213 "//llvm/tools/llvm-mc",
214 "//llvm/tools/llvm-nm:symlinks",
215 "//llvm/tools/llvm-objcopy:symlinks",
216 "//llvm/tools/llvm-pdbutil",
217 "//llvm/tools/llvm-readobj:symlinks",
218 "//llvm/tools/yaml2obj",
219 "//llvm/utils/FileCheck",
220 "//llvm/utils/count",
221 "//llvm/utils/llvm-lit",
222 "//llvm/utils/not",
223 "//llvm/utils/split-file",
224 ]
225 testonly = true
226 }
227
228 # This is the action that runs all of lldb's tests, check-lldb.
229 action("check-lldb") {
230 script = "$root_out_dir/bin/llvm-lit"
231 if (host_os == "win") {
232 script += ".py"
233 }
234 args = [
235 "-sv",
236 rebase_path(".", root_out_dir),
237 ]
238 outputs = [ "$target_gen_dir/run-lit" ] # Non-existing, so that ninja runs it
239 # each time.
240
241 # Since check-lldb is always dirty, //:default doesn't depend on it so that
242 # it's not part of the default ninja target. Hence, check-lld shouldn't
243 # have any deps except :test, so that the default target is sure to build
244 # all the deps.
245 deps = [ ":test" ]
246 testonly = true
247
248 pool = "//:console"
249 }