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