xref: /aosp_15_r20/external/flatbuffers/src/BUILD.bazel (revision 890232f25432b36107d06881e0a25aaa6b473652)
1# @unused
2load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
3
4package(
5    default_visibility = ["//visibility:private"],
6)
7
8# Public flatc library to compile flatbuffer files at runtime.
9cc_library(
10    name = "flatbuffers",
11    srcs = [
12        "code_generators.cpp",
13        "idl_gen_fbs.cpp",
14        "idl_gen_text.cpp",
15        "idl_parser.cpp",
16        "reflection.cpp",
17        "util.cpp",
18    ],
19    hdrs = ["//:public_headers"],
20    linkopts = select({
21        # TODO: Bazel uses `clang` instead of `clang++` to link
22        # C++ code on BSD. Temporarily adding these linker flags while
23        # we wait for Bazel to resolve
24        # https://github.com/bazelbuild/bazel/issues/12023.
25        "//:platform_freebsd": ["-lm"],
26        "//:platform_openbsd": ["-lm"],
27        "//conditions:default": [],
28    }),
29    strip_include_prefix = "/include",
30    visibility = ["//:__pkg__"],
31)
32
33# Public flatc compiler library.
34cc_library(
35    name = "flatc_library",
36    srcs = [
37        "annotated_binary_text_gen.cpp",
38        "annotated_binary_text_gen.h",
39        "bfbs_gen.h",
40        "bfbs_gen_lua.cpp",
41        "bfbs_gen_lua.h",
42        "bfbs_namer.h",
43        "binary_annotator.cpp",
44        "binary_annotator.h",
45        "flatc.cpp",
46        "namer.h",
47    ],
48    hdrs = [
49        "//:flatc_headers",
50    ],
51    strip_include_prefix = "/include",
52    visibility = ["//:__pkg__"],
53    deps = [
54        ":flatbuffers",
55    ],
56)
57
58# Public flatc compiler.
59cc_library(
60    name = "flatc",
61    srcs = [
62        "bfbs_gen.h",
63        "bfbs_gen_lua.cpp",
64        "bfbs_gen_lua.h",
65        "bfbs_namer.h",
66        "flatc_main.cpp",
67        "idl_gen_cpp.cpp",
68        "idl_gen_csharp.cpp",
69        "idl_gen_dart.cpp",
70        "idl_gen_go.cpp",
71        "idl_gen_grpc.cpp",
72        "idl_gen_java.cpp",
73        "idl_gen_json_schema.cpp",
74        "idl_gen_kotlin.cpp",
75        "idl_gen_lobster.cpp",
76        "idl_gen_lua.cpp",
77        "idl_gen_php.cpp",
78        "idl_gen_python.cpp",
79        "idl_gen_rust.cpp",
80        "idl_gen_swift.cpp",
81        "idl_gen_text.cpp",
82        "idl_gen_ts.cpp",
83        "idl_namer.h",
84        "namer.h",
85        "util.cpp",
86    ],
87    hdrs = [
88        "//:flatc_headers",
89    ],
90    strip_include_prefix = "/include",
91    visibility = ["//:__pkg__"],
92    deps = [
93        ":flatc_library",
94        "//grpc/src/compiler:cpp_generator",
95        "//grpc/src/compiler:go_generator",
96        "//grpc/src/compiler:java_generator",
97        "//grpc/src/compiler:python_generator",
98        "//grpc/src/compiler:swift_generator",
99        "//grpc/src/compiler:ts_generator",
100    ],
101)
102