Skip to content

Commit 447bb27

Browse files
committed
Merge remote-tracking branch 'origin/main' into maxd/test-toolchain-argument
2 parents 133fbee + d231c3f commit 447bb27

File tree

166 files changed

+1938
-1390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+1938
-1390
lines changed

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626

2727
Sources/XCBuildSupport/* @jakepetroules
2828

29-
* @bnbarham @MaxDesiatov @tomerd
29+
* @bnbarham @MaxDesiatov @jakepetroules @francescomikulis

Examples/package-info/Package.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// swift-tools-version:5.5
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "package-info",
7+
platforms: [
8+
.macOS(.v12),
9+
.iOS(.v13)
10+
],
11+
dependencies: [
12+
// This just points to the SwiftPM at the root of this repository.
13+
.package(name: "swift-package-manager", path: "../../"),
14+
// You will want to depend on a stable semantic version instead:
15+
// .package(url: "https://github.com/apple/swift-package-manager", .exact("0.4.0"))
16+
],
17+
targets: [
18+
.executableTarget(
19+
name: "package-info",
20+
dependencies: [
21+
.product(name: "SwiftPM", package: "swift-package-manager")
22+
]
23+
),
24+
]
25+
)

Examples/package-info/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# package-info
2+
3+
Sample package built on top of libSwiftPM.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import Basics
2+
import Workspace
3+
4+
@main
5+
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
6+
struct Example {
7+
static func main() async throws {
8+
// PREREQUISITES
9+
// ============
10+
11+
// We need a package to work with.
12+
// This computes the path of this package root based on the file location
13+
let packagePath = try AbsolutePath(validating: #file).parentDirectory.parentDirectory.parentDirectory
14+
15+
// LOADING
16+
// =======
17+
18+
// There are several levels of information available.
19+
// Each takes longer to load than the level above it, but provides more detail.
20+
21+
let observability = ObservabilitySystem({ print("\($0): \($1)") })
22+
23+
let workspace = try Workspace(forRootPackage: packagePath)
24+
25+
let manifest = try await workspace.loadRootManifest(at: packagePath, observabilityScope: observability.topScope)
26+
27+
let package = try await workspace.loadRootPackage(at: packagePath, observabilityScope: observability.topScope)
28+
29+
let graph = try workspace.loadPackageGraph(rootPath: packagePath, observabilityScope: observability.topScope)
30+
31+
// EXAMPLES
32+
// ========
33+
34+
// Manifest
35+
let products = manifest.products.map({ $0.name }).joined(separator: ", ")
36+
print("Products:", products)
37+
38+
let targets = manifest.targets.map({ $0.name }).joined(separator: ", ")
39+
print("Targets:", targets)
40+
41+
// Package
42+
let executables = package.targets.filter({ $0.type == .executable }).map({ $0.name })
43+
print("Executable targets:", executables)
44+
45+
// PackageGraph
46+
let numberOfFiles = graph.reachableTargets.reduce(0, { $0 + $1.sources.paths.count })
47+
print("Total number of source files (including dependencies):", numberOfFiles)
48+
}
49+
}

Fixtures/Miscellaneous/Plugins/DependentPlugins/Package.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ let package = Package(
1010
targets: [
1111
.executableTarget(name: "MyExecutable"),
1212
.executableTarget(name: "MyExecutable2"),
13-
13+
1414
.plugin(
1515
name: "MyPlugin",
1616
capability: .buildTool(),
1717
dependencies: [
1818
"MyExecutable"
1919
]
2020
),
21-
21+
2222
.plugin(
2323
name: "MyPlugin2",
2424
capability: .buildTool(),
@@ -34,5 +34,6 @@ let package = Package(
3434
"MyPlugin2",
3535
]
3636
),
37-
]
37+
],
38+
swiftLanguageVersions: [.v5]
3839
)

Fixtures/Miscellaneous/Plugins/MyBuildToolPluginDependencies/Sources/MySourceGenBuildTool/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ let variableName = URL(fileURLWithPath: inputFile).deletingPathExtension().lastP
1313

1414
let inputData = FileManager.default.contents(atPath: inputFile) ?? Data()
1515
let dataAsHex = inputData.map { String(format: "%02hhx", $0) }.joined()
16-
let outputString = "public var \(variableName) = \(dataAsHex.quotedForSourceCode)\n"
16+
let outputString = "public let \(variableName) = \(dataAsHex.quotedForSourceCode)\n"
1717
let outputData = outputString.data(using: .utf8)
1818
FileManager.default.createFile(atPath: outputFile, contents: outputData)

Fixtures/Miscellaneous/Plugins/MySourceGenPlugin/Sources/MySourceGenBuildTool/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ let variableName = URL(fileURLWithPath: inputFile).deletingPathExtension().lastP
1313

1414
let inputData = FileManager.default.contents(atPath: inputFile) ?? Data()
1515
let dataAsHex = inputData.map { String(format: "%02hhx", $0) }.joined()
16-
let outputString = "public var \(variableName) = \(dataAsHex.quotedForSourceCode)\n"
16+
let outputString = "public let \(variableName) = \(dataAsHex.quotedForSourceCode)\n"
1717
let outputData = outputString.data(using: .utf8)
1818
FileManager.default.createFile(atPath: outputFile, contents: outputData)

Fixtures/Miscellaneous/Plugins/MySourceGenPluginUsingURLBasedAPI/Sources/MySourceGenBuildTool/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ let variableName = URL(fileURLWithPath: inputFile).deletingPathExtension().lastP
1313

1414
let inputData = FileManager.default.contents(atPath: inputFile) ?? Data()
1515
let dataAsHex = inputData.map { String(format: "%02hhx", $0) }.joined()
16-
let outputString = "public var \(variableName) = \(dataAsHex.quotedForSourceCode)\n"
16+
let outputString = "public let \(variableName) = \(dataAsHex.quotedForSourceCode)\n"
1717
let outputData = outputString.data(using: .utf8)
1818
FileManager.default.createFile(atPath: outputFile, contents: outputData)

Fixtures/Miscellaneous/Plugins/PluginWithInternalExecutable/Sources/PluginExecutable/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ let variableName = URL(fileURLWithPath: inputFile).deletingPathExtension().lastP
1212

1313
let inputData = FileManager.default.contents(atPath: inputFile) ?? Data()
1414
let dataAsHex = inputData.map { String(format: "%02hhx", $0) }.joined()
15-
let outputString = "public var \(variableName) = \(dataAsHex.quotedForSourceCode)\n"
15+
let outputString = "public let \(variableName) = \(dataAsHex.quotedForSourceCode)\n"
1616
let outputData = outputString.data(using: .utf8)
1717
FileManager.default.createFile(atPath: outputFile, contents: outputData)

IntegrationTests/Tests/IntegrationTests/BasicTests.swift

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ final class BasicTests: XCTestCase {
1919

2020
func testExamplePackageDealer() throws {
2121
try XCTSkipIf(isSelfHosted, "These packages don't use the latest runtime library, which doesn't work with self-hosted builds.")
22+
try skipUnlessAtLeastSwift6()
2223

2324
try withTemporaryDirectory { tempDir in
2425
let packagePath = tempDir.appending(component: "dealer")
@@ -93,9 +94,7 @@ final class BasicTests: XCTestCase {
9394
}
9495

9596
func testSwiftPackageInitExec() throws {
96-
#if swift(<5.5)
97-
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
98-
#endif
97+
try skipUnlessAtLeastSwift6()
9998

10099
try withTemporaryDirectory { tempDir in
101100
// Create a new package with an executable target.
@@ -122,9 +121,7 @@ final class BasicTests: XCTestCase {
122121
}
123122

124123
func testSwiftPackageInitExecTests() throws {
125-
#if swift(<5.5)
126-
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
127-
#endif
124+
try skipUnlessAtLeastSwift6()
128125

129126
try XCTSkip("FIXME: swift-test invocations are timing out in Xcode and self-hosted CI")
130127

@@ -149,6 +146,8 @@ final class BasicTests: XCTestCase {
149146
}
150147

151148
func testSwiftPackageInitLib() throws {
149+
try skipUnlessAtLeastSwift6()
150+
152151
try withTemporaryDirectory { tempDir in
153152
// Create a new package with an executable target.
154153
let packagePath = tempDir.appending(component: "Project")
@@ -167,6 +166,8 @@ final class BasicTests: XCTestCase {
167166
}
168167

169168
func testSwiftPackageLibsTests() throws {
169+
try skipUnlessAtLeastSwift6()
170+
170171
try XCTSkip("FIXME: swift-test invocations are timing out in Xcode and self-hosted CI")
171172

172173
try withTemporaryDirectory { tempDir in
@@ -225,9 +226,7 @@ final class BasicTests: XCTestCase {
225226
}
226227

227228
func testSwiftRun() throws {
228-
#if swift(<5.5)
229-
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
230-
#endif
229+
try skipUnlessAtLeastSwift6()
231230

232231
try withTemporaryDirectory { tempDir in
233232
let packagePath = tempDir.appending(component: "secho")
@@ -256,6 +255,8 @@ final class BasicTests: XCTestCase {
256255
}
257256

258257
func testSwiftTest() throws {
258+
try skipUnlessAtLeastSwift6()
259+
259260
try XCTSkip("FIXME: swift-test invocations are timing out in Xcode and self-hosted CI")
260261

261262
try withTemporaryDirectory { tempDir in
@@ -377,3 +378,9 @@ private extension Character {
377378
}
378379
}
379380
}
381+
382+
private func skipUnlessAtLeastSwift6() throws {
383+
#if compiler(<6.0)
384+
try XCTSkipIf(true, "Skipping because test requires at least Swift 6.0")
385+
#endif
386+
}

IntegrationTests/Tests/IntegrationTests/SwiftPMTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ final class SwiftPMTests: XCTestCase {
5353
#if !os(macOS)
5454
try XCTSkip("Test requires macOS")
5555
#endif
56+
#if swift(<6.0)
57+
try XCTSkipIf(true, "Skipping because test requires at least Swift 6.0")
58+
#endif
5659

5760
try withTemporaryDirectory { tmpDir in
5861
let packagePath = tmpDir.appending(component: "foo")

Package.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,12 @@ let package = Package(
725725
dependencies: ["XCBuildSupport", "SPMTestSupport"],
726726
exclude: ["Inputs/Foo.pc"]
727727
),
728+
// Examples (These are built to ensure they stay up to date with the API.)
729+
.executableTarget(
730+
name: "package-info",
731+
dependencies: ["Workspace"],
732+
path: "Examples/package-info/Sources/package-info"
733+
)
728734
],
729735
swiftLanguageVersions: [.v5]
730736
)

Sources/Basics/ProgressAnimation/NinjaProgressAnimation.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import protocol TSCBasic.WritableByteStream
1515

1616
extension ProgressAnimation {
1717
/// A ninja-like progress animation that adapts to the provided output stream.
18-
package static func ninja(
18+
@_spi(SwiftPMInternal)
19+
public static func ninja(
1920
stream: WritableByteStream,
2021
verbose: Bool
2122
) -> any ProgressAnimationProtocol {

Sources/Basics/ProgressAnimation/PercentProgressAnimation.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import protocol TSCBasic.WritableByteStream
1515

1616
extension ProgressAnimation {
1717
/// A percent-based progress animation that adapts to the provided output stream.
18-
package static func percent(
18+
@_spi(SwiftPMInternal)
19+
public static func percent(
1920
stream: WritableByteStream,
2021
verbose: Bool,
2122
header: String

Sources/Basics/ProgressAnimation/ProgressAnimationProtocol.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ import class TSCBasic.LocalFileOutputByteStream
1515
import protocol TSCBasic.WritableByteStream
1616
import protocol TSCUtility.ProgressAnimationProtocol
1717

18-
package typealias ProgressAnimationProtocol = TSCUtility.ProgressAnimationProtocol
18+
@_spi(SwiftPMInternal)
19+
public typealias ProgressAnimationProtocol = TSCUtility.ProgressAnimationProtocol
1920

2021
/// Namespace to nest public progress animations under.
21-
package enum ProgressAnimation {
22+
@_spi(SwiftPMInternal)
23+
public enum ProgressAnimation {
2224
/// Dynamically create a progress animation based on the current stream
2325
/// capabilities and desired verbosity.
2426
///

Sources/Basics/ProgressAnimation/ThrottledProgressAnimation.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,27 @@ final class ThrottledProgressAnimation: ProgressAnimationProtocol {
5656
}
5757
}
5858

59+
@_spi(SwiftPMInternal)
5960
extension ProgressAnimationProtocol {
60-
package func throttled<C: Clock>(
61+
@_spi(SwiftPMInternal)
62+
public func throttled<C: Clock>(
6163
now: @escaping () -> C.Instant,
6264
interval: C.Duration,
6365
clock: C.Type = C.self
6466
) -> some ProgressAnimationProtocol {
6567
ThrottledProgressAnimation(self, now: now, interval: interval, clock: clock)
6668
}
6769

68-
package func throttled<C: Clock>(
70+
@_spi(SwiftPMInternal)
71+
public func throttled<C: Clock>(
6972
clock: C,
7073
interval: C.Duration
7174
) -> some ProgressAnimationProtocol {
7275
self.throttled(now: { clock.now }, interval: interval, clock: C.self)
7376
}
7477

75-
package func throttled(
78+
@_spi(SwiftPMInternal)
79+
public func throttled(
7680
interval: ContinuousClock.Duration
7781
) -> some ProgressAnimationProtocol {
7882
self.throttled(clock: ContinuousClock(), interval: interval)

0 commit comments

Comments
 (0)