Debian Codegraph @

llvm/utils/gn/secondary/clang-tools-extra/clangd/test/BUILD.gn

raw
1 import("//clang-tools-extra/clangd/xpc/enable.gni")
2 import("//llvm/triples.gni")
3 import("//llvm/utils/gn/build/libs/zlib/enable.gni")
4 import("//llvm/utils/gn/build/write_cmake_config.gni")
5 import("clangd_lit_site_cfg_files.gni")
6
7 template("write_lit_config") {
8 write_cmake_config(target_name) {
9 input = invoker.input
10 output = invoker.output
11 values = [
12 "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
13 "LLVM_LIBS_DIR=", # needed only for shared builds
14 ]
15 if (host_os == "win") {
16 # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
17 values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin") ]
18 } else {
19 values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib") ]
20 }
21 values += invoker.extra_values
22 }
23 }
24
25 write_lit_config("lit_site_cfg") {
26 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
27 input = "//clang-tools-extra/clangd/test/lit.site.cfg.py.in"
28 output = clangd_lit_site_cfg_file
29
30 extra_values = [
31 "CMAKE_CURRENT_BINARY_DIR=" +
32 rebase_path(get_label_info("//clang-tools-extra/clangd/test",
33 "target_out_dir")),
34 "CMAKE_CURRENT_SOURCE_DIR=" +
35 rebase_path("//clang-tools-extra/clangd/test"),
36
37 "CURRENT_TOOLS_DIR=",
38 "CLANGD_BUILD_DEXP=1",
39 "CLANGD_ENABLE_REMOTE=0",
40 "CLANGD_TIDY_CHECKS=1",
41 "LLVM_HOST_TRIPLE=$llvm_current_triple",
42 "LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build.
43 "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
44 "LLVM_TARGET_TRIPLE=$llvm_target_triple",
45 "Python3_EXECUTABLE=$python_path",
46 ]
47
48 if (clangd_build_xpc) {
49 extra_values += [ "CLANGD_BUILD_XPC=1" ]
50 } else {
51 extra_values += [ "CLANGD_BUILD_XPC=0" ]
52 }
53
54 if (llvm_enable_zlib) {
55 extra_values += [ "LLVM_ENABLE_ZLIB=1" ]
56 } else {
57 extra_values += [ "LLVM_ENABLE_ZLIB=0" ]
58 }
59 }
60
61 write_lit_config("lit_unit_site_cfg") {
62 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
63 input = "//clang-tools-extra/clangd/unittests/lit.site.cfg.py.in"
64 output = clangd_lit_unit_site_cfg_file
65 extra_values = [
66 "CMAKE_CURRENT_BINARY_DIR=" +
67 rebase_path(get_label_info("//clang-tools-extra/clangd/unittests",
68 "target_out_dir")),
69 "CMAKE_CURRENT_SOURCE_DIR=" +
70 rebase_path("//clang-tools-extra/clangd/unittests"),
71 ]
72 }
73
74 # This target should contain all dependencies of check-clangd.
75 # //:default depends on it, so that ninja's default target builds all
76 # prerequisites for check-clang but doesn't run check-clang itself.
77 group("test") {
78 deps = [
79 ":lit_site_cfg",
80 ":lit_unit_site_cfg",
81 "//clang-tools-extra/clangd/index/dex/dexp",
82 "//clang-tools-extra/clangd/indexer:clangd-indexer",
83 "//clang-tools-extra/clangd/tool:clangd",
84 "//clang-tools-extra/clangd/unittests:ClangdTests",
85 "//llvm/utils/FileCheck",
86 "//llvm/utils/llvm-lit",
87 "//llvm/utils/not",
88 "//llvm/utils/split-file",
89 ]
90 if (clangd_build_xpc) {
91 deps += [
92 "//clang-tools-extra/clangd/unittests/xpc:ClangdXpcTests",
93 "//clang-tools-extra/clangd/xpc/test-client:clangd-xpc-test-client",
94 ]
95 }
96 testonly = true
97 }
98
99 action("check-clangd") {
100 script = "$root_out_dir/bin/llvm-lit"
101 if (host_os == "win") {
102 script += ".py"
103 }
104 args = [
105 "-sv",
106
107 # clangd doesn't put unittest configs in test/unit like every other project.
108 # Because of that, this needs to pass two folders here, while every other
109 # project only needs to pass CMAKE_CURRENT_BINARY_DIR.
110 rebase_path(get_path_info(clangd_lit_site_cfg_file, "dir"), root_out_dir),
111 rebase_path(get_path_info(clangd_lit_unit_site_cfg_file, "dir"),
112 root_out_dir),
113 ]
114 outputs = [ "$target_gen_dir/run-lit" ] # Non-existing, so that ninja runs it
115 # each time.
116
117 # Since check-clangd is always dirty, //:default doesn't depend on it so
118 # that it's not part of the default ninja target. Hence, check-clangd
119 # shouldn't have any deps except :test. so that the default target is sure to
120 # build all the deps.
121 deps = [ ":test" ]
122 testonly = true
123
124 pool = "//:console"
125 }