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