Fix buildifier warnings found in new bazel (#5517)
[platform/upstream/flatbuffers.git] / BUILD
1 licenses(["notice"])
2
3 load("@rules_cc//cc:defs.bzl", "cc_library")
4
5 package(
6     default_visibility = ["//visibility:public"],
7     features = [
8         "-layering_check",
9         "-parse_headers",
10     ],
11 )
12
13 exports_files([
14     "LICENSE",
15 ])
16
17 load(":build_defs.bzl", "flatbuffer_cc_library")
18
19 # Public flatc library to compile flatbuffer files at runtime.
20 cc_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"],
32     includes = ["include/"],
33     linkstatic = 1,
34 )
35
36 # Public C++ headers for the Flatbuffers library.
37 filegroup(
38     name = "public_headers",
39     srcs = [
40         "include/flatbuffers/base.h",
41         "include/flatbuffers/code_generators.h",
42         "include/flatbuffers/flatbuffers.h",
43         "include/flatbuffers/flexbuffers.h",
44         "include/flatbuffers/hash.h",
45         "include/flatbuffers/idl.h",
46         "include/flatbuffers/minireflect.h",
47         "include/flatbuffers/reflection.h",
48         "include/flatbuffers/reflection_generated.h",
49         "include/flatbuffers/stl_emulation.h",
50         "include/flatbuffers/util.h",
51     ],
52 )
53
54 # Public flatc compiler library.
55 cc_library(
56     name = "flatc_library",
57     srcs = [
58         "src/code_generators.cpp",
59         "src/flatc.cpp",
60         "src/idl_gen_fbs.cpp",
61         "src/idl_parser.cpp",
62         "src/reflection.cpp",
63         "src/util.cpp",
64     ],
65     hdrs = [
66         "include/flatbuffers/flatc.h",
67         ":public_headers",
68     ],
69     includes = [
70         "grpc/",
71         "include/",
72     ],
73 )
74
75 # Public flatc compiler.
76 cc_binary(
77     name = "flatc",
78     srcs = [
79         "grpc/src/compiler/config.h",
80         "grpc/src/compiler/cpp_generator.cc",
81         "grpc/src/compiler/cpp_generator.h",
82         "grpc/src/compiler/go_generator.cc",
83         "grpc/src/compiler/go_generator.h",
84         "grpc/src/compiler/java_generator.cc",
85         "grpc/src/compiler/java_generator.h",
86         "grpc/src/compiler/schema_interface.h",
87         "src/flatc_main.cpp",
88         "src/idl_gen_cpp.cpp",
89         "src/idl_gen_dart.cpp",
90         "src/idl_gen_general.cpp",
91         "src/idl_gen_go.cpp",
92         "src/idl_gen_grpc.cpp",
93         "src/idl_gen_js_ts.cpp",
94         "src/idl_gen_json_schema.cpp",
95         "src/idl_gen_kotlin.cpp",
96         "src/idl_gen_lobster.cpp",
97         "src/idl_gen_lua.cpp",
98         "src/idl_gen_php.cpp",
99         "src/idl_gen_python.cpp",
100         "src/idl_gen_rust.cpp",
101         "src/idl_gen_text.cpp",
102         "src/util.cpp",
103     ],
104     includes = [
105         "grpc/",
106         "include/",
107     ],
108     deps = [
109         ":flatc_library",
110     ],
111 )
112
113 cc_library(
114     name = "runtime_cc",
115     hdrs = [
116         "include/flatbuffers/base.h",
117         "include/flatbuffers/flatbuffers.h",
118         "include/flatbuffers/flexbuffers.h",
119         "include/flatbuffers/stl_emulation.h",
120         "include/flatbuffers/util.h",
121     ],
122     includes = ["include/"],
123     linkstatic = 1,
124 )
125
126 # Test binary.
127 cc_test(
128     name = "flatbuffers_test",
129     testonly = 1,
130     srcs = [
131         "include/flatbuffers/minireflect.h",
132         "include/flatbuffers/registry.h",
133         "src/code_generators.cpp",
134         "src/idl_gen_fbs.cpp",
135         "src/idl_gen_general.cpp",
136         "src/idl_gen_text.cpp",
137         "src/idl_parser.cpp",
138         "src/reflection.cpp",
139         "src/util.cpp",
140         "tests/namespace_test/namespace_test1_generated.h",
141         "tests/namespace_test/namespace_test2_generated.h",
142         "tests/native_type_test_impl.cpp",
143         "tests/native_type_test_impl.h",
144         "tests/test.cpp",
145         "tests/test_assert.cpp",
146         "tests/test_assert.h",
147         "tests/test_builder.cpp",
148         "tests/test_builder.h",
149         "tests/union_vector/union_vector_generated.h",
150         ":public_headers",
151     ],
152     copts = [
153         "-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE",
154         "-DBAZEL_TEST_DATA_PATH",
155     ],
156     data = [
157         ":tests/arrays_test.bfbs",
158         ":tests/arrays_test.fbs",
159         ":tests/arrays_test.golden",
160         ":tests/include_test/include_test1.fbs",
161         ":tests/include_test/sub/include_test2.fbs",
162         ":tests/monster_extra.fbs",
163         ":tests/monster_test.bfbs",
164         ":tests/monster_test.fbs",
165         ":tests/monsterdata_extra.json",
166         ":tests/monsterdata_test.golden",
167         ":tests/monsterdata_test.json",
168         ":tests/native_type_test.fbs",
169         ":tests/prototest/imported.proto",
170         ":tests/prototest/test.golden",
171         ":tests/prototest/test.proto",
172         ":tests/prototest/test_union.golden",
173         ":tests/unicode_test.json",
174         ":tests/union_vector/union_vector.fbs",
175         ":tests/union_vector/union_vector.json",
176     ],
177     includes = [
178         "include/",
179         "tests/",
180     ],
181     deps = [
182         ":arrays_test_cc_fbs",
183         ":monster_extra_cc_fbs",
184         ":monster_test_cc_fbs",
185         ":native_type_test_cc_fbs",
186     ],
187 )
188
189 # Test bzl rules
190
191 flatbuffer_cc_library(
192     name = "monster_test_cc_fbs",
193     srcs = ["tests/monster_test.fbs"],
194     include_paths = ["tests/include_test"],
195     includes = [
196         "tests/include_test/include_test1.fbs",
197         "tests/include_test/sub/include_test2.fbs",
198     ],
199 )
200
201 flatbuffer_cc_library(
202     name = "monster_extra_cc_fbs",
203     srcs = ["tests/monster_extra.fbs"],
204 )
205
206 flatbuffer_cc_library(
207     name = "arrays_test_cc_fbs",
208     srcs = ["tests/arrays_test.fbs"],
209     flatc_args = [
210         "--gen-object-api",
211         "--gen-compare",
212         "--no-includes",
213         "--gen-mutable",
214         "--reflect-names",
215         "--cpp-ptr-type flatbuffers::unique_ptr",
216         "--scoped-enums",
217     ],
218 )
219
220 flatbuffer_cc_library(
221     name = "native_type_test_cc_fbs",
222     srcs = ["tests/native_type_test.fbs"],
223     flatc_args = [
224         "--gen-object-api",
225         "--gen-mutable",
226         "--cpp-ptr-type flatbuffers::unique_ptr",
227     ],
228 )