blob: 108c0cd8e3bb82a67f61d7e9c5278c0d3969b2fd [file] [log] [blame]
Advait Jain4ff98412022-07-20 15:10:20 -07001load("@build_bazel_rules_android//android:rules.bzl", "android_library")
2load(":build_defs.bzl", "flatbuffer_py_strip_prefix_srcs")
3
4package(default_visibility = ["//visibility:public"])
5
6licenses(["notice"]) # Apache 2.0
7
8exports_files(["LICENSE.txt"])
9
10licenses(["notice"])
11
12config_setting(
13 name = "freebsd",
14 values = {"cpu": "freebsd"},
15)
16
17config_setting(
18 name = "windows",
19 values = {"cpu": "x64_windows"},
20)
21
22load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
23
24# Public flatc library to compile flatbuffer files at runtime.
25cc_library(
26 name = "flatbuffers",
27 hdrs = ["//:public_headers"],
28 linkstatic = 1,
29 strip_include_prefix = "/include",
30 visibility = ["//visibility:public"],
31 deps = ["//src:flatbuffers"],
32)
33
34# Public C++ headers for the Flatbuffers library.
35filegroup(
36 name = "public_headers",
37 srcs = [
38 "include/flatbuffers/base.h",
39 "include/flatbuffers/code_generators.h",
40 "include/flatbuffers/flatbuffers.h",
41 "include/flatbuffers/flexbuffers.h",
42 "include/flatbuffers/hash.h",
43 "include/flatbuffers/idl.h",
44 "include/flatbuffers/minireflect.h",
45 "include/flatbuffers/reflection.h",
46 "include/flatbuffers/reflection_generated.h",
47 "include/flatbuffers/registry.h",
48 "include/flatbuffers/stl_emulation.h",
49 "include/flatbuffers/util.h",
50 ],
51 visibility = ["//:__subpackages__"],
52)
53
54# Public flatc compiler library.
55cc_library(
56 name = "flatc_library",
57 linkstatic = 1,
58 visibility = ["//visibility:public"],
59 deps = [
60 "@flatbuffers//src:flatc_library",
61 ],
62)
63
64# Public flatc compiler.
65cc_binary(
66 name = "flatc",
67 linkopts = select({
68 ":freebsd": [
69 "-lm",
70 ],
71 ":windows": [],
72 "//conditions:default": [
73 "-lm",
74 "-ldl",
75 ],
76 }),
77 visibility = ["//visibility:public"],
78 deps = [
79 "@flatbuffers//src:flatc",
80 ],
81)
82
83filegroup(
84 name = "flatc_headers",
85 srcs = [
86 "include/flatbuffers/flatc.h",
87 ],
88 visibility = ["//:__subpackages__"],
89)
90
91# Library used by flatbuffer_cc_library rules.
92cc_library(
93 name = "runtime_cc",
94 hdrs = [
95 "include/flatbuffers/base.h",
96 "include/flatbuffers/flatbuffers.h",
97 "include/flatbuffers/flexbuffers.h",
98 "include/flatbuffers/stl_emulation.h",
99 "include/flatbuffers/util.h",
100 ],
101 linkstatic = 1,
102 strip_include_prefix = "/include",
103 visibility = ["//visibility:public"],
104)
105
106flatbuffer_py_strip_prefix_srcs(
107 name = "flatbuffer_py_strip_prefix",
108 srcs = [
109 "python/flatbuffers/__init__.py",
110 "python/flatbuffers/builder.py",
111 "python/flatbuffers/compat.py",
112 "python/flatbuffers/encode.py",
113 "python/flatbuffers/number_types.py",
114 "python/flatbuffers/packer.py",
115 "python/flatbuffers/table.py",
116 "python/flatbuffers/util.py",
117 ],
118 strip_prefix = "python/flatbuffers/",
119)
120
121filegroup(
122 name = "runtime_py_srcs",
123 srcs = [
124 "__init__.py",
125 "builder.py",
126 "compat.py",
127 "encode.py",
128 "number_types.py",
129 "packer.py",
130 "table.py",
131 "util.py",
132 ],
133)
134
135py_library(
136 name = "runtime_py",
137 srcs = [":runtime_py_srcs"],
138 visibility = ["//visibility:public"],
139)
140
141filegroup(
142 name = "runtime_java_srcs",
143 srcs = glob(["java/com/google/flatbuffers/**/*.java"]),
144)
145
146java_library(
147 name = "runtime_java",
148 srcs = [":runtime_java_srcs"],
149 visibility = ["//visibility:public"],
150)
151
152android_library(
153 name = "runtime_android",
154 srcs = [":runtime_java_srcs"],
155 visibility = ["//visibility:public"],
156)