Skip to content

[6.0] Cherry-pick recent NFC changes to reduce merge conflicts #7721

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 9 commits into from
Jun 27, 2024
Merged
2 changes: 1 addition & 1 deletion CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ needs to be listed here.
- Quinn McHenry <[email protected]>
- Rahul Malik <[email protected]>
- Randy Becker <[email protected]>
- Rauhul Varma <rauhul@users.noreply.github.com>
- Rauhul Varma <rauhul@apple.com>
- Renzo Crisóstomo <[email protected]>
- Rich Ellis <[email protected]>
- Rick Ballard <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions Examples/package-info/Sources/package-info/example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ struct Example {
print("Targets:", targets)

// Package
let executables = package.targets.filter({ $0.type == .executable }).map({ $0.name })
let executables = package.modules.filter({ $0.type == .executable }).map({ $0.name })
print("Executable targets:", executables)

// PackageGraph
let numberOfFiles = graph.reachableTargets.reduce(0, { $0 + $1.sources.paths.count })
let numberOfFiles = graph.reachableModules.reduce(0, { $0 + $1.sources.paths.count })
print("Total number of source files (including dependencies):", numberOfFiles)
}
}
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ let package = Package(
"SPMBuildCore"
],
exclude: ["CMakeLists.txt"],
swiftSettings: [.enableExperimentalFeature("AccessLevelOnImport")]
swiftSettings: [
.enableExperimentalFeature("AccessLevelOnImport"),
]
),

// MARK: SwiftPM specific support libraries
Expand All @@ -188,6 +190,7 @@ let package = Package(
exclude: ["CMakeLists.txt", "Vendor/README.md"],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency"),
.enableExperimentalFeature("AccessLevelOnImport"),
]
),

Expand Down
10 changes: 5 additions & 5 deletions Sources/Basics/Archiver/TarArchiver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import class Dispatch.DispatchQueue
import struct Dispatch.DispatchTime
import struct TSCBasic.FileSystemError
import class TSCBasic.Process

/// An `Archiver` that handles Tar archives using the command-line `tar` tool.
public struct TarArchiver: Archiver {
Expand Down Expand Up @@ -58,7 +57,7 @@ public struct TarArchiver: Archiver {
throw FileSystemError(.notDirectory, destinationPath.underlying)
}

let process = TSCBasic.Process(
let process = AsyncProcess(
arguments: [self.tarCommand, "zxf", archivePath.pathString, "-C", destinationPath.pathString]
)

Expand Down Expand Up @@ -91,9 +90,10 @@ public struct TarArchiver: Archiver {
throw FileSystemError(.notDirectory, directory.underlying)
}

let process = TSCBasic.Process(
let process = AsyncProcess(
arguments: [self.tarCommand, "acf", destinationPath.pathString, directory.basename],
workingDirectory: directory.parentDirectory.underlying
environment: .current,
workingDirectory: directory.parentDirectory
)

guard let registrationKey = self.cancellator.register(process) else {
Expand Down Expand Up @@ -121,7 +121,7 @@ public struct TarArchiver: Archiver {
throw FileSystemError(.noEntry, path.underlying)
}

let process = TSCBasic.Process(arguments: [self.tarCommand, "tf", path.pathString])
let process = AsyncProcess(arguments: [self.tarCommand, "tf", path.pathString])
guard let registrationKey = self.cancellator.register(process) else {
throw CancellationError.failedToRegisterProcess(process)
}
Expand Down
17 changes: 7 additions & 10 deletions Sources/Basics/Archiver/ZipArchiver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import Dispatch
import struct TSCBasic.FileSystemError
import class TSCBasic.Process

/// An `Archiver` that handles ZIP archives using the command-line `zip` and `unzip` tools.
public struct ZipArchiver: Archiver, Cancellable {
Expand Down Expand Up @@ -49,11 +48,9 @@ public struct ZipArchiver: Archiver, Cancellable {
}

#if os(Windows)
let process = TSCBasic
.Process(arguments: ["tar.exe", "xf", archivePath.pathString, "-C", destinationPath.pathString])
let process = AsyncProcess(arguments: ["tar.exe", "xf", archivePath.pathString, "-C", destinationPath.pathString])
#else
let process = TSCBasic
.Process(arguments: ["unzip", archivePath.pathString, "-d", destinationPath.pathString])
let process = AsyncProcess(arguments: ["unzip", archivePath.pathString, "-d", destinationPath.pathString])
#endif
guard let registrationKey = self.cancellator.register(process) else {
throw CancellationError.failedToRegisterProcess(process)
Expand Down Expand Up @@ -85,10 +82,10 @@ public struct ZipArchiver: Archiver, Cancellable {
}

#if os(Windows)
let process = TSCBasic.Process(
let process = AsyncProcess(
// FIXME: are these the right arguments?
arguments: ["tar.exe", "-a", "-c", "-f", destinationPath.pathString, directory.basename],
workingDirectory: directory.parentDirectory.underlying
workingDirectory: directory.parentDirectory
)
#else
// This is to work around `swift package-registry publish` tool failing on
Expand All @@ -97,7 +94,7 @@ public struct ZipArchiver: Archiver, Cancellable {
// Instead of passing `workingDirectory` param to TSC.Process, which will trigger
// SPM_posix_spawn_file_actions_addchdir_np_supported check, we shell out and
// do `cd` explicitly before `zip`.
let process = TSCBasic.Process(
let process = AsyncProcess(
arguments: [
"/bin/sh",
"-c",
Expand Down Expand Up @@ -132,9 +129,9 @@ public struct ZipArchiver: Archiver, Cancellable {
}

#if os(Windows)
let process = TSCBasic.Process(arguments: ["tar.exe", "tf", path.pathString])
let process = AsyncProcess(arguments: ["tar.exe", "tf", path.pathString])
#else
let process = TSCBasic.Process(arguments: ["unzip", "-t", path.pathString])
let process = AsyncProcess(arguments: ["unzip", "-t", path.pathString])
#endif
guard let registrationKey = self.cancellator.register(process) else {
throw CancellationError.failedToRegisterProcess(process)
Expand Down
Loading