Skip to content

Commit 371744e

Browse files
authored
Add protoc product (#1836)
1 parent c036968 commit 371744e

File tree

3 files changed

+115
-2
lines changed

3 files changed

+115
-2
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,12 @@ test-plugin: build ${PROTOC_GEN_SWIFT}
209209

210210
# Test the SPM plugin.
211211
test-spm-plugin:
212-
env PROTOC_PATH=$(shell realpath ${PROTOC}) ${SWIFT} test --package-path PluginExamples
212+
@SWIFT_VERSION=$$(${SWIFT} --version | head -n1 | sed 's/.*Swift version \([0-9]*\)\..*/\1/'); \
213+
if [ "$$SWIFT_VERSION" -lt 6 ]; then \
214+
env PROTOC_PATH=$$(realpath ${PROTOC}) ${SWIFT} test --package-path PluginExamples; \
215+
else \
216+
${SWIFT} test --package-path PluginExamples; \
217+
fi
213218

214219
compile-tests: \
215220
compile-tests-multimodule \

Package.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ let package = Package(
1818
name: "protoc-gen-swift",
1919
targets: ["protoc-gen-swift"]
2020
),
21+
.executable(
22+
name: "protoc",
23+
targets: ["protoc"]
24+
),
2125
.library(
2226
name: "SwiftProtobuf",
2327
targets: ["SwiftProtobuf"]
@@ -50,6 +54,12 @@ let package = Package(
5054
dependencies: ["SwiftProtobuf"],
5155
swiftSettings: .packageSettings
5256
),
57+
.binaryTarget(
58+
name: "protoc",
59+
url:
60+
"https://github.com/apple/swift-protobuf/releases/download/protoc-artifactbundle-v31.1/protoc-31.1.artifactbundle.zip",
61+
checksum: "f18bf2cfbbebd83133a4c29733b01871e3afdc73c102d62949a841d4f9bab86f"
62+
),
5363
.executableTarget(
5464
name: "protoc-gen-swift",
5565
dependencies: ["SwiftProtobufPluginLibrary", "SwiftProtobuf"],
@@ -65,7 +75,7 @@ let package = Package(
6575
.plugin(
6676
name: "SwiftProtobufPlugin",
6777
capability: .buildTool(),
68-
dependencies: ["protoc-gen-swift"]
78+
dependencies: ["protoc-gen-swift", "protoc"]
6979
),
7080
.testTarget(
7181
name: "SwiftProtobufTests",

[email protected]

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// swift-tools-version:5.10
2+
3+
// Package.swift
4+
//
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See LICENSE.txt for license information:
9+
// https://github.com/apple/swift-protobuf/blob/main/LICENSE.txt
10+
//
11+
12+
import PackageDescription
13+
14+
let package = Package(
15+
name: "SwiftProtobuf",
16+
products: [
17+
.executable(
18+
name: "protoc-gen-swift",
19+
targets: ["protoc-gen-swift"]
20+
),
21+
.library(
22+
name: "SwiftProtobuf",
23+
targets: ["SwiftProtobuf"]
24+
),
25+
.library(
26+
name: "SwiftProtobufPluginLibrary",
27+
targets: ["SwiftProtobufPluginLibrary"]
28+
),
29+
.plugin(
30+
name: "SwiftProtobufPlugin",
31+
targets: ["SwiftProtobufPlugin"]
32+
),
33+
],
34+
targets: [
35+
.target(
36+
name: "SwiftProtobuf",
37+
exclude: ["CMakeLists.txt"],
38+
resources: [.copy("PrivacyInfo.xcprivacy")],
39+
swiftSettings: .packageSettings
40+
),
41+
.target(
42+
name: "SwiftProtobufPluginLibrary",
43+
dependencies: ["SwiftProtobuf"],
44+
exclude: ["CMakeLists.txt"],
45+
resources: [.copy("PrivacyInfo.xcprivacy")],
46+
swiftSettings: .packageSettings
47+
),
48+
.target(
49+
name: "SwiftProtobufTestHelpers",
50+
dependencies: ["SwiftProtobuf"],
51+
swiftSettings: .packageSettings
52+
),
53+
.executableTarget(
54+
name: "protoc-gen-swift",
55+
dependencies: ["SwiftProtobufPluginLibrary", "SwiftProtobuf"],
56+
exclude: ["CMakeLists.txt"],
57+
swiftSettings: .packageSettings
58+
),
59+
.executableTarget(
60+
name: "Conformance",
61+
dependencies: ["SwiftProtobuf"],
62+
exclude: ["failure_list_swift.txt", "text_format_failure_list_swift.txt"],
63+
swiftSettings: .packageSettings
64+
),
65+
.plugin(
66+
name: "SwiftProtobufPlugin",
67+
capability: .buildTool(),
68+
dependencies: ["protoc-gen-swift"]
69+
),
70+
.testTarget(
71+
name: "SwiftProtobufTests",
72+
dependencies: ["SwiftProtobuf"],
73+
swiftSettings: .packageSettings
74+
),
75+
.testTarget(
76+
name: "SwiftProtobufPluginLibraryTests",
77+
dependencies: ["SwiftProtobufPluginLibrary", "SwiftProtobufTestHelpers"],
78+
swiftSettings: .packageSettings
79+
),
80+
.testTarget(
81+
name: "protoc-gen-swiftTests",
82+
dependencies: ["protoc-gen-swift", "SwiftProtobufTestHelpers"],
83+
swiftSettings: .packageSettings
84+
),
85+
],
86+
swiftLanguageVersions: [.v5]
87+
)
88+
89+
// Settings for every Swift target in this package, like project-level settings
90+
// in an Xcode project.
91+
extension Array where Element == PackageDescription.SwiftSetting {
92+
static var packageSettings: Self {
93+
[
94+
.enableExperimentalFeature("StrictConcurrency=complete"),
95+
.enableUpcomingFeature("ExistentialAny"),
96+
]
97+
}
98+
}

0 commit comments

Comments
 (0)