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