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")
7 template("write_lit_config") {
8 write_cmake_config(target_name) {
10 output = invoker.output
12 "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
13 "LLVM_LIBS_DIR=", # needed only for shared builds
15 values += invoker.extra_values
19 write_lit_config("lit_site_cfg") {
20 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
21 input = "//clang-tools-extra/clangd/test/lit.site.cfg.py.in"
22 output = clangd_lit_site_cfg_file
25 "CMAKE_CURRENT_BINARY_DIR=" +
26 rebase_path(get_label_info("//clang-tools-extra/clangd/test",
28 "CMAKE_CURRENT_SOURCE_DIR=" +
29 rebase_path("//clang-tools-extra/clangd/test"),
31 "CLANG_LIBS_DIR=", # needed only for shared builds
33 "CLANGD_ENABLE_REMOTE=0",
34 "CLANGD_TIDY_CHECKS=1",
35 "LLVM_HOST_TRIPLE=$llvm_current_triple",
36 "LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build.
37 "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
38 "TARGET_TRIPLE=$llvm_target_triple",
39 "Python3_EXECUTABLE=$python_path",
42 if (clangd_build_xpc) {
43 extra_values += [ "CLANGD_BUILD_XPC=1" ]
45 extra_values += [ "CLANGD_BUILD_XPC=0" ]
48 if (llvm_enable_zlib) {
49 extra_values += [ "LLVM_ENABLE_ZLIB=1" ]
51 extra_values += [ "LLVM_ENABLE_ZLIB=0" ]
55 write_lit_config("lit_unit_site_cfg") {
56 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
57 input = "//clang-tools-extra/clangd/unittests/lit.site.cfg.py.in"
58 output = clangd_lit_unit_site_cfg_file
60 "CMAKE_CURRENT_BINARY_DIR=" +
61 rebase_path(get_label_info("//clang-tools-extra/clangd/unittests",
63 "CMAKE_CURRENT_SOURCE_DIR=" +
64 rebase_path("//clang-tools-extra/clangd/unittests"),
66 if (host_os == "win") {
67 # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
68 extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin") ]
70 extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib") ]
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.
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",
89 if (clangd_build_xpc) {
91 "//clang-tools-extra/clangd/unittests/xpc:ClangdXpcTests",
92 "//clang-tools-extra/clangd/xpc/test-client:clangd-xpc-test-client",
98 action("check-clangd") {
99 script = "$root_out_dir/bin/llvm-lit"
100 if (host_os == "win") {
106 # clangd doesn't put unittest configs in test/unit like every other project.
107 # Because of that, this needs to pass two folders here, while every other
108 # project only needs to pass CMAKE_CURRENT_BINARY_DIR.
109 rebase_path(get_path_info(clangd_lit_site_cfg_file, "dir"), root_out_dir),
110 rebase_path(get_path_info(clangd_lit_unit_site_cfg_file, "dir"),
113 outputs = [ "$target_gen_dir/run-lit" ] # Non-existing, so that ninja runs it
116 # Since check-clangd is always dirty, //:default doesn't depend on it so
117 # that it's not part of the default ninja target. Hence, check-clangd
118 # shouldn't have any deps except :test. so that the default target is sure to
119 # build all the deps.