xref: /llvm-project/llvm/utils/gn/secondary/clang/utils/TableGen/clang_tablegen.gni (revision b1061e36d9833d9a712579e29a318732df0b744c)
1# This file introduces a template for running clang-tblgen.
2#
3# Parameters:
4#
5#   args (required)
6#       [list of strings] Flags to pass to clang-tblgen.
7#
8#   output_name (optional)
9#       Basename of the generated output file.
10#       Defaults to target name with ".inc" appended.
11#
12#   td_file (optional)
13#       The .td file to pass to llvm-tblgen.
14#       Defaults to target name with ".td" appended.
15#
16#   visibility (optional)
17#       GN's regular visibility attribute, see `gn help visibility`.
18#
19# Example of usage:
20#
21#   clang_tablegen("DiagnosticGroups") {
22#     args = [ "-gen-clang-diag-groups" ]
23#     td_file = "Diagnostic.td"
24#   }
25
26import("//llvm/utils/TableGen/tablegen.gni")
27
28template("clang_tablegen") {
29  tablegen(target_name) {
30    forward_variables_from(invoker,
31                           [
32                             "output_name",
33                             "td_file",
34                             "visibility",
35                           ])
36
37    args = [
38             "-I",
39             rebase_path("//clang/include", root_build_dir),
40           ] + invoker.args
41    tblgen_target = "//clang/utils/TableGen:clang-tblgen"
42  }
43}
44