From 8f6bfe8c3b84038d41513498d9aae952fb4055af Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 16 Jan 2024 15:31:15 +0000 Subject: [PATCH 01/31] Fix `package` access modifier in XCBuild support `package` access modifier was previously not supported in `swift build --build-system xcode`. This causes build issues when attempting to produce Universal binaries for SwiftPM, for example in this job https://ci.swift.org/job/swift-PR-source-compat-suite-debug-macos/1297/consoleFull. The reason was that `-package-name` option was not added to `OTHER_SWIFT_FLAGS` in `PIFBuilder.swift`. Additionally, in llbuild support code we were shelling out to Swift Driver for every target to check whether `-package-name` is supported. Now with `-package-name` options calculation generalized across build systems, Swift Driver checks are done once per `BuildParameters` initialization, which reduces excessive shelling for llbuild. Resolves rdar://120925895. --- Package.swift | 3 +- .../SwiftTargetBuildDescription.swift | 2 +- Sources/CoreCommands/SwiftTool.swift | 8 +- .../DriverSupport/DriverSupportUtils.swift | 12 ++- .../Resolution/ResolvedTarget.swift | 2 +- Sources/PackageModel/Target/SwiftTarget.swift | 2 +- .../BuildParameters+Driver.swift | 12 ++- .../BuildParameters/BuildParameters.swift | 4 +- Sources/SPMBuildCore/CMakeLists.txt | 1 + .../ResolvedPackage+Extensions.swift | 24 ++++++ Sources/SPMTestSupport/PIFTester.swift | 82 +++++++++++++++---- Sources/SPMTestSupport/SwiftPMProduct.swift | 5 +- Sources/SPMTestSupport/misc.swift | 3 +- Sources/XCBuildSupport/PIFBuilder.swift | 52 +++++++++--- Sources/XCBuildSupport/XcodeBuildSystem.swift | 3 +- Sources/swift-bootstrap/main.swift | 10 ++- Tests/BuildTests/BuildPlanTests.swift | 39 +++++++-- .../XCBuildSupportTests/PIFBuilderTests.swift | 77 +++++++++++------ Utilities/build-using-self | 2 +- 19 files changed, 263 insertions(+), 80 deletions(-) create mode 100644 Sources/SPMBuildCore/ResolvedPackage+Extensions.swift diff --git a/Package.swift b/Package.swift index 7b6a495ad63..63ed1331755 100644 --- a/Package.swift +++ b/Package.swift @@ -4,7 +4,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2014-2023 Apple Inc. and the Swift project authors +// Copyright (c) 2014-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -461,6 +461,7 @@ let package = Package( .product(name: "ArgumentParser", package: "swift-argument-parser"), "Basics", "Build", + "DriverSupport", "PackageGraph", "PackageLoading", "PackageModel", diff --git a/Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift b/Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift index a934404205f..aaabd9b8852 100644 --- a/Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift +++ b/Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift @@ -422,7 +422,7 @@ public final class SwiftTargetBuildDescription { private func packageNameArgumentIfSupported(with pkg: ResolvedPackage, packageAccess: Bool) -> [String] { let flag = "-package-name" if pkg.manifest.usePackageNameFlag, - DriverSupport.checkToolchainDriverFlags(flags: [flag], toolchain: self.buildParameters.toolchain, fileSystem: self.fileSystem) { + DriverSupport.isPackageNameSupported(toolchain: self.buildParameters.toolchain, fileSystem: self.fileSystem) { if packageAccess { let pkgID = pkg.identity.description.spm_mangledToC99ExtendedIdentifier() return [flag, pkgID] diff --git a/Sources/CoreCommands/SwiftTool.swift b/Sources/CoreCommands/SwiftTool.swift index 0ed863b0098..5d0026dbe69 100644 --- a/Sources/CoreCommands/SwiftTool.swift +++ b/Sources/CoreCommands/SwiftTool.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2014-2023 Apple Inc. and the Swift project authors +// Copyright (c) 2014-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -721,7 +721,11 @@ public final class SwiftTool { enableParseableModuleInterfaces: options.build.shouldEnableParseableModuleInterfaces, explicitTargetDependencyImportCheckingMode: options.build.explicitTargetDependencyImportCheck.modeParameter, useIntegratedSwiftDriver: options.build.useIntegratedSwiftDriver, - useExplicitModuleBuild: options.build.useExplicitModuleBuild + useExplicitModuleBuild: options.build.useExplicitModuleBuild, + isPackageAccessModifierSupported: DriverSupport.isPackageNameSupported( + toolchain: toolchain, + fileSystem: self.fileSystem + ) ), linkingParameters: .init( linkerDeadStrip: options.linker.linkerDeadStrip, diff --git a/Sources/DriverSupport/DriverSupportUtils.swift b/Sources/DriverSupport/DriverSupportUtils.swift index 9e5bf00a739..c923a60e00d 100644 --- a/Sources/DriverSupport/DriverSupportUtils.swift +++ b/Sources/DriverSupport/DriverSupportUtils.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2022 Apple Inc. and the Swift project authors +// Copyright (c) 2022-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -17,11 +17,11 @@ import class TSCBasic.Process import enum TSCBasic.ProcessEnv import struct TSCBasic.ProcessResult -public enum DriverSupport { +package enum DriverSupport { private static var flagsMap = ThreadSafeBox<[String: Set]>() // This checks _frontend_ supported flags, which are not necessarily supported in the driver. - public static func checkSupportedFrontendFlags( + package static func checkSupportedFrontendFlags( flags: Set, toolchain: PackageModel.Toolchain, fileSystem: FileSystem @@ -54,7 +54,7 @@ public enum DriverSupport { // This checks if given flags are supported in the built-in toolchain driver. Currently // there's no good way to get the supported flags from it, so run `swiftc -h` directly // to get the flags and cache the result. - public static func checkToolchainDriverFlags( + static func checkToolchainDriverFlags( flags: Set, toolchain: PackageModel.Toolchain, fileSystem: FileSystem @@ -83,4 +83,8 @@ public enum DriverSupport { return false } } + + package static func isPackageNameSupported(toolchain: PackageModel.Toolchain, fileSystem: FileSystem) -> Bool { + DriverSupport.checkToolchainDriverFlags(flags: ["-package-name"], toolchain: toolchain, fileSystem: fileSystem) + } } diff --git a/Sources/PackageGraph/Resolution/ResolvedTarget.swift b/Sources/PackageGraph/Resolution/ResolvedTarget.swift index ec0f83c584f..22d673c89d7 100644 --- a/Sources/PackageGraph/Resolution/ResolvedTarget.swift +++ b/Sources/PackageGraph/Resolution/ResolvedTarget.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2014-2023 Apple Inc. and the Swift project authors +// Copyright (c) 2014-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information diff --git a/Sources/PackageModel/Target/SwiftTarget.swift b/Sources/PackageModel/Target/SwiftTarget.swift index f23f79db6fe..45f24596c0c 100644 --- a/Sources/PackageModel/Target/SwiftTarget.swift +++ b/Sources/PackageModel/Target/SwiftTarget.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2014-2023 Apple Inc. and the Swift project authors +// Copyright (c) 2014-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information diff --git a/Sources/SPMBuildCore/BuildParameters/BuildParameters+Driver.swift b/Sources/SPMBuildCore/BuildParameters/BuildParameters+Driver.swift index 6007d1d6046..a526bcf3855 100644 --- a/Sources/SPMBuildCore/BuildParameters/BuildParameters+Driver.swift +++ b/Sources/SPMBuildCore/BuildParameters/BuildParameters+Driver.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2020-2023 Apple Inc. and the Swift project authors +// Copyright (c) 2020-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -25,13 +25,15 @@ extension BuildParameters { enableParseableModuleInterfaces: Bool = false, explicitTargetDependencyImportCheckingMode: TargetDependencyImportCheckingMode = .none, useIntegratedSwiftDriver: Bool = false, - useExplicitModuleBuild: Bool = false + useExplicitModuleBuild: Bool = false, + isPackageAccessModifierSupported: Bool = false ) { self.canRenameEntrypointFunctionName = canRenameEntrypointFunctionName self.enableParseableModuleInterfaces = enableParseableModuleInterfaces self.explicitTargetDependencyImportCheckingMode = explicitTargetDependencyImportCheckingMode self.useIntegratedSwiftDriver = useIntegratedSwiftDriver self.useExplicitModuleBuild = useExplicitModuleBuild + self.isPackageAccessModifierSupported = isPackageAccessModifierSupported } /// Whether to enable the entry-point-function-name feature. @@ -45,11 +47,15 @@ extension BuildParameters { /// `.swiftmodule`s. public var enableParseableModuleInterfaces: Bool - /// Whether to use the integrated Swift driver rather than shelling out + /// Whether to use the integrated Swift Driver rather than shelling out /// to a separate process. public var useIntegratedSwiftDriver: Bool /// Whether to use the explicit module build flow (with the integrated driver). public var useExplicitModuleBuild: Bool + + /// Whether the version of Swift Driver used in the currently selected toolchain + /// supports `-package-name` options. + package var isPackageAccessModifierSupported: Bool } } diff --git a/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift b/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift index cbc5cb5499c..0f285ec4997 100644 --- a/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift +++ b/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2020-2023 Apple Inc. and the Swift project authors +// Copyright (c) 2020-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -132,7 +132,7 @@ public struct BuildParameters: Encodable { isXcodeBuildSystemEnabled: Bool = false, shouldSkipBuilding: Bool = false, debuggingParameters: Debugging? = nil, - driverParameters: Driver = .init(), + driverParameters: Driver, linkingParameters: Linking = .init(), outputParameters: Output = .init(), testingParameters: Testing? = nil diff --git a/Sources/SPMBuildCore/CMakeLists.txt b/Sources/SPMBuildCore/CMakeLists.txt index d5c3ee43344..ed5d5d5d828 100644 --- a/Sources/SPMBuildCore/CMakeLists.txt +++ b/Sources/SPMBuildCore/CMakeLists.txt @@ -23,6 +23,7 @@ add_library(SPMBuildCore Plugins/PluginMessages.swift Plugins/PluginScriptRunner.swift PrebuildCommandResult.swift + ResolvedPackage+Extensions.swift Triple+Extensions.swift XCFrameworkMetadata.swift) # NOTE(compnerd) workaround for CMake not setting up include flags yet diff --git a/Sources/SPMBuildCore/ResolvedPackage+Extensions.swift b/Sources/SPMBuildCore/ResolvedPackage+Extensions.swift new file mode 100644 index 00000000000..791299fe0bc --- /dev/null +++ b/Sources/SPMBuildCore/ResolvedPackage+Extensions.swift @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2014-2024 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +import struct PackageGraph.ResolvedPackage +import struct PackageGraph.ResolvedTarget + +extension ResolvedPackage { + package func packageNameArgument(target: ResolvedTarget, isPackageNameSupported: Bool) -> [String] { + if self.manifest.usePackageNameFlag, target.packageAccess { + ["-package-name", self.identity.description.spm_mangledToC99ExtendedIdentifier()] + } else { + [] + } + } +} diff --git a/Sources/SPMTestSupport/PIFTester.swift b/Sources/SPMTestSupport/PIFTester.swift index 4e4641fa016..85b64cbf6e5 100644 --- a/Sources/SPMTestSupport/PIFTester.swift +++ b/Sources/SPMTestSupport/PIFTester.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2014-2020 Apple Inc. and the Swift project authors +// Copyright (c) 2014-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -32,7 +32,12 @@ public final class PIFWorkspaceTester { targetMap = Dictionary(uniqueKeysWithValues: targetsByGUID) } - public func checkProject(_ guid: PIF.GUID, file: StaticString = #file, line: UInt = #line, body: (PIFProjectTester) -> Void) throws { + public func checkProject( + _ guid: PIF.GUID, + file: StaticString = #file, + line: UInt = #line, + body: (PIFProjectTester) -> Void + ) throws { guard let project = projectMap[guid] else { return XCTFail("project \(guid) not found", file: file, line: line) } @@ -55,10 +60,20 @@ public final class PIFProjectTester { fileprivate init(project: PIF.Project, targetMap: [PIF.GUID: PIF.BaseTarget]) throws { self.project = project self.targetMap = targetMap - self.fileMap = try collectFiles(from: project.groupTree, parentPath: project.path, projectPath: project.path, builtProductsPath: project.path) + self.fileMap = try collectFiles( + from: project.groupTree, + parentPath: project.path, + projectPath: project.path, + builtProductsPath: project.path + ) } - public func checkTarget(_ guid: PIF.GUID, file: StaticString = #file, line: UInt = #line, body: ((PIFTargetTester) -> Void)? = nil) { + public func checkTarget( + _ guid: PIF.GUID, + file: StaticString = #file, + line: UInt = #line, + body: ((PIFTargetTester) -> Void)? = nil + ) { guard let baseTarget = baseTarget(withGUID: guid) else { let guids = project.targets.map { $0.guid }.joined(separator: ", ") return XCTFail("target \(guid) not found among \(guids)", file: file, line: line) @@ -71,13 +86,23 @@ public final class PIFProjectTester { body?(PIFTargetTester(target: target, targetMap: targetMap, fileMap: fileMap)) } - public func checkNoTarget(_ guid: PIF.GUID, file: StaticString = #file, line: UInt = #line, body: ((PIFTargetTester) -> Void)? = nil) { + public func checkNoTarget( + _ guid: PIF.GUID, + file: StaticString = #file, + line: UInt = #line, + body: ((PIFTargetTester) -> Void)? = nil + ) { if baseTarget(withGUID: guid) != nil { XCTFail("target \(guid) found", file: file, line: line) } } - public func checkAggregateTarget(_ guid: PIF.GUID, file: StaticString = #file, line: UInt = #line, body: ((PIFAggregateTargetTester) -> Void)? = nil) { + public func checkAggregateTarget( + _ guid: PIF.GUID, + file: StaticString = #file, + line: UInt = #line, + body: ((PIFAggregateTargetTester) -> Void)? = nil + ) { guard let baseTarget = baseTarget(withGUID: guid) else { let guids = project.targets.map { $0.guid }.joined(separator: ", ") return XCTFail("target \(guid) not found among \(guids)", file: file, line: line) @@ -90,7 +115,12 @@ public final class PIFProjectTester { body?(PIFAggregateTargetTester(target: target, targetMap: targetMap, fileMap: fileMap)) } - public func checkBuildConfiguration(_ name: String, file: StaticString = #file, line: UInt = #line, body: (PIFBuildConfigurationTester) -> Void) { + public func checkBuildConfiguration( + _ name: String, + file: StaticString = #file, + line: UInt = #line, + body: (PIFBuildConfigurationTester) -> Void + ) { guard let configuration = buildConfiguration(withName: name) else { let names = project.buildConfigurations.map { $0.name }.joined(separator: ", ") return XCTFail("build configuration \(name) not found among \(names)", file: file, line: line) @@ -151,7 +181,12 @@ public class PIFBaseTargetTester { }) } - public func checkBuildConfiguration(_ name: String, file: StaticString = #file, line: UInt = #line, body: (PIFBuildConfigurationTester) -> Void) { + public func checkBuildConfiguration( + _ name: String, + file: StaticString = #file, + line: UInt = #line, + body: (PIFBuildConfigurationTester) -> Void + ) { guard let configuration = buildConfiguration(withName: name) else { return XCTFail("build configuration \(name) not found", file: file, line: line) } @@ -163,19 +198,33 @@ public class PIFBaseTargetTester { return baseTarget.buildConfigurations.first { $0.name == name } } - public func checkImpartedBuildSettings(file: StaticString = #file, line: UInt = #line, _ body: (PIFBuildSettingsTester) -> Void) { - let buildSettingsTester = PIFBuildSettingsTester(buildSettings: baseTarget.buildConfigurations.first!.impartedBuildProperties.buildSettings) + public func checkImpartedBuildSettings( + file: StaticString = #file, + line: UInt = #line, + _ body: (PIFBuildSettingsTester) -> Void + ) { + let buildSettingsTester = PIFBuildSettingsTester( + buildSettings: baseTarget.buildConfigurations.first!.impartedBuildProperties.buildSettings + ) body(buildSettingsTester) } - public func checkAllImpartedBuildSettings(file: StaticString = #file, line: UInt = #line, _ body: (PIFBuildSettingsTester) -> Void) { - let buildSettingsTester = PIFBuildSettingsTester(buildSettings: baseTarget.buildConfigurations.first!.impartedBuildProperties.buildSettings) + public func checkAllImpartedBuildSettings( + file: StaticString = #file, + line: UInt = #line, + _ body: (PIFBuildSettingsTester) -> Void + ) { + let buildSettingsTester = PIFBuildSettingsTester( + buildSettings: baseTarget.buildConfigurations.first!.impartedBuildProperties.buildSettings + ) body(buildSettingsTester) buildSettingsTester.checkUncheckedSettings(file: file, line: line) } public func checkNoImpartedBuildSettings(file: StaticString = #file, line: UInt = #line) { - let buildSettingsTester = PIFBuildSettingsTester(buildSettings: baseTarget.buildConfigurations.first!.impartedBuildProperties.buildSettings) + let buildSettingsTester = PIFBuildSettingsTester( + buildSettings: baseTarget.buildConfigurations.first!.impartedBuildProperties.buildSettings + ) buildSettingsTester.checkUncheckedSettings(file: file, line: line) } } @@ -313,7 +362,12 @@ private func collectFiles( files[reference.guid] = referencePath.pathString } else if let group = reference as? PIF.Group { for child in group.children { - let childFiles = try collectFiles(from: child, parentPath: referencePath, projectPath: projectPath, builtProductsPath: builtProductsPath) + let childFiles = try collectFiles( + from: child, + parentPath: referencePath, + projectPath: projectPath, + builtProductsPath: builtProductsPath + ) files.merge(childFiles, uniquingKeysWith: { _, _ in fatalError("non-unique GUID") }) } } diff --git a/Sources/SPMTestSupport/SwiftPMProduct.swift b/Sources/SPMTestSupport/SwiftPMProduct.swift index b62a99b428c..c8c326884c2 100644 --- a/Sources/SPMTestSupport/SwiftPMProduct.swift +++ b/Sources/SPMTestSupport/SwiftPMProduct.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2019 Apple Inc. and the Swift project authors +// Copyright (c) 2019-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -128,7 +128,8 @@ extension SwiftPM { completeArgs += ["--package-path", packagePath.pathString] } completeArgs += args - + + print(completeArgs) return try Process.popen(arguments: completeArgs, environment: environment) } } diff --git a/Sources/SPMTestSupport/misc.swift b/Sources/SPMTestSupport/misc.swift index 938343b7540..dce491c8272 100644 --- a/Sources/SPMTestSupport/misc.swift +++ b/Sources/SPMTestSupport/misc.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2014-2020 Apple Inc. and the Swift project authors +// Copyright (c) 2014-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -96,6 +96,7 @@ public func testWithTemporaryDirectory( } let fixtureDir = try verifyFixtureExists(at: fixtureSubpath, file: file, line: line) + print(fixtureDir) let preparedFixture = try setup( fixtureDir: fixtureDir, in: tmpDirPath, diff --git a/Sources/XCBuildSupport/PIFBuilder.swift b/Sources/XCBuildSupport/PIFBuilder.swift index 3621752b8d6..375fd383f37 100644 --- a/Sources/XCBuildSupport/PIFBuilder.swift +++ b/Sources/XCBuildSupport/PIFBuilder.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2014-2023 Apple Inc. and the Swift project authors +// Copyright (c) 2014-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -19,9 +19,12 @@ import SPMBuildCore import func TSCBasic.topologicalSort import func TSCBasic.memoize +import DriverSupport /// The parameters required by `PIFBuilder`. struct PIFBuilderParameters { + /// Whether the toolchain supports `-package-name` option. + let isPackageAccessModifierSupported: Bool /// Whether or not build for testability is enabled. let enableTestability: Bool @@ -132,7 +135,13 @@ public final class PIFBuilder { } // Convenience method for generating PIF. - public static func generatePIF(buildParameters: BuildParameters, packageGraph: PackageGraph, fileSystem: FileSystem, observabilityScope: ObservabilityScope, preservePIFModelStructure: Bool) throws -> String { + public static func generatePIF( + buildParameters: BuildParameters, + packageGraph: PackageGraph, + fileSystem: FileSystem, + observabilityScope: ObservabilityScope, + preservePIFModelStructure: Bool + ) throws -> String { let parameters = PIFBuilderParameters(buildParameters) let builder = Self.init( graph: packageGraph, @@ -250,18 +259,18 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder { metadata: package.underlying.diagnosticsMetadata ) - executableTargetProductMap = try Dictionary(throwingUniqueKeysWithValues: + self.executableTargetProductMap = try Dictionary(throwingUniqueKeysWithValues: package.products.filter { $0.type == .executable }.map { ($0.mainTarget, $0) } ) super.init() - guid = package.pifProjectGUID - name = package.manifest.displayName // TODO: use identity instead? - path = package.path - projectDirectory = package.path - developmentRegion = package.manifest.defaultLocalization ?? "en" - binaryGroup = groupTree.addGroup(path: "/", sourceTree: .absolute, name: "Binaries") + self.guid = package.pifProjectGUID + self.name = package.manifest.displayName // TODO: use identity instead? + self.path = package.path + self.projectDirectory = package.path + self.developmentRegion = package.manifest.defaultLocalization ?? "en" + self.binaryGroup = groupTree.addGroup(path: "/", sourceTree: .absolute, name: "Binaries") // Configure the project-wide build settings. First we set those that are in common between the "Debug" and // "Release" configurations, and then we set those that are different. @@ -463,6 +472,8 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder { settings[.CLANG_CXX_LANGUAGE_STANDARD] = clangTarget.cxxLanguageStandard } else if let swiftTarget = mainTarget.underlying as? SwiftTarget { settings[.SWIFT_VERSION] = swiftTarget.swiftVersion.description + + settings.addCommonSwiftSettings(package: self.package, target: mainTarget, parameters: self.parameters) } if let resourceBundle = addResourceBundle(for: mainTarget, in: pifTarget) { @@ -493,7 +504,7 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder { let executableName: String let productType: PIF.Target.ProductType if product.type == .library(.dynamic) { - if parameters.shouldCreateDylibForDynamicProducts { + if self.parameters.shouldCreateDylibForDynamicProducts { pifTargetProductName = "lib\(product.name).dylib" executableName = pifTargetProductName productType = .dynamicLibrary @@ -512,7 +523,7 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder { // depend on. XCBuild will not produce a separate artifact for a package product, but will instead consider any // dependency on the package product to be a dependency on the whole set of targets on which the package product // depends. - let pifTarget = addTarget( + let pifTarget = self.addTarget( guid: product.pifTargetGUID, name: targetName(for: product), productType: productType, @@ -643,6 +654,8 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder { settings[.SWIFT_OBJC_INTERFACE_HEADER_DIR] = "$(OBJROOT)/GeneratedModuleMaps/$(PLATFORM_NAME)" settings[.SWIFT_OBJC_INTERFACE_HEADER_NAME] = "\(target.name)-Swift.h" + settings.addCommonSwiftSettings(package: self.package, target: target, parameters: self.parameters) + moduleMapFileContents = """ module \(target.c99name) { header "\(target.name)-Swift.h" @@ -1655,6 +1668,23 @@ extension PIF.PlatformFilter { ] } +private extension PIF.BuildSettings { + mutating func addCommonSwiftSettings( + package: ResolvedPackage, + target: ResolvedTarget, + parameters: PIFBuilderParameters + ) { + let packageOptions = package.packageNameArgument( + target: target, + isPackageNameSupported: parameters.isPackageAccessModifierSupported + ) + if !packageOptions.isEmpty { + self[.OTHER_SWIFT_FLAGS] = packageOptions + } + + } +} + private extension PIF.BuildSettings.Platform { static func from(platform: PackageModel.Platform) -> PIF.BuildSettings.Platform? { switch platform { diff --git a/Sources/XCBuildSupport/XcodeBuildSystem.swift b/Sources/XCBuildSupport/XcodeBuildSystem.swift index 9eeb82ac32d..2eba400bcc4 100644 --- a/Sources/XCBuildSupport/XcodeBuildSystem.swift +++ b/Sources/XCBuildSupport/XcodeBuildSystem.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2020 Apple Inc. and the Swift project authors +// Copyright (c) 2020-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -319,6 +319,7 @@ extension BuildConfiguration { extension PIFBuilderParameters { public init(_ buildParameters: BuildParameters) { self.init( + isPackageAccessModifierSupported: buildParameters.driverParameters.isPackageAccessModifierSupported, enableTestability: buildParameters.testingParameters.enableTestability, shouldCreateDylibForDynamicProducts: buildParameters.shouldCreateDylibForDynamicProducts, toolchainLibDir: (try? buildParameters.toolchain.toolchainLibDir) ?? .root, diff --git a/Sources/swift-bootstrap/main.swift b/Sources/swift-bootstrap/main.swift index 7891cd06ade..7350a56d41e 100644 --- a/Sources/swift-bootstrap/main.swift +++ b/Sources/swift-bootstrap/main.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2022 Apple Inc. and the Swift project authors +// Copyright (c) 2022-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -14,6 +14,7 @@ import ArgumentParser import Basics import Build import Dispatch +import DriverSupport import Foundation import OrderedCollections import PackageGraph @@ -287,7 +288,11 @@ struct SwiftBootstrapBuildTool: ParsableCommand { isXcodeBuildSystemEnabled: buildSystem == .xcode, driverParameters: .init( explicitTargetDependencyImportCheckingMode: explicitTargetDependencyImportCheck == .error ? .error : .none, - useIntegratedSwiftDriver: useIntegratedSwiftDriver + useIntegratedSwiftDriver: useIntegratedSwiftDriver, + isPackageAccessModifierSupported: DriverSupport.isPackageNameSupported( + toolchain: targetToolchain, + fileSystem: self.fileSystem + ) ), linkingParameters: .init( shouldDisableLocalRpath: shouldDisableLocalRpath @@ -301,7 +306,6 @@ struct SwiftBootstrapBuildTool: ParsableCommand { let packageGraphLoader = { try self.loadPackageGraph(packagePath: packagePath, manifestLoader: manifestLoader) - } switch buildSystem { diff --git a/Tests/BuildTests/BuildPlanTests.swift b/Tests/BuildTests/BuildPlanTests.swift index ce047c2c459..977f8d7b48a 100644 --- a/Tests/BuildTests/BuildPlanTests.swift +++ b/Tests/BuildTests/BuildPlanTests.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2014-2021 Apple Inc. and the Swift project authors +// Copyright (c) 2014-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -12,7 +12,7 @@ @testable import Basics @testable import Build -import DriverSupport +@testable import DriverSupport @testable import PackageGraph import PackageLoading @testable import PackageModel @@ -643,6 +643,36 @@ final class BuildPlanTests: XCTestCase { } XCTAssertMatch(stdout, .contains("Build complete!")) } + } + + func testPackageNameFlagXCBuild() throws { + try XCTSkipIfCI() // test is disabled because it isn't stable, see rdar://118239206 + let isFlagSupportedInDriver = try DriverSupport.checkToolchainDriverFlags( + flags: ["package-name"], + toolchain: UserToolchain.default, + fileSystem: localFileSystem + ) + try fixture(name: "Miscellaneous/PackageNameFlag") { fixturePath in + let (stdout, _) = try executeSwiftBuild( + fixturePath.appending("appPkg"), + extraArgs: ["--build-system", "xcode", "-vv"] + ) + XCTAssertMatch(stdout, .contains("-module-name Foo")) + XCTAssertMatch(stdout, .contains("-module-name Zoo")) + XCTAssertMatch(stdout, .contains("-module-name Bar")) + XCTAssertMatch(stdout, .contains("-module-name Baz")) + XCTAssertMatch(stdout, .contains("-module-name App")) + XCTAssertMatch(stdout, .contains("-module-name exe")) + if isFlagSupportedInDriver { + XCTAssertMatch(stdout, .contains("-package-name apppkg")) + XCTAssertMatch(stdout, .contains("-package-name foopkg")) + // the flag is not supported if tools-version < 5.9 + XCTAssertNoMatch(stdout, .contains("-package-name barpkg")) + } else { + XCTAssertNoMatch(stdout, .contains("-package-name")) + } + XCTAssertMatch(stdout, .contains("Build succeeded")) + } } func testTargetsWithPackageAccess() throws { @@ -3445,9 +3475,8 @@ final class BuildPlanTests: XCTestCase { observabilityScope: observability.topScope )) result.checkProductsCount(2) - result - .checkTargetsCount(5) // There are two additional targets on non-Apple platforms, for test discovery and - // test entry point + // There are two additional targets on non-Apple platforms, for test discovery and test entry point + result.checkTargetsCount(5) let buildPath = result.plan.productsBuildPath diff --git a/Tests/XCBuildSupportTests/PIFBuilderTests.swift b/Tests/XCBuildSupportTests/PIFBuilderTests.swift index dcabed69073..15a2e7fbdb1 100644 --- a/Tests/XCBuildSupportTests/PIFBuilderTests.swift +++ b/Tests/XCBuildSupportTests/PIFBuilderTests.swift @@ -2218,7 +2218,7 @@ class PIFBuilderTests: XCTestCase { } } - func testBuildSettings() throws { + func buildSettingsTestCase(isPackageAccessModifierSupported: Bool) throws { #if !os(macOS) try XCTSkipIf(true, "test is only supported on macOS") #endif @@ -2228,6 +2228,8 @@ class PIFBuilderTests: XCTestCase { "/Foo/Sources/FooTests/FooTests.swift" ) + let toolsVersion: ToolsVersion = if isPackageAccessModifierSupported { .v5_9 } else { .v5 } + let mainTargetType: TargetDescription.TargetType = if toolsVersion >= .v5_9 { .executable } else { .regular } let observability = ObservabilitySystem.makeForTesting() let graph = try loadPackageGraph( fileSystem: fs, @@ -2235,28 +2237,32 @@ class PIFBuilderTests: XCTestCase { Manifest.createRootManifest( displayName: "Foo", path: "/Foo", - toolsVersion: .v5, + toolsVersion: toolsVersion, products: [ .init(name: "FooLib", type: .library(.automatic), targets: ["FooLib"]), ], targets: [ - .init(name: "foo", settings: [ - .init( - tool: .c, - kind: .define("ENABLE_BEST_MODE")), - .init( - tool: .cxx, - kind: .headerSearchPath("some/path"), - condition: .init(platformNames: ["macos"])), - .init( - tool: .linker, - kind: .linkedLibrary("z"), - condition: .init(config: "debug")), - .init( - tool: .swift, - kind: .unsafeFlags(["-secret", "value"]), - condition: .init(platformNames: ["macos", "linux"], config: "release")), - ]), + .init( + name: "foo", + type: mainTargetType, + settings: [ + .init( + tool: .c, + kind: .define("ENABLE_BEST_MODE")), + .init( + tool: .cxx, + kind: .headerSearchPath("some/path"), + condition: .init(platformNames: ["macos"])), + .init( + tool: .linker, + kind: .linkedLibrary("z"), + condition: .init(config: "debug")), + .init( + tool: .swift, + kind: .unsafeFlags(["-secret", "value"]), + condition: .init(platformNames: ["macos", "linux"], config: "release")), + ] + ), .init(name: "FooLib", settings: [ .init( tool: .c, @@ -2291,7 +2297,8 @@ class PIFBuilderTests: XCTestCase { kind: .unsafeFlags(["-secret", "value"]), condition: .init(platformNames: ["macos", "linux"], config: "release")), ]), - ]), + ] + ), ], shouldCreateMultipleTestProducts: true, observabilityScope: observability.topScope @@ -2299,7 +2306,7 @@ class PIFBuilderTests: XCTestCase { let builder = PIFBuilder( graph: graph, - parameters: .mock(), + parameters: .mock(isPackageAccessModifierSupported: isPackageAccessModifierSupported), fileSystem: fs, observabilityScope: observability.topScope ) @@ -2307,6 +2314,12 @@ class PIFBuilderTests: XCTestCase { XCTAssertNoDiagnostics(observability.diagnostics) + let packageNameOptions = if isPackageAccessModifierSupported { + ["-package-name", "foo"] + } else { + [String]?.none + } + try PIFTester(pif) { workspace in try workspace.checkProject("PACKAGE:/Foo") { project in project.checkTarget("PACKAGE-PRODUCT:foo") { target in @@ -2319,7 +2332,7 @@ class PIFBuilderTests: XCTestCase { "/Foo/Sources/foo/some/path" ]) XCTAssertEqual(settings[.OTHER_LDFLAGS], ["$(inherited)", "-lz"]) - XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS], nil) + XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS], packageNameOptions) } } @@ -2332,7 +2345,7 @@ class PIFBuilderTests: XCTestCase { "/Foo/Sources/foo/some/path" ]) XCTAssertEqual(settings[.OTHER_LDFLAGS], nil) - XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS], nil) + XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS], packageNameOptions) XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS, for: .macOS], ["$(inherited)", "-secret", "value"]) XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS, for: .linux], ["$(inherited)", "-secret", "value"]) } @@ -2371,7 +2384,7 @@ class PIFBuilderTests: XCTestCase { "/Foo/Sources/FooLib/some/path" ]) XCTAssertEqual(settings[.OTHER_LDFLAGS], ["$(inherited)", "-lz"]) - XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS], nil) + XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS], packageNameOptions) } } @@ -2384,7 +2397,7 @@ class PIFBuilderTests: XCTestCase { "/Foo/Sources/FooLib/some/path" ]) XCTAssertEqual(settings[.OTHER_LDFLAGS], nil) - XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS], nil) + XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS], packageNameOptions) XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS, for: .macOS], ["$(inherited)", "-secret", "value"]) XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS, for: .linux], ["$(inherited)", "-secret", "value"]) } @@ -2408,7 +2421,7 @@ class PIFBuilderTests: XCTestCase { "/Foo/Sources/FooTests/some/path" ]) XCTAssertEqual(settings[.OTHER_LDFLAGS], ["$(inherited)", "-lz"]) - XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS], nil) + XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS], packageNameOptions) } } @@ -2421,7 +2434,7 @@ class PIFBuilderTests: XCTestCase { "/Foo/Sources/FooTests/some/path" ]) XCTAssertEqual(settings[.OTHER_LDFLAGS], nil) - XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS], nil) + XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS], packageNameOptions) XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS, for: .macOS], ["$(inherited)", "-secret", "value"]) XCTAssertEqual(settings[.OTHER_SWIFT_FLAGS, for: .linux], ["$(inherited)", "-secret", "value"]) } @@ -2431,6 +2444,14 @@ class PIFBuilderTests: XCTestCase { } } + func testBuildSettings() throws { + try buildSettingsTestCase(isPackageAccessModifierSupported: false) + } + + func testBuildSettingsPackageAccess() throws { + try buildSettingsTestCase(isPackageAccessModifierSupported: true) + } + func testConditionalDependencies() throws { #if !os(macOS) try XCTSkipIf(true, "test is only supported on macOS") @@ -2620,9 +2641,11 @@ class PIFBuilderTests: XCTestCase { extension PIFBuilderParameters { static func mock( + isPackageAccessModifierSupported: Bool = false, shouldCreateDylibForDynamicProducts: Bool = false ) -> Self { PIFBuilderParameters( + isPackageAccessModifierSupported: isPackageAccessModifierSupported, enableTestability: false, shouldCreateDylibForDynamicProducts: shouldCreateDylibForDynamicProducts, toolchainLibDir: "/toolchain/lib", diff --git a/Utilities/build-using-self b/Utilities/build-using-self index bb27d73da38..1511f30c04e 100755 --- a/Utilities/build-using-self +++ b/Utilities/build-using-self @@ -3,7 +3,7 @@ ## ## This source file is part of the Swift open source project ## -## Copyright (c) 2014-2022 Apple Inc. and the Swift project authors +## Copyright (c) 2014-2024 Apple Inc. and the Swift project authors ## Licensed under Apache License v2.0 with Runtime Library Exception ## ## See http://swift.org/LICENSE.txt for license information From 582cd2bc67976fffb12858534715be6c8dc50f91 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 16 Jan 2024 15:33:38 +0000 Subject: [PATCH 02/31] Fix formatting, remove excessive `print`, reduce the diff --- Sources/SPMTestSupport/SwiftPMProduct.swift | 3 +-- Sources/SPMTestSupport/misc.swift | 3 +-- Sources/XCBuildSupport/PIFBuilder.swift | 1 - Utilities/build-using-self | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Sources/SPMTestSupport/SwiftPMProduct.swift b/Sources/SPMTestSupport/SwiftPMProduct.swift index c8c326884c2..1c10b1fda4e 100644 --- a/Sources/SPMTestSupport/SwiftPMProduct.swift +++ b/Sources/SPMTestSupport/SwiftPMProduct.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2019-2024 Apple Inc. and the Swift project authors +// Copyright (c) 2019 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -129,7 +129,6 @@ extension SwiftPM { } completeArgs += args - print(completeArgs) return try Process.popen(arguments: completeArgs, environment: environment) } } diff --git a/Sources/SPMTestSupport/misc.swift b/Sources/SPMTestSupport/misc.swift index dce491c8272..938343b7540 100644 --- a/Sources/SPMTestSupport/misc.swift +++ b/Sources/SPMTestSupport/misc.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2014-2024 Apple Inc. and the Swift project authors +// Copyright (c) 2014-2020 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -96,7 +96,6 @@ public func testWithTemporaryDirectory( } let fixtureDir = try verifyFixtureExists(at: fixtureSubpath, file: file, line: line) - print(fixtureDir) let preparedFixture = try setup( fixtureDir: fixtureDir, in: tmpDirPath, diff --git a/Sources/XCBuildSupport/PIFBuilder.swift b/Sources/XCBuildSupport/PIFBuilder.swift index 375fd383f37..1927a7f16a3 100644 --- a/Sources/XCBuildSupport/PIFBuilder.swift +++ b/Sources/XCBuildSupport/PIFBuilder.swift @@ -1681,7 +1681,6 @@ private extension PIF.BuildSettings { if !packageOptions.isEmpty { self[.OTHER_SWIFT_FLAGS] = packageOptions } - } } diff --git a/Utilities/build-using-self b/Utilities/build-using-self index 1511f30c04e..bb27d73da38 100755 --- a/Utilities/build-using-self +++ b/Utilities/build-using-self @@ -3,7 +3,7 @@ ## ## This source file is part of the Swift open source project ## -## Copyright (c) 2014-2024 Apple Inc. and the Swift project authors +## Copyright (c) 2014-2022 Apple Inc. and the Swift project authors ## Licensed under Apache License v2.0 with Runtime Library Exception ## ## See http://swift.org/LICENSE.txt for license information From 9b9d0ed81dd819d64dd211ebc0fc9ab183f6f35c Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 16 Jan 2024 16:01:18 +0000 Subject: [PATCH 03/31] Enable `testPackageNameFlagXCBuild` only on macOS --- Tests/BuildTests/BuildPlanTests.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tests/BuildTests/BuildPlanTests.swift b/Tests/BuildTests/BuildPlanTests.swift index 977f8d7b48a..48a703cf99c 100644 --- a/Tests/BuildTests/BuildPlanTests.swift +++ b/Tests/BuildTests/BuildPlanTests.swift @@ -643,8 +643,9 @@ final class BuildPlanTests: XCTestCase { } XCTAssertMatch(stdout, .contains("Build complete!")) } - } + } + #if os(macOS) func testPackageNameFlagXCBuild() throws { try XCTSkipIfCI() // test is disabled because it isn't stable, see rdar://118239206 let isFlagSupportedInDriver = try DriverSupport.checkToolchainDriverFlags( @@ -674,6 +675,7 @@ final class BuildPlanTests: XCTestCase { XCTAssertMatch(stdout, .contains("Build succeeded")) } } + #endif func testTargetsWithPackageAccess() throws { let isFlagSupportedInDriver = try DriverSupport.checkToolchainDriverFlags( From 796c1b15dc714517580a5ee5820780a7552220bb Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 16 Jan 2024 16:18:51 +0000 Subject: [PATCH 04/31] Fix CMake build --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddbb5447b3d..029f3ffa337 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,5 +51,8 @@ find_package(dispatch QUIET) find_package(Foundation QUIET) find_package(SQLite3 REQUIRED) +# Enable `package` modifier for the whole package. +add_compile_options("$<$:-package-name;SwiftPM>") + add_subdirectory(Sources) add_subdirectory(cmake/modules) From 82a22b3f5ea521efa7d130620fb5816586b44e6f Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 16 Jan 2024 16:57:56 +0000 Subject: [PATCH 05/31] Address PR feedback --- .../SwiftTargetBuildDescription.swift | 24 ++++++++----------- Tests/BuildTests/BuildPlanTests.swift | 1 - 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift b/Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift index aaabd9b8852..5775f80c200 100644 --- a/Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift +++ b/Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift @@ -419,18 +419,6 @@ public final class SwiftTargetBuildDescription { try self.fileSystem.writeIfChanged(path: path, string: content) } - private func packageNameArgumentIfSupported(with pkg: ResolvedPackage, packageAccess: Bool) -> [String] { - let flag = "-package-name" - if pkg.manifest.usePackageNameFlag, - DriverSupport.isPackageNameSupported(toolchain: self.buildParameters.toolchain, fileSystem: self.fileSystem) { - if packageAccess { - let pkgID = pkg.identity.description.spm_mangledToC99ExtendedIdentifier() - return [flag, pkgID] - } - } - return [] - } - private func macroArguments() throws -> [String] { var args = [String]() @@ -631,7 +619,10 @@ public final class SwiftTargetBuildDescription { args += ["-user-module-version", version.description] } - args += self.packageNameArgumentIfSupported(with: self.package, packageAccess: self.target.packageAccess) + args += self.package.packageNameArgument( + target: self.target, + isPackageNameSupported: self.buildParameters.driverParameters.isPackageAccessModifierSupported + ) args += try self.macroArguments() // rdar://117578677 @@ -656,7 +647,12 @@ public final class SwiftTargetBuildDescription { result.append("-module-name") result.append(self.target.c99name) - result.append(contentsOf: packageNameArgumentIfSupported(with: self.package, packageAccess: self.target.packageAccess)) + result.append( + contentsOf: self.package.packageNameArgument( + target: self.target, + isPackageNameSupported: self.buildParameters.driverParameters.isPackageAccessModifierSupported + ) + ) if !scanInvocation { result.append("-emit-dependencies") diff --git a/Tests/BuildTests/BuildPlanTests.swift b/Tests/BuildTests/BuildPlanTests.swift index 48a703cf99c..76449d48dd1 100644 --- a/Tests/BuildTests/BuildPlanTests.swift +++ b/Tests/BuildTests/BuildPlanTests.swift @@ -647,7 +647,6 @@ final class BuildPlanTests: XCTestCase { #if os(macOS) func testPackageNameFlagXCBuild() throws { - try XCTSkipIfCI() // test is disabled because it isn't stable, see rdar://118239206 let isFlagSupportedInDriver = try DriverSupport.checkToolchainDriverFlags( flags: ["package-name"], toolchain: UserToolchain.default, From 2f60251778dbbd9ae29819614239b3a5bf10a908 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 16 Jan 2024 17:58:19 +0000 Subject: [PATCH 06/31] Add missing `SwiftDriver` dependency to `XCBuildSupport` --- Sources/XCBuildSupport/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/XCBuildSupport/CMakeLists.txt b/Sources/XCBuildSupport/CMakeLists.txt index 178e0bc1ba7..50c5f001e2a 100644 --- a/Sources/XCBuildSupport/CMakeLists.txt +++ b/Sources/XCBuildSupport/CMakeLists.txt @@ -18,6 +18,7 @@ target_link_libraries(XCBuildSupport PUBLIC TSCBasic TSCUtility PackageGraph + SwiftDriver ) set_target_properties(XCBuildSupport PROPERTIES From 427b5185c62d0f1aae566cbf191805e411003902 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 16 Jan 2024 21:01:59 +0000 Subject: [PATCH 07/31] Update BuildParameters.swift --- Sources/SPMBuildCore/BuildParameters/BuildParameters.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift b/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift index 0f285ec4997..cbc5cb5499c 100644 --- a/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift +++ b/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2020-2024 Apple Inc. and the Swift project authors +// Copyright (c) 2020-2023 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -132,7 +132,7 @@ public struct BuildParameters: Encodable { isXcodeBuildSystemEnabled: Bool = false, shouldSkipBuilding: Bool = false, debuggingParameters: Debugging? = nil, - driverParameters: Driver, + driverParameters: Driver = .init(), linkingParameters: Linking = .init(), outputParameters: Output = .init(), testingParameters: Testing? = nil From 46d01e5dbd5f4a1bd74b23fb55166ae39472259f Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 19 Jan 2024 12:38:09 +0000 Subject: [PATCH 08/31] Replace `package` modifier with `@testable` at place of use --- Sources/PackageGraph/PackageGraph.swift | 2 +- Tests/FunctionalTests/PluginTests.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/PackageGraph/PackageGraph.swift b/Sources/PackageGraph/PackageGraph.swift index 15d33a97495..bd3446b0499 100644 --- a/Sources/PackageGraph/PackageGraph.swift +++ b/Sources/PackageGraph/PackageGraph.swift @@ -180,7 +180,7 @@ public struct PackageGraph { } /// Computes a map from each executable target in any of the root packages to the corresponding test targets. - package func computeTestTargetsForExecutableTargets() throws -> [ResolvedTarget.ID: [ResolvedTarget]] { + func computeTestTargetsForExecutableTargets() throws -> [ResolvedTarget.ID: [ResolvedTarget]] { var result = [ResolvedTarget.ID: [ResolvedTarget]]() let rootTargets = IdentifiableSet(rootPackages.flatMap { $0.targets }) diff --git a/Tests/FunctionalTests/PluginTests.swift b/Tests/FunctionalTests/PluginTests.swift index 5905034012c..20eb444400e 100644 --- a/Tests/FunctionalTests/PluginTests.swift +++ b/Tests/FunctionalTests/PluginTests.swift @@ -11,7 +11,7 @@ //===----------------------------------------------------------------------===// import Basics -import PackageGraph +@testable import PackageGraph import PackageLoading import PackageModel @testable import SPMBuildCore From 6e4917115e38192b9e01055cdd06f18b9a3b41ac Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 19 Jan 2024 13:12:52 +0000 Subject: [PATCH 09/31] Replace `package` with `@_spi(SwiftPMInternal)` --- Sources/DriverSupport/DriverSupportUtils.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Sources/DriverSupport/DriverSupportUtils.swift b/Sources/DriverSupport/DriverSupportUtils.swift index c923a60e00d..8094bbdd85b 100644 --- a/Sources/DriverSupport/DriverSupportUtils.swift +++ b/Sources/DriverSupport/DriverSupportUtils.swift @@ -17,11 +17,13 @@ import class TSCBasic.Process import enum TSCBasic.ProcessEnv import struct TSCBasic.ProcessResult -package enum DriverSupport { +@_spi(SwiftPMInternal) +public enum DriverSupport { private static var flagsMap = ThreadSafeBox<[String: Set]>() - // This checks _frontend_ supported flags, which are not necessarily supported in the driver. - package static func checkSupportedFrontendFlags( + /// This checks _frontend_ supported flags, which are not necessarily supported in the driver. + @_spi(SwiftPMInternal) + public static func checkSupportedFrontendFlags( flags: Set, toolchain: PackageModel.Toolchain, fileSystem: FileSystem @@ -84,7 +86,8 @@ package enum DriverSupport { } } - package static func isPackageNameSupported(toolchain: PackageModel.Toolchain, fileSystem: FileSystem) -> Bool { + @_spi(SwiftPMInternal) + public static func isPackageNameSupported(toolchain: PackageModel.Toolchain, fileSystem: FileSystem) -> Bool { DriverSupport.checkToolchainDriverFlags(flags: ["-package-name"], toolchain: toolchain, fileSystem: fileSystem) } } From 42c868af98c01ae4a8c47151a0777ac9ef6b2eb1 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 19 Jan 2024 14:33:52 +0000 Subject: [PATCH 10/31] Fix remaining use of `package var` --- .../SPMBuildCore/BuildParameters/BuildParameters+Driver.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/SPMBuildCore/BuildParameters/BuildParameters+Driver.swift b/Sources/SPMBuildCore/BuildParameters/BuildParameters+Driver.swift index a526bcf3855..0355f182cfb 100644 --- a/Sources/SPMBuildCore/BuildParameters/BuildParameters+Driver.swift +++ b/Sources/SPMBuildCore/BuildParameters/BuildParameters+Driver.swift @@ -56,6 +56,7 @@ extension BuildParameters { /// Whether the version of Swift Driver used in the currently selected toolchain /// supports `-package-name` options. - package var isPackageAccessModifierSupported: Bool + @_spi(SwiftPMInternal) + public var isPackageAccessModifierSupported: Bool } } From 6bbf6e239b18fd18a691fb8a2e83dcf0e0eab500 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 19 Jan 2024 14:44:45 +0000 Subject: [PATCH 11/31] Fix use of `package func` --- Sources/SPMBuildCore/ResolvedPackage+Extensions.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/SPMBuildCore/ResolvedPackage+Extensions.swift b/Sources/SPMBuildCore/ResolvedPackage+Extensions.swift index 791299fe0bc..f4e433b8631 100644 --- a/Sources/SPMBuildCore/ResolvedPackage+Extensions.swift +++ b/Sources/SPMBuildCore/ResolvedPackage+Extensions.swift @@ -14,7 +14,8 @@ import struct PackageGraph.ResolvedPackage import struct PackageGraph.ResolvedTarget extension ResolvedPackage { - package func packageNameArgument(target: ResolvedTarget, isPackageNameSupported: Bool) -> [String] { + @_spi(SwiftPMInternal) + public func packageNameArgument(target: ResolvedTarget, isPackageNameSupported: Bool) -> [String] { if self.manifest.usePackageNameFlag, target.packageAccess { ["-package-name", self.identity.description.spm_mangledToC99ExtendedIdentifier()] } else { From 031ead4c0394d52c29769b5e33997f02c5daa744 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 19 Jan 2024 14:59:00 +0000 Subject: [PATCH 12/31] Add required `@_spi(SwiftPMInternal)` on imports --- .../SwiftTargetBuildDescription.swift | 15 ++++++++++++++- Sources/Build/BuildOperation.swift | 10 ++++++++-- .../Commands/Utilities/SymbolGraphExtract.swift | 5 ++++- Sources/CoreCommands/SwiftTool.swift | 5 ++++- Sources/XCBuildSupport/PIFBuilder.swift | 2 ++ Sources/XCBuildSupport/XcodeBuildSystem.swift | 2 ++ Sources/swift-bootstrap/main.swift | 3 +++ Tests/BuildTests/BuildPlanTests.swift | 6 +++++- Tests/CommandsTests/APIDiffTests.swift | 3 +++ 9 files changed, 45 insertions(+), 6 deletions(-) diff --git a/Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift b/Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift index 5775f80c200..392074e4df2 100644 --- a/Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift +++ b/Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift @@ -11,10 +11,16 @@ //===----------------------------------------------------------------------===// import Basics + +@_spi(SwiftPMInternal) +import DriverSupport + import Foundation import PackageGraph import PackageLoading import PackageModel + +@_spi(SwiftPMInternal) import SPMBuildCore #if USE_IMPL_ONLY_IMPORTS @@ -438,7 +444,14 @@ public final class SwiftTargetBuildDescription { #endif // If we're using an OSS toolchain, add the required arguments bringing in the plugin server from the default toolchain if available. - if self.buildParameters.toolchain.isSwiftDevelopmentToolchain, DriverSupport.checkSupportedFrontendFlags(flags: ["-external-plugin-path"], toolchain: self.buildParameters.toolchain, fileSystem: self.fileSystem), let pluginServer = try self.buildParameters.toolchain.swiftPluginServerPath { + if self.buildParameters.toolchain.isSwiftDevelopmentToolchain, + DriverSupport.checkSupportedFrontendFlags( + flags: ["-external-plugin-path"], + toolchain: self.buildParameters.toolchain, + fileSystem: self.fileSystem + ), + let pluginServer = try self.buildParameters.toolchain.swiftPluginServerPath + { let toolchainUsrPath = pluginServer.parentDirectory.parentDirectory let pluginPathComponents = ["lib", "swift", "host", "plugins"] diff --git a/Sources/Build/BuildOperation.swift b/Sources/Build/BuildOperation.swift index 4e53d621ae3..d3c9644ea4b 100644 --- a/Sources/Build/BuildOperation.swift +++ b/Sources/Build/BuildOperation.swift @@ -31,10 +31,16 @@ import class TSCUtility.NinjaProgressAnimation import protocol TSCUtility.ProgressAnimationProtocol #if USE_IMPL_ONLY_IMPORTS -@_implementationOnly import DriverSupport -@_implementationOnly import SwiftDriver +@_implementationOnly +@_spi(SwiftPMInternal) +import DriverSupport + +@_implementationOnly +import SwiftDriver #else +@_spi(SwiftPMInternal) import DriverSupport + import SwiftDriver #endif diff --git a/Sources/Commands/Utilities/SymbolGraphExtract.swift b/Sources/Commands/Utilities/SymbolGraphExtract.swift index f9423384c9b..44ba76a89ab 100644 --- a/Sources/Commands/Utilities/SymbolGraphExtract.swift +++ b/Sources/Commands/Utilities/SymbolGraphExtract.swift @@ -17,8 +17,11 @@ import PackageModel import SPMBuildCore #if USE_IMPL_ONLY_IMPORTS -@_implementationOnly import DriverSupport +@_implementationOnly +@_spi(SwiftPMInternal) +import DriverSupport #else +@_spi(SwiftPMInternal) import DriverSupport #endif diff --git a/Sources/CoreCommands/SwiftTool.swift b/Sources/CoreCommands/SwiftTool.swift index 5d0026dbe69..d817ebcbecd 100644 --- a/Sources/CoreCommands/SwiftTool.swift +++ b/Sources/CoreCommands/SwiftTool.swift @@ -22,8 +22,11 @@ import SPMBuildCore import Workspace #if USE_IMPL_ONLY_IMPORTS -@_implementationOnly import DriverSupport +@_implementationOnly +@_spi(SwiftPMInternal) +import DriverSupport #else +@_spi(SwiftPMInternal) import DriverSupport #endif diff --git a/Sources/XCBuildSupport/PIFBuilder.swift b/Sources/XCBuildSupport/PIFBuilder.swift index a1bd8a1ad52..5f74733b9fb 100644 --- a/Sources/XCBuildSupport/PIFBuilder.swift +++ b/Sources/XCBuildSupport/PIFBuilder.swift @@ -15,6 +15,8 @@ import Basics import PackageModel import PackageLoading import PackageGraph + +@_spi(SwiftPMInternal) import SPMBuildCore import func TSCBasic.topologicalSort diff --git a/Sources/XCBuildSupport/XcodeBuildSystem.swift b/Sources/XCBuildSupport/XcodeBuildSystem.swift index 2eba400bcc4..123f52cefdc 100644 --- a/Sources/XCBuildSupport/XcodeBuildSystem.swift +++ b/Sources/XCBuildSupport/XcodeBuildSystem.swift @@ -15,6 +15,8 @@ import Dispatch import class Foundation.JSONEncoder import PackageGraph import PackageModel + +@_spi(SwiftPMInternal) import SPMBuildCore import protocol TSCBasic.OutputByteStream diff --git a/Sources/swift-bootstrap/main.swift b/Sources/swift-bootstrap/main.swift index 7350a56d41e..bc4cb566527 100644 --- a/Sources/swift-bootstrap/main.swift +++ b/Sources/swift-bootstrap/main.swift @@ -14,7 +14,10 @@ import ArgumentParser import Basics import Build import Dispatch + +@_spi(SwiftPMInternal) import DriverSupport + import Foundation import OrderedCollections import PackageGraph diff --git a/Tests/BuildTests/BuildPlanTests.swift b/Tests/BuildTests/BuildPlanTests.swift index 708f25d1b83..e57c0faa8f8 100644 --- a/Tests/BuildTests/BuildPlanTests.swift +++ b/Tests/BuildTests/BuildPlanTests.swift @@ -12,7 +12,11 @@ @testable import Basics @testable import Build -@testable import DriverSupport + +@testable +@_spi(SwiftPMInternal) +import DriverSupport + @testable import PackageGraph import PackageLoading @testable import PackageModel diff --git a/Tests/CommandsTests/APIDiffTests.swift b/Tests/CommandsTests/APIDiffTests.swift index 7ab9a5fdd20..0f700957ac8 100644 --- a/Tests/CommandsTests/APIDiffTests.swift +++ b/Tests/CommandsTests/APIDiffTests.swift @@ -13,7 +13,10 @@ import Basics import Build import Commands + +@_spi(SwiftPMInternal) import DriverSupport + import Foundation import PackageModel import SourceControl From 44d7267730f6312bf5b0bea02966250c4e4053c3 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 22 Jan 2024 13:09:44 +0000 Subject: [PATCH 13/31] Update `SourceKitLSPAPI/CMakeLists.txt` --- Sources/SourceKitLSPAPI/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/SourceKitLSPAPI/CMakeLists.txt b/Sources/SourceKitLSPAPI/CMakeLists.txt index 243bda5650f..f28f793c1c1 100644 --- a/Sources/SourceKitLSPAPI/CMakeLists.txt +++ b/Sources/SourceKitLSPAPI/CMakeLists.txt @@ -11,7 +11,8 @@ add_library(SourceKitLSPAPI STATIC PluginTargetBuildDescription.swift) target_link_libraries(SourceKitLSPAPI PUBLIC Build - SPMBuildCore) + SPMBuildCore + SwiftDriver) # NOTE(compnerd) workaround for CMake not setting up include flags yet set_target_properties(SourceKitLSPAPI PROPERTIES From 4d4a8f439f44acf26034ea08f119f7bf2a3bafcf Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 22 Jan 2024 16:08:34 +0000 Subject: [PATCH 14/31] Update `XCBuildSupport/CMakeLists.txt` --- Sources/XCBuildSupport/CMakeLists.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Sources/XCBuildSupport/CMakeLists.txt b/Sources/XCBuildSupport/CMakeLists.txt index 50c5f001e2a..747333da119 100644 --- a/Sources/XCBuildSupport/CMakeLists.txt +++ b/Sources/XCBuildSupport/CMakeLists.txt @@ -13,12 +13,14 @@ add_library(XCBuildSupport STATIC XCBuildMessage.swift XCBuildOutputParser.swift XcodeBuildSystem.swift) -target_link_libraries(XCBuildSupport PUBLIC - Build - TSCBasic - TSCUtility - PackageGraph - SwiftDriver +target_link_libraries(XCBuildSupport + PUBLIC + Build + TSCBasic + TSCUtility + PackageGraph + PRIVATE + SwiftDriver ) set_target_properties(XCBuildSupport PROPERTIES From e23f9c77cdae592a485fd7e8d33c07c83862703a Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 22 Jan 2024 21:31:49 +0000 Subject: [PATCH 15/31] Update `swift-bootstrap/CMakeLists.txt` --- Sources/swift-bootstrap/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/swift-bootstrap/CMakeLists.txt b/Sources/swift-bootstrap/CMakeLists.txt index f2c40f4c8a0..92052ac7098 100644 --- a/Sources/swift-bootstrap/CMakeLists.txt +++ b/Sources/swift-bootstrap/CMakeLists.txt @@ -15,6 +15,7 @@ target_link_libraries(swift-bootstrap PRIVATE PackageGraph PackageLoading PackageModel + SwiftDriver TSCBasic TSCUtility XCBuildSupport) From 553f559109cf2950c6716632ea37730c296aa105 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 23 Jan 2024 14:26:01 +0000 Subject: [PATCH 16/31] Update `SwiftSDKTool/CMakeLists.txt` --- Sources/SwiftSDKTool/CMakeLists.txt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Sources/SwiftSDKTool/CMakeLists.txt b/Sources/SwiftSDKTool/CMakeLists.txt index 607582ab432..b4198191950 100644 --- a/Sources/SwiftSDKTool/CMakeLists.txt +++ b/Sources/SwiftSDKTool/CMakeLists.txt @@ -17,12 +17,16 @@ add_library(SwiftSDKTool ListSwiftSDKs.swift RemoveSwiftSDK.swift SwiftSDKTool.swift) -target_link_libraries(SwiftSDKTool PUBLIC - ArgumentParser - Basics - CoreCommands - SPMBuildCore - PackageModel) +target_link_libraries(SwiftSDKTool + PUBLIC + ArgumentParser + Basics + CoreCommands + SPMBuildCore + PackageModel + PRIVATE + SwiftDriver) + # NOTE(compnerd) workaround for CMake not setting up include flags yet set_target_properties(SwiftSDKTool PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) From 95ff5da647e93b4d0afdf5510adad7c9aa4633cf Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Wed, 24 Jan 2024 15:12:46 +0000 Subject: [PATCH 17/31] Update `swift-experimental-sdk/CMakeLists.txt` --- Sources/swift-experimental-sdk/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/swift-experimental-sdk/CMakeLists.txt b/Sources/swift-experimental-sdk/CMakeLists.txt index b7d9cace5f8..283afcd7a12 100644 --- a/Sources/swift-experimental-sdk/CMakeLists.txt +++ b/Sources/swift-experimental-sdk/CMakeLists.txt @@ -9,6 +9,7 @@ add_executable(swift-experimental-sdk Entrypoint.swift) target_link_libraries(swift-experimental-sdk PRIVATE + SwiftDriver SwiftSDKTool) target_compile_options(swift-experimental-sdk PRIVATE From e83dc697b10898367464851091f73ac6cff64fcf Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 26 Jan 2024 12:30:33 +0000 Subject: [PATCH 18/31] Update `swift-build/CMakeLists.txt` --- Sources/swift-build/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/swift-build/CMakeLists.txt b/Sources/swift-build/CMakeLists.txt index 4488799b1f5..218d09da71d 100644 --- a/Sources/swift-build/CMakeLists.txt +++ b/Sources/swift-build/CMakeLists.txt @@ -9,7 +9,8 @@ add_executable(swift-build main.swift) target_link_libraries(swift-build PRIVATE - Commands) + Commands + SwiftDriver) install(TARGETS swift-build DESTINATION bin) From 35d949bc4cf58db709bdaa000090452a3125181d Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 26 Jan 2024 12:34:16 +0000 Subject: [PATCH 19/31] Update `swift-package/CMakeLists.txt` --- Sources/swift-package/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/swift-package/CMakeLists.txt b/Sources/swift-package/CMakeLists.txt index 3468bdefcdc..f89dd7e0f70 100644 --- a/Sources/swift-package/CMakeLists.txt +++ b/Sources/swift-package/CMakeLists.txt @@ -10,6 +10,7 @@ add_executable(swift-package Entrypoint.swift) target_link_libraries(swift-package PRIVATE Commands + SwiftDriver TSCBasic) target_compile_options(swift-package PRIVATE From 3be01c325134ad6c5fa1e90e430f018a7677c977 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 26 Jan 2024 12:34:45 +0000 Subject: [PATCH 20/31] Update `swift-run/CMakeLists.txt` --- Sources/swift-run/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/swift-run/CMakeLists.txt b/Sources/swift-run/CMakeLists.txt index 26b4ac9e321..70dc405ccc5 100644 --- a/Sources/swift-run/CMakeLists.txt +++ b/Sources/swift-run/CMakeLists.txt @@ -9,7 +9,8 @@ add_executable(swift-run main.swift) target_link_libraries(swift-run PRIVATE - Commands) + Commands + SwiftDriver) install(TARGETS swift-run RUNTIME DESTINATION bin) From 1565886c276e947072631e9706b591dfc427d724 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 26 Jan 2024 12:35:10 +0000 Subject: [PATCH 21/31] Update `swift-test/CMakeLists.txt` --- Sources/swift-test/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/swift-test/CMakeLists.txt b/Sources/swift-test/CMakeLists.txt index 896da188ad9..959afac542d 100644 --- a/Sources/swift-test/CMakeLists.txt +++ b/Sources/swift-test/CMakeLists.txt @@ -9,7 +9,8 @@ add_executable(swift-test main.swift) target_link_libraries(swift-test PRIVATE - Commands) + Commands + SwiftDriver) install(TARGETS swift-test RUNTIME DESTINATION bin) From c57d3f50f6f766c490935373268359829932c660 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 16 Feb 2024 18:35:15 +0000 Subject: [PATCH 22/31] Clean up `DriverSupport` imports --- Package.swift | 1 - Sources/Build/BuildOperation.swift | 22 ++++++++----------- .../Utilities/SymbolGraphExtract.swift | 5 +---- .../DriverSupport/DriverSupportUtils.swift | 3 --- Sources/SourceKitLSPAPI/CMakeLists.txt | 3 +-- Sources/SwiftSDKTool/CMakeLists.txt | 16 +++++--------- Sources/swift-build/CMakeLists.txt | 3 +-- Sources/swift-experimental-sdk/CMakeLists.txt | 1 - Sources/swift-package/CMakeLists.txt | 1 - Sources/swift-run/CMakeLists.txt | 3 +-- Sources/swift-test/CMakeLists.txt | 3 +-- 11 files changed, 20 insertions(+), 41 deletions(-) diff --git a/Package.swift b/Package.swift index 524574159ae..4938aea929b 100644 --- a/Package.swift +++ b/Package.swift @@ -463,7 +463,6 @@ let package = Package( .product(name: "ArgumentParser", package: "swift-argument-parser"), "Basics", "Build", - "DriverSupport", "PackageGraph", "PackageLoading", "PackageModel", diff --git a/Sources/Build/BuildOperation.swift b/Sources/Build/BuildOperation.swift index 55cac6d62d4..65f7d9e5c8f 100644 --- a/Sources/Build/BuildOperation.swift +++ b/Sources/Build/BuildOperation.swift @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// -@_spi(SwiftPMInternal) import Basics import LLBuildManifest import PackageGraph @@ -27,18 +26,15 @@ import enum TSCBasic.ProcessEnv import struct TSCBasic.RegEx import enum TSCUtility.Diagnostics +import class TSCUtility.MultiLineNinjaProgressAnimation +import class TSCUtility.NinjaProgressAnimation +import protocol TSCUtility.ProgressAnimationProtocol #if USE_IMPL_ONLY_IMPORTS -@_implementationOnly -@_spi(SwiftPMInternal) -import DriverSupport - -@_implementationOnly -import SwiftDriver +@_implementationOnly import DriverSupport +@_implementationOnly import SwiftDriver #else -@_spi(SwiftPMInternal) import DriverSupport - import SwiftDriver #endif @@ -613,10 +609,10 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS /// building the package structure target. private func createBuildSystem(buildDescription: BuildDescription?) throws -> SPMLLBuild.BuildSystem { // Figure out which progress bar we have to use during the build. - let progressAnimation = ProgressAnimation.ninja( - stream: self.outputStream, - verbose: self.logLevel.isVerbose - ) + let progressAnimation: ProgressAnimationProtocol = self.logLevel.isVerbose + ? MultiLineNinjaProgressAnimation(stream: self.outputStream) + : NinjaProgressAnimation(stream: self.outputStream) + let buildExecutionContext = BuildExecutionContext( productsBuildParameters: self.productsBuildParameters, toolsBuildParameters: self.toolsBuildParameters, diff --git a/Sources/Commands/Utilities/SymbolGraphExtract.swift b/Sources/Commands/Utilities/SymbolGraphExtract.swift index 44ba76a89ab..f9423384c9b 100644 --- a/Sources/Commands/Utilities/SymbolGraphExtract.swift +++ b/Sources/Commands/Utilities/SymbolGraphExtract.swift @@ -17,11 +17,8 @@ import PackageModel import SPMBuildCore #if USE_IMPL_ONLY_IMPORTS -@_implementationOnly -@_spi(SwiftPMInternal) -import DriverSupport +@_implementationOnly import DriverSupport #else -@_spi(SwiftPMInternal) import DriverSupport #endif diff --git a/Sources/DriverSupport/DriverSupportUtils.swift b/Sources/DriverSupport/DriverSupportUtils.swift index 8094bbdd85b..73d182c8000 100644 --- a/Sources/DriverSupport/DriverSupportUtils.swift +++ b/Sources/DriverSupport/DriverSupportUtils.swift @@ -17,12 +17,10 @@ import class TSCBasic.Process import enum TSCBasic.ProcessEnv import struct TSCBasic.ProcessResult -@_spi(SwiftPMInternal) public enum DriverSupport { private static var flagsMap = ThreadSafeBox<[String: Set]>() /// This checks _frontend_ supported flags, which are not necessarily supported in the driver. - @_spi(SwiftPMInternal) public static func checkSupportedFrontendFlags( flags: Set, toolchain: PackageModel.Toolchain, @@ -86,7 +84,6 @@ public enum DriverSupport { } } - @_spi(SwiftPMInternal) public static func isPackageNameSupported(toolchain: PackageModel.Toolchain, fileSystem: FileSystem) -> Bool { DriverSupport.checkToolchainDriverFlags(flags: ["-package-name"], toolchain: toolchain, fileSystem: fileSystem) } diff --git a/Sources/SourceKitLSPAPI/CMakeLists.txt b/Sources/SourceKitLSPAPI/CMakeLists.txt index f28f793c1c1..243bda5650f 100644 --- a/Sources/SourceKitLSPAPI/CMakeLists.txt +++ b/Sources/SourceKitLSPAPI/CMakeLists.txt @@ -11,8 +11,7 @@ add_library(SourceKitLSPAPI STATIC PluginTargetBuildDescription.swift) target_link_libraries(SourceKitLSPAPI PUBLIC Build - SPMBuildCore - SwiftDriver) + SPMBuildCore) # NOTE(compnerd) workaround for CMake not setting up include flags yet set_target_properties(SourceKitLSPAPI PROPERTIES diff --git a/Sources/SwiftSDKTool/CMakeLists.txt b/Sources/SwiftSDKTool/CMakeLists.txt index b4198191950..607582ab432 100644 --- a/Sources/SwiftSDKTool/CMakeLists.txt +++ b/Sources/SwiftSDKTool/CMakeLists.txt @@ -17,16 +17,12 @@ add_library(SwiftSDKTool ListSwiftSDKs.swift RemoveSwiftSDK.swift SwiftSDKTool.swift) -target_link_libraries(SwiftSDKTool - PUBLIC - ArgumentParser - Basics - CoreCommands - SPMBuildCore - PackageModel - PRIVATE - SwiftDriver) - +target_link_libraries(SwiftSDKTool PUBLIC + ArgumentParser + Basics + CoreCommands + SPMBuildCore + PackageModel) # NOTE(compnerd) workaround for CMake not setting up include flags yet set_target_properties(SwiftSDKTool PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) diff --git a/Sources/swift-build/CMakeLists.txt b/Sources/swift-build/CMakeLists.txt index 218d09da71d..4488799b1f5 100644 --- a/Sources/swift-build/CMakeLists.txt +++ b/Sources/swift-build/CMakeLists.txt @@ -9,8 +9,7 @@ add_executable(swift-build main.swift) target_link_libraries(swift-build PRIVATE - Commands - SwiftDriver) + Commands) install(TARGETS swift-build DESTINATION bin) diff --git a/Sources/swift-experimental-sdk/CMakeLists.txt b/Sources/swift-experimental-sdk/CMakeLists.txt index 283afcd7a12..b7d9cace5f8 100644 --- a/Sources/swift-experimental-sdk/CMakeLists.txt +++ b/Sources/swift-experimental-sdk/CMakeLists.txt @@ -9,7 +9,6 @@ add_executable(swift-experimental-sdk Entrypoint.swift) target_link_libraries(swift-experimental-sdk PRIVATE - SwiftDriver SwiftSDKTool) target_compile_options(swift-experimental-sdk PRIVATE diff --git a/Sources/swift-package/CMakeLists.txt b/Sources/swift-package/CMakeLists.txt index f89dd7e0f70..3468bdefcdc 100644 --- a/Sources/swift-package/CMakeLists.txt +++ b/Sources/swift-package/CMakeLists.txt @@ -10,7 +10,6 @@ add_executable(swift-package Entrypoint.swift) target_link_libraries(swift-package PRIVATE Commands - SwiftDriver TSCBasic) target_compile_options(swift-package PRIVATE diff --git a/Sources/swift-run/CMakeLists.txt b/Sources/swift-run/CMakeLists.txt index 70dc405ccc5..26b4ac9e321 100644 --- a/Sources/swift-run/CMakeLists.txt +++ b/Sources/swift-run/CMakeLists.txt @@ -9,8 +9,7 @@ add_executable(swift-run main.swift) target_link_libraries(swift-run PRIVATE - Commands - SwiftDriver) + Commands) install(TARGETS swift-run RUNTIME DESTINATION bin) diff --git a/Sources/swift-test/CMakeLists.txt b/Sources/swift-test/CMakeLists.txt index 959afac542d..896da188ad9 100644 --- a/Sources/swift-test/CMakeLists.txt +++ b/Sources/swift-test/CMakeLists.txt @@ -9,8 +9,7 @@ add_executable(swift-test main.swift) target_link_libraries(swift-test PRIVATE - Commands - SwiftDriver) + Commands) install(TARGETS swift-test RUNTIME DESTINATION bin) From 398dd3e4b89390e7053a8aa68552b50a44f1b5ee Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 16 Feb 2024 18:56:50 +0000 Subject: [PATCH 23/31] More cleanups --- Package.swift | 2 +- Sources/swift-bootstrap/CMakeLists.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index 4938aea929b..5f537781a0d 100644 --- a/Package.swift +++ b/Package.swift @@ -334,7 +334,7 @@ let package = Package( .target( /** Support for building using Xcode's build system */ name: "XCBuildSupport", - dependencies: ["SPMBuildCore", "PackageGraph"], + dependencies: ["DriverSupport", "SPMBuildCore", "PackageGraph"], exclude: ["CMakeLists.txt", "CODEOWNERS"] ), .target( diff --git a/Sources/swift-bootstrap/CMakeLists.txt b/Sources/swift-bootstrap/CMakeLists.txt index 92052ac7098..f2c40f4c8a0 100644 --- a/Sources/swift-bootstrap/CMakeLists.txt +++ b/Sources/swift-bootstrap/CMakeLists.txt @@ -15,7 +15,6 @@ target_link_libraries(swift-bootstrap PRIVATE PackageGraph PackageLoading PackageModel - SwiftDriver TSCBasic TSCUtility XCBuildSupport) From 7749bab6a70f5362be7e02470d09a8bb59803429 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 16 Feb 2024 20:21:08 +0000 Subject: [PATCH 24/31] Add `DriverSupport` missing in `swift-bootstrap` CMake --- Sources/swift-bootstrap/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/swift-bootstrap/CMakeLists.txt b/Sources/swift-bootstrap/CMakeLists.txt index f2c40f4c8a0..8ad39abe3d8 100644 --- a/Sources/swift-bootstrap/CMakeLists.txt +++ b/Sources/swift-bootstrap/CMakeLists.txt @@ -12,6 +12,7 @@ target_link_libraries(swift-bootstrap PRIVATE ArgumentParser Basics Build + DriverSupport PackageGraph PackageLoading PackageModel From df2daf5ed5cd2a8d3d507b834e5aa8d55f01cd7b Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Sat, 17 Feb 2024 11:30:26 +0000 Subject: [PATCH 25/31] Add `SwiftDriver` as `PRIVATE` requirement to `target_link_libraries` --- Sources/SourceKitLSPAPI/CMakeLists.txt | 9 ++++++--- Sources/SwiftSDKTool/CMakeLists.txt | 16 ++++++++++------ Sources/swift-build/CMakeLists.txt | 3 ++- Sources/swift-experimental-sdk/CMakeLists.txt | 3 ++- Sources/swift-package/CMakeLists.txt | 3 ++- Sources/swift-run/CMakeLists.txt | 3 ++- Sources/swift-test/CMakeLists.txt | 3 ++- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Sources/SourceKitLSPAPI/CMakeLists.txt b/Sources/SourceKitLSPAPI/CMakeLists.txt index 243bda5650f..904c90c1bd5 100644 --- a/Sources/SourceKitLSPAPI/CMakeLists.txt +++ b/Sources/SourceKitLSPAPI/CMakeLists.txt @@ -9,9 +9,12 @@ add_library(SourceKitLSPAPI STATIC BuildDescription.swift PluginTargetBuildDescription.swift) -target_link_libraries(SourceKitLSPAPI PUBLIC - Build - SPMBuildCore) +target_link_libraries(SourceKitLSPAPI + PUBLIC + Build + SPMBuildCore + PRIVATE + SwiftDriver) # NOTE(compnerd) workaround for CMake not setting up include flags yet set_target_properties(SourceKitLSPAPI PROPERTIES diff --git a/Sources/SwiftSDKTool/CMakeLists.txt b/Sources/SwiftSDKTool/CMakeLists.txt index 607582ab432..b4198191950 100644 --- a/Sources/SwiftSDKTool/CMakeLists.txt +++ b/Sources/SwiftSDKTool/CMakeLists.txt @@ -17,12 +17,16 @@ add_library(SwiftSDKTool ListSwiftSDKs.swift RemoveSwiftSDK.swift SwiftSDKTool.swift) -target_link_libraries(SwiftSDKTool PUBLIC - ArgumentParser - Basics - CoreCommands - SPMBuildCore - PackageModel) +target_link_libraries(SwiftSDKTool + PUBLIC + ArgumentParser + Basics + CoreCommands + SPMBuildCore + PackageModel + PRIVATE + SwiftDriver) + # NOTE(compnerd) workaround for CMake not setting up include flags yet set_target_properties(SwiftSDKTool PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) diff --git a/Sources/swift-build/CMakeLists.txt b/Sources/swift-build/CMakeLists.txt index 4488799b1f5..218d09da71d 100644 --- a/Sources/swift-build/CMakeLists.txt +++ b/Sources/swift-build/CMakeLists.txt @@ -9,7 +9,8 @@ add_executable(swift-build main.swift) target_link_libraries(swift-build PRIVATE - Commands) + Commands + SwiftDriver) install(TARGETS swift-build DESTINATION bin) diff --git a/Sources/swift-experimental-sdk/CMakeLists.txt b/Sources/swift-experimental-sdk/CMakeLists.txt index b7d9cace5f8..fd034eef2f1 100644 --- a/Sources/swift-experimental-sdk/CMakeLists.txt +++ b/Sources/swift-experimental-sdk/CMakeLists.txt @@ -9,7 +9,8 @@ add_executable(swift-experimental-sdk Entrypoint.swift) target_link_libraries(swift-experimental-sdk PRIVATE - SwiftSDKTool) + SwiftSDKTool + SwiftDriver) target_compile_options(swift-experimental-sdk PRIVATE -parse-as-library) diff --git a/Sources/swift-package/CMakeLists.txt b/Sources/swift-package/CMakeLists.txt index 3468bdefcdc..f84402272b7 100644 --- a/Sources/swift-package/CMakeLists.txt +++ b/Sources/swift-package/CMakeLists.txt @@ -10,7 +10,8 @@ add_executable(swift-package Entrypoint.swift) target_link_libraries(swift-package PRIVATE Commands - TSCBasic) + TSCBasic + SwiftDriver) target_compile_options(swift-package PRIVATE -parse-as-library) diff --git a/Sources/swift-run/CMakeLists.txt b/Sources/swift-run/CMakeLists.txt index 26b4ac9e321..70dc405ccc5 100644 --- a/Sources/swift-run/CMakeLists.txt +++ b/Sources/swift-run/CMakeLists.txt @@ -9,7 +9,8 @@ add_executable(swift-run main.swift) target_link_libraries(swift-run PRIVATE - Commands) + Commands + SwiftDriver) install(TARGETS swift-run RUNTIME DESTINATION bin) diff --git a/Sources/swift-test/CMakeLists.txt b/Sources/swift-test/CMakeLists.txt index 896da188ad9..959afac542d 100644 --- a/Sources/swift-test/CMakeLists.txt +++ b/Sources/swift-test/CMakeLists.txt @@ -9,7 +9,8 @@ add_executable(swift-test main.swift) target_link_libraries(swift-test PRIVATE - Commands) + Commands + SwiftDriver) install(TARGETS swift-test RUNTIME DESTINATION bin) From f9b7f1afebb700b4555ce58ad4f9ddaee91308c4 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 23 Feb 2024 13:48:54 +0000 Subject: [PATCH 26/31] Reduce diff to `main` --- Sources/SourceKitLSPAPI/CMakeLists.txt | 9 +++------ Sources/SwiftSDKTool/CMakeLists.txt | 16 ++++++---------- Sources/swift-bootstrap/CMakeLists.txt | 7 ++----- Sources/swift-build/CMakeLists.txt | 3 +-- Sources/swift-experimental-sdk/CMakeLists.txt | 3 +-- Sources/swift-package/CMakeLists.txt | 3 +-- Sources/swift-run/CMakeLists.txt | 3 +-- Sources/swift-test/CMakeLists.txt | 3 +-- 8 files changed, 16 insertions(+), 31 deletions(-) diff --git a/Sources/SourceKitLSPAPI/CMakeLists.txt b/Sources/SourceKitLSPAPI/CMakeLists.txt index 904c90c1bd5..243bda5650f 100644 --- a/Sources/SourceKitLSPAPI/CMakeLists.txt +++ b/Sources/SourceKitLSPAPI/CMakeLists.txt @@ -9,12 +9,9 @@ add_library(SourceKitLSPAPI STATIC BuildDescription.swift PluginTargetBuildDescription.swift) -target_link_libraries(SourceKitLSPAPI - PUBLIC - Build - SPMBuildCore - PRIVATE - SwiftDriver) +target_link_libraries(SourceKitLSPAPI PUBLIC + Build + SPMBuildCore) # NOTE(compnerd) workaround for CMake not setting up include flags yet set_target_properties(SourceKitLSPAPI PROPERTIES diff --git a/Sources/SwiftSDKTool/CMakeLists.txt b/Sources/SwiftSDKTool/CMakeLists.txt index b4198191950..607582ab432 100644 --- a/Sources/SwiftSDKTool/CMakeLists.txt +++ b/Sources/SwiftSDKTool/CMakeLists.txt @@ -17,16 +17,12 @@ add_library(SwiftSDKTool ListSwiftSDKs.swift RemoveSwiftSDK.swift SwiftSDKTool.swift) -target_link_libraries(SwiftSDKTool - PUBLIC - ArgumentParser - Basics - CoreCommands - SPMBuildCore - PackageModel - PRIVATE - SwiftDriver) - +target_link_libraries(SwiftSDKTool PUBLIC + ArgumentParser + Basics + CoreCommands + SPMBuildCore + PackageModel) # NOTE(compnerd) workaround for CMake not setting up include flags yet set_target_properties(SwiftSDKTool PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) diff --git a/Sources/swift-bootstrap/CMakeLists.txt b/Sources/swift-bootstrap/CMakeLists.txt index 46ec5df6da4..f2c40f4c8a0 100644 --- a/Sources/swift-bootstrap/CMakeLists.txt +++ b/Sources/swift-bootstrap/CMakeLists.txt @@ -12,12 +12,9 @@ target_link_libraries(swift-bootstrap PRIVATE ArgumentParser Basics Build - DriverSupport PackageGraph PackageLoading PackageModel TSCBasic - TSCUtility) - -target_compile_definitions(swift-bootstrap - PRIVATE DISABLE_XCBUILD_SUPPORT) + TSCUtility + XCBuildSupport) diff --git a/Sources/swift-build/CMakeLists.txt b/Sources/swift-build/CMakeLists.txt index 218d09da71d..4488799b1f5 100644 --- a/Sources/swift-build/CMakeLists.txt +++ b/Sources/swift-build/CMakeLists.txt @@ -9,8 +9,7 @@ add_executable(swift-build main.swift) target_link_libraries(swift-build PRIVATE - Commands - SwiftDriver) + Commands) install(TARGETS swift-build DESTINATION bin) diff --git a/Sources/swift-experimental-sdk/CMakeLists.txt b/Sources/swift-experimental-sdk/CMakeLists.txt index fd034eef2f1..b7d9cace5f8 100644 --- a/Sources/swift-experimental-sdk/CMakeLists.txt +++ b/Sources/swift-experimental-sdk/CMakeLists.txt @@ -9,8 +9,7 @@ add_executable(swift-experimental-sdk Entrypoint.swift) target_link_libraries(swift-experimental-sdk PRIVATE - SwiftSDKTool - SwiftDriver) + SwiftSDKTool) target_compile_options(swift-experimental-sdk PRIVATE -parse-as-library) diff --git a/Sources/swift-package/CMakeLists.txt b/Sources/swift-package/CMakeLists.txt index f84402272b7..3468bdefcdc 100644 --- a/Sources/swift-package/CMakeLists.txt +++ b/Sources/swift-package/CMakeLists.txt @@ -10,8 +10,7 @@ add_executable(swift-package Entrypoint.swift) target_link_libraries(swift-package PRIVATE Commands - TSCBasic - SwiftDriver) + TSCBasic) target_compile_options(swift-package PRIVATE -parse-as-library) diff --git a/Sources/swift-run/CMakeLists.txt b/Sources/swift-run/CMakeLists.txt index 70dc405ccc5..26b4ac9e321 100644 --- a/Sources/swift-run/CMakeLists.txt +++ b/Sources/swift-run/CMakeLists.txt @@ -9,8 +9,7 @@ add_executable(swift-run main.swift) target_link_libraries(swift-run PRIVATE - Commands - SwiftDriver) + Commands) install(TARGETS swift-run RUNTIME DESTINATION bin) diff --git a/Sources/swift-test/CMakeLists.txt b/Sources/swift-test/CMakeLists.txt index 959afac542d..896da188ad9 100644 --- a/Sources/swift-test/CMakeLists.txt +++ b/Sources/swift-test/CMakeLists.txt @@ -9,8 +9,7 @@ add_executable(swift-test main.swift) target_link_libraries(swift-test PRIVATE - Commands - SwiftDriver) + Commands) install(TARGETS swift-test RUNTIME DESTINATION bin) From af4e9e67d456b1206fd1beb9f6ec8ff4a33a6995 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 23 Feb 2024 13:51:35 +0000 Subject: [PATCH 27/31] Add `@_spi(SwiftPMInternal)` on `isPackageNameSupported` --- Sources/DriverSupport/DriverSupportUtils.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/DriverSupport/DriverSupportUtils.swift b/Sources/DriverSupport/DriverSupportUtils.swift index 73d182c8000..7f8452ecc10 100644 --- a/Sources/DriverSupport/DriverSupportUtils.swift +++ b/Sources/DriverSupport/DriverSupportUtils.swift @@ -84,6 +84,7 @@ public enum DriverSupport { } } + @_spi(SwiftPMInternal) public static func isPackageNameSupported(toolchain: PackageModel.Toolchain, fileSystem: FileSystem) -> Bool { DriverSupport.checkToolchainDriverFlags(flags: ["-package-name"], toolchain: toolchain, fileSystem: fileSystem) } From 3d7fab2909675b3caf65028c50467d7de8557485 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 23 Feb 2024 13:53:17 +0000 Subject: [PATCH 28/31] Reduce diff to `main` --- Sources/Build/BuildOperation.swift | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Sources/Build/BuildOperation.swift b/Sources/Build/BuildOperation.swift index 933d2279923..fab2429cccf 100644 --- a/Sources/Build/BuildOperation.swift +++ b/Sources/Build/BuildOperation.swift @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +@_spi(SwiftPMInternal) import Basics import LLBuildManifest import PackageGraph @@ -26,9 +27,6 @@ import enum TSCBasic.ProcessEnv import struct TSCBasic.RegEx import enum TSCUtility.Diagnostics -import class TSCUtility.MultiLineNinjaProgressAnimation -import class TSCUtility.NinjaProgressAnimation -import protocol TSCUtility.ProgressAnimationProtocol #if USE_IMPL_ONLY_IMPORTS @_implementationOnly import DriverSupport @@ -696,10 +694,10 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS /// building the package structure target. private func createBuildSystem(buildDescription: BuildDescription?) throws -> SPMLLBuild.BuildSystem { // Figure out which progress bar we have to use during the build. - let progressAnimation: ProgressAnimationProtocol = self.logLevel.isVerbose - ? MultiLineNinjaProgressAnimation(stream: self.outputStream) - : NinjaProgressAnimation(stream: self.outputStream) - + let progressAnimation = ProgressAnimation.ninja( + stream: self.outputStream, + verbose: self.logLevel.isVerbose + ) let buildExecutionContext = BuildExecutionContext( productsBuildParameters: self.productsBuildParameters, toolsBuildParameters: self.toolsBuildParameters, From 2f7e094aa36c08dac81b45e22300f17baf81f5bc Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 23 Feb 2024 14:51:37 +0000 Subject: [PATCH 29/31] Add missing `SwiftDriver` requirement to `swift-bootstrap/CMakeLists.txt` --- Sources/swift-bootstrap/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/swift-bootstrap/CMakeLists.txt b/Sources/swift-bootstrap/CMakeLists.txt index f2c40f4c8a0..92052ac7098 100644 --- a/Sources/swift-bootstrap/CMakeLists.txt +++ b/Sources/swift-bootstrap/CMakeLists.txt @@ -15,6 +15,7 @@ target_link_libraries(swift-bootstrap PRIVATE PackageGraph PackageLoading PackageModel + SwiftDriver TSCBasic TSCUtility XCBuildSupport) From 7ca0f81e1693f2c62668973e8b2bd8fc2ee418f2 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 23 Feb 2024 15:25:37 +0000 Subject: [PATCH 30/31] Define `DISABLE_XCBUILD_SUPPORT` in `swift-bootstrap/CMakeLists.txt` --- Sources/swift-bootstrap/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/swift-bootstrap/CMakeLists.txt b/Sources/swift-bootstrap/CMakeLists.txt index 92052ac7098..e8cb9c4e879 100644 --- a/Sources/swift-bootstrap/CMakeLists.txt +++ b/Sources/swift-bootstrap/CMakeLists.txt @@ -17,5 +17,7 @@ target_link_libraries(swift-bootstrap PRIVATE PackageModel SwiftDriver TSCBasic - TSCUtility - XCBuildSupport) + TSCUtility) + +target_compile_definitions(swift-bootstrap + PRIVATE DISABLE_XCBUILD_SUPPORT) From 79f68c32f7ad70f1fb13f455c013034d1c2b4a22 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 23 Feb 2024 15:34:19 +0000 Subject: [PATCH 31/31] Remove unused imports --- .../Build/BuildDescription/SwiftTargetBuildDescription.swift | 3 --- Sources/XCBuildSupport/PIFBuilder.swift | 1 - 2 files changed, 4 deletions(-) diff --git a/Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift b/Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift index 429c0a9ed81..8479d732d5a 100644 --- a/Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift +++ b/Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift @@ -12,9 +12,6 @@ import Basics -@_spi(SwiftPMInternal) -import DriverSupport - import Foundation import PackageGraph import PackageLoading diff --git a/Sources/XCBuildSupport/PIFBuilder.swift b/Sources/XCBuildSupport/PIFBuilder.swift index 5f74733b9fb..bac8bfd0232 100644 --- a/Sources/XCBuildSupport/PIFBuilder.swift +++ b/Sources/XCBuildSupport/PIFBuilder.swift @@ -21,7 +21,6 @@ import SPMBuildCore import func TSCBasic.topologicalSort import func TSCBasic.memoize -import DriverSupport /// The parameters required by `PIFBuilder`. struct PIFBuilderParameters {