Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 1 | load("@rules_cc//cc:defs.bzl", "cc_test") |
Austin Schuh | a1d006e | 2022-09-14 21:50:42 -0700 | [diff] [blame] | 2 | load("//:build_defs.bzl", "flatbuffer_cc_library") |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 3 | |
| 4 | package(default_visibility = ["//visibility:private"]) |
| 5 | |
| 6 | # Test binary. |
| 7 | cc_test( |
| 8 | name = "flatbuffers_test", |
| 9 | testonly = 1, |
| 10 | srcs = [ |
Austin Schuh | a1d006e | 2022-09-14 21:50:42 -0700 | [diff] [blame] | 11 | "evolution_test.cpp", |
| 12 | "evolution_test.h", |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 13 | "evolution_test/evolution_v1_generated.h", |
| 14 | "evolution_test/evolution_v2_generated.h", |
Austin Schuh | a1d006e | 2022-09-14 21:50:42 -0700 | [diff] [blame] | 15 | "flexbuffers_test.cpp", |
| 16 | "flexbuffers_test.h", |
| 17 | "fuzz_test.cpp", |
| 18 | "fuzz_test.h", |
| 19 | "is_quiet_nan.h", |
| 20 | "json_test.cpp", |
| 21 | "json_test.h", |
| 22 | "monster_test.cpp", |
| 23 | "monster_test.h", |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 24 | "monster_test_bfbs_generated.h", |
| 25 | "namespace_test/namespace_test1_generated.h", |
| 26 | "namespace_test/namespace_test2_generated.h", |
Austin Schuh | a1d006e | 2022-09-14 21:50:42 -0700 | [diff] [blame] | 27 | "native_inline_table_test_generated.h", |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 28 | "native_type_test_impl.cpp", |
| 29 | "native_type_test_impl.h", |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 30 | "optional_scalars_generated.h", |
Austin Schuh | a1d006e | 2022-09-14 21:50:42 -0700 | [diff] [blame] | 31 | "optional_scalars_test.cpp", |
| 32 | "optional_scalars_test.h", |
| 33 | "parser_test.cpp", |
| 34 | "parser_test.h", |
| 35 | "proto_test.cpp", |
| 36 | "proto_test.h", |
| 37 | "reflection_test.cpp", |
| 38 | "reflection_test.h", |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 39 | "test.cpp", |
| 40 | "test_assert.cpp", |
| 41 | "test_assert.h", |
| 42 | "test_builder.cpp", |
| 43 | "test_builder.h", |
| 44 | "union_vector/union_vector_generated.h", |
Austin Schuh | a1d006e | 2022-09-14 21:50:42 -0700 | [diff] [blame] | 45 | "util_test.cpp", |
| 46 | "util_test.h", |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 47 | ], |
| 48 | copts = [ |
| 49 | "-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE", |
| 50 | "-DBAZEL_TEST_DATA_PATH", |
| 51 | ], |
| 52 | data = [ |
| 53 | ":arrays_test.bfbs", |
| 54 | ":arrays_test.fbs", |
| 55 | ":arrays_test.golden", |
| 56 | ":evolution_test/evolution_v1.fbs", |
| 57 | ":evolution_test/evolution_v1.json", |
| 58 | ":evolution_test/evolution_v2.fbs", |
| 59 | ":evolution_test/evolution_v2.json", |
| 60 | ":include_test/include_test1.fbs", |
| 61 | ":include_test/sub/include_test2.fbs", |
| 62 | ":monster_extra.fbs", |
| 63 | ":monster_test.bfbs", |
| 64 | ":monster_test.fbs", |
| 65 | ":monsterdata_extra.json", |
| 66 | ":monsterdata_test.golden", |
| 67 | ":monsterdata_test.json", |
James Kuszmaul | dac091f | 2022-03-22 09:35:06 -0700 | [diff] [blame] | 68 | ":name_clash_test/invalid_test1.fbs", |
| 69 | ":name_clash_test/invalid_test2.fbs", |
| 70 | ":name_clash_test/valid_test1.fbs", |
| 71 | ":name_clash_test/valid_test2.fbs", |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 72 | ":native_type_test.fbs", |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 73 | ":optional_scalars.fbs", |
Austin Schuh | a1d006e | 2022-09-14 21:50:42 -0700 | [diff] [blame] | 74 | ":optional_scalars.json", |
| 75 | ":optional_scalars_defaults.json", |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 76 | ":prototest/imported.proto", |
| 77 | ":prototest/test.golden", |
| 78 | ":prototest/test.proto", |
| 79 | ":prototest/test_include.golden", |
| 80 | ":prototest/test_suffix.golden", |
| 81 | ":prototest/test_union.golden", |
| 82 | ":prototest/test_union_include.golden", |
| 83 | ":prototest/test_union_suffix.golden", |
| 84 | ":unicode_test.json", |
| 85 | ":union_vector/union_vector.fbs", |
| 86 | ":union_vector/union_vector.json", |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 87 | ], |
| 88 | includes = [ |
| 89 | "", |
| 90 | "include/", |
| 91 | ], |
| 92 | deps = [ |
| 93 | ":arrays_test_cc_fbs", |
| 94 | ":monster_extra_cc_fbs", |
| 95 | ":monster_test_cc_fbs", |
| 96 | ":native_type_test_cc_fbs", |
| 97 | "//:flatbuffers", |
| 98 | ], |
| 99 | ) |
| 100 | |
| 101 | # Test bzl rules |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 102 | |
| 103 | cc_library( |
| 104 | name = "test_assert", |
| 105 | srcs = ["test_assert.cpp"], |
| 106 | hdrs = ["test_assert.h"], |
| 107 | visibility = ["//grpc/tests:__subpackages__"], |
| 108 | deps = ["//:flatbuffers"], |
| 109 | ) |
| 110 | |
| 111 | cc_library( |
| 112 | name = "test_builder", |
| 113 | srcs = ["test_builder.cpp"], |
| 114 | hdrs = ["test_builder.h"], |
| 115 | visibility = ["//grpc/tests:__subpackages__"], |
| 116 | deps = [ |
| 117 | ":monster_test_grpc", |
| 118 | ":test_assert", |
| 119 | "//:flatbuffers", |
| 120 | ], |
| 121 | ) |
| 122 | |
| 123 | cc_library( |
| 124 | name = "monster_test_grpc", |
| 125 | srcs = [ |
| 126 | "monster_test.grpc.fb.cc", |
| 127 | "monster_test.grpc.fb.h", |
| 128 | "monster_test_generated.h", |
| 129 | ], |
| 130 | hdrs = [ |
| 131 | "monster_test.grpc.fb.h", |
| 132 | "monster_test_generated.h", |
| 133 | ], |
| 134 | includes = ["."], |
| 135 | visibility = ["//grpc/tests:__subpackages__"], |
| 136 | deps = [ |
| 137 | "//:flatbuffers", |
| 138 | "@com_github_grpc_grpc//:grpc++", |
| 139 | ], |
| 140 | ) |
| 141 | |
| 142 | flatbuffer_cc_library( |
James Kuszmaul | dac091f | 2022-03-22 09:35:06 -0700 | [diff] [blame] | 143 | name = "include_test_fbs", |
| 144 | srcs = [ |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 145 | "include_test/include_test1.fbs", |
| 146 | "include_test/sub/include_test2.fbs", |
| 147 | ], |
James Kuszmaul | dac091f | 2022-03-22 09:35:06 -0700 | [diff] [blame] | 148 | include_paths = ["tests/include_test"], |
| 149 | ) |
| 150 | |
| 151 | flatbuffer_cc_library( |
| 152 | name = "monster_test_cc_fbs", |
| 153 | srcs = ["monster_test.fbs"], |
| 154 | include_paths = ["tests/include_test"], |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 155 | visibility = ["//grpc/tests:__subpackages__"], |
James Kuszmaul | dac091f | 2022-03-22 09:35:06 -0700 | [diff] [blame] | 156 | deps = [":include_test_fbs"], |
| 157 | ) |
| 158 | |
| 159 | # Test that running without --no-includes works properly (monster_test doesn't |
| 160 | # work cleanly due to the circular dependency in the include_tests/ files). |
| 161 | include_test_args = [ |
| 162 | "--gen-object-api", |
| 163 | "--gen-compare", |
| 164 | "--gen-mutable", |
| 165 | "--reflect-names", |
| 166 | "--cpp-ptr-type flatbuffers::unique_ptr", |
| 167 | "--force-empty", |
| 168 | ] |
| 169 | |
| 170 | flatbuffer_cc_library( |
| 171 | name = "included_test_fbs", |
| 172 | srcs = ["included_test.fbs"], |
| 173 | flatc_args = include_test_args, |
| 174 | ) |
| 175 | |
| 176 | flatbuffer_cc_library( |
| 177 | name = "includer_test_fbs", |
| 178 | srcs = ["includer_test.fbs"], |
| 179 | flatc_args = include_test_args, |
| 180 | deps = [":included_test_fbs"], |
| 181 | ) |
| 182 | |
| 183 | cc_library( |
| 184 | name = "include_build_test", |
| 185 | srcs = ["include_build_test.cc"], |
| 186 | deps = [":includer_test_fbs"], |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 187 | ) |
| 188 | |
| 189 | flatbuffer_cc_library( |
| 190 | name = "monster_extra_cc_fbs", |
| 191 | srcs = ["monster_extra.fbs"], |
| 192 | ) |
| 193 | |
| 194 | flatbuffer_cc_library( |
| 195 | name = "arrays_test_cc_fbs", |
| 196 | srcs = ["arrays_test.fbs"], |
| 197 | flatc_args = [ |
| 198 | "--gen-object-api", |
| 199 | "--gen-compare", |
| 200 | "--no-includes", |
| 201 | "--gen-mutable", |
| 202 | "--reflect-names", |
| 203 | "--cpp-ptr-type flatbuffers::unique_ptr", |
| 204 | "--scoped-enums", |
| 205 | ], |
| 206 | ) |
| 207 | |
| 208 | flatbuffer_cc_library( |
| 209 | name = "native_type_test_cc_fbs", |
| 210 | srcs = ["native_type_test.fbs"], |
| 211 | flatc_args = [ |
| 212 | "--gen-object-api", |
| 213 | "--gen-mutable", |
| 214 | "--cpp-ptr-type flatbuffers::unique_ptr", |
| 215 | ], |
| 216 | ) |
James Kuszmaul | dac091f | 2022-03-22 09:35:06 -0700 | [diff] [blame] | 217 | |
| 218 | flatbuffer_ts_library( |
| 219 | name = "typescript_ts_fbs", |
| 220 | srcs = ["typescript_keywords.fbs"], |
| 221 | deps = [ |
| 222 | "//tests/test_dir:include_ts_ts_fbs", |
| 223 | "//tests/test_dir:typescript_transitive_ts_ts_fbs", |
| 224 | ], |
| 225 | ) |