1import("//llvm/lib/DebugInfo/PDB/enable_dia.gni")
2import("//llvm/triples.gni")
3import("//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("lld_lit_site_cfg_files.gni")
8
9write_cmake_config("lit_site_cfg") {
10  # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
11  input = "//lld/test/lit.site.cfg.py.in"
12  output = lld_lit_site_cfg_file
13  dir = get_path_info(output, "dir")
14
15  values = [
16    "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
17    "LLD_BINARY_DIR=" + rebase_path(get_label_info("//lld", "target_out_dir")),
18    "CURRENT_LIBS_DIR=",  # FIXME: for shared builds only (?)
19    "CURRENT_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
20    "ENABLE_BACKTRACES=1",
21    "LLD_SOURCE_DIR=" + rebase_path("//lld"),
22    "LLVM_BINARY_DIR=" +
23        rebase_path(get_label_info("//llvm", "target_out_dir")),
24    "LLVM_LIBS_DIR=",  # needed only for shared builds
25    "LLVM_LIT_TOOLS_DIR=",  # Intentionally empty, matches cmake build.
26    "LLVM_SOURCE_DIR=" + rebase_path("//llvm"),
27    "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
28    "Python3_EXECUTABLE=$python_path",
29    "LLVM_TARGET_TRIPLE=$llvm_target_triple",
30
31    "LLD_DEFAULT_LD_LLD_IS_MINGW=0",
32    "LLVM_BUILD_EXAMPLES=0",
33    "LLVM_ENABLE_ZSTD=0",
34    "LLVM_BYE_LINK_INTO_TOOLS=0",
35  ]
36
37  if (host_os == "win") {
38    values += [
39      "LLVM_LIT_ERRC_MESSAGES=no such file or directory;is a directory;" +
40          "invalid argument;permission denied",
41      "LLVM_ENABLE_PLUGINS=0",
42
43      # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
44      "SHLIBDIR=" + rebase_path("$root_out_dir/bin", dir),
45    ]
46  } else {
47    values += [
48      "LLVM_LIT_ERRC_MESSAGES=",
49      "LLVM_ENABLE_PLUGINS=1",
50      "SHLIBDIR=" + rebase_path("$root_out_dir/lib", dir),
51    ]
52  }
53
54  if (host_os == "mac") {
55    values += [ "SHLIBEXT=.dylib" ]
56  } else if (host_os == "win") {
57    values += [ "SHLIBEXT=.dll" ]
58  } else {
59    values += [ "SHLIBEXT=.so" ]
60  }
61
62  if (llvm_enable_dia_sdk) {
63    values += [ "LLVM_ENABLE_DIA_SDK=1" ]
64  } else {
65    values += [ "LLVM_ENABLE_DIA_SDK=0" ]  # Must be 0.
66  }
67
68  if (llvm_enable_libxar) {
69    values += [ "LLVM_HAVE_LIBXAR=1" ]
70  } else {
71    values += [ "LLVM_HAVE_LIBXAR=0" ]  # Must be 0.
72  }
73
74  if (llvm_enable_libxml2) {
75    values += [ "LLVM_ENABLE_LIBXML2=1" ]
76  } else {
77    values += [ "LLVM_ENABLE_LIBXML2=0" ]  # Must be 0.
78  }
79
80  if (llvm_enable_zlib) {
81    values += [ "LLVM_ENABLE_ZLIB=1" ]
82  } else {
83    values += [ "LLVM_ENABLE_ZLIB=0" ]  # Must be 0.
84  }
85
86  if (current_cpu == "x64" || current_cpu == "arm64" ||
87      current_cpu == "ppc64") {
88    values += [ "CMAKE_SIZEOF_VOID_P=8" ]
89  } else {
90    values += [ "CMAKE_SIZEOF_VOID_P=4" ]
91  }
92}
93
94# This target should contain all dependencies of check-lld.
95# //:default depends on it, so that ninja's default target builds all
96# prerequisites for check-lld but doesn't run check-lld itself.
97group("test") {
98  deps = [
99    ":lit_site_cfg",
100    "//lld/tools/lld:symlinks",
101    "//llvm/tools/dsymutil",
102    "//llvm/tools/llc",
103    "//llvm/tools/llvm-ar:symlinks",
104    "//llvm/tools/llvm-as",
105    "//llvm/tools/llvm-bcanalyzer",
106    "//llvm/tools/llvm-cvtres",
107    "//llvm/tools/llvm-dis",
108    "//llvm/tools/llvm-dwarfdump",
109    "//llvm/tools/llvm-lipo:symlinks",
110    "//llvm/tools/llvm-mc",
111    "//llvm/tools/llvm-nm:symlinks",
112    "//llvm/tools/llvm-objcopy:symlinks",
113    "//llvm/tools/llvm-objdump:symlinks",
114    "//llvm/tools/llvm-pdbutil",
115    "//llvm/tools/llvm-profdata",
116    "//llvm/tools/llvm-readobj:symlinks",
117    "//llvm/tools/llvm-symbolizer:symlinks",
118    "//llvm/tools/obj2yaml",
119    "//llvm/tools/opt",
120    "//llvm/tools/yaml2obj",
121    "//llvm/utils/FileCheck",
122    "//llvm/utils/count",
123    "//llvm/utils/llvm-lit",
124    "//llvm/utils/not",
125    "//llvm/utils/split-file",
126  ]
127  testonly = true
128}
129
130# This is the action that runs all of lld's tests, check-lld.
131action("check-lld") {
132  script = "$root_out_dir/bin/llvm-lit"
133  if (host_os == "win") {
134    script += ".py"
135  }
136  args = [
137    "-sv",
138    rebase_path(".", root_out_dir),
139  ]
140  outputs = [ "$target_gen_dir/run-lit" ]  # Non-existing, so that ninja runs it
141                                           # each time.
142
143  # Since check-lld is always dirty, //:default doesn't depend on it so that
144  # it's not part of the default ninja target.  Hence, check-lld shouldn't
145  # have any deps except :test, so that the default target is sure to build
146  # all the deps.
147  deps = [ ":test" ]
148  testonly = true
149
150  pool = "//:console"
151}
152