Add initial Bazel WORKSPACE and BUILD (#4608)
[platform/upstream/flatbuffers.git] / BUILD
1 package(
2     default_visibility = ["//visibility:public"],
3     features = [
4         "-layering_check",
5         "-parse_headers",
6     ],
7 )
8
9 exports_files([
10     "LICENSE",
11 ])
12
13 FLATBUFFERS_COPTS = [
14     "-Wno-implicit-fallthrough",
15     "-linclude",
16 ]
17
18 # Public flatc library to compile flatbuffer files at runtime.
19 cc_library(
20     name = "flatbuffers",
21     srcs = [
22         "src/code_generators.cpp",
23         "src/idl_gen_fbs.cpp",
24         "src/idl_gen_general.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     copts = FLATBUFFERS_COPTS,
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/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     copts = FLATBUFFERS_COPTS,
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/schema_interface.h",
85         "src/flatc_main.cpp",
86         "src/idl_gen_cpp.cpp",
87         "src/idl_gen_general.cpp",
88         "src/idl_gen_go.cpp",
89         "src/idl_gen_grpc.cpp",
90         "src/idl_gen_js.cpp",
91         "src/idl_gen_json_schema.cpp",
92         "src/idl_gen_php.cpp",
93         "src/idl_gen_python.cpp",
94         "src/idl_gen_text.cpp",
95     ],
96     copts = FLATBUFFERS_COPTS,
97     includes = [
98         "grpc/",
99         "include/",
100     ],
101     deps = [
102         ":flatc_library",
103     ],
104 )
105
106 # Test binary.
107 cc_test(
108     name = "flatbuffers_test",
109     testonly = 1,
110     srcs = [
111         "include/flatbuffers/minireflect.h",
112         "include/flatbuffers/registry.h",
113         "src/code_generators.cpp",
114         "src/idl_gen_fbs.cpp",
115         "src/idl_gen_general.cpp",
116         "src/idl_gen_text.cpp",
117         "src/idl_parser.cpp",
118         "src/reflection.cpp",
119         "src/util.cpp",
120         "tests/monster_test_generated.h",
121         "tests/namespace_test/namespace_test1_generated.h",
122         "tests/namespace_test/namespace_test2_generated.h",
123         "tests/test.cpp",
124         "tests/union_vector/union_vector_generated.h",
125         ":public_headers",
126     ],
127     copts = FLATBUFFERS_COPTS + [
128         "-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE",
129     ],
130     data = [
131         ":tests/include_test/include_test1.fbs",
132         ":tests/include_test/sub/include_test2.fbs",
133         ":tests/monster_test.bfbs",
134         ":tests/monster_test.fbs",
135         ":tests/monsterdata_test.golden",
136         ":tests/prototest/imported.proto",
137         ":tests/prototest/test.golden",
138         ":tests/prototest/test.proto",
139         ":tests/union_vector/union_vector.fbs",
140     ],
141     includes = ["include/"],
142 )