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