From fd20ec6b6edaa8436a9861b770297c855d91ceea Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 15 Mar 2022 20:44:59 -0400 Subject: [PATCH] [gn build] (manually) port 89cd86bbc58a (clang-pseudo move) --- llvm/utils/gn/secondary/BUILD.gn | 1 + .../pseudo/lib}/BUILD.gn | 5 +- .../clang-tools-extra/pseudo/test/BUILD.gn | 93 ++++++++++++++++++++++ .../test/clang_pseudo_lit_site_cfg_files.gni | 4 + .../pseudo/tool}/BUILD.gn | 3 +- .../pseudo/unittests}/BUILD.gn | 4 +- llvm/utils/gn/secondary/clang/test/BUILD.gn | 1 - llvm/utils/gn/secondary/clang/unittests/BUILD.gn | 1 - .../gn/secondary/llvm/utils/llvm-lit/BUILD.gn | 13 +++ 9 files changed, 118 insertions(+), 7 deletions(-) rename llvm/utils/gn/secondary/{clang/lib/Tooling/Syntax/Pseudo => clang-tools-extra/pseudo/lib}/BUILD.gn (78%) create mode 100644 llvm/utils/gn/secondary/clang-tools-extra/pseudo/test/BUILD.gn create mode 100644 llvm/utils/gn/secondary/clang-tools-extra/pseudo/test/clang_pseudo_lit_site_cfg_files.gni rename llvm/utils/gn/secondary/{clang/tools/clang-pseudo => clang-tools-extra/pseudo/tool}/BUILD.gn (71%) rename llvm/utils/gn/secondary/{clang/unittests/Tooling/Syntax/Pseudo => clang-tools-extra/pseudo/unittests}/BUILD.gn (82%) diff --git a/llvm/utils/gn/secondary/BUILD.gn b/llvm/utils/gn/secondary/BUILD.gn index 827a61b..ce1a029 100644 --- a/llvm/utils/gn/secondary/BUILD.gn +++ b/llvm/utils/gn/secondary/BUILD.gn @@ -5,6 +5,7 @@ import("//llvm/utils/gn/build/toolchain/compiler.gni") group("default") { deps = [ "//clang-tools-extra/clangd/test", + "//clang-tools-extra/pseudo/test", "//clang-tools-extra/test", "//clang/test", "//clang/tools/scan-build", diff --git a/llvm/utils/gn/secondary/clang/lib/Tooling/Syntax/Pseudo/BUILD.gn b/llvm/utils/gn/secondary/clang-tools-extra/pseudo/lib/BUILD.gn similarity index 78% rename from llvm/utils/gn/secondary/clang/lib/Tooling/Syntax/Pseudo/BUILD.gn rename to llvm/utils/gn/secondary/clang-tools-extra/pseudo/lib/BUILD.gn index 416969d..07c1d5c 100644 --- a/llvm/utils/gn/secondary/clang/lib/Tooling/Syntax/Pseudo/BUILD.gn +++ b/llvm/utils/gn/secondary/clang-tools-extra/pseudo/lib/BUILD.gn @@ -1,11 +1,12 @@ -static_library("Pseudo") { - output_name = "clangToolingSyntaxPseudo" +static_library("lib") { + output_name = "clangPseudo" configs += [ "//llvm/utils/gn/build:clang_code" ] deps = [ "//clang/lib/Basic", "//clang/lib/Lex", "//llvm/lib/Support", ] + include_dirs = [ "../include" ] sources = [ "DirectiveMap.cpp", "Grammar.cpp", diff --git a/llvm/utils/gn/secondary/clang-tools-extra/pseudo/test/BUILD.gn b/llvm/utils/gn/secondary/clang-tools-extra/pseudo/test/BUILD.gn new file mode 100644 index 0000000..e58f492 --- /dev/null +++ b/llvm/utils/gn/secondary/clang-tools-extra/pseudo/test/BUILD.gn @@ -0,0 +1,93 @@ +import("//llvm/triples.gni") +import("//llvm/utils/gn/build/write_cmake_config.gni") +import("clang_pseudo_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 + ] + 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/pseudo/test/lit.site.cfg.py.in" + output = clang_pseudo_lit_site_cfg_file + + extra_values = [ + "CMAKE_CURRENT_BINARY_DIR=" + + rebase_path(get_label_info("//clang-tools-extra/pseudo/test", + "target_out_dir")), + "CMAKE_CURRENT_SOURCE_DIR=" + + rebase_path("//clang-tools-extra/pseudo/test"), + + "CLANG_TOOLS_DIR=", + "LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build. + "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"), + "TARGET_TRIPLE=$llvm_target_triple", + "Python3_EXECUTABLE=$python_path", + ] +} + +write_lit_config("lit_unit_site_cfg") { + # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER. + input = "//clang-tools-extra/pseudo/test/Unit/lit.site.cfg.py.in" + output = clang_pseudo_lit_unit_site_cfg_file + extra_values = [ + "CMAKE_CURRENT_BINARY_DIR=" + + rebase_path(get_label_info("//clang-tools-extra/pseudo/unittests", + "target_out_dir")), + "CMAKE_CURRENT_SOURCE_DIR=" + + rebase_path("//clang-tools-extra/pseudo/test"), + ] + if (host_os == "win") { + # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn + extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin") ] + } else { + extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib") ] + } +} + +# This target should contain all dependencies of check-pseudo. +# //: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/pseudo/tool:clang-pseudo", + "//clang-tools-extra/pseudo/unittests:ClangPseudoTests", + "//llvm/utils/FileCheck", + "//llvm/utils/llvm-lit", + "//llvm/utils/not", + ] + testonly = true +} + +action("check-clang-pseudo") { + script = "$root_out_dir/bin/llvm-lit" + if (host_os == "win") { + script += ".py" + } + args = [ + "-sv", + rebase_path(get_path_info(clang_pseudo_lit_site_cfg_file, "dir"), + root_out_dir), + ] + outputs = [ "$target_gen_dir/run-lit" ] # Non-existing, so that ninja runs it + # each time. + + # Since check-clang-pseudo is always dirty, //:default doesn't depend on it so + # that it's not part of the default ninja target. Hence, check-clang-pseudo + # 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" +} diff --git a/llvm/utils/gn/secondary/clang-tools-extra/pseudo/test/clang_pseudo_lit_site_cfg_files.gni b/llvm/utils/gn/secondary/clang-tools-extra/pseudo/test/clang_pseudo_lit_site_cfg_files.gni new file mode 100644 index 0000000..ca469e5 --- /dev/null +++ b/llvm/utils/gn/secondary/clang-tools-extra/pseudo/test/clang_pseudo_lit_site_cfg_files.gni @@ -0,0 +1,4 @@ +clang_pseudo_lit_site_cfg_file = + "$root_gen_dir/clang-tools-extra/pseudo/test/lit.site.cfg.py" +clang_pseudo_lit_unit_site_cfg_file = + "$root_gen_dir/clang-tools-extra/pseudo/test/Unit/lit.site.cfg.py" diff --git a/llvm/utils/gn/secondary/clang/tools/clang-pseudo/BUILD.gn b/llvm/utils/gn/secondary/clang-tools-extra/pseudo/tool/BUILD.gn similarity index 71% rename from llvm/utils/gn/secondary/clang/tools/clang-pseudo/BUILD.gn rename to llvm/utils/gn/secondary/clang-tools-extra/pseudo/tool/BUILD.gn index ecbebd9..6bdae01 100644 --- a/llvm/utils/gn/secondary/clang/tools/clang-pseudo/BUILD.gn +++ b/llvm/utils/gn/secondary/clang-tools-extra/pseudo/tool/BUILD.gn @@ -2,8 +2,9 @@ executable("clang-pseudo") { configs += [ "//llvm/utils/gn/build:clang_code" ] deps = [ "//clang/lib/Basic", - "//clang/lib/Tooling/Syntax/Pseudo", + "//clang-tools-extra/pseudo/lib", "//llvm/lib/Support", ] + include_dirs = [ "../include" ] sources = [ "ClangPseudo.cpp" ] } diff --git a/llvm/utils/gn/secondary/clang/unittests/Tooling/Syntax/Pseudo/BUILD.gn b/llvm/utils/gn/secondary/clang-tools-extra/pseudo/unittests/BUILD.gn similarity index 82% rename from llvm/utils/gn/secondary/clang/unittests/Tooling/Syntax/Pseudo/BUILD.gn rename to llvm/utils/gn/secondary/clang-tools-extra/pseudo/unittests/BUILD.gn index 4eb9fdf..b2e05a5 100644 --- a/llvm/utils/gn/secondary/clang/unittests/Tooling/Syntax/Pseudo/BUILD.gn +++ b/llvm/utils/gn/secondary/clang-tools-extra/pseudo/unittests/BUILD.gn @@ -6,10 +6,10 @@ unittest("ClangPseudoTests") { "//clang/lib/Basic", "//clang/lib/Lex", "//clang/lib/Testing", - "//clang/lib/Tooling/Syntax/Pseudo", + "//clang-tools-extra/pseudo/lib", "//llvm/lib/Support", - "//llvm/lib/Testing/Support", ] + include_dirs = [ "../include" ] sources = [ "DirectiveMapTest.cpp", "GrammarTest.cpp", diff --git a/llvm/utils/gn/secondary/clang/test/BUILD.gn b/llvm/utils/gn/secondary/clang/test/BUILD.gn index 48e1f17..f342786 100644 --- a/llvm/utils/gn/secondary/clang/test/BUILD.gn +++ b/llvm/utils/gn/secondary/clang/test/BUILD.gn @@ -147,7 +147,6 @@ group("test") { "//clang/tools/clang-format", "//clang/tools/clang-import-test", "//clang/tools/clang-offload-bundler", - "//clang/tools/clang-pseudo", "//clang/tools/clang-refactor", "//clang/tools/clang-rename", "//clang/tools/clang-repl", diff --git a/llvm/utils/gn/secondary/clang/unittests/BUILD.gn b/llvm/utils/gn/secondary/clang/unittests/BUILD.gn index d33e5d7..5521995 100644 --- a/llvm/utils/gn/secondary/clang/unittests/BUILD.gn +++ b/llvm/utils/gn/secondary/clang/unittests/BUILD.gn @@ -21,7 +21,6 @@ group("unittests") { "Serialization:SerializationTests", "Tooling:ToolingTests", "Tooling/Syntax:SyntaxTests", - "Tooling/Syntax/Pseudo:ClangPseudoTests", ] if (clang_enable_static_analyzer) { deps += [ diff --git a/llvm/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn b/llvm/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn index aa0c5f8..2e43ec0 100644 --- a/llvm/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn @@ -1,4 +1,5 @@ import("//clang-tools-extra/clangd/test/clangd_lit_site_cfg_files.gni") +import("//clang-tools-extra/pseudo/test/clang_pseudo_lit_site_cfg_files.gni") 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") @@ -22,6 +23,10 @@ write_cmake_config("llvm-lit") { deps += [ "//clang-tools-extra/test:lit_site_cfg", "//clang-tools-extra/test:lit_unit_site_cfg", + "//clang-tools-extra/clangd/test:lit_site_cfg", + "//clang-tools-extra/clangd/test:lit_unit_site_cfg", + "//clang-tools-extra/pseudo/test:lit_site_cfg", + "//clang-tools-extra/pseudo/test:lit_unit_site_cfg", "//clang/test:lit_site_cfg", "//clang/test:lit_unit_site_cfg", "//lld/test:lit_site_cfg", @@ -52,6 +57,14 @@ write_cmake_config("llvm-lit") { clangd_lit_unit_site_cfg_file, ], [ + "//clang-tools-extra/pseudo/test/lit.cfg.py", + clang_pseudo_lit_site_cfg_file, + ], + [ + "//clang-tools-extra/pseudo/test/Unit/lit.cfg.py", + clang_pseudo_lit_unit_site_cfg_file, + ], + [ "//clang/test/lit.cfg.py", clang_lit_site_cfg_file, ], -- 2.7.4