From a2c5ea614cd5330de4b56a9937377f65309a31f8 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Mon, 13 Feb 2023 10:09:00 -0800 Subject: [PATCH] [ObjC] make the bazel build always use generated WKTs. This is done in basically the same way the C++ does this. It was tested locally be putting `#error` directives in the pre-generated sources and running the bazel build (it worked). PiperOrigin-RevId: 509261352 --- objectivec/BUILD.bazel | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/objectivec/BUILD.bazel b/objectivec/BUILD.bazel index fae65c298f..0965de5b27 100644 --- a/objectivec/BUILD.bazel +++ b/objectivec/BUILD.bazel @@ -7,9 +7,11 @@ 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. # -# TODO: Improve the bazel build so it uses these generated headers so it is -# always current, and only the builds that can't easily build protoc and -# generate the files rely on the checked in ones. +# 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", @@ -59,16 +61,6 @@ staleness_test( objc_library( name = "objectivec", hdrs = [ - "GPBAny.pbobjc.h", - "GPBApi.pbobjc.h", - "GPBDuration.pbobjc.h", - "GPBEmpty.pbobjc.h", - "GPBFieldMask.pbobjc.h", - "GPBSourceContext.pbobjc.h", - "GPBStruct.pbobjc.h", - "GPBTimestamp.pbobjc.h", - "GPBType.pbobjc.h", - "GPBWrappers.pbobjc.h", "GPBArray.h", "GPBBootstrap.h", "GPBCodedInputStream.h", @@ -109,39 +101,30 @@ objc_library( "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 = [ - "GPBAny.pbobjc.m", - "GPBApi.pbobjc.m", "GPBArray.m", "GPBCodedInputStream.m", "GPBCodedOutputStream.m", "GPBDescriptor.m", "GPBDictionary.m", - "GPBDuration.pbobjc.m", - "GPBEmpty.pbobjc.m", "GPBExtensionInternals.m", "GPBExtensionRegistry.m", - "GPBFieldMask.pbobjc.m", "GPBMessage.m", "GPBRootObject.m", - "GPBSourceContext.pbobjc.m", - "GPBStruct.pbobjc.m", - "GPBTimestamp.pbobjc.m", - "GPBType.pbobjc.m", "GPBUnknownField.m", "GPBUnknownFieldSet.m", "GPBUtilities.m", "GPBWellKnownTypes.m", "GPBWireFormat.m", - "GPBWrappers.pbobjc.m", - ], + ] + ["wkt/GPB" + wkt + ".pbobjc.m" for wkt in _OBJC_WKT_NAMES], target_compatible_with = select({ "@platforms//os:macos": [], "@platforms//os:ios": [], @@ -159,8 +142,8 @@ objc_library( conformance_test( name = "conformance_test", failure_list = "//conformance:failure_list_objc.txt", - testee = "//conformance:conformance_objc", target_compatible_with = ["@platforms//os:macos"], + testee = "//conformance:conformance_objc", ) # -------------------------------------------------------------------