blob: 05553e19e720462d1417485d290b06b2a04c12a8 [file] [log] [blame]
Austin Schuh4ac96a82019-08-14 20:24:23 -07001licenses(["notice"])
2
Alex Perrycb7da4b2019-08-28 19:35:56 -07003load("@//tools:environments.bzl", "mcu_cpus")
4
Austin Schuh4ac96a82019-08-14 20:24:23 -07005package(
6 default_visibility = ["//visibility:public"],
7 features = [
8 "-layering_check",
9 "-parse_headers",
10 ],
11)
12
13exports_files([
14 "LICENSE",
15])
16
17load(":build_defs.bzl", "flatbuffer_cc_library")
18
19# Public flatc library to compile flatbuffer files at runtime.
20cc_library(
21 name = "flatbuffers",
22 srcs = [
23 "src/code_generators.cpp",
24 "src/idl_gen_fbs.cpp",
25 "src/idl_gen_general.cpp",
26 "src/idl_gen_text.cpp",
27 "src/idl_parser.cpp",
28 "src/reflection.cpp",
29 "src/util.cpp",
30 ],
31 hdrs = [":public_headers"],
Austin Schuh3e95e5d2019-09-20 00:08:54 -070032 copts = ["-Wno-cast-align"],
Austin Schuh4ac96a82019-08-14 20:24:23 -070033 includes = ["include/"],
34 linkstatic = 1,
35)
36
37# Public C++ headers for the Flatbuffers library.
38filegroup(
39 name = "public_headers",
40 srcs = [
41 "include/flatbuffers/base.h",
42 "include/flatbuffers/code_generators.h",
43 "include/flatbuffers/flatbuffers.h",
44 "include/flatbuffers/flexbuffers.h",
45 "include/flatbuffers/hash.h",
46 "include/flatbuffers/idl.h",
47 "include/flatbuffers/minireflect.h",
48 "include/flatbuffers/reflection.h",
49 "include/flatbuffers/reflection_generated.h",
50 "include/flatbuffers/stl_emulation.h",
51 "include/flatbuffers/util.h",
52 ],
53)
54
55# Public flatc compiler library.
56cc_library(
57 name = "flatc_library",
58 srcs = [
59 "src/code_generators.cpp",
60 "src/flatc.cpp",
61 "src/idl_gen_fbs.cpp",
62 "src/idl_parser.cpp",
63 "src/reflection.cpp",
64 "src/util.cpp",
65 ],
66 hdrs = [
67 "include/flatbuffers/flatc.h",
68 ":public_headers",
69 ],
70 includes = [
71 "grpc/",
72 "include/",
73 ],
74)
75
76# Public flatc compiler.
77cc_binary(
78 name = "flatc",
79 srcs = [
80 "grpc/src/compiler/config.h",
81 "grpc/src/compiler/cpp_generator.cc",
82 "grpc/src/compiler/cpp_generator.h",
83 "grpc/src/compiler/go_generator.cc",
84 "grpc/src/compiler/go_generator.h",
85 "grpc/src/compiler/java_generator.cc",
86 "grpc/src/compiler/java_generator.h",
87 "grpc/src/compiler/schema_interface.h",
88 "src/flatc_main.cpp",
89 "src/idl_gen_cpp.cpp",
90 "src/idl_gen_dart.cpp",
91 "src/idl_gen_general.cpp",
Austin Schuh4ac96a82019-08-14 20:24:23 -070092 "src/idl_gen_go.cpp",
93 "src/idl_gen_grpc.cpp",
94 "src/idl_gen_js_ts.cpp",
95 "src/idl_gen_json_schema.cpp",
Austin Schuh3e95e5d2019-09-20 00:08:54 -070096 "src/idl_gen_kotlin.cpp",
Austin Schuh4ac96a82019-08-14 20:24:23 -070097 "src/idl_gen_lobster.cpp",
98 "src/idl_gen_lua.cpp",
99 "src/idl_gen_php.cpp",
100 "src/idl_gen_python.cpp",
101 "src/idl_gen_rust.cpp",
102 "src/idl_gen_text.cpp",
103 "src/util.cpp",
104 ],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700105 data = [
106 "reflection/reflection.fbs",
107 ],
Austin Schuh4ac96a82019-08-14 20:24:23 -0700108 includes = [
109 "grpc/",
110 "include/",
111 ],
112 deps = [
113 ":flatc_library",
114 ],
115)
116
117cc_library(
118 name = "runtime_cc",
119 hdrs = [
120 "include/flatbuffers/base.h",
121 "include/flatbuffers/flatbuffers.h",
122 "include/flatbuffers/flexbuffers.h",
123 "include/flatbuffers/stl_emulation.h",
124 "include/flatbuffers/util.h",
125 ],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700126 compatible_with = mcu_cpus,
Austin Schuh4ac96a82019-08-14 20:24:23 -0700127 includes = ["include/"],
128 linkstatic = 1,
129)
130
131# Test binary.
132cc_test(
133 name = "flatbuffers_test",
134 testonly = 1,
135 srcs = [
136 "include/flatbuffers/minireflect.h",
137 "include/flatbuffers/registry.h",
138 "src/code_generators.cpp",
139 "src/idl_gen_fbs.cpp",
140 "src/idl_gen_general.cpp",
141 "src/idl_gen_text.cpp",
142 "src/idl_parser.cpp",
143 "src/reflection.cpp",
144 "src/util.cpp",
145 "tests/namespace_test/namespace_test1_generated.h",
146 "tests/namespace_test/namespace_test2_generated.h",
Austin Schuh4ac96a82019-08-14 20:24:23 -0700147 "tests/native_type_test_impl.cpp",
Austin Schuh3e95e5d2019-09-20 00:08:54 -0700148 "tests/native_type_test_impl.h",
Austin Schuh4ac96a82019-08-14 20:24:23 -0700149 "tests/test.cpp",
150 "tests/test_assert.cpp",
151 "tests/test_assert.h",
152 "tests/test_builder.cpp",
153 "tests/test_builder.h",
154 "tests/union_vector/union_vector_generated.h",
155 ":public_headers",
156 ],
157 copts = [
158 "-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE",
159 "-DBAZEL_TEST_DATA_PATH",
160 ],
161 data = [
Austin Schuh3e95e5d2019-09-20 00:08:54 -0700162 ":tests/arrays_test.bfbs",
163 ":tests/arrays_test.fbs",
164 ":tests/arrays_test.golden",
Austin Schuh4ac96a82019-08-14 20:24:23 -0700165 ":tests/include_test/include_test1.fbs",
166 ":tests/include_test/sub/include_test2.fbs",
Austin Schuh3e95e5d2019-09-20 00:08:54 -0700167 ":tests/monster_extra.fbs",
Austin Schuh4ac96a82019-08-14 20:24:23 -0700168 ":tests/monster_test.bfbs",
169 ":tests/monster_test.fbs",
Austin Schuh3e95e5d2019-09-20 00:08:54 -0700170 ":tests/monsterdata_extra.json",
Austin Schuh4ac96a82019-08-14 20:24:23 -0700171 ":tests/monsterdata_test.golden",
172 ":tests/monsterdata_test.json",
Austin Schuh3e95e5d2019-09-20 00:08:54 -0700173 ":tests/native_type_test.fbs",
Austin Schuh4ac96a82019-08-14 20:24:23 -0700174 ":tests/prototest/imported.proto",
175 ":tests/prototest/test.golden",
176 ":tests/prototest/test.proto",
177 ":tests/prototest/test_union.golden",
178 ":tests/unicode_test.json",
179 ":tests/union_vector/union_vector.fbs",
180 ":tests/union_vector/union_vector.json",
Austin Schuh4ac96a82019-08-14 20:24:23 -0700181 ],
182 includes = [
183 "include/",
184 "tests/",
185 ],
186 deps = [
Austin Schuh3e95e5d2019-09-20 00:08:54 -0700187 ":arrays_test_cc_fbs",
Austin Schuh4ac96a82019-08-14 20:24:23 -0700188 ":monster_extra_cc_fbs",
189 ":monster_test_cc_fbs",
Austin Schuh4ac96a82019-08-14 20:24:23 -0700190 ":native_type_test_cc_fbs",
191 ],
192)
193
194# Test bzl rules
195
196flatbuffer_cc_library(
197 name = "monster_test_cc_fbs",
198 srcs = ["tests/monster_test.fbs"],
199 include_paths = ["tests/include_test"],
200 includes = [
201 "tests/include_test/include_test1.fbs",
202 "tests/include_test/sub/include_test2.fbs",
203 ],
204)
205
206flatbuffer_cc_library(
207 name = "monster_extra_cc_fbs",
208 srcs = ["tests/monster_extra.fbs"],
209)
210
211flatbuffer_cc_library(
212 name = "arrays_test_cc_fbs",
213 srcs = ["tests/arrays_test.fbs"],
214 flatc_args = [
215 "--gen-object-api",
216 "--gen-compare",
217 "--no-includes",
218 "--gen-mutable",
219 "--reflect-names",
220 "--cpp-ptr-type flatbuffers::unique_ptr",
Austin Schuh3e95e5d2019-09-20 00:08:54 -0700221 "--scoped-enums",
222 ],
Austin Schuh4ac96a82019-08-14 20:24:23 -0700223)
224
225flatbuffer_cc_library(
226 name = "native_type_test_cc_fbs",
227 srcs = ["tests/native_type_test.fbs"],
228 flatc_args = [
229 "--gen-object-api",
230 "--gen-mutable",
Austin Schuh3e95e5d2019-09-20 00:08:54 -0700231 "--cpp-ptr-type flatbuffers::unique_ptr",
232 ],
Austin Schuh4ac96a82019-08-14 20:24:23 -0700233)
James Kuszmaulf385c462019-12-24 09:37:34 -0800234
235py_library(
236 name = "flatpy",
237 srcs = glob(["python/flatbuffers/*.py"]),
238 imports = ["python/"],
239)
Alex Perryb3b50792020-01-18 16:13:45 -0800240
241filegroup(
242 name = "flatjs",
243 srcs = ["js/flatbuffers.js"],
244)