[gn build] (manually) merge c4c3883
[lldb.git] / llvm / utils / gn / secondary / clang-tools-extra / test / BUILD.gn
1 import("//clang/lib/StaticAnalyzer/Frontend/enable.gni")
2 import("//llvm/triples.gni")
3 import("//llvm/utils/gn/build/write_cmake_config.gni")
4 import("clang_tools_extra_lit_site_cfg_files.gni")
5
6 template("write_lit_config") {
7   write_cmake_config(target_name) {
8     input = invoker.input
9     output = invoker.output
10     values = [
11       "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
12       "CLANG_TOOLS_BINARY_DIR=" +
13           rebase_path(get_label_info("//clang-tools-extra", "target_out_dir")),
14       "CLANG_TOOLS_SOURCE_DIR=" + rebase_path("//clang-tools-extra"),
15       "LLVM_LIBS_DIR=",  # needed only for shared builds
16       "TARGET_TRIPLE=$llvm_target_triple",
17     ]
18     if (host_os == "win") {
19       # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
20       values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin") ]
21     } else {
22       values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib") ]
23     }
24     values += invoker.extra_values
25   }
26 }
27
28 write_lit_config("lit_site_cfg") {
29   # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
30   input = "//clang-tools-extra/test/lit.site.cfg.py.in"
31   output = clang_tools_extra_lit_site_cfg_file
32
33   extra_values = [
34     "CLANG_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
35     "LLVM_LIT_TOOLS_DIR=",  # Intentionally empty, matches cmake build.
36     "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
37     "Python3_EXECUTABLE=$python_path",
38   ]
39
40   if (clang_enable_static_analyzer) {
41     extra_values += [ "CLANG_ENABLE_STATIC_ANALYZER=1" ]
42   } else {
43     extra_values += [ "CLANG_ENABLE_STATIC_ANALYZER=0" ]
44   }
45 }
46
47 write_lit_config("lit_unit_site_cfg") {
48   # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
49   input = "//clang-tools-extra/test/Unit/lit.site.cfg.py.in"
50   output = clang_tools_extra_lit_unit_site_cfg_file
51   extra_values = []
52 }
53
54 # This target should contain all dependencies of check-clang-tools.
55 # //:default depends on it, so that ninja's default target builds all
56 # prerequisites for check-clang but doesn't run check-clang itself.
57 group("test") {
58   deps = [
59     ":lit_site_cfg",
60     ":lit_unit_site_cfg",
61     "//clang-tools-extra/clang-apply-replacements/tool:clang-apply-replacements",
62     "//clang-tools-extra/clang-change-namespace/tool:clang-change-namespace",
63     "//clang-tools-extra/clang-doc/tool:clang-doc",
64     "//clang-tools-extra/clang-include-fixer/find-all-symbols/tool:find-all-symbols",
65     "//clang-tools-extra/clang-include-fixer/tool:clang-include-fixer",
66     "//clang-tools-extra/clang-move/tool:clang-move",
67     "//clang-tools-extra/clang-query/tool:clang-query",
68     "//clang-tools-extra/clang-reorder-fields/tool:clang-reorder-fields",
69     "//clang-tools-extra/clang-tidy/tool:clang-tidy",
70     "//clang-tools-extra/modularize",
71     "//clang-tools-extra/pp-trace",
72     "//clang-tools-extra/unittests",
73     "//clang/lib/Headers",
74     "//clang/tools/c-index-test",
75     "//clang/tools/clang-rename",
76     "//clang/tools/driver:symlinks",
77     "//llvm/tools/llvm-bcanalyzer",
78     "//llvm/utils/FileCheck",
79     "//llvm/utils/count",
80     "//llvm/utils/llvm-lit",
81     "//llvm/utils/not",
82   ]
83   testonly = true
84 }
85
86 action("check-clang-tools") {
87   script = "$root_out_dir/bin/llvm-lit"
88   if (host_os == "win") {
89     script += ".py"
90   }
91   args = [
92     "-sv",
93     rebase_path(".", root_out_dir),
94   ]
95   outputs = [ "$target_gen_dir/run-lit" ]  # Non-existing, so that ninja runs it
96                                            # each time.
97
98   # Since check-clang-tools is always dirty, //:default doesn't depend on it so
99   # that it's not part of the default ninja target.  Hence, check-clang-tools
100   # shouldn't have any deps except :test. so that the default target is sure to
101   # build all the deps.
102   deps = [ ":test" ]
103   testonly = true
104
105   pool = "//:console"
106 }