Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split SwiftProtobuf into SwiftProtobufCore & SwiftProtobufFoundationCompat #1331

Merged
merged 7 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DevTools/LibraryVersions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
_PODSPEC_PATH = os.path.join(_PROJECT_ROOT, 'SwiftProtobuf.podspec')
_VERSION_SWIFT_PATH = os.path.join(_PROJECT_ROOT, 'Sources/SwiftProtobuf/Version.swift')
_VERSION_SWIFT_PATH = os.path.join(_PROJECT_ROOT, 'Sources/SwiftProtobufCore/Version.swift')

def Fail(message):
sys.stderr.write('Error: %s\n' % message)
Expand Down
1,088 changes: 544 additions & 544 deletions FuzzTesting/Sources/FuzzCommon/fuzz_testing.pb.swift

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ regenerate-library-protos: build ${PROTOC_GEN_SWIFT}
${GENERATE_SRCS} \
--tfiws_opt=FileNaming=DropPath \
--tfiws_opt=Visibility=Public \
--tfiws_out=Sources/SwiftProtobuf \
--tfiws_out=Sources/SwiftProtobufCore \
${LIBRARY_PROTOS}

# Rebuild just the protos used by the plugin
Expand Down Expand Up @@ -411,7 +411,7 @@ Tests/protoc-gen-swiftTests/DescriptorTestData.swift: build ${PROTOC_GEN_SWIFT}
# public protocol, struct, enum, or class name, as well as every
# method or property defined in a public protocol, struct, or class.
# It also gives us a large collection of Swift names.
Protos/mined_words.txt: Sources/SwiftProtobuf/*.swift
Protos/mined_words.txt: Sources/SwiftProtobufCore/*.swift
@echo Building $@
@cat $^ | \
grep -E '\b(public|func|var)\b' | \
Expand Down
12 changes: 10 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,17 @@ let package = Package(
],
targets: [
.target(
name: "SwiftProtobuf",
name: "SwiftProtobufCore",
exclude: ["CMakeLists.txt"]
),
.target(
name: "SwiftProtobufFoundationCompat",
dependencies: ["SwiftProtobufCore"]
),
.target(
name: "SwiftProtobuf",
dependencies: ["SwiftProtobufCore", "SwiftProtobufFoundationCompat"]
),
.target(
name: "SwiftProtobufPluginLibrary",
dependencies: ["SwiftProtobuf"],
Expand Down Expand Up @@ -67,7 +75,7 @@ let package = Package(
),
.testTarget(
name: "SwiftProtobufTests",
dependencies: ["SwiftProtobuf"]
dependencies: ["SwiftProtobuf", "SwiftProtobufCore"]
),
.testTarget(
name: "SwiftProtobufPluginLibraryTests",
Expand Down
6 changes: 5 additions & 1 deletion Package@swift-5.0.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ let package = Package(
.library(name: "SwiftProtobufPluginLibrary", targets: ["SwiftProtobufPluginLibrary"]),
],
targets: [
.target(name: "SwiftProtobuf"),
.target(name: "SwiftProtobufCore"),
.target(name: "SwiftProtobufFoundationCompat",
dependencies: ["SwiftProtobufCore"]),
.target(name: "SwiftProtobuf",
dependencies: ["SwiftProtobufCore", "SwiftProtobufFoundationCompat"]),
.target(name: "SwiftProtobufPluginLibrary",
dependencies: ["SwiftProtobuf"]),
.target(name: "SwiftProtobufTestHelpers",
Expand Down
6 changes: 5 additions & 1 deletion Package@swift-5.1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ let package = Package(
.library(name: "SwiftProtobufPluginLibrary", targets: ["SwiftProtobufPluginLibrary"]),
],
targets: [
.target(name: "SwiftProtobuf"),
.target(name: "SwiftProtobufCore"),
.target(name: "SwiftProtobufFoundationCompat",
dependencies: ["SwiftProtobufCore"]),
.target(name: "SwiftProtobuf",
dependencies: ["SwiftProtobufCore", "SwiftProtobufFoundationCompat"]),
.target(name: "SwiftProtobufPluginLibrary",
dependencies: ["SwiftProtobuf"]),
.target(name: "SwiftProtobufTestHelpers",
Expand Down
6 changes: 5 additions & 1 deletion Package@swift-5.2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ let package = Package(
.library(name: "SwiftProtobufPluginLibrary", targets: ["SwiftProtobufPluginLibrary"]),
],
targets: [
.target(name: "SwiftProtobuf"),
.target(name: "SwiftProtobufCore"),
.target(name: "SwiftProtobufFoundationCompat",
dependencies: ["SwiftProtobufCore"]),
.target(name: "SwiftProtobuf",
dependencies: ["SwiftProtobufCore", "SwiftProtobufFoundationCompat"]),
.target(name: "SwiftProtobufPluginLibrary",
dependencies: ["SwiftProtobuf"]),
.target(name: "SwiftProtobufTestHelpers",
Expand Down
6 changes: 5 additions & 1 deletion Package@swift-5.3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ let package = Package(
.library(name: "SwiftProtobufPluginLibrary", targets: ["SwiftProtobufPluginLibrary"]),
],
targets: [
.target(name: "SwiftProtobuf"),
.target(name: "SwiftProtobufCore"),
.target(name: "SwiftProtobufFoundationCompat",
dependencies: ["SwiftProtobufCore"]),
.target(name: "SwiftProtobuf",
dependencies: ["SwiftProtobufCore", "SwiftProtobufFoundationCompat"]),
.target(name: "SwiftProtobufPluginLibrary",
dependencies: ["SwiftProtobuf"]),
.target(name: "SwiftProtobufTestHelpers",
Expand Down
6 changes: 5 additions & 1 deletion Package@swift-5.4.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ let package = Package(
.library(name: "SwiftProtobufPluginLibrary", targets: ["SwiftProtobufPluginLibrary"]),
],
targets: [
.target(name: "SwiftProtobuf"),
.target(name: "SwiftProtobufCore"),
.target(name: "SwiftProtobufFoundationCompat",
dependencies: ["SwiftProtobufCore"]),
.target(name: "SwiftProtobuf",
dependencies: ["SwiftProtobufCore", "SwiftProtobufFoundationCompat"]),
.target(name: "SwiftProtobufPluginLibrary",
dependencies: ["SwiftProtobuf"]),
.target(name: "SwiftProtobufTestHelpers",
Expand Down
6 changes: 5 additions & 1 deletion Package@swift-5.5.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ let package = Package(
.library(name: "SwiftProtobufPluginLibrary", targets: ["SwiftProtobufPluginLibrary"]),
],
targets: [
.target(name: "SwiftProtobuf"),
.target(name: "SwiftProtobufCore"),
.target(name: "SwiftProtobufFoundationCompat",
dependencies: ["SwiftProtobufCore"]),
.target(name: "SwiftProtobuf",
dependencies: ["SwiftProtobufCore", "SwiftProtobufFoundationCompat"]),
.target(name: "SwiftProtobufPluginLibrary",
dependencies: ["SwiftProtobuf"]),
.target(name: "SwiftProtobufTestHelpers",
Expand Down
2 changes: 1 addition & 1 deletion Protos/generated_swift_names_enum_cases.proto
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ enum GeneratedSwiftReservedEnum {
subVisitor = 735;
Swift = 736;
swiftPrefix = 737;
SwiftProtobuf = 738;
SwiftProtobufCore = 738;
syntax = 739;
T = 740;
tag = 741;
Expand Down
2 changes: 1 addition & 1 deletion Protos/generated_swift_names_enums.proto
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ message GeneratedSwiftReservedEnums {
enum subVisitor { NONE_subVisitor = 0; }
enum Swift { NONE_Swift = 0; }
enum swiftPrefix { NONE_swiftPrefix = 0; }
enum SwiftProtobuf { NONE_SwiftProtobuf = 0; }
enum SwiftProtobufCore { NONE_SwiftProtobufCore = 0; }
enum syntax { NONE_syntax = 0; }
enum T { NONE_T = 0; }
enum tag { NONE_tag = 0; }
Expand Down
2 changes: 1 addition & 1 deletion Protos/generated_swift_names_fields.proto
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ message GeneratedSwiftReservedFields {
int32 subVisitor = 735;
int32 Swift = 736;
int32 swiftPrefix = 737;
int32 SwiftProtobuf = 738;
int32 SwiftProtobufCore = 738;
int32 syntax = 739;
int32 T = 740;
int32 tag = 741;
Expand Down
2 changes: 1 addition & 1 deletion Protos/generated_swift_names_messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ message GeneratedSwiftReservedMessages {
message subVisitor { int32 subVisitor = 1; }
message Swift { int32 Swift = 1; }
message swiftPrefix { int32 swiftPrefix = 1; }
message SwiftProtobuf { int32 SwiftProtobuf = 1; }
message SwiftProtobufCore { int32 SwiftProtobufCore = 1; }
message syntax { int32 syntax = 1; }
message T { int32 T = 1; }
message tag { int32 tag = 1; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,34 @@
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors

import Foundation
import SwiftProtobuf
import SwiftProtobufCore

// If the compiler emits an error on this type, it is because this file
// was generated by a version of the `protoc` Swift plug-in that is
// incompatible with the version of SwiftProtobuf to which you are linking.
// Please ensure that you are building against the same version of the API
// that was used to generate this file.
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
struct _3: SwiftProtobuf.ProtobufAPIVersion_3 {}
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobufCore.ProtobufAPIVersionCheck {
struct _3: SwiftProtobufCore.ProtobufAPIVersion_3 {}
typealias Version = _3
}

/// Configuration used to define the mappings for generated proto files
/// to the Swift module they will be included in.
struct SwiftProtobuf_GenSwift_ModuleMappings {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// SwiftProtobufCore.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.

/// The mappings.
var mapping: [SwiftProtobuf_GenSwift_ModuleMappings.Entry] = []

var unknownFields = SwiftProtobuf.UnknownStorage()
var unknownFields = SwiftProtobufCore.UnknownStorage()

/// Individual listing of the module name and the files that will go
/// into it.
struct Entry {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// SwiftProtobufCore.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.

Expand All @@ -59,7 +59,7 @@ struct SwiftProtobuf_GenSwift_ModuleMappings {
/// or `path/to/file.proto`.
var protoFilePath: [String] = []

var unknownFields = SwiftProtobuf.UnknownStorage()
var unknownFields = SwiftProtobufCore.UnknownStorage()

init() {}
}
Expand All @@ -76,13 +76,13 @@ extension SwiftProtobuf_GenSwift_ModuleMappings.Entry: @unchecked Sendable {}

fileprivate let _protobuf_package = "swift_protobuf.gen_swift"

extension SwiftProtobuf_GenSwift_ModuleMappings: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
extension SwiftProtobuf_GenSwift_ModuleMappings: SwiftProtobufCore.Message, SwiftProtobufCore._MessageImplementationBase, SwiftProtobufCore._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".ModuleMappings"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
static let _protobuf_nameMap: SwiftProtobufCore._NameMap = [
1: .same(proto: "mapping"),
]

mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
mutating func decodeMessage<D: SwiftProtobufCore.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
Expand All @@ -94,7 +94,7 @@ extension SwiftProtobuf_GenSwift_ModuleMappings: SwiftProtobuf.Message, SwiftPro
}
}

func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
func traverse<V: SwiftProtobufCore.Visitor>(visitor: inout V) throws {
if !self.mapping.isEmpty {
try visitor.visitRepeatedMessageField(value: self.mapping, fieldNumber: 1)
}
Expand All @@ -108,14 +108,14 @@ extension SwiftProtobuf_GenSwift_ModuleMappings: SwiftProtobuf.Message, SwiftPro
}
}

extension SwiftProtobuf_GenSwift_ModuleMappings.Entry: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
extension SwiftProtobuf_GenSwift_ModuleMappings.Entry: SwiftProtobufCore.Message, SwiftProtobufCore._MessageImplementationBase, SwiftProtobufCore._ProtoNameProviding {
static let protoMessageName: String = SwiftProtobuf_GenSwift_ModuleMappings.protoMessageName + ".Entry"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
static let _protobuf_nameMap: SwiftProtobufCore._NameMap = [
1: .standard(proto: "module_name"),
2: .standard(proto: "proto_file_path"),
]

mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
mutating func decodeMessage<D: SwiftProtobufCore.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
Expand All @@ -128,7 +128,7 @@ extension SwiftProtobuf_GenSwift_ModuleMappings.Entry: SwiftProtobuf.Message, Sw
}
}

func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
func traverse<V: SwiftProtobufCore.Visitor>(visitor: inout V) throws {
if !self.moduleName.isEmpty {
try visitor.visitSingularStringField(value: self.moduleName, fieldNumber: 1)
}
Expand Down
Loading