| 1 |
import("//llvm/triples.gni") |
| 2 |
import("//llvm/utils/gn/build/write_cmake_config.gni") |
| 3 |
import("clang_pseudo_lit_site_cfg_files.gni") |
| 4 |
|
| 5 |
template("write_lit_config") { |
| 6 |
write_cmake_config(target_name) { |
| 7 |
input = invoker.input |
| 8 |
output = invoker.output |
| 9 |
values = [ |
| 10 |
"LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit", |
| 11 |
"LLVM_LIBS_DIR=", # needed only for shared builds |
| 12 |
] |
| 13 |
values += invoker.extra_values |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
write_lit_config("lit_site_cfg") { |
| 18 |
# Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER. |
| 19 |
input = "//clang-tools-extra/pseudo/test/lit.site.cfg.py.in" |
| 20 |
output = clang_pseudo_lit_site_cfg_file |
| 21 |
|
| 22 |
extra_values = [ |
| 23 |
"CMAKE_CURRENT_BINARY_DIR=" + |
| 24 |
rebase_path(get_label_info("//clang-tools-extra/pseudo/test", |
| 25 |
"target_out_dir")), |
| 26 |
"CMAKE_CURRENT_SOURCE_DIR=" + |
| 27 |
rebase_path("//clang-tools-extra/pseudo/test"), |
| 28 |
|
| 29 |
"CURRENT_TOOLS_DIR=", |
| 30 |
"LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build. |
| 31 |
"LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"), |
| 32 |
"TARGET_TRIPLE=$llvm_target_triple", |
| 33 |
"Python3_EXECUTABLE=$python_path", |
| 34 |
] |
| 35 |
} |
| 36 |
|
| 37 |
write_lit_config("lit_unit_site_cfg") { |
| 38 |
# Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER. |
| 39 |
input = "//clang-tools-extra/pseudo/test/Unit/lit.site.cfg.py.in" |
| 40 |
output = clang_pseudo_lit_unit_site_cfg_file |
| 41 |
extra_values = [ |
| 42 |
"CMAKE_CURRENT_BINARY_DIR=" + |
| 43 |
rebase_path(get_label_info("//clang-tools-extra/pseudo/unittests", |
| 44 |
"target_out_dir")), |
| 45 |
"CMAKE_CURRENT_SOURCE_DIR=" + |
| 46 |
rebase_path("//clang-tools-extra/pseudo/test"), |
| 47 |
] |
| 48 |
if (host_os == "win") { |
| 49 |
# See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn |
| 50 |
extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin") ] |
| 51 |
} else { |
| 52 |
extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib") ] |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
# This target should contain all dependencies of check-pseudo. |
| 57 |
# //:default depends on it, so that ninja's default target builds all |
| 58 |
# prerequisites for check-clang but doesn't run check-clang itself. |
| 59 |
group("test") { |
| 60 |
deps = [ |
| 61 |
":lit_site_cfg", |
| 62 |
":lit_unit_site_cfg", |
| 63 |
"//clang-tools-extra/pseudo/tool:clang-pseudo", |
| 64 |
"//clang-tools-extra/pseudo/unittests:ClangPseudoTests", |
| 65 |
"//llvm/utils/FileCheck", |
| 66 |
"//llvm/utils/llvm-lit", |
| 67 |
"//llvm/utils/not", |
| 68 |
] |
| 69 |
testonly = true |
| 70 |
} |
| 71 |
|
| 72 |
action("check-clang-pseudo") { |
| 73 |
script = "$root_out_dir/bin/llvm-lit" |
| 74 |
if (host_os == "win") { |
| 75 |
script += ".py" |
| 76 |
} |
| 77 |
args = [ |
| 78 |
"-sv", |
| 79 |
rebase_path(get_path_info(clang_pseudo_lit_site_cfg_file, "dir"), |
| 80 |
root_out_dir), |
| 81 |
] |
| 82 |
outputs = [ "$target_gen_dir/run-lit" ] # Non-existing, so that ninja runs it |
| 83 |
# each time. |
| 84 |
|
| 85 |
# Since check-clang-pseudo is always dirty, //:default doesn't depend on it so |
| 86 |
# that it's not part of the default ninja target. Hence, check-clang-pseudo |
| 87 |
# shouldn't have any deps except :test. so that the default target is sure to |
| 88 |
# build all the deps. |
| 89 |
deps = [ ":test" ] |
| 90 |
testonly = true |
| 91 |
|
| 92 |
pool = "//:console" |
| 93 |
} |