Skip to content

Commit

Permalink
Use Swift 6 mode on the plugin examples to ensure generated code comp…
Browse files Browse the repository at this point in the history
…iles in this mode (#1740)
  • Loading branch information
thomasvl authored Jan 7, 2025
1 parent f554d76 commit 8d33562
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 26 deletions.
41 changes: 15 additions & 26 deletions PluginExamples/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.8
// swift-tools-version: 6.0

import PackageDescription

Expand All @@ -7,23 +7,7 @@ let package = Package(
dependencies: [
.package(path: "../")
],
targets: targets()
)

private func targets() -> [Target] {
var testDependencies: [Target.Dependency] = [
.target(name: "Simple"),
.target(name: "Nested"),
.target(name: "Import"),
]
#if compiler(>=5.9)
testDependencies.append(.target(name: "AccessLevelOnImport"))
#endif
var targets: [Target] = [
.testTarget(
name: "ExampleTests",
dependencies: testDependencies
),
targets: [
.target(
name: "Simple",
dependencies: [
Expand Down Expand Up @@ -51,9 +35,6 @@ private func targets() -> [Target] {
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
]
),
]
#if compiler(>=5.9)
targets.append(
.target(
name: "AccessLevelOnImport",
dependencies: [
Expand All @@ -65,8 +46,16 @@ private func targets() -> [Target] {
plugins: [
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
]
)
)
#endif
return targets
}
),
.testTarget(
name: "ExampleTests",
dependencies: [
.target(name: "Simple"),
.target(name: "Nested"),
.target(name: "Import"),
.target(name: "AccessLevelOnImport"),
]
),
],
swiftLanguageModes: [.v6]
)
47 changes: 47 additions & 0 deletions PluginExamples/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// swift-tools-version: 5.8

import PackageDescription

let package = Package(
name: "PluginExamples",
dependencies: [
.package(path: "../")
],
targets: [
.testTarget(
name: "ExampleTests",
dependencies: [
.target(name: "Simple"),
.target(name: "Nested"),
.target(name: "Import"),
]
),
.target(
name: "Simple",
dependencies: [
.product(name: "SwiftProtobuf", package: "swift-protobuf")
],
plugins: [
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
]
),
.target(
name: "Nested",
dependencies: [
.product(name: "SwiftProtobuf", package: "swift-protobuf")
],
plugins: [
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
]
),
.target(
name: "Import",
dependencies: [
.product(name: "SwiftProtobuf", package: "swift-protobuf")
],
plugins: [
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
]
),
]
)
60 changes: 60 additions & 0 deletions PluginExamples/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// swift-tools-version: 5.9

import PackageDescription

let package = Package(
name: "PluginExamples",
dependencies: [
.package(path: "../")
],
targets: [
.target(
name: "Simple",
dependencies: [
.product(name: "SwiftProtobuf", package: "swift-protobuf")
],
plugins: [
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
]
),
.target(
name: "Nested",
dependencies: [
.product(name: "SwiftProtobuf", package: "swift-protobuf")
],
plugins: [
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
]
),
.target(
name: "Import",
dependencies: [
.product(name: "SwiftProtobuf", package: "swift-protobuf")
],
plugins: [
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
]
),
.target(
name: "AccessLevelOnImport",
dependencies: [
.product(name: "SwiftProtobuf", package: "swift-protobuf")
],
swiftSettings: [
.enableExperimentalFeature("AccessLevelOnImport")
],
plugins: [
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
]
),
.testTarget(
name: "ExampleTests",
dependencies: [
.target(name: "Simple"),
.target(name: "Nested"),
.target(name: "Import"),
.target(name: "AccessLevelOnImport"),
]
),
]
)
1 change: 1 addition & 0 deletions PluginExamples/Sources/Nested/Nested/Nested.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ syntax = "proto3";

message Nested {
string name = 1;
Nested next = 2;
}

0 comments on commit 8d33562

Please sign in to comment.