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 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") ]
19 values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib") ]
21 values += invoker.extra_values
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
31 "CMAKE_CURRENT_BINARY_DIR=" +
32 rebase_path(get_label_info("//clang-tools-extra/clangd/test",
34 "CMAKE_CURRENT_SOURCE_DIR=" +
35 rebase_path("//clang-tools-extra/clangd/test"),
38 "CLANGD_ENABLE_REMOTE=0",
39 "CLANGD_TIDY_CHECKS=1",
40 "LLVM_HOST_TRIPLE=$llvm_current_triple",
41 "LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build.
42 "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
43 "LLVM_TARGET_TRIPLE=$llvm_target_triple",
44 "Python3_EXECUTABLE=$python_path",
47 if (clangd_build_xpc) {
48 extra_values += [ "CLANGD_BUILD_XPC=1" ]
50 extra_values += [ "CLANGD_BUILD_XPC=0" ]
53 if (llvm_enable_zlib) {
54 extra_values += [ "LLVM_ENABLE_ZLIB=1" ]
56 extra_values += [ "LLVM_ENABLE_ZLIB=0" ]
60 write_lit_config("lit_unit_site_cfg") {
61 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
62 input = "//clang-tools-extra/clangd/unittests/lit.site.cfg.py.in"
63 output = clangd_lit_unit_site_cfg_file
65 "CMAKE_CURRENT_BINARY_DIR=" +
66 rebase_path(get_label_info("//clang-tools-extra/clangd/unittests",
68 "CMAKE_CURRENT_SOURCE_DIR=" +
69 rebase_path("//clang-tools-extra/clangd/unittests"),
73 # This target should contain all dependencies of check-clangd.
74 # //:default depends on it, so that ninja's default target builds all
75 # prerequisites for check-clang but doesn't run check-clang itself.
80 "//clang-tools-extra/clangd/index/dex/dexp",
81 "//clang-tools-extra/clangd/indexer:clangd-indexer",
82 "//clang-tools-extra/clangd/tool:clangd",
83 "//clang-tools-extra/clangd/unittests:ClangdTests",
84 "//llvm/utils/FileCheck",
85 "//llvm/utils/llvm-lit",
88 if (clangd_build_xpc) {
90 "//clang-tools-extra/clangd/unittests/xpc:ClangdXpcTests",
91 "//clang-tools-extra/clangd/xpc/test-client:clangd-xpc-test-client",
97 action("check-clangd") {
98 script = "$root_out_dir/bin/llvm-lit"
99 if (host_os == "win") {
105 # clangd doesn't put unittest configs in test/unit like every other project.
106 # Because of that, this needs to pass two folders here, while every other
107 # project only needs to pass CMAKE_CURRENT_BINARY_DIR.
108 rebase_path(get_path_info(clangd_lit_site_cfg_file, "dir"), root_out_dir),
109 rebase_path(get_path_info(clangd_lit_unit_site_cfg_file, "dir"),
112 outputs = [ "$target_gen_dir/run-lit" ] # Non-existing, so that ninja runs it
115 # Since check-clangd is always dirty, //:default doesn't depend on it so
116 # that it's not part of the default ninja target. Hence, check-clangd
117 # shouldn't have any deps except :test. so that the default target is sure to
118 # build all the deps.