[llvm] r357232 - gn build: Add check-clang-tools to run clang-tools-extra lit tests

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 28 19:49:14 PDT 2019


Author: nico
Date: Thu Mar 28 19:49:13 2019
New Revision: 357232

URL: http://llvm.org/viewvc/llvm-project?rev=357232&view=rev
Log:
gn build: Add check-clang-tools to run clang-tools-extra lit tests

Only runs the clang-tools-extra lit tests; not yet the unit tests.

Add a build file for clangd-indexer too, since it's needed for
the tests.

Differential Revision: https://reviews.llvm.org/D59955

Added:
    llvm/trunk/utils/gn/secondary/clang-tools-extra/clangd/indexer/
    llvm/trunk/utils/gn/secondary/clang-tools-extra/clangd/indexer/BUILD.gn
    llvm/trunk/utils/gn/secondary/clang-tools-extra/test/
    llvm/trunk/utils/gn/secondary/clang-tools-extra/test/BUILD.gn
    llvm/trunk/utils/gn/secondary/clang-tools-extra/test/clang_tools_extra_lit_site_cfg_files.gni
Modified:
    llvm/trunk/utils/gn/secondary/BUILD.gn
    llvm/trunk/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn

Modified: llvm/trunk/utils/gn/secondary/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/BUILD.gn?rev=357232&r1=357231&r2=357232&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/BUILD.gn Thu Mar 28 19:49:13 2019
@@ -4,18 +4,7 @@ import("//llvm/utils/gn/build/toolchain/
 
 group("default") {
   deps = [
-    "//clang-tools-extra/clang-apply-replacements/tool:clang-apply-replacements",
-    "//clang-tools-extra/clang-change-namespace/tool:clang-change-namespace",
-    "//clang-tools-extra/clang-doc/tool:clang-doc",
-    "//clang-tools-extra/clang-include-fixer/find-all-symbols/tool:find-all-symbols",
-    "//clang-tools-extra/clang-include-fixer/tool:clang-include-fixer",
-    "//clang-tools-extra/clang-move/tool:clang-move",
-    "//clang-tools-extra/clang-query/tool:clang-query",
-    "//clang-tools-extra/clang-reorder-fields/tool:clang-reorder-fields",
-    "//clang-tools-extra/clang-tidy/tool:clang-tidy",
-    "//clang-tools-extra/clangd/tool:clangd",
-    "//clang-tools-extra/modularize",
-    "//clang-tools-extra/pp-trace",
+    "//clang-tools-extra/test",
     "//clang/test",
     "//lld/test",
     "//llvm/test",

Added: llvm/trunk/utils/gn/secondary/clang-tools-extra/clangd/indexer/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang-tools-extra/clangd/indexer/BUILD.gn?rev=357232&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang-tools-extra/clangd/indexer/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang-tools-extra/clangd/indexer/BUILD.gn Thu Mar 28 19:49:13 2019
@@ -0,0 +1,17 @@
+executable("clangd-indexer") {
+  configs += [ "//llvm/utils/gn/build:clang_code" ]
+  deps = [
+    "//clang-tools-extra/clangd",
+    "//clang/lib/AST",
+    "//clang/lib/Basic",
+    "//clang/lib/Frontend",
+    "//clang/lib/Index",
+    "//clang/lib/Lex",
+    "//clang/lib/Tooling",
+    "//llvm/lib/Support",
+  ]
+  include_dirs = [ "..", ]
+  sources = [
+    "IndexerMain.cpp",
+  ]
+}

Added: llvm/trunk/utils/gn/secondary/clang-tools-extra/test/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang-tools-extra/test/BUILD.gn?rev=357232&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang-tools-extra/test/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang-tools-extra/test/BUILD.gn Thu Mar 28 19:49:13 2019
@@ -0,0 +1,120 @@
+import("//clang/lib/StaticAnalyzer/Frontend/enable.gni")
+import("//llvm/triples.gni")
+import("//llvm/utils/gn/build/write_cmake_config.gni")
+import("clang_tools_extra_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",
+      "CLANG_TOOLS_BINARY_DIR=" +
+          rebase_path(get_label_info("//clang-tools-extra", "target_out_dir")),
+      "CLANG_TOOLS_SOURCE_DIR=" + rebase_path("//clang-tools-extra"),
+      "LLVM_LIBS_DIR=",  # needed only for shared builds
+      "TARGET_TRIPLE=$llvm_target_triple",
+    ]
+    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/test/lit.site.cfg.py.in"
+  output = clang_tools_extra_lit_site_cfg_file
+
+  extra_values = [
+    "CLANG_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
+    "LLVM_LIT_TOOLS_DIR=",  # Intentionally empty, matches cmake build.
+    "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
+    "PYTHON_EXECUTABLE=$python_path",
+    "CLANGD_BUILD_XPC_SUPPORT=0",  # FIXME
+  ]
+
+  if (clang_enable_static_analyzer) {
+    extra_values += [ "CLANG_ENABLE_STATIC_ANALYZER=1" ]
+  } else {
+    extra_values += [ "CLANG_ENABLE_STATIC_ANALYZER=0" ]
+  }
+}
+
+write_lit_config("lit_unit_site_cfg") {
+  # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
+  input = "//clang-tools-extra/test/Unit/lit.site.cfg.py.in"
+  output = clang_tools_extra_lit_unit_site_cfg_file
+  extra_values = []
+}
+
+# This target should contain all dependencies of check-clang-tools.
+# //: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/clang-apply-replacements/tool:clang-apply-replacements",
+    "//clang-tools-extra/clang-change-namespace/tool:clang-change-namespace",
+    "//clang-tools-extra/clang-doc/tool:clang-doc",
+    "//clang-tools-extra/clang-include-fixer/find-all-symbols/tool:find-all-symbols",
+    "//clang-tools-extra/clang-include-fixer/tool:clang-include-fixer",
+    "//clang-tools-extra/clang-move/tool:clang-move",
+    "//clang-tools-extra/clang-query/tool:clang-query",
+    "//clang-tools-extra/clang-reorder-fields/tool:clang-reorder-fields",
+    "//clang-tools-extra/clang-tidy/tool:clang-tidy",
+    "//clang-tools-extra/clangd/indexer:clangd-indexer",
+    "//clang-tools-extra/clangd/tool:clangd",
+    "//clang-tools-extra/modularize",
+    "//clang-tools-extra/pp-trace",
+    "//clang/lib/Headers",
+    "//clang/tools/c-index-test",
+    "//clang/tools/clang-rename",
+    "//clang/tools/driver:symlinks",
+    "//llvm/tools/llvm-bcanalyzer",
+    "//llvm/utils/FileCheck",
+    "//llvm/utils/count",
+    "//llvm/utils/llvm-lit",
+    "//llvm/utils/not",
+  ]
+
+  # FIXME: dep on "//clang-tools-extra/unittests" once it exists
+  # FIXME: dep on dexp once it exist
+  testonly = true
+}
+
+action("check-clang-tools") {
+  script = "$root_out_dir/bin/llvm-lit"
+  if (host_os == "win") {
+    script += ".py"
+  }
+  args = [
+    "-sv",
+    "--param",
+    "clang_site_config=" +
+        rebase_path(clang_tools_extra_lit_site_cfg_file, root_out_dir),
+    "--param",
+    "clang_unit_site_config=" +
+        rebase_path(clang_tools_extra_lit_unit_site_cfg_file, root_out_dir),
+    rebase_path(".", root_out_dir),
+  ]
+  outputs = [
+    "$target_gen_dir/run-lit",  # Non-existing, so that ninja runs it each time.
+  ]
+
+  # Since check-clang-tools is always dirty, //:default doesn't depend on it so
+  # that it's not part of the default ninja target.  Hence, check-clang
+  # 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"
+}

