Skip to content

Commit 3f4f2e7

Browse files
authored
Revert all of the functionality related to provided libraries (#7801)
This is not the direction we'd like to go for this feature.
1 parent 947392e commit 3f4f2e7

File tree

51 files changed

+659
-1994
lines changed

Some content is hidden

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

51 files changed

+659
-1994
lines changed

Package.swift

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,6 @@ let systemSQLitePkgConfig: String? = "sqlite3"
8282
*/
8383
let autoProducts = [swiftPMProduct, swiftPMDataModelProduct]
8484

85-
let packageModelResourcesSettings: [SwiftSetting]
86-
let packageModelResources: [Resource]
87-
if ProcessInfo.processInfo.environment["SWIFTPM_USE_LIBRARIES_METADATA"] == nil {
88-
packageModelResources = []
89-
packageModelResourcesSettings = [.define("SKIP_RESOURCE_SUPPORT")]
90-
} else {
91-
packageModelResources = [
92-
.copy("InstalledLibrariesSupport/provided-libraries.json"),
93-
]
94-
packageModelResourcesSettings = []
95-
}
96-
9785
let package = Package(
9886
name: "SwiftPM",
9987
platforms: [
@@ -245,9 +233,7 @@ let package = Package(
245233
/** Primitive Package model objects */
246234
name: "PackageModel",
247235
dependencies: ["Basics"],
248-
exclude: ["CMakeLists.txt", "README.md"],
249-
resources: packageModelResources,
250-
swiftSettings: packageModelResourcesSettings
236+
exclude: ["CMakeLists.txt", "README.md"]
251237
),
252238

253239
.target(

Sources/Build/BuildDescription/ProductBuildDescription.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
4646
// Computed during build planning.
4747
var dylibs: [ProductBuildDescription] = []
4848

49-
/// The list of provided libraries that are going to be used by this product.
50-
var providedLibraries: [String: AbsolutePath] = [:]
51-
5249
/// Any additional flags to be added. These flags are expected to be computed during build planning.
5350
var additionalFlags: [String] = []
5451

@@ -161,8 +158,6 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
161158
args += ["-F", self.buildParameters.buildPath.pathString]
162159
}
163160

164-
self.providedLibraries.forEach { args += ["-L", $1.pathString, "-l", $0] }
165-
166161
args += ["-L", self.buildParameters.buildPath.pathString]
167162
args += try ["-o", binaryPath.pathString]
168163
args += ["-module-name", self.product.name.spm_mangledToC99ExtendedIdentifier()]

Sources/Build/BuildManifest/LLBuildManifestBuilder+Swift.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,8 @@ extension LLBuildManifestBuilder {
427427
if target.underlying is SystemLibraryModule { return }
428428
// Ignore Binary Modules.
429429
if target.underlying is BinaryModule { return }
430-
// Ignore Plugin Targets.
430+
// Ignore Plugin Modules.
431431
if target.underlying is PluginModule { return }
432-
// Ignore Provided Libraries.
433-
if target.underlying is ProvidedLibraryModule { return }
434432

435433
// Depend on the binary for executable targets.
436434
if target.type == .executable && prepareForIndexing == .off {

Sources/Build/BuildOperation.swift

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,6 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
195195
/// Alternative path to search for pkg-config `.pc` files.
196196
private let pkgConfigDirectories: [AbsolutePath]
197197

198-
/// Map of dependency package identities by root packages that depend on them.
199-
private let dependenciesByRootPackageIdentity: [PackageIdentity: [PackageIdentity]]
200-
201-
/// Map of root package identities by target names which are declared in them.
202-
private let rootPackageIdentityByTargetName: [String: PackageIdentity]
203-
204198
public convenience init(
205199
productsBuildParameters: BuildParameters,
206200
toolsBuildParameters: BuildParameters,
@@ -210,8 +204,6 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
210204
scratchDirectory: AbsolutePath,
211205
additionalFileRules: [FileRuleDescription],
212206
pkgConfigDirectories: [AbsolutePath],
213-
dependenciesByRootPackageIdentity: [PackageIdentity: [PackageIdentity]],
214-
targetsByRootPackageIdentity: [PackageIdentity: [String]],
215207
outputStream: OutputByteStream,
216208
logLevel: Basics.Diagnostic.Severity,
217209
fileSystem: Basics.FileSystem,
@@ -227,8 +219,6 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
227219
traitConfiguration: nil,
228220
additionalFileRules: additionalFileRules,
229221
pkgConfigDirectories: pkgConfigDirectories,
230-
dependenciesByRootPackageIdentity: dependenciesByRootPackageIdentity,
231-
targetsByRootPackageIdentity: targetsByRootPackageIdentity,
232222
outputStream: outputStream,
233223
logLevel: logLevel,
234224
fileSystem: fileSystem,
@@ -246,8 +236,6 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
246236
traitConfiguration: TraitConfiguration?,
247237
additionalFileRules: [FileRuleDescription],
248238
pkgConfigDirectories: [AbsolutePath],
249-
dependenciesByRootPackageIdentity: [PackageIdentity: [PackageIdentity]],
250-
targetsByRootPackageIdentity: [PackageIdentity: [String]],
251239
outputStream: OutputByteStream,
252240
logLevel: Basics.Diagnostic.Severity,
253241
fileSystem: Basics.FileSystem,
@@ -276,8 +264,6 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
276264
self.additionalFileRules = additionalFileRules
277265
self.pluginConfiguration = pluginConfiguration
278266
self.pkgConfigDirectories = pkgConfigDirectories
279-
self.dependenciesByRootPackageIdentity = dependenciesByRootPackageIdentity
280-
self.rootPackageIdentityByTargetName = (try? Dictionary<String, PackageIdentity>(throwingUniqueKeysWithValues: targetsByRootPackageIdentity.lazy.flatMap { e in e.value.map { ($0, e.key) } })) ?? [:]
281267
}
282268

283269
public func getPackageGraph() throws -> ModulesGraph {
@@ -399,81 +385,6 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
399385
}
400386
}
401387

402-
private static var didEmitUnexpressedDependencies = false
403-
404-
private func detectUnexpressedDependencies() {
405-
return self.detectUnexpressedDependencies(
406-
// Note: once we switch from the toolchain global metadata, we will have to ensure we can match the right metadata used during the build.
407-
availableLibraries: self.config.toolchain(for: .target).providedLibraries,
408-
targetDependencyMap: self.buildDescription.targetDependencyMap
409-
)
410-
}
411-
412-
// TODO: Currently this function will only match frameworks.
413-
func detectUnexpressedDependencies(
414-
availableLibraries: [ProvidedLibrary],
415-
targetDependencyMap: [String: [String]]?
416-
) {
417-
// Ensure we only emit these once, regardless of how many builds are being done.
418-
guard !Self.didEmitUnexpressedDependencies else {
419-
return
420-
}
421-
Self.didEmitUnexpressedDependencies = true
422-
423-
let availableFrameworks = Dictionary<String, PackageIdentity>(uniqueKeysWithValues: availableLibraries.compactMap {
424-
if let identity = Set($0.metadata.identities.map(\.identity)).spm_only {
425-
return ("\($0.metadata.productName).framework", identity)
426-
} else {
427-
return nil
428-
}
429-
})
430-
431-
targetDependencyMap?.keys.forEach { targetName in
432-
let c99name = targetName.spm_mangledToC99ExtendedIdentifier()
433-
// Since we're analysing post-facto, we don't know which parameters are the correct ones.
434-
let possibleTempsPaths = [BuildParameters.Destination]([.target, .host]).map {
435-
self.config.buildPath(for: $0).appending(component: "\(c99name).build")
436-
}
437-
438-
let usedSDKDependencies: [String] = Set(possibleTempsPaths).flatMap { possibleTempsPath in
439-
guard let contents = try? self.fileSystem.readFileContents(
440-
possibleTempsPath.appending(component: "\(c99name).d")
441-
) else {
442-
return [String]()
443-
}
444-
445-
// FIXME: We need a real makefile deps parser here...
446-
let deps = contents.description.split(whereSeparator: { $0.isWhitespace })
447-
return deps.filter {
448-
!$0.hasPrefix(possibleTempsPath.parentDirectory.pathString)
449-
}.compactMap {
450-
try? AbsolutePath(validating: String($0))
451-
}.compactMap {
452-
return $0.components.first(where: { $0.hasSuffix(".framework") })
453-
}
454-
}
455-
456-
let dependencies: [PackageIdentity]
457-
if let rootPackageIdentity = self.rootPackageIdentityByTargetName[targetName] {
458-
dependencies = self.dependenciesByRootPackageIdentity[rootPackageIdentity] ?? []
459-
} else {
460-
dependencies = []
461-
}
462-
463-
Set(usedSDKDependencies).forEach {
464-
if availableFrameworks.keys.contains($0) {
465-
if let availableFrameworkPackageIdentity = availableFrameworks[$0], !dependencies.contains(
466-
availableFrameworkPackageIdentity
467-
) {
468-
observabilityScope.emit(
469-
warning: "target '\(targetName)' has an unexpressed depedency on '\(availableFrameworkPackageIdentity)'"
470-
)
471-
}
472-
}
473-
}
474-
}
475-
}
476-
477388
/// Perform a build using the given build description and subset.
478389
public func build(subset: BuildSubset) throws {
479390
guard !self.config.shouldSkipBuilding(for: .target) else {
@@ -514,8 +425,6 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
514425

515426
let duration = buildStartTime.distance(to: .now())
516427

517-
self.detectUnexpressedDependencies()
518-
519428
let subsetDescriptor: String?
520429
switch subset {
521430
case .product(let productName, _):

Sources/Build/BuildPlan/BuildPlan+Product.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ extension BuildPlan {
116116
}
117117
buildProduct.libraryBinaryPaths = dependencies.libraryBinaryPaths
118118

119-
buildProduct.providedLibraries = dependencies.providedLibraries
120-
121119
buildProduct.availableTools = dependencies.availableTools
122120
}
123121

@@ -130,7 +128,6 @@ extension BuildPlan {
130128
staticTargets: [ResolvedModule],
131129
systemModules: [ResolvedModule],
132130
libraryBinaryPaths: Set<AbsolutePath>,
133-
providedLibraries: [String: AbsolutePath],
134131
availableTools: [String: AbsolutePath]
135132
) {
136133
/* Prior to tools-version 5.9, we used to erroneously recursively traverse executable/plugin dependencies and statically include their
@@ -208,7 +205,6 @@ extension BuildPlan {
208205
var staticTargets = [ResolvedModule]()
209206
var systemModules = [ResolvedModule]()
210207
var libraryBinaryPaths: Set<AbsolutePath> = []
211-
var providedLibraries = [String: AbsolutePath]()
212208
var availableTools = [String: AbsolutePath]()
213209

214210
for dependency in allTargets {
@@ -262,8 +258,6 @@ extension BuildPlan {
262258
}
263259
case .plugin:
264260
continue
265-
case .providedLibrary:
266-
providedLibraries[target.name] = target.underlying.path
267261
}
268262

269263
case .product(let product, _):
@@ -279,7 +273,7 @@ extension BuildPlan {
279273
staticTargets.append(contentsOf: derivedTestTargets)
280274
}
281275

282-
return (linkLibraries, staticTargets, systemModules, libraryBinaryPaths, providedLibraries, availableTools)
276+
return (linkLibraries, staticTargets, systemModules, libraryBinaryPaths, availableTools)
283277
}
284278

285279
/// Extracts the artifacts from an artifactsArchive

Sources/Build/BuildPlan/BuildPlan+Swift.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import struct Basics.InternalError
14+
1415
import class PackageModel.BinaryModule
1516
import class PackageModel.ClangModule
1617
import class PackageModel.SystemLibraryModule
17-
import class PackageModel.ProvidedLibraryModule
1818

1919
extension BuildPlan {
2020
func plan(swiftTarget: SwiftModuleBuildDescription) throws {
@@ -49,10 +49,6 @@ extension BuildPlan {
4949
swiftTarget.libraryBinaryPaths.insert(library.libraryPath)
5050
}
5151
}
52-
case let target as ProvidedLibraryModule:
53-
swiftTarget.additionalFlags += [
54-
"-I", target.path.pathString
55-
]
5652
default:
5753
break
5854
}

Sources/Build/BuildPlan/BuildPlan.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
455455
toolsVersion: toolsVersion,
456456
fileSystem: fileSystem
457457
))
458-
case is SystemLibraryModule, is BinaryModule, is ProvidedLibraryModule:
458+
case is SystemLibraryModule, is BinaryModule:
459459
break
460460
default:
461461
throw InternalError("unhandled \(target.underlying)")

Sources/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# See http://swift.org/LICENSE.txt for license information
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9-
add_compile_definitions(SKIP_RESOURCE_SUPPORT)
109
add_compile_definitions(USE_IMPL_ONLY_IMPORTS)
1110

1211
add_subdirectory(Basics)

Sources/Commands/PackageCommands/Update.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ extension SwiftPackageCommand {
7171
case .removed:
7272
report += "\n"
7373
report += "- \(package.identity) \(currentVersion)"
74-
case .unchanged, .usesLibrary:
74+
case .unchanged:
7575
continue
7676
}
7777
}

Sources/Commands/Snippets/Cards/TopCard.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ fileprivate extension Module.Kind {
151151
return "snippets"
152152
case .macro:
153153
return "macros"
154-
case .providedLibrary:
155-
return "provided libraries"
156154
}
157155
}
158156
}

Sources/CoreCommands/BuildSystemSupport.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ private struct NativeBuildSystemFactory: BuildSystemFactory {
5656
traitConfiguration: traitConfiguration,
5757
additionalFileRules: FileRuleDescription.swiftpmFileTypes,
5858
pkgConfigDirectories: self.swiftCommandState.options.locations.pkgConfigDirectories,
59-
dependenciesByRootPackageIdentity: rootPackageInfo.dependencies,
60-
targetsByRootPackageIdentity: rootPackageInfo.targets,
6159
outputStream: outputStream ?? self.swiftCommandState.outputStream,
6260
logLevel: logLevel ?? self.swiftCommandState.logLevel,
6361
fileSystem: self.swiftCommandState.fileSystem,

Sources/CoreCommands/SwiftCommandState.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import var TSCBasic.stderrStream
5353
import class TSCBasic.TerminalController
5454
import class TSCBasic.ThreadSafeOutputByteStream
5555

56-
import TSCUtility // cannot be scoped because of `String.spm_mangleToC99ExtendedIdentifier()`
56+
import var TSCUtility.verbosity
5757

5858
typealias Diagnostic = Basics.Diagnostic
5959

@@ -503,6 +503,7 @@ public final class SwiftCommandState {
503503
return (identities, targets)
504504
}
505505

506+
506507
private func getEditsDirectory() throws -> AbsolutePath {
507508
// TODO: replace multiroot-data-file with explicit overrides
508509
if let multiRootPackageDataFile = options.locations.multirootPackageDataFile {

Sources/PackageGraph/BoundVersion.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
import struct PackageModel.ProvidedLibrary
1413
import struct TSCUtility.Version
1514

1615
/// A bound version for a package within an assignment.
@@ -23,7 +22,7 @@ public enum BoundVersion: Equatable, Hashable {
2322
case excluded
2423

2524
/// The version of the package to include.
26-
case version(Version, library: ProvidedLibrary? = nil)
25+
case version(Version)
2726

2827
/// The package assignment is unversioned.
2928
case unversioned
@@ -37,7 +36,7 @@ extension BoundVersion: CustomStringConvertible {
3736
switch self {
3837
case .excluded:
3938
return "excluded"
40-
case .version(let version, _):
39+
case .version(let version):
4140
return version.description
4241
case .unversioned:
4342
return "unversioned"

Sources/PackageGraph/ModulesGraph+Loading.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ private func createResolvedPackages(
697697
dependencyProductName: productRef.name,
698698
dependencyPackageName: productRef.package,
699699
dependencyProductInDecl: !declProductsAsDependency.isEmpty,
700-
similarProductName: bestMatchedProductName,
700+
similarProductName: bestMatchedProductName,
701701
packageContainingSimilarProduct: packageContainingBestMatchedProduct
702702
)
703703
packageObservabilityScope.emit(error)

0 commit comments

Comments
 (0)