1 import("//clang-tools-extra/clangd/xpc/enable.gni")
2 import("//llvm/triples.gni")
3 import("//llvm/utils/gn/build/write_cmake_config.gni")
4 import("clangd_lit_site_cfg_files.gni")
6 template("write_lit_config") {
7 write_cmake_config(target_name) {
9 output = invoker.output
11 "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
12 "LLVM_LIBS_DIR=", # needed only for shared builds
14 values += invoker.extra_values
18 write_lit_config("lit_site_cfg") {
19 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
20 input = "//clang-tools-extra/clangd/test/lit.site.cfg.py.in"
21 output = clangd_lit_site_cfg_file
24 "CMAKE_CURRENT_BINARY_DIR=" + rebase_path(
25 get_label_info("//clang-tools-extra/clangd/test", "target_out_dir")),
26 "CMAKE_CURRENT_SOURCE_DIR=" +
27 rebase_path("//clang-tools-extra/clangd/test"),
29 "CLANG_LIBS_DIR=", # needed only for shared builds
31 "LLVM_HOST_TRIPLE=$llvm_current_triple",
32 "LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build.
33 "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
34 "TARGET_TRIPLE=$llvm_target_triple",
37 if (clangd_build_xpc) {
38 extra_values += [ "CLANGD_BUILD_XPC=1" ]
40 extra_values += [ "CLANGD_BUILD_XPC=0" ]
44 write_lit_config("lit_unit_site_cfg") {
45 # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
46 input = "//clang-tools-extra/clangd/unittests/lit.site.cfg.py.in"
47 output = clangd_lit_unit_site_cfg_file
49 "CMAKE_CURRENT_BINARY_DIR=" +
50 rebase_path(get_label_info("//clang-tools-extra/clangd/unittests",
52 "CMAKE_CURRENT_SOURCE_DIR=" +
53 rebase_path("//clang-tools-extra/clangd/unittests"),
55 if (host_os == "win") {
56 # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
57 extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin") ]
59 extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib") ]
63 # This target should contain all dependencies of check-clangd.
64 # //:default depends on it, so that ninja's default target builds all
65 # prerequisites for check-clang but doesn't run check-clang itself.
70 "//clang-tools-extra/clangd/index/dex/dexp",
71 "//clang-tools-extra/clangd/indexer:clangd-indexer",
72 "//clang-tools-extra/clangd/tool:clangd",
73 "//clang-tools-extra/clangd/unittests:ClangdTests",
74 "//llvm/utils/FileCheck",
75 "//llvm/utils/llvm-lit",
78 if (clangd_build_xpc) {
80 "//clang-tools-extra/clangd/unittests/xpc:ClangdXpcTests",
81 "//clang-tools-extra/clangd/xpc/test-client:clangd-xpc-test-client",
87 action("check-clangd") {
88 script = "$root_out_dir/bin/llvm-lit"
89 if (host_os == "win") {
94 rebase_path(get_path_info(clangd_lit_site_cfg_file, "dir"), root_out_dir),
95 rebase_path(get_path_info(clangd_lit_unit_site_cfg_file, "dir"),
99 "$target_gen_dir/run-lit", # Non-existing, so that ninja runs it each time.
102 # Since check-clangd is always dirty, //:default doesn't depend on it so
103 # that it's not part of the default ninja target. Hence, check-clangd
104 # shouldn't have any deps except :test. so that the default target is sure to
105 # build all the deps.