[gn build] (manually) port cd2292ef824 (PseudoCXX)
authorNico Weber <thakis@chromium.org>
Wed, 25 May 2022 12:39:29 +0000 (08:39 -0400)
committerNico Weber <thakis@chromium.org>
Fri, 1 Jul 2022 08:45:35 +0000 (10:45 +0200)
This target will be used in the next commit.

llvm/utils/gn/secondary/clang-tools-extra/pseudo/cxx/BUILD.gn [deleted file]
llvm/utils/gn/secondary/clang-tools-extra/pseudo/include/BUILD.gn [new file with mode: 0644]
llvm/utils/gn/secondary/clang-tools-extra/pseudo/lib/cxx/BUILD.gn [new file with mode: 0644]

diff --git a/llvm/utils/gn/secondary/clang-tools-extra/pseudo/cxx/BUILD.gn b/llvm/utils/gn/secondary/clang-tools-extra/pseudo/cxx/BUILD.gn
deleted file mode 100644 (file)
index c2a8d61..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# FIXME: Nothing depends on this yet.
-static_library("cxx") {
-  output_name = "clangPseudoCXX"
-  configs += [ "//llvm/utils/gn/build:clang_code" ]
-  deps = [ "//clang-tools-extra/pseudo/lib/grammar" ]
-  sources = [ "CXX.cpp" ]
-}
diff --git a/llvm/utils/gn/secondary/clang-tools-extra/pseudo/include/BUILD.gn b/llvm/utils/gn/secondary/clang-tools-extra/pseudo/include/BUILD.gn
new file mode 100644 (file)
index 0000000..8a86255
--- /dev/null
@@ -0,0 +1,39 @@
+import("//llvm/utils/gn/build/compiled_action.gni")
+
+template("gen") {
+  compiled_action(target_name) {
+    tool = "//clang-tools-extra/pseudo/gen:clang-pseudo-gen"
+    inputs = [ "../lib/cxx/cxx.bnf" ]
+    outputs = [ "$target_gen_dir/$target_name" ]
+    args = [
+      "--grammar",
+      rebase_path(inputs[0], root_build_dir),
+      "-o",
+      rebase_path(outputs[0], root_build_dir),
+      invoker.flag,
+    ]
+  }
+}
+
+gen("CXXSymbols.inc") {
+  flag = "--emit-symbol-list"
+}
+
+gen("CXXBNF.inc") {
+  flag = "--emit-grammar-content"
+}
+
+config("cxx_gen_config") {
+  visibility = [ ":cxx_gen" ]
+  include_dirs = [ target_gen_dir ]
+}
+
+group("cxx_gen") {
+  deps = [
+    ":CXXSymbols.inc",
+    ":CXXBNF.inc",
+  ]
+
+  # Let targets depending on this find the generated files.
+  public_configs = [ ":cxx_gen_config" ]
+}
diff --git a/llvm/utils/gn/secondary/clang-tools-extra/pseudo/lib/cxx/BUILD.gn b/llvm/utils/gn/secondary/clang-tools-extra/pseudo/lib/cxx/BUILD.gn
new file mode 100644 (file)
index 0000000..3db60e2
--- /dev/null
@@ -0,0 +1,13 @@
+static_library("cxx") {
+  output_name = "clangPseudoCXX"
+  configs += [ "//llvm/utils/gn/build:clang_code" ]
+  deps = [
+    "//clang-tools-extra/pseudo/lib/grammar",
+    "//llvm/lib/Support",
+  ]
+
+  # public_deps because this target's public headers include generated headers.
+  public_deps = [ "//clang-tools-extra/pseudo/include:cxx_gen" ]
+  include_dirs = [ "../../include" ]
+  sources = [ "CXX.cpp" ]
+}