Austin Schuh | 4ac96a8 | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 1 | licenses(["notice"]) |
| 2 | |
| 3 | package( |
| 4 | default_visibility = ["//visibility:public"], |
| 5 | features = [ |
| 6 | "-layering_check", |
| 7 | "-parse_headers", |
| 8 | ], |
| 9 | ) |
| 10 | |
| 11 | exports_files([ |
| 12 | "LICENSE", |
| 13 | ]) |
| 14 | |
| 15 | load(":build_defs.bzl", "flatbuffer_cc_library") |
| 16 | |
| 17 | # Public flatc library to compile flatbuffer files at runtime. |
| 18 | cc_library( |
| 19 | name = "flatbuffers", |
| 20 | srcs = [ |
| 21 | "src/code_generators.cpp", |
| 22 | "src/idl_gen_fbs.cpp", |
| 23 | "src/idl_gen_general.cpp", |
| 24 | "src/idl_gen_text.cpp", |
| 25 | "src/idl_parser.cpp", |
| 26 | "src/reflection.cpp", |
| 27 | "src/util.cpp", |
| 28 | ], |
| 29 | hdrs = [":public_headers"], |
| 30 | includes = ["include/"], |
| 31 | linkstatic = 1, |
| 32 | ) |
| 33 | |
| 34 | # Public C++ headers for the Flatbuffers library. |
| 35 | filegroup( |
| 36 | name = "public_headers", |
| 37 | srcs = [ |
| 38 | "include/flatbuffers/base.h", |
| 39 | "include/flatbuffers/code_generators.h", |
| 40 | "include/flatbuffers/flatbuffers.h", |
| 41 | "include/flatbuffers/flexbuffers.h", |
| 42 | "include/flatbuffers/hash.h", |
| 43 | "include/flatbuffers/idl.h", |
| 44 | "include/flatbuffers/minireflect.h", |
| 45 | "include/flatbuffers/reflection.h", |
| 46 | "include/flatbuffers/reflection_generated.h", |
| 47 | "include/flatbuffers/stl_emulation.h", |
| 48 | "include/flatbuffers/util.h", |
| 49 | ], |
| 50 | ) |
| 51 | |
| 52 | # Public flatc compiler library. |
| 53 | cc_library( |
| 54 | name = "flatc_library", |
| 55 | srcs = [ |
| 56 | "src/code_generators.cpp", |
| 57 | "src/flatc.cpp", |
| 58 | "src/idl_gen_fbs.cpp", |
| 59 | "src/idl_parser.cpp", |
| 60 | "src/reflection.cpp", |
| 61 | "src/util.cpp", |
| 62 | ], |
| 63 | hdrs = [ |
| 64 | "include/flatbuffers/flatc.h", |
| 65 | ":public_headers", |
| 66 | ], |
| 67 | includes = [ |
| 68 | "grpc/", |
| 69 | "include/", |
| 70 | ], |
| 71 | ) |
| 72 | |
| 73 | # Public flatc compiler. |
| 74 | cc_binary( |
| 75 | name = "flatc", |
| 76 | srcs = [ |
| 77 | "grpc/src/compiler/config.h", |
| 78 | "grpc/src/compiler/cpp_generator.cc", |
| 79 | "grpc/src/compiler/cpp_generator.h", |
| 80 | "grpc/src/compiler/go_generator.cc", |
| 81 | "grpc/src/compiler/go_generator.h", |
| 82 | "grpc/src/compiler/java_generator.cc", |
| 83 | "grpc/src/compiler/java_generator.h", |
| 84 | "grpc/src/compiler/schema_interface.h", |
| 85 | "src/flatc_main.cpp", |
| 86 | "src/idl_gen_cpp.cpp", |
| 87 | "src/idl_gen_dart.cpp", |
| 88 | "src/idl_gen_general.cpp", |
| 89 | "src/idl_gen_kotlin.cpp", |
| 90 | "src/idl_gen_go.cpp", |
| 91 | "src/idl_gen_grpc.cpp", |
| 92 | "src/idl_gen_js_ts.cpp", |
| 93 | "src/idl_gen_json_schema.cpp", |
| 94 | "src/idl_gen_lobster.cpp", |
| 95 | "src/idl_gen_lua.cpp", |
| 96 | "src/idl_gen_php.cpp", |
| 97 | "src/idl_gen_python.cpp", |
| 98 | "src/idl_gen_rust.cpp", |
| 99 | "src/idl_gen_text.cpp", |
| 100 | "src/util.cpp", |
| 101 | ], |
| 102 | includes = [ |
| 103 | "grpc/", |
| 104 | "include/", |
| 105 | ], |
| 106 | deps = [ |
| 107 | ":flatc_library", |
| 108 | ], |
| 109 | ) |
| 110 | |
| 111 | cc_library( |
| 112 | name = "runtime_cc", |
| 113 | hdrs = [ |
| 114 | "include/flatbuffers/base.h", |
| 115 | "include/flatbuffers/flatbuffers.h", |
| 116 | "include/flatbuffers/flexbuffers.h", |
| 117 | "include/flatbuffers/stl_emulation.h", |
| 118 | "include/flatbuffers/util.h", |
| 119 | ], |
| 120 | includes = ["include/"], |
| 121 | linkstatic = 1, |
| 122 | ) |
| 123 | |
| 124 | # Test binary. |
| 125 | cc_test( |
| 126 | name = "flatbuffers_test", |
| 127 | testonly = 1, |
| 128 | srcs = [ |
| 129 | "include/flatbuffers/minireflect.h", |
| 130 | "include/flatbuffers/registry.h", |
| 131 | "src/code_generators.cpp", |
| 132 | "src/idl_gen_fbs.cpp", |
| 133 | "src/idl_gen_general.cpp", |
| 134 | "src/idl_gen_text.cpp", |
| 135 | "src/idl_parser.cpp", |
| 136 | "src/reflection.cpp", |
| 137 | "src/util.cpp", |
| 138 | "tests/namespace_test/namespace_test1_generated.h", |
| 139 | "tests/namespace_test/namespace_test2_generated.h", |
| 140 | "tests/native_type_test_impl.h", |
| 141 | "tests/native_type_test_impl.cpp", |
| 142 | "tests/test.cpp", |
| 143 | "tests/test_assert.cpp", |
| 144 | "tests/test_assert.h", |
| 145 | "tests/test_builder.cpp", |
| 146 | "tests/test_builder.h", |
| 147 | "tests/union_vector/union_vector_generated.h", |
| 148 | ":public_headers", |
| 149 | ], |
| 150 | copts = [ |
| 151 | "-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE", |
| 152 | "-DBAZEL_TEST_DATA_PATH", |
| 153 | ], |
| 154 | data = [ |
| 155 | ":tests/include_test/include_test1.fbs", |
| 156 | ":tests/include_test/sub/include_test2.fbs", |
| 157 | ":tests/monster_test.bfbs", |
| 158 | ":tests/monster_test.fbs", |
| 159 | ":tests/monsterdata_test.golden", |
| 160 | ":tests/monsterdata_test.json", |
| 161 | ":tests/prototest/imported.proto", |
| 162 | ":tests/prototest/test.golden", |
| 163 | ":tests/prototest/test.proto", |
| 164 | ":tests/prototest/test_union.golden", |
| 165 | ":tests/unicode_test.json", |
| 166 | ":tests/union_vector/union_vector.fbs", |
| 167 | ":tests/union_vector/union_vector.json", |
| 168 | ":tests/monster_extra.fbs", |
| 169 | ":tests/monsterdata_extra.json", |
| 170 | ":tests/arrays_test.bfbs", |
| 171 | ":tests/arrays_test.fbs", |
| 172 | ":tests/arrays_test.golden", |
| 173 | ":tests/native_type_test.fbs", |
| 174 | ], |
| 175 | includes = [ |
| 176 | "include/", |
| 177 | "tests/", |
| 178 | ], |
| 179 | deps = [ |
| 180 | ":monster_extra_cc_fbs", |
| 181 | ":monster_test_cc_fbs", |
| 182 | ":arrays_test_cc_fbs", |
| 183 | ":native_type_test_cc_fbs", |
| 184 | ], |
| 185 | ) |
| 186 | |
| 187 | # Test bzl rules |
| 188 | |
| 189 | flatbuffer_cc_library( |
| 190 | name = "monster_test_cc_fbs", |
| 191 | srcs = ["tests/monster_test.fbs"], |
| 192 | include_paths = ["tests/include_test"], |
| 193 | includes = [ |
| 194 | "tests/include_test/include_test1.fbs", |
| 195 | "tests/include_test/sub/include_test2.fbs", |
| 196 | ], |
| 197 | ) |
| 198 | |
| 199 | flatbuffer_cc_library( |
| 200 | name = "monster_extra_cc_fbs", |
| 201 | srcs = ["tests/monster_extra.fbs"], |
| 202 | ) |
| 203 | |
| 204 | flatbuffer_cc_library( |
| 205 | name = "arrays_test_cc_fbs", |
| 206 | srcs = ["tests/arrays_test.fbs"], |
| 207 | flatc_args = [ |
| 208 | "--gen-object-api", |
| 209 | "--gen-compare", |
| 210 | "--no-includes", |
| 211 | "--gen-mutable", |
| 212 | "--reflect-names", |
| 213 | "--cpp-ptr-type flatbuffers::unique_ptr", |
| 214 | "--scoped-enums" ], |
| 215 | ) |
| 216 | |
| 217 | flatbuffer_cc_library( |
| 218 | name = "native_type_test_cc_fbs", |
| 219 | srcs = ["tests/native_type_test.fbs"], |
| 220 | flatc_args = [ |
| 221 | "--gen-object-api", |
| 222 | "--gen-mutable", |
| 223 | "--cpp-ptr-type flatbuffers::unique_ptr" ], |
| 224 | ) |
| 225 | |