Skip to content

Commit 1b060a3

Browse files
authored
Enable InternalImportsByDefault in remaining modules (#2042)
This PR enables `InternalImportsByDefault` on `GRPCHealth` and `InteroperabilityTests`. It also regenerates the protos with the latest version of swift-protobuf (v1.28.1), and increases its min version to 1.28.1 to make sure that we don't get build failures when using earlier generators.
1 parent d4d1a2e commit 1b060a3

File tree

9 files changed

+25
-17
lines changed

9 files changed

+25
-17
lines changed

Package@swift-6.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,8 @@ extension Target {
550550
],
551551
swiftSettings: [
552552
.swiftLanguageMode(.v6),
553-
.enableUpcomingFeature("ExistentialAny")
553+
.enableUpcomingFeature("ExistentialAny"),
554+
.enableUpcomingFeature("InternalImportsByDefault")
554555
]
555556
)
556557
}
@@ -950,7 +951,8 @@ extension Target {
950951
path: "Sources/Services/Health",
951952
swiftSettings: [
952953
.swiftLanguageMode(.v6),
953-
.enableUpcomingFeature("ExistentialAny")
954+
.enableUpcomingFeature("ExistentialAny"),
955+
.enableUpcomingFeature("InternalImportsByDefault")
954956
]
955957
)
956958
}

Protos/generate.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ bin_path=$(swift build -c release --show-bin-path)
2929
protoc_gen_swift="$bin_path/protoc-gen-swift"
3030
protoc_generate_grpc_swift="$bin_path/protoc-gen-grpc-swift"
3131

32-
# Genreates gRPC by invoking protoc with the gRPC Swift plugin.
32+
# Generates gRPC by invoking protoc with the gRPC Swift plugin.
3333
# Parameters:
3434
# - $1: .proto file
3535
# - $2: proto path
@@ -46,7 +46,7 @@ function generate_grpc {
4646
invoke_protoc "${args[@]}" "$proto"
4747
}
4848

49-
# Genreates messages by invoking protoc with the Swift plugin.
49+
# Generates messages by invoking protoc with the Swift plugin.
5050
# Parameters:
5151
# - $1: .proto file
5252
# - $2: proto path
@@ -228,8 +228,8 @@ function generate_service_messages_interop_tests {
228228
local output="$root/Sources/InteroperabilityTests/Generated"
229229

230230
for proto in "${protos[@]}"; do
231-
generate_message "$proto" "$here/tests/interoperability" "$output" "Visibility=Public" "FileNaming=DropPath"
232-
generate_grpc "$proto" "$here/tests/interoperability" "$output" "Visibility=Public" "Server=true" "_V2=true" "FileNaming=DropPath"
231+
generate_message "$proto" "$here/tests/interoperability" "$output" "Visibility=Public" "FileNaming=DropPath" "UseAccessLevelOnImports=true"
232+
generate_grpc "$proto" "$here/tests/interoperability" "$output" "Visibility=Public" "Server=true" "_V2=true" "FileNaming=DropPath" "UseAccessLevelOnImports=true"
233233
done
234234
}
235235

@@ -260,8 +260,8 @@ function generate_health_service {
260260
local proto="$here/upstream/grpc/health/v1/health.proto"
261261
local output="$root/Sources/Services/Health/Generated"
262262

263-
generate_message "$proto" "$(dirname "$proto")" "$output" "Visibility=Package"
264-
generate_grpc "$proto" "$(dirname "$proto")" "$output" "Visibility=Package" "Client=true" "Server=true" "_V2=true"
263+
generate_message "$proto" "$(dirname "$proto")" "$output" "Visibility=Package" "UseAccessLevelOnImports=true"
264+
generate_grpc "$proto" "$(dirname "$proto")" "$output" "Visibility=Package" "Client=true" "Server=true" "_V2=true" "UseAccessLevelOnImports=true"
265265
}
266266

267267
#------------------------------------------------------------------------------

Sources/InteroperabilityTests/Generated/empty.pb.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
// See the License for the specific language governing permissions and
2323
// limitations under the License.
2424

25-
import SwiftProtobuf
25+
public import SwiftProtobuf
2626

2727
// If the compiler emits an error on this type, it is because this file
2828
// was generated by a version of the `protoc` Swift plug-in that is

Sources/InteroperabilityTests/Generated/messages.pb.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
// Message definitions to be used by integration test service definitions.
2626

27-
import Foundation
28-
import SwiftProtobuf
27+
public import Foundation
28+
public import SwiftProtobuf
2929

3030
// If the compiler emits an error on this type, it is because this file
3131
// was generated by a version of the `protoc` Swift plug-in that is

Sources/InteroperabilityTests/InteroperabilityTestCase.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import GRPCCore
16+
public import GRPCCore
1717

1818
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
1919
public protocol InteroperabilityTest {

Sources/InteroperabilityTests/InteroperabilityTestCases.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17-
import GRPCCore
17+
internal import GRPCCore
1818

19-
import struct Foundation.Data
19+
private import struct Foundation.Data
2020

2121
/// This test verifies that implementations support zero-size messages. Ideally, client
2222
/// implementations would verify that the request and response were zero bytes serialized, but

Sources/InteroperabilityTests/TestService.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
import Foundation
18-
import GRPCCore
17+
private import Foundation
18+
public import GRPCCore
1919

2020
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
2121
public struct TestService: Grpc_Testing_TestService.ServiceProtocol {

Sources/Services/Health/Generated/health.pb.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
// The canonical version of this proto can be found at
2626
// https://github.com/grpc/grpc-proto/blob/master/grpc/health/v1/health.proto
2727

28-
import SwiftProtobuf
28+
package import SwiftProtobuf
2929

3030
// If the compiler emits an error on this type, it is because this file
3131
// was generated by a version of the `protoc` Swift plug-in that is

Sources/protoc-gen-grpc-swift/Options.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,16 @@ struct GeneratorOptions {
7474
private(set) var gRPCModuleName = "GRPC"
7575
private(set) var swiftProtobufModuleName = "SwiftProtobuf"
7676
private(set) var generateReflectionData = false
77+
7778
#if compiler(>=6.0)
7879
private(set) var v2 = false
7980
#endif
81+
82+
#if compiler(>=6.0)
8083
private(set) var useAccessLevelOnImports = true
84+
#else
85+
private(set) var useAccessLevelOnImports = false
86+
#endif
8187

8288
init(parameter: any CodeGeneratorParameter) throws {
8389
try self.init(pairs: parameter.parsedPairs)

0 commit comments

Comments
 (0)