1import("//llvm/lib/DebugInfo/PDB/enable_dia.gni")
2import("//llvm/triples.gni")
3import("//llvm/utils/gn/build/libs/xml/enable.gni")
4import("//llvm/utils/gn/build/libs/zlib/enable.gni")
5import("//llvm/utils/gn/build/write_cmake_config.gni")
6import("lld_lit_site_cfg_files.gni")
7
8# The bits common to writing lit.site.cfg.py.in and Unit/lit.site.cfg.py.in.
9template("write_lit_cfg") {
10  write_cmake_config(target_name) {
11    input = invoker.input
12    output = invoker.output
13    values = [
14      "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
15      "LLD_BINARY_DIR=" +
16          rebase_path(get_label_info("//lld", "target_out_dir")),
17      "LLD_SOURCE_DIR=" + rebase_path("//lld"),
18      "LLVM_BINARY_DIR=" +
19          rebase_path(get_label_info("//llvm", "target_out_dir")),
20      "LLVM_LIBRARY_OUTPUT_INTDIR=",  # FIXME: for shared builds only (?)
21      "LLVM_LIBS_DIR=",  # needed only for shared builds
22      "LLVM_LIT_TOOLS_DIR=",  # Intentionally empty, matches cmake build.
23      "LLVM_RUNTIME_OUTPUT_INTDIR=" + rebase_path("$root_out_dir/bin"),
24      "LLVM_SOURCE_DIR=" + rebase_path("//llvm"),
25      "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
26      "Python3_EXECUTABLE=$python_path",
27      "TARGET_TRIPLE=$llvm_target_triple",
28    ]
29    values += invoker.extra_values
30  }
31}
32
33write_lit_cfg("lit_site_cfg") {
34  # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
35  input = "//lld/test/lit.site.cfg.py.in"
36  output = lld_lit_site_cfg_file
37
38  extra_values = [ "LLD_DEFAULT_LD_LLD_IS_MINGW=0" ]  # Must be 0.
39
40  if (llvm_enable_dia_sdk) {
41    extra_values += [ "LLVM_ENABLE_DIA_SDK=1" ]
42  } else {
43    extra_values += [ "LLVM_ENABLE_DIA_SDK=0" ]  # Must be 0.
44  }
45
46  if (llvm_enable_libxml2) {
47    extra_values += [ "LLVM_ENABLE_LIBXML2=1" ]
48  } else {
49    extra_values += [ "LLVM_ENABLE_LIBXML2=0" ]  # Must be 0.
50  }
51
52  if (llvm_enable_zlib) {
53    extra_values += [ "LLVM_ENABLE_ZLIB=1" ]
54  } else {
55    extra_values += [ "LLVM_ENABLE_ZLIB=0" ]  # Must be 0.
56  }
57
58  if (current_cpu == "x64" || current_cpu == "arm64" ||
59      current_cpu == "ppc64") {
60    extra_values += [ "CMAKE_SIZEOF_VOID_P=8" ]
61  } else {
62    extra_values += [ "CMAKE_SIZEOF_VOID_P=4" ]
63  }
64}
65
66write_lit_cfg("lit_unit_site_cfg") {
67  # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
68  input = "//lld/test/Unit/lit.site.cfg.py.in"
69  output = lld_lit_unit_site_cfg_file
70  extra_values = [ "LLVM_BUILD_MODE=." ]
71}
72
73# This target should contain all dependencies of check-lld.
74# //:default depends on it, so that ninja's default target builds all
75# prerequisites for check-lld but doesn't run check-lld itself.
76group("test") {
77  deps = [
78    ":lit_site_cfg",
79    ":lit_unit_site_cfg",
80    "//lld/tools/lld:symlinks",
81    "//lld/unittests",
82    "//llvm/tools/llc",
83    "//llvm/tools/llvm-ar:symlinks",
84    "//llvm/tools/llvm-as",
85    "//llvm/tools/llvm-bcanalyzer",
86    "//llvm/tools/llvm-cvtres",
87    "//llvm/tools/llvm-dis",
88    "//llvm/tools/llvm-dwarfdump",
89    "//llvm/tools/llvm-lipo",
90    "//llvm/tools/llvm-mc",
91    "//llvm/tools/llvm-nm:symlinks",
92    "//llvm/tools/llvm-objcopy:symlinks",
93    "//llvm/tools/llvm-objdump:symlinks",
94    "//llvm/tools/llvm-pdbutil",
95    "//llvm/tools/llvm-readobj:symlinks",
96    "//llvm/tools/llvm-symbolizer:symlinks",
97    "//llvm/tools/obj2yaml",
98    "//llvm/tools/opt",
99    "//llvm/tools/split-file",
100    "//llvm/tools/yaml2obj",
101    "//llvm/utils/FileCheck",
102    "//llvm/utils/count",
103    "//llvm/utils/llvm-lit",
104    "//llvm/utils/not",
105  ]
106  testonly = true
107}
108
109# This is the action that runs all of lld's tests, check-lld.
110action("check-lld") {
111  script = "$root_out_dir/bin/llvm-lit"
112  if (host_os == "win") {
113    script += ".py"
114  }
115  args = [
116    "-sv",
117    rebase_path(".", root_out_dir),
118  ]
119  outputs = [ "$target_gen_dir/run-lit" ]  # Non-existing, so that ninja runs it
120                                           # each time.
121
122  # Since check-lld is always dirty, //:default doesn't depend on it so that
123  # it's not part of the default ninja target.  Hence, check-lld shouldn't
124  # have any deps except :test, so that the default target is sure to build
125  # all the deps.
126  deps = [ ":test" ]
127  testonly = true
128
129  pool = "//:console"
130}
131