Yannic Bonenberger | 8b93b8e | 2020-07-08 17:21:38 +0200 | [diff] [blame] | 1 | load("@rules_cc//cc:defs.bzl", "objc_library") |
David L. Jones | d76f8c8 | 2022-04-22 16:58:16 -0700 | [diff] [blame] | 2 | load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") |
Adam Cozzette | 7286ffc | 2023-09-12 13:06:39 -0700 | [diff] [blame] | 3 | load("//upb/cmake:build_defs.bzl", "staleness_test") |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 4 | load("//conformance:defs.bzl", "conformance_test") |
Protobuf Team Bot | e2aa06e | 2023-02-10 14:11:22 -0800 | [diff] [blame] | 5 | load(":defs.bzl", "objc_proto_camel_case_name") |
| 6 | |
| 7 | # The WKTs have to be checked in to support the CocoaPods and Xcode builds. This |
| 8 | # generule and test ensure the source are current. |
| 9 | # |
Thomas Van Lenten | 17ee68a | 2023-05-03 13:48:06 -0700 | [diff] [blame] | 10 | # TODO: Improve the bazel build so it uses these generated headers so it is |
| 11 | # always current, and only the builds that can't easily build protoc and |
| 12 | # generate the files rely on the checked in ones. |
Protobuf Team Bot | e2aa06e | 2023-02-10 14:11:22 -0800 | [diff] [blame] | 13 | |
| 14 | _WELL_KNOWN_TYPES = [ |
| 15 | "any", |
| 16 | "api", |
| 17 | "duration", |
| 18 | "empty", |
| 19 | "field_mask", |
| 20 | "source_context", |
| 21 | "struct", |
| 22 | "timestamp", |
| 23 | "type", |
| 24 | "wrappers", |
| 25 | ] |
| 26 | |
| 27 | _OBJC_WKT_NAMES = [objc_proto_camel_case_name(x) for x in _WELL_KNOWN_TYPES] |
| 28 | |
| 29 | _OBJC_EXTS = [ |
| 30 | ".pbobjc.h", |
| 31 | ".pbobjc.m", |
| 32 | ] |
| 33 | |
| 34 | genrule( |
| 35 | name = "gen_wkt_sources", |
| 36 | srcs = ["//src/google/protobuf:well_known_type_protos"], |
| 37 | outs = ["wkt/GPB" + wkt + ext for wkt in _OBJC_WKT_NAMES for ext in _OBJC_EXTS], |
| 38 | cmd = " && ".join([ |
| 39 | "$(execpath //:protoc) --objc_out=$(RULEDIR)/wkt --proto_path=src $(SRCS)", |
| 40 | ] + [ |
| 41 | "mv $(RULEDIR)/wkt/google/protobuf/" + wkt + ext + " $(RULEDIR)/wkt/GPB" + wkt + ext |
| 42 | for wkt in _OBJC_WKT_NAMES |
| 43 | for ext in _OBJC_EXTS |
| 44 | ]), |
Deanna Garcia | f8a5142 | 2023-05-01 12:00:29 -0700 | [diff] [blame] | 45 | tags = ["manual"], |
Adam Cozzette | 501ecec | 2023-09-26 14:36:20 -0700 | [diff] [blame] | 46 | tools = ["//:protoc"], |
Protobuf Team Bot | e2aa06e | 2023-02-10 14:11:22 -0800 | [diff] [blame] | 47 | ) |
| 48 | |
| 49 | staleness_test( |
| 50 | name = "well_known_types_staleness_test", |
| 51 | outs = ["GPB" + wkt + ext for wkt in _OBJC_WKT_NAMES for ext in _OBJC_EXTS], |
| 52 | generated_pattern = "wkt/%s", |
| 53 | tags = ["manual"], |
| 54 | ) |
| 55 | |
| 56 | ################################################################################ |
| 57 | # Objective-C Runtime Library |
| 58 | ################################################################################ |
Yannic Bonenberger | 8b93b8e | 2020-07-08 17:21:38 +0200 | [diff] [blame] | 59 | |
| 60 | objc_library( |
| 61 | name = "objectivec", |
| 62 | hdrs = [ |
Thomas Van Lenten | 17ee68a | 2023-05-03 13:48:06 -0700 | [diff] [blame] | 63 | "GPBAny.pbobjc.h", |
| 64 | "GPBApi.pbobjc.h", |
| 65 | "GPBDuration.pbobjc.h", |
| 66 | "GPBEmpty.pbobjc.h", |
| 67 | "GPBFieldMask.pbobjc.h", |
| 68 | "GPBSourceContext.pbobjc.h", |
| 69 | "GPBStruct.pbobjc.h", |
| 70 | "GPBTimestamp.pbobjc.h", |
| 71 | "GPBType.pbobjc.h", |
| 72 | "GPBWrappers.pbobjc.h", |
Yannic Bonenberger | 8b93b8e | 2020-07-08 17:21:38 +0200 | [diff] [blame] | 73 | "GPBArray.h", |
| 74 | "GPBBootstrap.h", |
| 75 | "GPBCodedInputStream.h", |
| 76 | "GPBCodedOutputStream.h", |
| 77 | "GPBDescriptor.h", |
| 78 | "GPBDictionary.h", |
| 79 | "GPBExtensionInternals.h", |
| 80 | "GPBExtensionRegistry.h", |
| 81 | "GPBMessage.h", |
| 82 | "GPBProtocolBuffers.h", |
| 83 | "GPBProtocolBuffers_RuntimeSupport.h", |
| 84 | "GPBRootObject.h", |
| 85 | "GPBRuntimeTypes.h", |
| 86 | "GPBUnknownField.h", |
| 87 | "GPBUnknownFieldSet.h", |
| 88 | "GPBUtilities.h", |
| 89 | "GPBWellKnownTypes.h", |
| 90 | "GPBWireFormat.h", |
| 91 | "google/protobuf/Any.pbobjc.h", |
| 92 | "google/protobuf/Api.pbobjc.h", |
| 93 | "google/protobuf/Duration.pbobjc.h", |
| 94 | "google/protobuf/Empty.pbobjc.h", |
| 95 | "google/protobuf/FieldMask.pbobjc.h", |
| 96 | "google/protobuf/SourceContext.pbobjc.h", |
| 97 | "google/protobuf/Struct.pbobjc.h", |
| 98 | "google/protobuf/Timestamp.pbobjc.h", |
| 99 | "google/protobuf/Type.pbobjc.h", |
| 100 | "google/protobuf/Wrappers.pbobjc.h", |
| 101 | # Package private headers, but exposed because the generated sources |
| 102 | # need to use them. |
| 103 | "GPBArray_PackagePrivate.h", |
| 104 | "GPBCodedInputStream_PackagePrivate.h", |
| 105 | "GPBCodedOutputStream_PackagePrivate.h", |
| 106 | "GPBDescriptor_PackagePrivate.h", |
| 107 | "GPBDictionary_PackagePrivate.h", |
| 108 | "GPBMessage_PackagePrivate.h", |
| 109 | "GPBRootObject_PackagePrivate.h", |
| 110 | "GPBUnknownFieldSet_PackagePrivate.h", |
| 111 | "GPBUnknownField_PackagePrivate.h", |
| 112 | "GPBUtilities_PackagePrivate.h", |
Thomas Van Lenten | 17ee68a | 2023-05-03 13:48:06 -0700 | [diff] [blame] | 113 | ], |
Yannic Bonenberger | 8b93b8e | 2020-07-08 17:21:38 +0200 | [diff] [blame] | 114 | copts = [ |
| 115 | "-Wno-vla", |
| 116 | ], |
| 117 | includes = [ |
| 118 | ".", |
| 119 | ], |
| 120 | non_arc_srcs = [ |
Thomas Van Lenten | 17ee68a | 2023-05-03 13:48:06 -0700 | [diff] [blame] | 121 | "GPBAny.pbobjc.m", |
| 122 | "GPBApi.pbobjc.m", |
Yannic Bonenberger | 8b93b8e | 2020-07-08 17:21:38 +0200 | [diff] [blame] | 123 | "GPBArray.m", |
| 124 | "GPBCodedInputStream.m", |
| 125 | "GPBCodedOutputStream.m", |
| 126 | "GPBDescriptor.m", |
| 127 | "GPBDictionary.m", |
Thomas Van Lenten | 17ee68a | 2023-05-03 13:48:06 -0700 | [diff] [blame] | 128 | "GPBDuration.pbobjc.m", |
| 129 | "GPBEmpty.pbobjc.m", |
Yannic Bonenberger | 8b93b8e | 2020-07-08 17:21:38 +0200 | [diff] [blame] | 130 | "GPBExtensionInternals.m", |
| 131 | "GPBExtensionRegistry.m", |
Thomas Van Lenten | 17ee68a | 2023-05-03 13:48:06 -0700 | [diff] [blame] | 132 | "GPBFieldMask.pbobjc.m", |
Yannic Bonenberger | 8b93b8e | 2020-07-08 17:21:38 +0200 | [diff] [blame] | 133 | "GPBMessage.m", |
| 134 | "GPBRootObject.m", |
Thomas Van Lenten | 17ee68a | 2023-05-03 13:48:06 -0700 | [diff] [blame] | 135 | "GPBSourceContext.pbobjc.m", |
| 136 | "GPBStruct.pbobjc.m", |
| 137 | "GPBTimestamp.pbobjc.m", |
| 138 | "GPBType.pbobjc.m", |
Yannic Bonenberger | 8b93b8e | 2020-07-08 17:21:38 +0200 | [diff] [blame] | 139 | "GPBUnknownField.m", |
| 140 | "GPBUnknownFieldSet.m", |
| 141 | "GPBUtilities.m", |
| 142 | "GPBWellKnownTypes.m", |
| 143 | "GPBWireFormat.m", |
Thomas Van Lenten | 17ee68a | 2023-05-03 13:48:06 -0700 | [diff] [blame] | 144 | "GPBWrappers.pbobjc.m", |
| 145 | ], |
Protobuf Team Bot | b977cf5 | 2023-02-09 12:02:43 -0800 | [diff] [blame] | 146 | target_compatible_with = select({ |
| 147 | "@platforms//os:macos": [], |
| 148 | "@platforms//os:ios": [], |
| 149 | "@platforms//os:tvos": [], |
| 150 | "@platforms//os:watchos": [], |
| 151 | "//conditions:default": ["@platforms//:incompatible"], |
| 152 | }), |
Yannic Bonenberger | 8b93b8e | 2020-07-08 17:21:38 +0200 | [diff] [blame] | 153 | visibility = ["//visibility:public"], |
| 154 | ) |
David L. Jones | d76f8c8 | 2022-04-22 16:58:16 -0700 | [diff] [blame] | 155 | |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 156 | ################################################################################ |
| 157 | # Tests |
| 158 | ################################################################################ |
| 159 | |
| 160 | conformance_test( |
| 161 | name = "conformance_test", |
| 162 | failure_list = "//conformance:failure_list_objc.txt", |
Thomas Van Lenten | 6c7c5a5 | 2023-12-12 14:03:01 -0800 | [diff] [blame] | 163 | maximum_edition = "2023", |
Protobuf Team Bot | b977cf5 | 2023-02-09 12:02:43 -0800 | [diff] [blame] | 164 | target_compatible_with = ["@platforms//os:macos"], |
Protobuf Team Bot | a2c5ea6 | 2023-02-13 10:09:00 -0800 | [diff] [blame] | 165 | testee = "//conformance:conformance_objc", |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 166 | ) |
| 167 | |
Protobuf Team Bot | 2fed1e3 | 2023-02-09 11:28:29 -0800 | [diff] [blame] | 168 | # ------------------------------------------------------------------- |
| 169 | # Current Version Check between Generator and Runtime Sources |
| 170 | sh_test( |
| 171 | name = "check_version_stamps", |
| 172 | size = "small", |
| 173 | srcs = ["DevTools/check_version_stamps.sh"], |
| 174 | data = [ |
| 175 | "GPBBootstrap.h", |
| 176 | "//src/google/protobuf/compiler/objectivec:file.cc", |
| 177 | ], |
| 178 | ) |
| 179 | |
Protobuf Team Bot | 26dae8d | 2023-02-09 14:10:41 -0800 | [diff] [blame] | 180 | # ------------------------------------------------------------------- |
| 181 | # Validation of pddm expansion. |
| 182 | |
| 183 | py_binary( |
| 184 | name = "pddm", |
| 185 | srcs = ["DevTools/pddm.py"], |
| 186 | ) |
| 187 | |
| 188 | py_test( |
| 189 | name = "pddm_tests", |
| 190 | size = "small", |
| 191 | srcs = [ |
| 192 | "DevTools/pddm.py", |
| 193 | "DevTools/pddm_tests.py", |
| 194 | ], |
| 195 | ) |
| 196 | |
| 197 | sh_test( |
| 198 | name = "sources_pddm_expansion_test", |
| 199 | size = "small", |
| 200 | srcs = ["DevTools/sources_pddm_expansion_test.sh"], |
| 201 | data = [":pddm"] + glob([ |
| 202 | "**/*.h", |
| 203 | "**/*.m", |
| 204 | "**/*.pddm", |
| 205 | ]), |
| 206 | ) |
| 207 | |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 208 | ################################################################################ |
| 209 | # Distribution files |
| 210 | ################################################################################ |
| 211 | |
David L. Jones | d76f8c8 | 2022-04-22 16:58:16 -0700 | [diff] [blame] | 212 | pkg_files( |
| 213 | name = "dist_files", |
| 214 | srcs = glob([ |
| 215 | "*.h", |
| 216 | "*.m", |
| 217 | "**/*.h", |
| 218 | "**/*.m", |
| 219 | "**/*.mm", |
| 220 | "**/*.swift", |
| 221 | "DevTools/*.sh", |
| 222 | "DevTools/*.py", |
| 223 | "ProtocolBuffers_iOS.xcodeproj/**/*", |
| 224 | "ProtocolBuffers_OSX.xcodeproj/**/*", |
| 225 | "ProtocolBuffers_tvOS.xcodeproj/**/*", |
David L. Jones | d76f8c8 | 2022-04-22 16:58:16 -0700 | [diff] [blame] | 226 | "Tests/*.pddm", |
| 227 | "Tests/*.txt", |
| 228 | "Tests/*.plist", |
| 229 | "Tests/*.proto", |
| 230 | ]) + [ |
| 231 | ".clang-format", |
David L. Jones | 95da0ba | 2022-04-29 17:57:55 -0700 | [diff] [blame] | 232 | "BUILD.bazel", |
David L. Jones | d76f8c8 | 2022-04-22 16:58:16 -0700 | [diff] [blame] | 233 | "README.md", |
| 234 | "Tests/golden_message", |
| 235 | "Tests/golden_packed_fields_message", |
| 236 | "generate_well_known_types.sh", |
| 237 | ], |
| 238 | strip_prefix = strip_prefix.from_root(""), |
| 239 | visibility = ["//pkg:__pkg__"], |
| 240 | ) |