-
Notifications
You must be signed in to change notification settings - Fork 23
Update to swift v1.38.0 #2472
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
Merged
Merged
Update to swift v1.38.0 #2472
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| * | ||
| !Dockerfile | ||
| !extramoduleimports.patch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # syntax=docker/dockerfile:1.23 | ||
| FROM swift:6.3.2-bookworm@sha256:40918972df286d15aa47f4686c98a211f0a6152ca1d48b3dbccd6f56a3c34815 AS build | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get install -y libstdc++-12-dev unzip | ||
| COPY --link extramoduleimports.patch /app/extramoduleimports.patch | ||
| WORKDIR /app | ||
| RUN git clone --depth 1 --branch 1.38.0 https://github.com/apple/swift-protobuf --recursive | ||
| WORKDIR /app/swift-protobuf | ||
| RUN git apply /app/extramoduleimports.patch | ||
| RUN swift build -c release --static-swift-stdlib -Xlinker -s | ||
|
|
||
| FROM gcr.io/distroless/cc-debian13:latest@sha256:56aaf20ab2523a346a67c8e8f8e8dabe447447d0788b82284d14ad79cd5f93cc AS base | ||
|
|
||
| FROM scratch | ||
| COPY --link --from=base / / | ||
| COPY --link --from=build /app/swift-protobuf/.build/release/protoc-gen-swift . | ||
| USER nobody | ||
| ENTRYPOINT [ "/protoc-gen-swift" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| version: v1 | ||
| name: buf.build/apple/swift | ||
| plugin_version: v1.38.0 | ||
| source_url: https://github.com/apple/swift-protobuf | ||
| integration_guide_url: https://github.com/apple/swift-protobuf#getting-started | ||
| description: Base types for Swift. Generates message and enum types. | ||
| output_languages: | ||
| - swift | ||
| registry: | ||
| swift: | ||
| deps: | ||
| - source: https://github.com/apple/swift-protobuf.git | ||
| package: swift-protobuf | ||
| swift_versions: [ ".v6" ] | ||
| products: [ SwiftProtobuf ] | ||
| version: 1.38.0 | ||
| opts: | ||
| - Visibility=Public | ||
| - FileNaming=PathToUnderscores | ||
| spdx_license_id: Apache-2.0 | ||
| license_url: https://github.com/apple/swift-protobuf/blob/1.38.0/LICENSE.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| diff --git a/Sources/protoc-gen-swift/FileGenerator.swift b/Sources/protoc-gen-swift/FileGenerator.swift | ||
| index d370e25..cea7bd2 100644 | ||
| --- a/Sources/protoc-gen-swift/FileGenerator.swift | ||
| +++ b/Sources/protoc-gen-swift/FileGenerator.swift | ||
| @@ -161,6 +161,14 @@ class FileGenerator { | ||
| return | ||
| } | ||
|
|
||
| + let neededCustomImports = generatorOptions.extraModuleImports | ||
| + if !neededCustomImports.isEmpty { | ||
| + p.print() | ||
| + for i in neededCustomImports { | ||
| + p.print("import \(i)\n") | ||
| + } | ||
| + } | ||
| + | ||
| p.print() | ||
| generateVersionCheck(printer: &p) | ||
|
|
||
| diff --git a/Sources/protoc-gen-swift/GeneratorOptions.swift b/Sources/protoc-gen-swift/GeneratorOptions.swift | ||
| index 159e621..a8f631e 100644 | ||
| --- a/Sources/protoc-gen-swift/GeneratorOptions.swift | ||
| +++ b/Sources/protoc-gen-swift/GeneratorOptions.swift | ||
| @@ -115,6 +115,7 @@ package class GeneratorOptions { | ||
| } | ||
| } | ||
|
|
||
| + let extraModuleImports: [String] | ||
| let outputNaming: OutputNaming | ||
| let enumGeneration: EnumGeneration | ||
| let protoToModuleMappings: ProtoFileToModuleMappings | ||
| @@ -146,6 +147,7 @@ package class GeneratorOptions { | ||
| } | ||
|
|
||
| package init(parameter: any CodeGeneratorParameter) throws { | ||
| + var externalModuleImports: [String] = [] | ||
| var outputNaming: OutputNaming = .fullPath | ||
| var enumGeneration: EnumGeneration = .none | ||
| var moduleMapPath: String? | ||
| @@ -238,6 +240,15 @@ package class GeneratorOptions { | ||
| value: pair.value | ||
| ) | ||
| } | ||
| + case "ExtraModuleImports": | ||
| + if !pair.value.isEmpty { | ||
| + externalModuleImports.append(pair.value) | ||
| + } else { | ||
| + throw GenerationError.invalidParameterValue( | ||
| + name: pair.key, | ||
| + value: pair.value | ||
| + ) | ||
| + } | ||
| default: | ||
| throw GenerationError.unknownParameter(name: pair.key) | ||
| } | ||
| @@ -272,6 +283,7 @@ package class GeneratorOptions { | ||
| visibilitySourceSnippet = "package " | ||
| } | ||
|
|
||
| + self.extraModuleImports = externalModuleImports | ||
| self.experimentalStripNonfunctionalCodegen = experimentalStripNonfunctionalCodegen | ||
| self.experimentalHiddenNames = experimentalHiddenNames | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| h1:qeyF/DAfv+fz8bCazdKuLL5Bjrrp1/xTp7aS3oCwqeI= |
1 change: 1 addition & 0 deletions
1
tests/testdata/buf.build/apple/swift/v1.38.0/petapis/plugin.sum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| h1:3NaCKHGNbSrmK831WmWSaoWMEVq5dt45Fok8MEgOcgU= |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to regenerate this as the previous patch failed to apply cleanly to the new version.