From a67cce2626f931cd8dee8bb4e42b78d9444f2368 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Tue, 1 Mar 2022 14:16:50 -0500 Subject: [PATCH] Simplify imports of the WKTs within the library itself. Overdue followup to https://github.com/protocolbuffers/protobuf/pull/7173 Since all the files are at the same level as the runtime headers, there is no need for things to be framework based imports, they should all just work like the other headers do. - Directly generate the bundled header imports into the preamble section when generating for a bundled proto. - Update the preamble generation to skip the CPP wrapper when generating for a bundled proto file. - Regenerate the WKTs. - Update GPBProtocolBuffer.h to also skip the CPP wrapping. GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS in the podspec and non bundled files still has to exist because that comes into play for those files to find the runtime headers. --- objectivec/GPBAny.pbobjc.h | 18 ++------- objectivec/GPBAny.pbobjc.m | 20 ++-------- objectivec/GPBApi.pbobjc.h | 18 ++------- objectivec/GPBApi.pbobjc.m | 26 +++---------- objectivec/GPBDuration.pbobjc.h | 18 ++------- objectivec/GPBDuration.pbobjc.m | 20 ++-------- objectivec/GPBEmpty.pbobjc.h | 18 ++------- objectivec/GPBEmpty.pbobjc.m | 20 ++-------- objectivec/GPBFieldMask.pbobjc.h | 18 ++------- objectivec/GPBFieldMask.pbobjc.m | 20 ++-------- objectivec/GPBProtocolBuffers.h | 39 +++++-------------- objectivec/GPBSourceContext.pbobjc.h | 18 ++------- objectivec/GPBSourceContext.pbobjc.m | 20 ++-------- objectivec/GPBStruct.pbobjc.h | 18 ++------- objectivec/GPBStruct.pbobjc.m | 18 +-------- objectivec/GPBTimestamp.pbobjc.h | 18 ++------- objectivec/GPBTimestamp.pbobjc.m | 20 ++-------- objectivec/GPBType.pbobjc.h | 18 ++------- objectivec/GPBType.pbobjc.m | 24 ++---------- objectivec/GPBWrappers.pbobjc.h | 18 ++------- objectivec/GPBWrappers.pbobjc.m | 20 ++-------- .../compiler/objectivec/objectivec_file.cc | 36 ++++++++++++++--- 22 files changed, 103 insertions(+), 360 deletions(-) diff --git a/objectivec/GPBAny.pbobjc.h b/objectivec/GPBAny.pbobjc.h index 5ed3f2ee683a..7fb4129b139e 100644 --- a/objectivec/GPBAny.pbobjc.h +++ b/objectivec/GPBAny.pbobjc.h @@ -1,21 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/any.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import - #import - #import -#else - #import "GPBDescriptor.h" - #import "GPBMessage.h" - #import "GPBRootObject.h" -#endif +#import "GPBDescriptor.h" +#import "GPBMessage.h" +#import "GPBRootObject.h" #if GOOGLE_PROTOBUF_OBJC_VERSION < 30004 #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. diff --git a/objectivec/GPBAny.pbobjc.m b/objectivec/GPBAny.pbobjc.m index a5143f15dc3c..7632c8c279b4 100644 --- a/objectivec/GPBAny.pbobjc.m +++ b/objectivec/GPBAny.pbobjc.m @@ -1,23 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/any.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBAny.pbobjc.h" -#endif +#import "GPBProtocolBuffers_RuntimeSupport.h" +#import "GPBAny.pbobjc.h" + // @@protoc_insertion_point(imports) #pragma clang diagnostic push diff --git a/objectivec/GPBApi.pbobjc.h b/objectivec/GPBApi.pbobjc.h index 5d55ebf39921..1634a9212ebb 100644 --- a/objectivec/GPBApi.pbobjc.h +++ b/objectivec/GPBApi.pbobjc.h @@ -1,21 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/api.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import - #import - #import -#else - #import "GPBDescriptor.h" - #import "GPBMessage.h" - #import "GPBRootObject.h" -#endif +#import "GPBDescriptor.h" +#import "GPBMessage.h" +#import "GPBRootObject.h" #if GOOGLE_PROTOBUF_OBJC_VERSION < 30004 #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. diff --git a/objectivec/GPBApi.pbobjc.m b/objectivec/GPBApi.pbobjc.m index 5915ce112262..639462b19d02 100644 --- a/objectivec/GPBApi.pbobjc.m +++ b/objectivec/GPBApi.pbobjc.m @@ -1,27 +1,11 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/api.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import - #import - #import -#else - #import "GPBApi.pbobjc.h" - #import "GPBSourceContext.pbobjc.h" - #import "GPBType.pbobjc.h" -#endif +#import "GPBProtocolBuffers_RuntimeSupport.h" +#import "GPBApi.pbobjc.h" +#import "GPBSourceContext.pbobjc.h" +#import "GPBType.pbobjc.h" + // @@protoc_insertion_point(imports) #pragma clang diagnostic push diff --git a/objectivec/GPBDuration.pbobjc.h b/objectivec/GPBDuration.pbobjc.h index 88527f520d3c..d6236b07f34d 100644 --- a/objectivec/GPBDuration.pbobjc.h +++ b/objectivec/GPBDuration.pbobjc.h @@ -1,21 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/duration.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import - #import - #import -#else - #import "GPBDescriptor.h" - #import "GPBMessage.h" - #import "GPBRootObject.h" -#endif +#import "GPBDescriptor.h" +#import "GPBMessage.h" +#import "GPBRootObject.h" #if GOOGLE_PROTOBUF_OBJC_VERSION < 30004 #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. diff --git a/objectivec/GPBDuration.pbobjc.m b/objectivec/GPBDuration.pbobjc.m index d3cc7e31ca3f..11ba5e5f7b33 100644 --- a/objectivec/GPBDuration.pbobjc.m +++ b/objectivec/GPBDuration.pbobjc.m @@ -1,23 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/duration.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBDuration.pbobjc.h" -#endif +#import "GPBProtocolBuffers_RuntimeSupport.h" +#import "GPBDuration.pbobjc.h" + // @@protoc_insertion_point(imports) #pragma clang diagnostic push diff --git a/objectivec/GPBEmpty.pbobjc.h b/objectivec/GPBEmpty.pbobjc.h index 45600ead863a..8a31c04ff511 100644 --- a/objectivec/GPBEmpty.pbobjc.h +++ b/objectivec/GPBEmpty.pbobjc.h @@ -1,21 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/empty.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import - #import - #import -#else - #import "GPBDescriptor.h" - #import "GPBMessage.h" - #import "GPBRootObject.h" -#endif +#import "GPBDescriptor.h" +#import "GPBMessage.h" +#import "GPBRootObject.h" #if GOOGLE_PROTOBUF_OBJC_VERSION < 30004 #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. diff --git a/objectivec/GPBEmpty.pbobjc.m b/objectivec/GPBEmpty.pbobjc.m index df3e398170af..8aefddb5b46a 100644 --- a/objectivec/GPBEmpty.pbobjc.m +++ b/objectivec/GPBEmpty.pbobjc.m @@ -1,23 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/empty.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBEmpty.pbobjc.h" -#endif +#import "GPBProtocolBuffers_RuntimeSupport.h" +#import "GPBEmpty.pbobjc.h" + // @@protoc_insertion_point(imports) #pragma clang diagnostic push diff --git a/objectivec/GPBFieldMask.pbobjc.h b/objectivec/GPBFieldMask.pbobjc.h index 3028b775dcd6..c4667b44db26 100644 --- a/objectivec/GPBFieldMask.pbobjc.h +++ b/objectivec/GPBFieldMask.pbobjc.h @@ -1,21 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/field_mask.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import - #import - #import -#else - #import "GPBDescriptor.h" - #import "GPBMessage.h" - #import "GPBRootObject.h" -#endif +#import "GPBDescriptor.h" +#import "GPBMessage.h" +#import "GPBRootObject.h" #if GOOGLE_PROTOBUF_OBJC_VERSION < 30004 #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. diff --git a/objectivec/GPBFieldMask.pbobjc.m b/objectivec/GPBFieldMask.pbobjc.m index 3605f89d8057..ab25d3f9b1ea 100644 --- a/objectivec/GPBFieldMask.pbobjc.m +++ b/objectivec/GPBFieldMask.pbobjc.m @@ -1,23 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/field_mask.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBFieldMask.pbobjc.h" -#endif +#import "GPBProtocolBuffers_RuntimeSupport.h" +#import "GPBFieldMask.pbobjc.h" + // @@protoc_insertion_point(imports) #pragma clang diagnostic push diff --git a/objectivec/GPBProtocolBuffers.h b/objectivec/GPBProtocolBuffers.h index c5df91639698..619c08228bb6 100644 --- a/objectivec/GPBProtocolBuffers.h +++ b/objectivec/GPBProtocolBuffers.h @@ -44,33 +44,14 @@ #import "GPBWellKnownTypes.h" #import "GPBWireFormat.h" -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - // Well-known proto types -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import - #import - #import - #import - #import - #import - #import - #import - #import - #import -#else - #import "GPBAny.pbobjc.h" - #import "GPBApi.pbobjc.h" - #import "GPBDuration.pbobjc.h" - #import "GPBEmpty.pbobjc.h" - #import "GPBFieldMask.pbobjc.h" - #import "GPBSourceContext.pbobjc.h" - #import "GPBStruct.pbobjc.h" - #import "GPBTimestamp.pbobjc.h" - #import "GPBType.pbobjc.h" - #import "GPBWrappers.pbobjc.h" -#endif +#import "GPBAny.pbobjc.h" +#import "GPBApi.pbobjc.h" +#import "GPBDuration.pbobjc.h" +#import "GPBEmpty.pbobjc.h" +#import "GPBFieldMask.pbobjc.h" +#import "GPBSourceContext.pbobjc.h" +#import "GPBStruct.pbobjc.h" +#import "GPBTimestamp.pbobjc.h" +#import "GPBType.pbobjc.h" +#import "GPBWrappers.pbobjc.h" diff --git a/objectivec/GPBSourceContext.pbobjc.h b/objectivec/GPBSourceContext.pbobjc.h index 7a103362b565..b17fec0b788c 100644 --- a/objectivec/GPBSourceContext.pbobjc.h +++ b/objectivec/GPBSourceContext.pbobjc.h @@ -1,21 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/source_context.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import - #import - #import -#else - #import "GPBDescriptor.h" - #import "GPBMessage.h" - #import "GPBRootObject.h" -#endif +#import "GPBDescriptor.h" +#import "GPBMessage.h" +#import "GPBRootObject.h" #if GOOGLE_PROTOBUF_OBJC_VERSION < 30004 #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. diff --git a/objectivec/GPBSourceContext.pbobjc.m b/objectivec/GPBSourceContext.pbobjc.m index b3e6fa759ce4..376d4421de2d 100644 --- a/objectivec/GPBSourceContext.pbobjc.m +++ b/objectivec/GPBSourceContext.pbobjc.m @@ -1,23 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/source_context.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBSourceContext.pbobjc.h" -#endif +#import "GPBProtocolBuffers_RuntimeSupport.h" +#import "GPBSourceContext.pbobjc.h" + // @@protoc_insertion_point(imports) #pragma clang diagnostic push diff --git a/objectivec/GPBStruct.pbobjc.h b/objectivec/GPBStruct.pbobjc.h index abdd6c82be37..dd6ab28f0e81 100644 --- a/objectivec/GPBStruct.pbobjc.h +++ b/objectivec/GPBStruct.pbobjc.h @@ -1,21 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/struct.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import - #import - #import -#else - #import "GPBDescriptor.h" - #import "GPBMessage.h" - #import "GPBRootObject.h" -#endif +#import "GPBDescriptor.h" +#import "GPBMessage.h" +#import "GPBRootObject.h" #if GOOGLE_PROTOBUF_OBJC_VERSION < 30004 #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. diff --git a/objectivec/GPBStruct.pbobjc.m b/objectivec/GPBStruct.pbobjc.m index 554046a9fe50..726cfb860ea7 100644 --- a/objectivec/GPBStruct.pbobjc.m +++ b/objectivec/GPBStruct.pbobjc.m @@ -1,25 +1,11 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/struct.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif +#import "GPBProtocolBuffers_RuntimeSupport.h" +#import "GPBStruct.pbobjc.h" #import -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBStruct.pbobjc.h" -#endif // @@protoc_insertion_point(imports) #pragma clang diagnostic push diff --git a/objectivec/GPBTimestamp.pbobjc.h b/objectivec/GPBTimestamp.pbobjc.h index a328afc7c93d..8203383bdd98 100644 --- a/objectivec/GPBTimestamp.pbobjc.h +++ b/objectivec/GPBTimestamp.pbobjc.h @@ -1,21 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/timestamp.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import - #import - #import -#else - #import "GPBDescriptor.h" - #import "GPBMessage.h" - #import "GPBRootObject.h" -#endif +#import "GPBDescriptor.h" +#import "GPBMessage.h" +#import "GPBRootObject.h" #if GOOGLE_PROTOBUF_OBJC_VERSION < 30004 #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. diff --git a/objectivec/GPBTimestamp.pbobjc.m b/objectivec/GPBTimestamp.pbobjc.m index 736a75d19f9d..72d348f42a6b 100644 --- a/objectivec/GPBTimestamp.pbobjc.m +++ b/objectivec/GPBTimestamp.pbobjc.m @@ -1,23 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/timestamp.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBTimestamp.pbobjc.h" -#endif +#import "GPBProtocolBuffers_RuntimeSupport.h" +#import "GPBTimestamp.pbobjc.h" + // @@protoc_insertion_point(imports) #pragma clang diagnostic push diff --git a/objectivec/GPBType.pbobjc.h b/objectivec/GPBType.pbobjc.h index 747e15d455dc..ee02b0a6834d 100644 --- a/objectivec/GPBType.pbobjc.h +++ b/objectivec/GPBType.pbobjc.h @@ -1,21 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/type.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import - #import - #import -#else - #import "GPBDescriptor.h" - #import "GPBMessage.h" - #import "GPBRootObject.h" -#endif +#import "GPBDescriptor.h" +#import "GPBMessage.h" +#import "GPBRootObject.h" #if GOOGLE_PROTOBUF_OBJC_VERSION < 30004 #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. diff --git a/objectivec/GPBType.pbobjc.m b/objectivec/GPBType.pbobjc.m index 70dae31c68a0..556df1971165 100644 --- a/objectivec/GPBType.pbobjc.m +++ b/objectivec/GPBType.pbobjc.m @@ -1,29 +1,13 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/type.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif +#import "GPBProtocolBuffers_RuntimeSupport.h" +#import "GPBType.pbobjc.h" +#import "GPBAny.pbobjc.h" +#import "GPBSourceContext.pbobjc.h" #import -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import - #import - #import -#else - #import "GPBType.pbobjc.h" - #import "GPBAny.pbobjc.h" - #import "GPBSourceContext.pbobjc.h" -#endif // @@protoc_insertion_point(imports) #pragma clang diagnostic push diff --git a/objectivec/GPBWrappers.pbobjc.h b/objectivec/GPBWrappers.pbobjc.h index 713bafc89b02..e6741ae120c4 100644 --- a/objectivec/GPBWrappers.pbobjc.h +++ b/objectivec/GPBWrappers.pbobjc.h @@ -1,21 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/wrappers.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import - #import - #import -#else - #import "GPBDescriptor.h" - #import "GPBMessage.h" - #import "GPBRootObject.h" -#endif +#import "GPBDescriptor.h" +#import "GPBMessage.h" +#import "GPBRootObject.h" #if GOOGLE_PROTOBUF_OBJC_VERSION < 30004 #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. diff --git a/objectivec/GPBWrappers.pbobjc.m b/objectivec/GPBWrappers.pbobjc.m index 32201d4d8305..b02a0716e236 100644 --- a/objectivec/GPBWrappers.pbobjc.m +++ b/objectivec/GPBWrappers.pbobjc.m @@ -1,23 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/wrappers.proto -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBWrappers.pbobjc.h" -#endif +#import "GPBProtocolBuffers_RuntimeSupport.h" +#import "GPBWrappers.pbobjc.h" + // @@protoc_insertion_point(imports) #pragma clang diagnostic push diff --git a/src/google/protobuf/compiler/objectivec/objectivec_file.cc b/src/google/protobuf/compiler/objectivec/objectivec_file.cc index e11ca0e24516..163639701d8f 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_file.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_file.cc @@ -245,7 +245,7 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { generation_options_.generate_for_named_framework, generation_options_.named_framework_to_proto_path_mappings_path, generation_options_.runtime_import_prefix, - is_bundled_proto_); + /* include_wkt_imports = */ false); const std::string header_extension(kHeaderExtension); for (int i = 0; i < file_->public_dependency_count(); i++) { import_writer.AddFile(file_->public_dependency(i), header_extension); @@ -340,8 +340,17 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { void FileGenerator::GenerateSource(io::Printer* printer) { // #import the runtime support. + const std::string header_extension(kHeaderExtension); std::vector headers; headers.push_back("GPBProtocolBuffers_RuntimeSupport.h"); + if (is_bundled_proto_) { + headers.push_back("GPB" + FilePathBasename(file_) + header_extension); + for (int i = 0; i < file_->dependency_count(); i++) { + const std::string header_name = + "GPB" + FilePathBasename(file_->dependency(i)) + header_extension; + headers.push_back(header_name); + } + } PrintFileRuntimePreamble(printer, headers); // Enums use atomic in the generated code, so add the system import as needed. @@ -359,8 +368,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) { generation_options_.generate_for_named_framework, generation_options_.named_framework_to_proto_path_mappings_path, generation_options_.runtime_import_prefix, - is_bundled_proto_); - const std::string header_extension(kHeaderExtension); + /* include_wkt_imports = */ false); // #import the header for this proto file. import_writer.AddFile(file_, header_extension); @@ -601,8 +609,26 @@ void FileGenerator::PrintFileRuntimePreamble( "// source: $filename$\n" "\n", "filename", file_->name()); - ImportWriter::PrintRuntimeImports( - printer, headers_to_import, generation_options_.runtime_import_prefix, true); + + if (is_bundled_proto_) { + // This is basically a clone of ImportWriter::PrintRuntimeImports() but + // without the CPP symbol gate, since within the bundled files, that isn't + // needed. + std::string import_prefix = generation_options_.runtime_import_prefix; + if (!import_prefix.empty()) { + import_prefix += "/"; + } + for (const auto& header : headers_to_import) { + printer->Print( + "#import \"$import_prefix$$header$\"\n", + "import_prefix", import_prefix, + "header", header); + } + } else { + ImportWriter::PrintRuntimeImports( + printer, headers_to_import, generation_options_.runtime_import_prefix, true); + } + printer->Print("\n"); }