import("//clang-tools-extra/clangd/xpc/enable.gni")
import("//llvm/triples.gni")
import("//llvm/utils/gn/build/libs/zlib/enable.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("clangd_lit_site_cfg_files.gni")
template("write_lit_config") {
write_cmake_config(target_name) {
input = invoker.input
output = invoker.output
values = [
"LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
"LLVM_LIBS_DIR=", # needed only for shared builds
]
if (host_os == "win") {
# See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin") ]
} else {
values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib") ]
}
values += invoker.extra_values
}
}
write_lit_config("lit_site_cfg") {
# Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
input = "//clang-tools-extra/clangd/test/lit.site.cfg.py.in"
output = clangd_lit_site_cfg_file
extra_values = [
"CMAKE_CURRENT_BINARY_DIR=" +
rebase_path(get_label_info("//clang-tools-extra/clangd/test",
"target_out_dir")),
"CMAKE_CURRENT_SOURCE_DIR=" +
rebase_path("//clang-tools-extra/clangd/test"),
"CURRENT_TOOLS_DIR=",
"CLANGD_ENABLE_REMOTE=0",
"CLANGD_TIDY_CHECKS=1",
"LLVM_HOST_TRIPLE=$llvm_current_triple",
"LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build.
"LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
"LLVM_TARGET_TRIPLE=$llvm_target_triple",
"Python3_EXECUTABLE=$python_path",
]
if (clangd_build_xpc) {
extra_values += [ "CLANGD_BUILD_XPC=1" ]
} else {
extra_values += [ "CLANGD_BUILD_XPC=0" ]
}
if (llvm_enable_zlib) {
extra_values += [ "LLVM_ENABLE_ZLIB=1" ]
} else {
extra_values += [ "LLVM_ENABLE_ZLIB=0" ]
}
}
write_lit_config("lit_unit_site_cfg") {
# Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
input = "//clang-tools-extra/clangd/unittests/lit.site.cfg.py.in"
output = clangd_lit_unit_site_cfg_file
extra_values = [
"CMAKE_CURRENT_BINARY_DIR=" +
rebase_path(get_label_info("//clang-tools-extra/clangd/unittests",
"target_out_dir")),
"CMAKE_CURRENT_SOURCE_DIR=" +
rebase_path("//clang-tools-extra/clangd/unittests"),
]
}
# This target should contain all dependencies of check-clangd.
# //:default depends on it, so that ninja's default target builds all
# prerequisites for check-clang but doesn't run check-clang itself.
group("test") {
deps = [
":lit_site_cfg",
":lit_unit_site_cfg",
"//clang-tools-extra/clangd/index/dex/dexp",
"//clang-tools-extra/clangd/indexer:clangd-indexer",
"//clang-tools-extra/clangd/tool:clangd",
"//clang-tools-extra/clangd/unittests:ClangdTests",
"//llvm/utils/FileCheck",
"//llvm/utils/llvm-lit",
"//llvm/utils/not",
"//llvm/utils/split-file",
]
if (clangd_build_xpc) {
deps += [
"//clang-tools-extra/clangd/unittests/xpc:ClangdXpcTests",
"//clang-tools-extra/clangd/xpc/test-client:clangd-xpc-test-client",
]
}
testonly = true
}
action("check-clangd") {
script = "$root_out_dir/bin/llvm-lit"
if (host_os == "win") {
script += ".py"
}
args = [
"-sv",
# clangd doesn't put unittest configs in test/unit like every other project.
# Because of that, this needs to pass two folders here, while every other
# project only needs to pass CMAKE_CURRENT_BINARY_DIR.
rebase_path(get_path_info(clangd_lit_site_cfg_file, "dir"), root_out_dir),
rebase_path(get_path_info(clangd_lit_unit_site_cfg_file, "dir"),
root_out_dir),
]
outputs = [ "$target_gen_dir/run-lit" ] # Non-existing, so that ninja runs it
# each time.
# Since check-clangd is always dirty, //:default doesn't depend on it so
# that it's not part of the default ninja target. Hence, check-clangd
# shouldn't have any deps except :test. so that the default target is sure to
# build all the deps.
deps = [ ":test" ]
testonly = true
pool = "//:console"
}