forked from protocolbuffers/protobuf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.bazel
221 lines (204 loc) · 6.54 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
load("@rules_cc//cc:defs.bzl", "objc_library")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@upb//cmake:build_defs.bzl", "staleness_test")
load("//conformance:defs.bzl", "conformance_test")
load(":defs.bzl", "objc_proto_camel_case_name")
# The WKTs have to be checked in to support the CocoaPods and Xcode builds. This
# generule and test ensure the source are current.
#
# Within the ":objectivec" target, the outputs of the genrule are then used to
# ensure they are always "current". This implementation is basically the same
# has how the WKTs are handled in src/google/protobuf/BUILD.bazel for the C++
# version. They share the potential downsides around layer checks and that
# someone could #include the header with the `wkt/` prefix on the name.
_WELL_KNOWN_TYPES = [
"any",
"api",
"duration",
"empty",
"field_mask",
"source_context",
"struct",
"timestamp",
"type",
"wrappers",
]
_OBJC_WKT_NAMES = [objc_proto_camel_case_name(x) for x in _WELL_KNOWN_TYPES]
_OBJC_EXTS = [
".pbobjc.h",
".pbobjc.m",
]
genrule(
name = "gen_wkt_sources",
srcs = ["//src/google/protobuf:well_known_type_protos"],
outs = ["wkt/GPB" + wkt + ext for wkt in _OBJC_WKT_NAMES for ext in _OBJC_EXTS],
cmd = " && ".join([
"$(execpath //:protoc) --objc_out=$(RULEDIR)/wkt --proto_path=src $(SRCS)",
] + [
"mv $(RULEDIR)/wkt/google/protobuf/" + wkt + ext + " $(RULEDIR)/wkt/GPB" + wkt + ext
for wkt in _OBJC_WKT_NAMES
for ext in _OBJC_EXTS
]),
exec_tools = ["//:protoc"],
)
staleness_test(
name = "well_known_types_staleness_test",
outs = ["GPB" + wkt + ext for wkt in _OBJC_WKT_NAMES for ext in _OBJC_EXTS],
generated_pattern = "wkt/%s",
tags = ["manual"],
)
################################################################################
# Objective-C Runtime Library
################################################################################
objc_library(
name = "objectivec",
hdrs = [
"GPBArray.h",
"GPBBootstrap.h",
"GPBCodedInputStream.h",
"GPBCodedOutputStream.h",
"GPBDescriptor.h",
"GPBDictionary.h",
"GPBExtensionInternals.h",
"GPBExtensionRegistry.h",
"GPBMessage.h",
"GPBProtocolBuffers.h",
"GPBProtocolBuffers_RuntimeSupport.h",
"GPBRootObject.h",
"GPBRuntimeTypes.h",
"GPBUnknownField.h",
"GPBUnknownFieldSet.h",
"GPBUtilities.h",
"GPBWellKnownTypes.h",
"GPBWireFormat.h",
"google/protobuf/Any.pbobjc.h",
"google/protobuf/Api.pbobjc.h",
"google/protobuf/Duration.pbobjc.h",
"google/protobuf/Empty.pbobjc.h",
"google/protobuf/FieldMask.pbobjc.h",
"google/protobuf/SourceContext.pbobjc.h",
"google/protobuf/Struct.pbobjc.h",
"google/protobuf/Timestamp.pbobjc.h",
"google/protobuf/Type.pbobjc.h",
"google/protobuf/Wrappers.pbobjc.h",
# Package private headers, but exposed because the generated sources
# need to use them.
"GPBArray_PackagePrivate.h",
"GPBCodedInputStream_PackagePrivate.h",
"GPBCodedOutputStream_PackagePrivate.h",
"GPBDescriptor_PackagePrivate.h",
"GPBDictionary_PackagePrivate.h",
"GPBMessage_PackagePrivate.h",
"GPBRootObject_PackagePrivate.h",
"GPBUnknownFieldSet_PackagePrivate.h",
"GPBUnknownField_PackagePrivate.h",
"GPBUtilities_PackagePrivate.h",
] + ["wkt/GPB" + wkt + ".pbobjc.h" for wkt in _OBJC_WKT_NAMES],
copts = [
"-Wno-vla",
],
includes = [
".",
"wkt",
],
non_arc_srcs = [
"GPBArray.m",
"GPBCodedInputStream.m",
"GPBCodedOutputStream.m",
"GPBDescriptor.m",
"GPBDictionary.m",
"GPBExtensionInternals.m",
"GPBExtensionRegistry.m",
"GPBMessage.m",
"GPBRootObject.m",
"GPBUnknownField.m",
"GPBUnknownFieldSet.m",
"GPBUtilities.m",
"GPBWellKnownTypes.m",
"GPBWireFormat.m",
] + ["wkt/GPB" + wkt + ".pbobjc.m" for wkt in _OBJC_WKT_NAMES],
target_compatible_with = select({
"@platforms//os:macos": [],
"@platforms//os:ios": [],
"@platforms//os:tvos": [],
"@platforms//os:watchos": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
visibility = ["//visibility:public"],
)
################################################################################
# Tests
################################################################################
conformance_test(
name = "conformance_test",
failure_list = "//conformance:failure_list_objc.txt",
target_compatible_with = ["@platforms//os:macos"],
testee = "//conformance:conformance_objc",
)
# -------------------------------------------------------------------
# Current Version Check between Generator and Runtime Sources
sh_test(
name = "check_version_stamps",
size = "small",
srcs = ["DevTools/check_version_stamps.sh"],
data = [
"GPBBootstrap.h",
"//src/google/protobuf/compiler/objectivec:file.cc",
],
)
# -------------------------------------------------------------------
# Validation of pddm expansion.
py_binary(
name = "pddm",
srcs = ["DevTools/pddm.py"],
)
py_test(
name = "pddm_tests",
size = "small",
srcs = [
"DevTools/pddm.py",
"DevTools/pddm_tests.py",
],
)
sh_test(
name = "sources_pddm_expansion_test",
size = "small",
srcs = ["DevTools/sources_pddm_expansion_test.sh"],
data = [":pddm"] + glob([
"**/*.h",
"**/*.m",
"**/*.pddm",
]),
)
################################################################################
# Distribution files
################################################################################
pkg_files(
name = "dist_files",
srcs = glob([
"*.h",
"*.m",
"**/*.h",
"**/*.m",
"**/*.mm",
"**/*.swift",
"DevTools/*.sh",
"DevTools/*.py",
"ProtocolBuffers_iOS.xcodeproj/**/*",
"ProtocolBuffers_OSX.xcodeproj/**/*",
"ProtocolBuffers_tvOS.xcodeproj/**/*",
"Tests/*.pddm",
"Tests/*.txt",
"Tests/*.plist",
"Tests/*.proto",
]) + [
".clang-format",
"BUILD.bazel",
"README.md",
"Tests/golden_message",
"Tests/golden_packed_fields_message",
"generate_well_known_types.sh",
],
strip_prefix = strip_prefix.from_root(""),
visibility = ["//pkg:__pkg__"],
)