-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A recent PR on Swift Package Manager (swiftlang/swift-package-manager#7202) added a `gitInformation` property to the package manifest's `Context` global. This property contains exactly the information we need from the GitStatus plugin. Let's remove it, then! Adopting the `gitInformation` property requires that we drop remaining support for Swift 5.10. We will continue to minimally support it in a separate Package.swift file (where we simply won't have git repo information at build time.) This PR does not strip out other 5.10 support code such as `XCTestScaffold`. Resolves rdar://121529847.
- Loading branch information
Showing
6 changed files
with
187 additions
and
181 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,160 @@ | ||
// swift-tools-version: 5.11 | ||
|
||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2023 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
// | ||
|
||
import PackageDescription | ||
import CompilerPluginSupport | ||
|
||
let package = Package( | ||
name: "swift-testing", | ||
|
||
platforms: [ | ||
.macOS(.v10_15), | ||
.iOS(.v13), | ||
.watchOS(.v6), | ||
.tvOS(.v13), | ||
.macCatalyst(.v13), | ||
.visionOS(.v1), | ||
], | ||
|
||
products: [ | ||
.library( | ||
name: "Testing", | ||
targets: ["Testing"] | ||
), | ||
], | ||
|
||
dependencies: [ | ||
.package(url: "/~https://github.com/apple/swift-syntax.git", from: "509.0.0"), | ||
], | ||
|
||
targets: [ | ||
.target( | ||
name: "Testing", | ||
dependencies: [ | ||
"TestingInternals", | ||
"TestingMacros", | ||
], | ||
cxxSettings: .packageSettings, | ||
swiftSettings: .packageSettings | ||
), | ||
.testTarget( | ||
name: "TestingTests", | ||
dependencies: [ | ||
"Testing", | ||
"_Testing_Foundation", | ||
], | ||
swiftSettings: .packageSettings | ||
), | ||
|
||
.macro( | ||
name: "TestingMacros", | ||
dependencies: [ | ||
.product(name: "SwiftDiagnostics", package: "swift-syntax"), | ||
.product(name: "SwiftSyntax", package: "swift-syntax"), | ||
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"), | ||
.product(name: "SwiftParser", package: "swift-syntax"), | ||
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"), | ||
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"), | ||
], | ||
swiftSettings: .packageSettings + [ | ||
// The only target which needs the ability to import this macro | ||
// implementation target's module is its unit test target. Users of the | ||
// macros this target implements use them via their declarations in the | ||
// Testing module. This target's module is never distributed to users, | ||
// but as an additional guard against accidental misuse, this specifies | ||
// the unit test target as the only allowable client. | ||
.unsafeFlags(["-Xfrontend", "-allowable-client", "-Xfrontend", "TestingMacrosTests"]), | ||
] | ||
), | ||
|
||
// "Support" targets: These contain C family code and are used exclusively | ||
// by other targets above, not directly included in product libraries. | ||
.target( | ||
name: "TestingInternals", | ||
cxxSettings: .packageSettings | ||
), | ||
|
||
// Cross-module overlays (unsupported) | ||
.target( | ||
name: "_Testing_Foundation", | ||
dependencies: [ | ||
"Testing", | ||
], | ||
swiftSettings: .packageSettings | ||
), | ||
], | ||
|
||
cxxLanguageStandard: .cxx20 | ||
) | ||
|
||
// BUG: swift-package-manager-#6367 | ||
#if !os(Windows) | ||
package.targets.append(contentsOf: [ | ||
.testTarget( | ||
name: "TestingMacrosTests", | ||
dependencies: [ | ||
"Testing", | ||
"TestingMacros", | ||
], | ||
swiftSettings: .packageSettings | ||
) | ||
]) | ||
#endif | ||
|
||
extension Array where Element == PackageDescription.SwiftSetting { | ||
/// Settings intended to be applied to every Swift target in this package. | ||
/// Analogous to project-level build settings in an Xcode project. | ||
static var packageSettings: Self { | ||
[ | ||
.unsafeFlags([ | ||
"-require-explicit-sendable", | ||
|
||
"-Xfrontend", "-define-availability", "-Xfrontend", "_mangledTypeNameAPI:macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0", | ||
"-Xfrontend", "-define-availability", "-Xfrontend", "_backtraceAsyncAPI:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0", | ||
"-Xfrontend", "-define-availability", "-Xfrontend", "_clockAPI:macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0", | ||
"-Xfrontend", "-define-availability", "-Xfrontend", "_regexAPI:macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0", | ||
"-Xfrontend", "-define-availability", "-Xfrontend", "_swiftVersionAPI:macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0", | ||
|
||
"-Xfrontend", "-define-availability", "-Xfrontend", "_distantFuture:macOS 99.0, iOS 99.0, watchOS 99.0, tvOS 99.0", | ||
]), | ||
.enableExperimentalFeature("StrictConcurrency"), | ||
.enableUpcomingFeature("ExistentialAny"), | ||
|
||
.enableExperimentalFeature("AccessLevelOnImport"), | ||
.enableUpcomingFeature("InternalImportsByDefault"), | ||
|
||
.define("SWT_TARGET_OS_APPLE", .when(platforms: [.macOS, .iOS, .macCatalyst, .watchOS, .tvOS, .visionOS])), | ||
] | ||
} | ||
} | ||
|
||
extension Array where Element == PackageDescription.CXXSetting { | ||
/// Settings intended to be applied to every C++ target in this package. | ||
/// Analogous to project-level build settings in an Xcode project. | ||
static var packageSettings: Self { | ||
var result = Self() | ||
|
||
// Capture the testing library's version as a C++ string constant. | ||
if let git = Context.gitInformation { | ||
let testingLibraryVersion = if let tag = git.currentTag { | ||
tag | ||
} else if git.hasUncommittedChanges { | ||
"\(git.currentCommit) (modified)" | ||
} else { | ||
git.currentCommit | ||
} | ||
result.append(.define("_SWT_TESTING_LIBRARY_VERSION", to: #""\#(testingLibraryVersion)""#)) | ||
} | ||
|
||
return result | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.