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