blob: 5a727dd541f8ac71c3066e3a878ff01603d2ed41 [file] [log] [blame]
Austin Schuh272c6132020-11-14 16:37:52 -08001load("@rules_cc//cc:defs.bzl", "cc_test")
James Kuszmauldac091f2022-03-22 09:35:06 -07002load("//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_ts_library")
Austin Schuh272c6132020-11-14 16:37:52 -08003
4package(default_visibility = ["//visibility:private"])
5
6# Test binary.
7cc_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 Schraderdada1072020-11-24 11:34:46 -080018 "optional_scalars_generated.h",
Austin Schuh272c6132020-11-14 16:37:52 -080019 "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 Schuh272c6132020-11-14 16:37:52 -080025 ],
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 Kuszmauldac091f2022-03-22 09:35:06 -070046 ":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 Schuh272c6132020-11-14 16:37:52 -080050 ":native_type_test.fbs",
Philipp Schraderdada1072020-11-24 11:34:46 -080051 ":optional_scalars.fbs",
Austin Schuh272c6132020-11-14 16:37:52 -080052 ":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 Schuh272c6132020-11-14 16:37:52 -080063 ],
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 Schuh272c6132020-11-14 16:37:52 -080078
79cc_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
87cc_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
99cc_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
118flatbuffer_cc_library(
James Kuszmauldac091f2022-03-22 09:35:06 -0700119 name = "include_test_fbs",
120 srcs = [
Austin Schuh272c6132020-11-14 16:37:52 -0800121 "include_test/include_test1.fbs",
122 "include_test/sub/include_test2.fbs",
123 ],
James Kuszmauldac091f2022-03-22 09:35:06 -0700124 include_paths = ["tests/include_test"],
125)
126
127flatbuffer_cc_library(
128 name = "monster_test_cc_fbs",
129 srcs = ["monster_test.fbs"],
130 include_paths = ["tests/include_test"],
Austin Schuh272c6132020-11-14 16:37:52 -0800131 visibility = ["//grpc/tests:__subpackages__"],
James Kuszmauldac091f2022-03-22 09:35:06 -0700132 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).
137include_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
146flatbuffer_cc_library(
147 name = "included_test_fbs",
148 srcs = ["included_test.fbs"],
149 flatc_args = include_test_args,
150)
151
152flatbuffer_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
159cc_library(
160 name = "include_build_test",
161 srcs = ["include_build_test.cc"],
162 deps = [":includer_test_fbs"],
Austin Schuh272c6132020-11-14 16:37:52 -0800163)
164
165flatbuffer_cc_library(
166 name = "monster_extra_cc_fbs",
167 srcs = ["monster_extra.fbs"],
168)
169
170flatbuffer_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
184flatbuffer_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 Kuszmauldac091f2022-03-22 09:35:06 -0700193
194flatbuffer_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)