1# @unused 2load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") 3 4package( 5 default_visibility = ["//visibility:private"], 6) 7 8filegroup( 9 name = "distribution", 10 srcs = [ 11 "BUILD.bazel", 12 ] + glob([ 13 "*.cpp", 14 "*.h", 15 ]), 16 visibility = ["//visibility:public"], 17) 18 19cc_library( 20 name = "code_generators", 21 srcs = ["code_generators.cpp"], 22 hdrs = [ 23 "//:public_headers", 24 ], 25 strip_include_prefix = "/include", 26 visibility = ["//:__subpackages__"], 27) 28 29cc_library( 30 name = "generate_fbs", 31 srcs = ["idl_gen_fbs.cpp"], 32 hdrs = ["idl_gen_fbs.h"], 33 strip_include_prefix = "/src", 34 visibility = ["//:__subpackages__"], 35 deps = [":code_generators"], 36) 37 38# Public flatc library to compile flatbuffer files at runtime. 39cc_library( 40 name = "flatbuffers", 41 srcs = [ 42 "idl_gen_text.cpp", 43 "idl_gen_text.h", 44 "idl_parser.cpp", 45 "reflection.cpp", 46 "util.cpp", 47 ], 48 hdrs = [ 49 "//:public_headers", 50 ], 51 linkopts = select({ 52 # TODO: Bazel uses `clang` instead of `clang++` to link 53 # C++ code on BSD. Temporarily adding these linker flags while 54 # we wait for Bazel to resolve 55 # https://github.com/bazelbuild/bazel/issues/12023. 56 "//:platform_freebsd": ["-lm"], 57 "//:platform_openbsd": ["-lm"], 58 "//conditions:default": [], 59 }), 60 strip_include_prefix = "/include", 61 visibility = ["//:__subpackages__"], 62 deps = [ 63 ":code_generators", 64 ":generate_fbs", 65 ], 66) 67 68# Public flatc compiler library. 69cc_library( 70 name = "flatc_library", 71 srcs = [ 72 "annotated_binary_text_gen.cpp", 73 "annotated_binary_text_gen.h", 74 "bfbs_gen.h", 75 "bfbs_gen_lua.cpp", 76 "bfbs_gen_lua.h", 77 "bfbs_gen_nim.cpp", 78 "bfbs_gen_nim.h", 79 "bfbs_namer.h", 80 "binary_annotator.cpp", 81 "binary_annotator.h", 82 "flatc.cpp", 83 "namer.h", 84 ], 85 hdrs = [ 86 "//:flatc_headers", 87 ], 88 strip_include_prefix = "/include", 89 visibility = ["//:__pkg__"], 90 deps = [ 91 ":flatbuffers", 92 "//include/codegen:namer", 93 ], 94) 95 96# Public flatc compiler. 97cc_library( 98 name = "flatc", 99 srcs = [ 100 "bfbs_gen.h", 101 "bfbs_gen_lua.cpp", 102 "bfbs_gen_lua.h", 103 "bfbs_gen_nim.cpp", 104 "bfbs_gen_nim.h", 105 "bfbs_namer.h", 106 "file_binary_writer.cpp", 107 "file_name_saving_file_manager.cpp", 108 "file_writer.cpp", 109 "flatc_main.cpp", 110 "idl_gen_binary.cpp", 111 "idl_gen_binary.h", 112 "idl_gen_cpp.cpp", 113 "idl_gen_cpp.h", 114 "idl_gen_csharp.cpp", 115 "idl_gen_csharp.h", 116 "idl_gen_dart.cpp", 117 "idl_gen_dart.h", 118 "idl_gen_go.cpp", 119 "idl_gen_go.h", 120 "idl_gen_grpc.cpp", 121 "idl_gen_java.cpp", 122 "idl_gen_java.h", 123 "idl_gen_json_schema.cpp", 124 "idl_gen_json_schema.h", 125 "idl_gen_kotlin.cpp", 126 "idl_gen_kotlin.h", 127 "idl_gen_kotlin_kmp.cpp", 128 "idl_gen_lobster.cpp", 129 "idl_gen_lobster.h", 130 "idl_gen_php.cpp", 131 "idl_gen_php.h", 132 "idl_gen_python.cpp", 133 "idl_gen_python.h", 134 "idl_gen_rust.cpp", 135 "idl_gen_rust.h", 136 "idl_gen_swift.cpp", 137 "idl_gen_swift.h", 138 "idl_gen_text.cpp", 139 "idl_gen_text.h", 140 "idl_gen_ts.cpp", 141 "idl_gen_ts.h", 142 "idl_namer.h", 143 "namer.h", 144 "util.cpp", 145 ], 146 hdrs = [ 147 "//:flatc_headers", 148 ], 149 strip_include_prefix = "/include", 150 visibility = ["//:__pkg__"], 151 deps = [ 152 ":flatc_library", 153 "//grpc/src/compiler:cpp_generator", 154 "//grpc/src/compiler:go_generator", 155 "//grpc/src/compiler:java_generator", 156 "//grpc/src/compiler:python_generator", 157 "//grpc/src/compiler:swift_generator", 158 "//grpc/src/compiler:ts_generator", 159 "//include/codegen:namer", 160 "//include/codegen:python", 161 ], 162) 163