Removed idl_gen_general.cpp and move contents to code_generators.cpp (#5625)
[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_text.cpp",
26         "src/idl_parser.cpp",
27         "src/reflection.cpp",
28         "src/util.cpp",
29     ],
30     hdrs = [":public_headers"],
31     includes = ["include/"],
32     linkstatic = 1,
33 )
34
35 # Public C++ headers for the Flatbuffers library.
36 filegroup(
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.
54 cc_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.
75 cc_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_csharp.cpp",
89         "src/idl_gen_dart.cpp",
90         "src/idl_gen_go.cpp",
91         "src/idl_gen_grpc.cpp",
92         "src/idl_gen_java.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_text.cpp",
136         "src/idl_parser.cpp",
137         "src/reflection.cpp",
138         "src/util.cpp",
139         "tests/evolution_test/evolution_v1_generated.h",
140         "tests/evolution_test/evolution_v2_generated.h",
141         "tests/namespace_test/namespace_test1_generated.h",
142         "tests/namespace_test/namespace_test2_generated.h",
143         "tests/native_type_test_impl.cpp",
144         "tests/native_type_test_impl.h",
145         "tests/test.cpp",
146         "tests/test_assert.cpp",
147         "tests/test_assert.h",
148         "tests/test_builder.cpp",
149         "tests/test_builder.h",
150         "tests/union_vector/union_vector_generated.h",
151         ":public_headers",
152     ],
153     copts = [
154         "-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE",
155         "-DBAZEL_TEST_DATA_PATH",
156     ],
157     data = [
158         ":tests/arrays_test.bfbs",
159         ":tests/arrays_test.fbs",
160         ":tests/arrays_test.golden",
161         ":tests/evolution_test/evolution_v1.fbs",
162         ":tests/evolution_test/evolution_v1.json",
163         ":tests/evolution_test/evolution_v2.fbs",
164         ":tests/evolution_test/evolution_v2.json",
165         ":tests/include_test/include_test1.fbs",
166         ":tests/include_test/sub/include_test2.fbs",
167         ":tests/monster_extra.fbs",
168         ":tests/monster_test.bfbs",
169         ":tests/monster_test.fbs",
170         ":tests/monsterdata_extra.json",
171         ":tests/monsterdata_test.golden",
172         ":tests/monsterdata_test.json",
173         ":tests/native_type_test.fbs",
174         ":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",
181     ],
182     includes = [
183         "include/",
184         "tests/",
185     ],
186     deps = [
187         ":arrays_test_cc_fbs",
188         ":monster_extra_cc_fbs",
189         ":monster_test_cc_fbs",
190         ":native_type_test_cc_fbs",
191     ],
192 )
193
194 # Test bzl rules
195
196 flatbuffer_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
206 flatbuffer_cc_library(
207     name = "monster_extra_cc_fbs",
208     srcs = ["tests/monster_extra.fbs"],
209 )
210
211 flatbuffer_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",
221         "--scoped-enums",
222     ],
223 )
224
225 flatbuffer_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",
231         "--cpp-ptr-type flatbuffers::unique_ptr",
232     ],
233 )