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