| 1 |
import("//clang-tools-extra/clang-tidy/enable.gni") |
| 2 |
import("//clang/lib/StaticAnalyzer/Frontend/enable.gni") |
| 3 |
import("//llvm/triples.gni") |
| 4 |
import("//llvm/utils/gn/build/write_cmake_config.gni") |
| 5 |
import("clang_tools_extra_lit_site_cfg_files.gni") |
| 6 |
|
| 7 |
template("write_lit_config") { |
| 8 |
write_cmake_config(target_name) { |
| 9 |
input = invoker.input |
| 10 |
output = invoker.output |
| 11 |
values = [ |
| 12 |
"LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit", |
| 13 |
"CLANG_TOOLS_BINARY_DIR=" + |
| 14 |
rebase_path(get_label_info("//clang-tools-extra", "target_out_dir")), |
| 15 |
"CLANG_TOOLS_SOURCE_DIR=" + rebase_path("//clang-tools-extra"), |
| 16 |
"LLVM_LIBS_DIR=", # needed only for shared builds |
| 17 |
"LLVM_TARGET_TRIPLE=$llvm_target_triple", |
| 18 |
] |
| 19 |
if (host_os == "win") { |
| 20 |
# See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn |
| 21 |
values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin") ] |
| 22 |
} else { |
| 23 |
values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib") ] |
| 24 |
} |
| 25 |
values += invoker.extra_values |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
write_lit_config("lit_site_cfg") { |
| 30 |
# Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER. |
| 31 |
input = "//clang-tools-extra/test/lit.site.cfg.py.in" |
| 32 |
output = clang_tools_extra_lit_site_cfg_file |
| 33 |
|
| 34 |
extra_values = [ |
| 35 |
"CURRENT_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"), |
| 36 |
"CLANG_PLUGIN_SUPPORT=0", |
| 37 |
"LLVM_HOST_TRIPLE=$llvm_current_triple", |
| 38 |
"LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build. |
| 39 |
"LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"), |
| 40 |
"Python3_EXECUTABLE=$python_path", |
| 41 |
] |
| 42 |
|
| 43 |
if (clang_tidy_enable_static_analyzer) { |
| 44 |
extra_values += [ "CLANG_TIDY_ENABLE_STATIC_ANALYZER=1" ] |
| 45 |
} else { |
| 46 |
extra_values += [ "CLANG_TIDY_ENABLE_STATIC_ANALYZER=0" ] |
| 47 |
} |
| 48 |
|
| 49 |
if (host_os == "mac") { |
| 50 |
extra_values += [ "LLVM_PLUGIN_EXT=.dylib" ] |
| 51 |
} else if (host_os == "win") { |
| 52 |
extra_values += [ "LLVM_PLUGIN_EXT=.dll" ] |
| 53 |
} else { |
| 54 |
extra_values += [ "LLVM_PLUGIN_EXT=.so" ] |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
write_lit_config("lit_unit_site_cfg") { |
| 59 |
# Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER. |
| 60 |
input = "//clang-tools-extra/test/Unit/lit.site.cfg.py.in" |
| 61 |
output = clang_tools_extra_lit_unit_site_cfg_file |
| 62 |
extra_values = [] |
| 63 |
} |
| 64 |
|
| 65 |
# This target should contain all dependencies of check-clang-tools. |
| 66 |
# //:default depends on it, so that ninja's default target builds all |
| 67 |
# prerequisites for check-clang but doesn't run check-clang itself. |
| 68 |
group("test") { |
| 69 |
deps = [ |
| 70 |
":lit_site_cfg", |
| 71 |
":lit_unit_site_cfg", |
| 72 |
"//clang-tools-extra/clang-apply-replacements/tool:clang-apply-replacements", |
| 73 |
"//clang-tools-extra/clang-change-namespace/tool:clang-change-namespace", |
| 74 |
"//clang-tools-extra/clang-doc/tool:clang-doc", |
| 75 |
"//clang-tools-extra/clang-include-fixer/find-all-symbols/tool:find-all-symbols", |
| 76 |
"//clang-tools-extra/clang-include-fixer/tool:clang-include-fixer", |
| 77 |
"//clang-tools-extra/clang-move/tool:clang-move", |
| 78 |
"//clang-tools-extra/clang-query/tool:clang-query", |
| 79 |
"//clang-tools-extra/clang-reorder-fields/tool:clang-reorder-fields", |
| 80 |
"//clang-tools-extra/clang-tidy/tool:clang-tidy", |
| 81 |
"//clang-tools-extra/modularize", |
| 82 |
"//clang-tools-extra/pp-trace", |
| 83 |
"//clang-tools-extra/unittests", |
| 84 |
"//clang/lib/Headers", |
| 85 |
"//clang/tools/c-index-test", |
| 86 |
"//clang/tools/driver:symlinks", |
| 87 |
"//llvm/tools/llvm-bcanalyzer", |
| 88 |
"//llvm/utils/FileCheck", |
| 89 |
"//llvm/utils/count", |
| 90 |
"//llvm/utils/llvm-lit", |
| 91 |
"//llvm/utils/not", |
| 92 |
] |
| 93 |
testonly = true |
| 94 |
} |
| 95 |
|
| 96 |
action("check-clang-tools") { |
| 97 |
script = "$root_out_dir/bin/llvm-lit" |
| 98 |
if (host_os == "win") { |
| 99 |
script += ".py" |
| 100 |
} |
| 101 |
args = [ |
| 102 |
"-sv", |
| 103 |
rebase_path(".", root_out_dir), |
| 104 |
] |
| 105 |
outputs = [ "$target_gen_dir/run-lit" ] # Non-existing, so that ninja runs it |
| 106 |
# each time. |
| 107 |
|
| 108 |
# Since check-clang-tools is always dirty, //:default doesn't depend on it so |
| 109 |
# that it's not part of the default ninja target. Hence, check-clang-tools |
| 110 |
# shouldn't have any deps except :test. so that the default target is sure to |
| 111 |
# build all the deps. |
| 112 |
deps = [ ":test" ] |
| 113 |
testonly = true |
| 114 |
|
| 115 |
pool = "//:console" |
| 116 |
} |