Skip to content

Commit

Permalink
Split the Package.swift files for CompileTests.
Browse files Browse the repository at this point in the history
Provide Swift version specifics, ensure under v6 it uses v6 mode to
ensure things compile cleanly there.
  • Loading branch information
thomasvl committed Jan 7, 2025
1 parent 8208b8d commit 4edbcbd
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 20 deletions.
21 changes: 3 additions & 18 deletions CompileTests/InternalImportsByDefault/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

// Package.swift
//
Expand All @@ -10,7 +10,6 @@

import PackageDescription

#if compiler(>=5.9)
let package = Package(
name: "CompileTests",
dependencies: [
Expand All @@ -37,20 +36,6 @@ let package = Package(
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
]
)
]
)
#else
let package = Package(
name: "CompileTests",
targets: [
.executableTarget(
name: "InternalImportsByDefault",
exclude: [
"swift-protobuf-config.json",
"Protos/SomeProtoWithBytes.proto",
"Protos/ServiceOnly.proto",
]
)
]
],
swiftLanguageModes: [.v6]
)
#endif
25 changes: 25 additions & 0 deletions CompileTests/InternalImportsByDefault/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// swift-tools-version: 5.8

// Package.swift
//
// Copyright (c) 2024 Apple Inc. and the project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See LICENSE.txt for license information:
// https://github.com/apple/swift-protobuf/blob/main/LICENSE.txt

import PackageDescription

let package = Package(
name: "CompileTests",
targets: [
.executableTarget(
name: "InternalImportsByDefault",
exclude: [
"swift-protobuf-config.json",
"Protos/SomeProtoWithBytes.proto",
"Protos/ServiceOnly.proto",
]
)
]
)
40 changes: 40 additions & 0 deletions CompileTests/InternalImportsByDefault/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// swift-tools-version: 5.9

// Package.swift
//
// Copyright (c) 2024 Apple Inc. and the project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See LICENSE.txt for license information:
// https://github.com/apple/swift-protobuf/blob/main/LICENSE.txt

import PackageDescription

let package = Package(
name: "CompileTests",
dependencies: [
.package(path: "../..")
],
targets: [
.executableTarget(
name: "InternalImportsByDefault",
dependencies: [
.product(name: "SwiftProtobuf", package: "swift-protobuf")
],
exclude: [
"Protos/SomeProtoWithBytes.proto",
"Protos/ServiceOnly.proto",
],
swiftSettings: [
.enableExperimentalFeature("InternalImportsByDefault"),
.enableExperimentalFeature("AccessLevelOnImport"),
// Enable warnings as errors so the build fails if warnings are
// present in generated code.
.unsafeFlags(["-warnings-as-errors"]),
],
plugins: [
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
]
)
]
)
5 changes: 3 additions & 2 deletions CompileTests/MultiModule/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.6
// swift-tools-version: 6.0

import PackageDescription

Expand Down Expand Up @@ -36,5 +36,6 @@ let package = Package(
.target(name: "ImportsAPublicly"),
]
),
]
],
swiftLanguageModes: [.v6]
)
40 changes: 40 additions & 0 deletions CompileTests/MultiModule/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// swift-tools-version: 5.8

import PackageDescription

let package = Package(
name: "CompileTests",
dependencies: [
.package(name: "swift-protobuf", path: "../..")
],
targets: [
.testTarget(
name: "Test1",
dependencies: ["ImportsAPublicly"]
),
.testTarget(
name: "Test2",
dependencies: ["ImportsImportsAPublicly"]
),
.target(
name: "ModuleA",
dependencies: [
.product(name: "SwiftProtobuf", package: "swift-protobuf")
]
),
.target(
name: "ImportsAPublicly",
dependencies: [
.product(name: "SwiftProtobuf", package: "swift-protobuf"),
.target(name: "ModuleA"),
]
),
.target(
name: "ImportsImportsAPublicly",
dependencies: [
.product(name: "SwiftProtobuf", package: "swift-protobuf"),
.target(name: "ImportsAPublicly"),
]
),
]
)
40 changes: 40 additions & 0 deletions CompileTests/MultiModule/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// swift-tools-version: 5.9

import PackageDescription

let package = Package(
name: "CompileTests",
dependencies: [
.package(name: "swift-protobuf", path: "../..")
],
targets: [
.testTarget(
name: "Test1",
dependencies: ["ImportsAPublicly"]
),
.testTarget(
name: "Test2",
dependencies: ["ImportsImportsAPublicly"]
),
.target(
name: "ModuleA",
dependencies: [
.product(name: "SwiftProtobuf", package: "swift-protobuf")
]
),
.target(
name: "ImportsAPublicly",
dependencies: [
.product(name: "SwiftProtobuf", package: "swift-protobuf"),
.target(name: "ModuleA"),
]
),
.target(
name: "ImportsImportsAPublicly",
dependencies: [
.product(name: "SwiftProtobuf", package: "swift-protobuf"),
.target(name: "ImportsAPublicly"),
]
),
]
)

0 comments on commit 4edbcbd

Please sign in to comment.