From 54c2224a793e7fe266cc6177dacb9e141ccee56f Mon Sep 17 00:00:00 2001 From: Owen Voorhees Date: Wed, 12 Mar 2025 18:58:22 -0700 Subject: [PATCH 1/2] Revert "Install Swift Build resource bundles in /usr/share/pm" This reverts commit c1519f2c49d086a381e96d91723d51821d2105fa. --- Sources/CoreCommands/BuildSystemSupport.swift | 1 - Sources/CoreCommands/Options.swift | 6 ----- Sources/CoreCommands/SwiftCommandState.swift | 14 ---------- .../SwiftBuildSupport/SwiftBuildSystem.swift | 26 ++++++++----------- Sources/swift-bootstrap/main.swift | 1 - Utilities/bootstrap | 5 ---- 6 files changed, 11 insertions(+), 42 deletions(-) diff --git a/Sources/CoreCommands/BuildSystemSupport.swift b/Sources/CoreCommands/BuildSystemSupport.swift index 9407a10f8a4..30a00599b9f 100644 --- a/Sources/CoreCommands/BuildSystemSupport.swift +++ b/Sources/CoreCommands/BuildSystemSupport.swift @@ -121,7 +121,6 @@ private struct SwiftBuildSystemFactory: BuildSystemFactory { explicitProduct: explicitProduct ) }, - packageManagerResourcesDirectory: swiftCommandState.packageManagerResourcesDirectory, outputStream: outputStream ?? self.swiftCommandState.outputStream, logLevel: logLevel ?? self.swiftCommandState.logLevel, fileSystem: self.swiftCommandState.fileSystem, diff --git a/Sources/CoreCommands/Options.swift b/Sources/CoreCommands/Options.swift index fbe63053edc..2b3f1265953 100644 --- a/Sources/CoreCommands/Options.swift +++ b/Sources/CoreCommands/Options.swift @@ -146,12 +146,6 @@ public struct LocationOptions: ParsableArguments { completion: .directory ) public var pkgConfigDirectories: [AbsolutePath] = [] - - @Option( - help: .init("Specify alternate path to search for SwiftPM resources.", visibility: .hidden), - completion: .directory - ) - public var packageManagerResourcesDirectory: AbsolutePath? @Flag(name: .customLong("ignore-lock"), help: .hidden) public var ignoreLock: Bool = false diff --git a/Sources/CoreCommands/SwiftCommandState.swift b/Sources/CoreCommands/SwiftCommandState.swift index b36eb3eb10e..70a7ce9699b 100644 --- a/Sources/CoreCommands/SwiftCommandState.swift +++ b/Sources/CoreCommands/SwiftCommandState.swift @@ -227,9 +227,6 @@ public final class SwiftCommandState { /// Path to the shared configuration directory public let sharedConfigurationDirectory: AbsolutePath - - /// Path to the package manager's own resources directory. - public let packageManagerResourcesDirectory: AbsolutePath? /// Path to the cross-compilation Swift SDKs directory. public let sharedSwiftSDKsDirectory: AbsolutePath @@ -374,17 +371,6 @@ public final class SwiftCommandState { warning: "`--experimental-swift-sdks-path` is deprecated and will be removed in a future version of SwiftPM. Use `--swift-sdks-path` instead." ) } - - if let packageManagerResourcesDirectory = options.locations.packageManagerResourcesDirectory { - self.packageManagerResourcesDirectory = packageManagerResourcesDirectory - } else if let cwd = localFileSystem.currentWorkingDirectory { - self.packageManagerResourcesDirectory = try? AbsolutePath(validating: CommandLine.arguments[0], relativeTo: cwd) - .parentDirectory.parentDirectory.appending(components: ["share", "pm"]) - } else { - self.packageManagerResourcesDirectory = try? AbsolutePath(validating: CommandLine.arguments[0]) - .parentDirectory.parentDirectory.appending(components: ["share", "pm"]) - } - self.sharedSwiftSDKsDirectory = try fileSystem.getSharedSwiftSDKsDirectory( explicitDirectory: options.locations.swiftSDKsDirectory ?? options.locations.deprecatedSwiftSDKsDirectory ) diff --git a/Sources/SwiftBuildSupport/SwiftBuildSystem.swift b/Sources/SwiftBuildSupport/SwiftBuildSystem.swift index a5e5f58a8a4..84a317a7878 100644 --- a/Sources/SwiftBuildSupport/SwiftBuildSystem.swift +++ b/Sources/SwiftBuildSupport/SwiftBuildSystem.swift @@ -62,13 +62,12 @@ func withService( func withSession( service: SWBBuildService, name: String, - packageManagerResourcesDirectory: Basics.AbsolutePath?, body: @escaping ( _ session: SWBBuildServiceSession, _ diagnostics: [SwiftBuild.SwiftBuildMessage.DiagnosticInfo] ) async throws -> Void ) async throws { - switch await service.createSession(name: name, resourceSearchPaths: packageManagerResourcesDirectory.map { [$0.pathString] } ?? [], cachePath: nil, inferiorProductsPath: nil, environment: nil) { + switch await service.createSession(name: name, cachePath: nil, inferiorProductsPath: nil, environment: nil) { case (.success(let session), let diagnostics): do { try await body(session, diagnostics) @@ -160,7 +159,6 @@ private final class PlanningOperationDelegate: SWBPlanningOperationDelegate, Sen public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { private let buildParameters: BuildParameters private let packageGraphLoader: () async throws -> ModulesGraph - private let packageManagerResourcesDirectory: Basics.AbsolutePath? private let logLevel: Basics.Diagnostic.Severity private var packageGraph: AsyncThrowingValueMemoizer = .init() private var pifBuilder: AsyncThrowingValueMemoizer = .init() @@ -211,7 +209,6 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { public init( buildParameters: BuildParameters, packageGraphLoader: @escaping () async throws -> ModulesGraph, - packageManagerResourcesDirectory: Basics.AbsolutePath?, outputStream: OutputByteStream, logLevel: Basics.Diagnostic.Severity, fileSystem: FileSystem, @@ -219,7 +216,6 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { ) throws { self.buildParameters = buildParameters self.packageGraphLoader = packageGraphLoader - self.packageManagerResourcesDirectory = packageManagerResourcesDirectory self.outputStream = outputStream self.logLevel = logLevel self.fileSystem = fileSystem @@ -260,16 +256,16 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { header: "" ) - do { - try await withSession(service: service, name: self.buildParameters.pifManifest.pathString, packageManagerResourcesDirectory: self.packageManagerResourcesDirectory) { session, _ in - // Load the workspace, and set the system information to the default - do { - try await session.loadWorkspace(containerPath: self.buildParameters.pifManifest.pathString) - try await session.setSystemInfo(.default()) - } catch { - self.observabilityScope.emit(error: error.localizedDescription) - throw error - } + do { + try await withSession(service: service, name: buildParameters.pifManifest.pathString) { session, _ in + // Load the workspace, and set the system information to the default + do { + try await session.loadWorkspace(containerPath: self.buildParameters.pifManifest.pathString) + try await session.setSystemInfo(.default()) + } catch { + self.observabilityScope.emit(error: error.localizedDescription) + throw error + } // Find the targets to build. let configuredTargets: [SWBConfiguredTarget] diff --git a/Sources/swift-bootstrap/main.swift b/Sources/swift-bootstrap/main.swift index ce22ee20825..aaac11435eb 100644 --- a/Sources/swift-bootstrap/main.swift +++ b/Sources/swift-bootstrap/main.swift @@ -361,7 +361,6 @@ struct SwiftBootstrapBuildTool: AsyncParsableCommand { return try SwiftBuildSystem( buildParameters: buildParameters, packageGraphLoader: asyncUnsafePackageGraphLoader, - packageManagerResourcesDirectory: nil, outputStream: TSCBasic.stdoutStream, logLevel: logLevel, fileSystem: self.fileSystem, diff --git a/Utilities/bootstrap b/Utilities/bootstrap index 4e2cbb10c00..6ada213b3f9 100755 --- a/Utilities/bootstrap +++ b/Utilities/bootstrap @@ -544,11 +544,6 @@ def install_swiftpm(prefix, args): dest = os.path.join(prefix, "lib", "swift", "pm", "PluginAPI") install_dylib(args, "PackagePlugin", dest, ["PackagePlugin"]) - # Install resource bundles produced during the build. - for file in os.listdir(args.bin_dir): - if file.endswith('.bundle') or file.endswith('.resources'): - install_binary(args, file, os.path.join(os.path.join(prefix, "share"), "pm")) - # Helper function that installs a dynamic library and a set of modules to a particular directory. @log_entry_exit From e842ca5838bceac526e84bbfc7ea858d0b1bd452 Mon Sep 17 00:00:00 2001 From: Owen Voorhees Date: Wed, 12 Mar 2025 19:04:57 -0700 Subject: [PATCH 2/2] Revert "Include Swift Build support in second stage bootstrap builds" This reverts commit 1523ce0e0feff7c41318dd46c422ecb31fd0bcb7. --- Utilities/bootstrap | 1 + 1 file changed, 1 insertion(+) diff --git a/Utilities/bootstrap b/Utilities/bootstrap index 6ada213b3f9..85c5fc30a1b 100755 --- a/Utilities/bootstrap +++ b/Utilities/bootstrap @@ -851,6 +851,7 @@ def get_swiftpm_env_cmd(args): if args.llbuild_link_framework: env_cmd.append("SWIFTPM_LLBUILD_FWK=1") + env_cmd.append("SWIFTPM_NO_SWBUILD_DEPENDENCY=1") env_cmd.append("SWIFTCI_USE_LOCAL_DEPS=1") env_cmd.append("SWIFTPM_MACOS_DEPLOYMENT_TARGET=%s" % g_macos_deployment_target)