Added: llvm/trunk/utils/gn/secondary/clang-tools-extra/test/clang_tools_extra_lit_site_cfg_files.gni
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang-tools-extra/test/clang_tools_extra_lit_site_cfg_files.gni?rev=357232&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang-tools-extra/test/clang_tools_extra_lit_site_cfg_files.gni (added)
+++ llvm/trunk/utils/gn/secondary/clang-tools-extra/test/clang_tools_extra_lit_site_cfg_files.gni Thu Mar 28 19:49:13 2019
@@ -0,0 +1,4 @@
+clang_tools_extra_lit_site_cfg_file =
+    "$root_gen_dir/clang-tools-extra/test/lit.site.cfg.py"
+clang_tools_extra_lit_unit_site_cfg_file =
+    "$root_gen_dir/clang-tools-extra/test/Unit/lit.site.cfg.py"

Modified: llvm/trunk/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn?rev=357232&r1=357231&r2=357232&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn Thu Mar 28 19:49:13 2019
@@ -1,3 +1,4 @@
+import("//clang-tools-extra/test/clang_tools_extra_lit_site_cfg_files.gni")
 import("//clang/test/clang_lit_site_cfg_files.gni")
 import("//lld/test/lld_lit_site_cfg_files.gni")
 import("//llvm/test/llvm_lit_site_cfg_files.gni")
@@ -24,6 +25,8 @@ write_cmake_config("llvm-lit") {
   config_map = ""
 
   deps += [
+    "//clang-tools-extra/test:lit_site_cfg",
+    "//clang-tools-extra/test:lit_unit_site_cfg",
     "//clang/test:lit_site_cfg",
     "//clang/test:lit_unit_site_cfg",
     "//lld/test:lit_site_cfg",
@@ -33,6 +36,12 @@ write_cmake_config("llvm-lit") {
   ]
 
   # Note: \n is converted into a newline by write_cmake_config.py, not by gn.
+  config_map +=
+      "map_config('" + rebase_path("//clang-tools-extra/test/lit.cfg.py") +
+      "', '" + rebase_path(clang_tools_extra_lit_site_cfg_file) + "')\n"
+  config_map +=
+      "map_config('" + rebase_path("//clang-tools-extra/test/Unit/lit.cfg.py") +
+      "', '" + rebase_path(clang_tools_extra_lit_unit_site_cfg_file) + "')\n"
   config_map += "map_config('" + rebase_path("//clang/test/lit.cfg.py") +
                 "', '" + rebase_path(clang_lit_site_cfg_file) + "')\n"
   config_map += "map_config('" + rebase_path("//clang/test/Unit/lit.cfg.py") +




More information about the llvm-commits mailing list