Skip to content

Commit 021ad80

Browse files
authored
[6.0] Revert all of the functionality related to provided libraries (#7800)
- Explanation: Remove provided libraries experimental feature. - Main Branch PR: #7801 - Risk: Very Low - Reviewed By: @bnbarham - Testing: No tests were added because this change removes functionality.
1 parent 2cd7852 commit 021ad80

File tree

50 files changed

+677
-2036
lines changed

Some content is hidden

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

50 files changed

+677
-2036
lines changed

Package.swift

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,6 @@ automatic linking type with `-auto` suffix appended to product's name.
7474
*/
7575
let autoProducts = [swiftPMProduct, swiftPMDataModelProduct]
7676

77-
let packageModelResourcesSettings: [SwiftSetting]
78-
let packageModelResources: [Resource]
79-
if ProcessInfo.processInfo.environment["SWIFTPM_USE_LIBRARIES_METADATA"] == nil {
80-
packageModelResources = []
81-
packageModelResourcesSettings = [.define("SKIP_RESOURCE_SUPPORT")]
82-
} else {
83-
packageModelResources = [
84-
.copy("InstalledLibrariesSupport/provided-libraries.json"),
85-
]
86-
packageModelResourcesSettings = []
87-
}
88-
8977
let package = Package(
9078
name: "SwiftPM",
9179
platforms: [
@@ -237,9 +225,7 @@ let package = Package(
237225
/** Primitive Package model objects */
238226
name: "PackageModel",
239227
dependencies: ["Basics"],
240-
exclude: ["CMakeLists.txt", "README.md"],
241-
resources: packageModelResources,
242-
swiftSettings: packageModelResourcesSettings
228+
exclude: ["CMakeLists.txt", "README.md"]
243229
),
244230

245231
.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 & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,6 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
102102
/// Alternative path to search for pkg-config `.pc` files.
103103
private let pkgConfigDirectories: [AbsolutePath]
104104

105-
/// Map of dependency package identities by root packages that depend on them.
106-
private let dependenciesByRootPackageIdentity: [PackageIdentity: [PackageIdentity]]
107-
108-
/// Map of root package identities by target names which are declared in them.
109-
private let rootPackageIdentityByTargetName: [String: PackageIdentity]
110-
111105
public init(
112106
productsBuildParameters: BuildParameters,
113107
toolsBuildParameters: BuildParameters,
@@ -117,8 +111,6 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
117111
scratchDirectory: AbsolutePath,
118112
additionalFileRules: [FileRuleDescription],
119113
pkgConfigDirectories: [AbsolutePath],
120-
dependenciesByRootPackageIdentity: [PackageIdentity: [PackageIdentity]],
121-
targetsByRootPackageIdentity: [PackageIdentity: [String]],
122114
outputStream: OutputByteStream,
123115
logLevel: Basics.Diagnostic.Severity,
124116
fileSystem: Basics.FileSystem,
@@ -139,8 +131,6 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
139131
self.pluginConfiguration = pluginConfiguration
140132
self.scratchDirectory = scratchDirectory
141133
self.pkgConfigDirectories = pkgConfigDirectories
142-
self.dependenciesByRootPackageIdentity = dependenciesByRootPackageIdentity
143-
self.rootPackageIdentityByTargetName = (try? Dictionary<String, PackageIdentity>(throwingUniqueKeysWithValues: targetsByRootPackageIdentity.lazy.flatMap { e in e.value.map { ($0, e.key) } })) ?? [:]
144134
self.outputStream = outputStream
145135
self.logLevel = logLevel
146136
self.fileSystem = fileSystem
@@ -260,81 +250,6 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
260250
}
261251
}
262252

263-
private static var didEmitUnexpressedDependencies = false
264-
265-
private func detectUnexpressedDependencies() {
266-
return self.detectUnexpressedDependencies(
267-
// Note: once we switch from the toolchain global metadata, we will have to ensure we can match the right metadata used during the build.
268-
availableLibraries: self.productsBuildParameters.toolchain.providedLibraries,
269-
targetDependencyMap: self.buildDescription.targetDependencyMap
270-
)
271-
}
272-
273-
// TODO: Currently this function will only match frameworks.
274-
func detectUnexpressedDependencies(
275-
availableLibraries: [ProvidedLibrary],
276-
targetDependencyMap: [String: [String]]?
277-
) {
278-
// Ensure we only emit these once, regardless of how many builds are being done.
279-
guard !Self.didEmitUnexpressedDependencies else {
280-
return
281-
}
282-
Self.didEmitUnexpressedDependencies = true
283-
284-
let availableFrameworks = Dictionary<String, PackageIdentity>(uniqueKeysWithValues: availableLibraries.compactMap {
285-
if let identity = Set($0.metadata.identities.map(\.identity)).spm_only {
286-
return ("\($0.metadata.productName).framework", identity)
287-
} else {
288-
return nil
289-
}
290-
})
291-
292-
targetDependencyMap?.keys.forEach { targetName in
293-
let c99name = targetName.spm_mangledToC99ExtendedIdentifier()
294-
// Since we're analysing post-facto, we don't know which parameters are the correct ones.
295-
let possibleTempsPaths = [productsBuildParameters, toolsBuildParameters].map {
296-
$0.buildPath.appending(component: "\(c99name).build")
297-
}
298-
299-
let usedSDKDependencies: [String] = Set(possibleTempsPaths).flatMap { possibleTempsPath in
300-
guard let contents = try? self.fileSystem.readFileContents(
301-
possibleTempsPath.appending(component: "\(c99name).d")
302-
) else {
303-
return [String]()
304-
}
305-
306-
// FIXME: We need a real makefile deps parser here...
307-
let deps = contents.description.split(whereSeparator: { $0.isWhitespace })
308-
return deps.filter {
309-
!$0.hasPrefix(possibleTempsPath.parentDirectory.pathString)
310-
}.compactMap {
311-
try? AbsolutePath(validating: String($0))
312-
}.compactMap {
313-
return $0.components.first(where: { $0.hasSuffix(".framework") })
314-
}
315-
}
316-
317-
let dependencies: [PackageIdentity]
318-
if let rootPackageIdentity = self.rootPackageIdentityByTargetName[targetName] {
319-
dependencies = self.dependenciesByRootPackageIdentity[rootPackageIdentity] ?? []
320-
} else {
321-
dependencies = []
322-
}
323-
324-
Set(usedSDKDependencies).forEach {
325-
if availableFrameworks.keys.contains($0) {
326-
if let availableFrameworkPackageIdentity = availableFrameworks[$0], !dependencies.contains(
327-
availableFrameworkPackageIdentity
328-
) {
329-
observabilityScope.emit(
330-
warning: "target '\(targetName)' has an unexpressed depedency on '\(availableFrameworkPackageIdentity)'"
331-
)
332-
}
333-
}
334-
}
335-
}
336-
}
337-
338253
/// Perform a build using the given build description and subset.
339254
public func build(subset: BuildSubset) throws {
340255
guard !self.productsBuildParameters.shouldSkipBuilding else {
@@ -373,8 +288,6 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
373288

374289
let duration = buildStartTime.distance(to: .now())
375290

376-
self.detectUnexpressedDependencies()
377-
378291
let subsetDescriptor: String?
379292
switch subset {
380293
case .product(let productName, _):
@@ -615,8 +528,6 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
615528
scratchDirectory: pluginsBuildParameters.dataPath,
616529
additionalFileRules: self.additionalFileRules,
617530
pkgConfigDirectories: self.pkgConfigDirectories,
618-
dependenciesByRootPackageIdentity: [:],
619-
targetsByRootPackageIdentity: [:],
620531
outputStream: self.outputStream,
621532
logLevel: self.logLevel,
622533
fileSystem: self.fileSystem,

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
@@ -425,7 +425,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
425425
toolsVersion: toolsVersion,
426426
fileSystem: fileSystem
427427
))
428-
case is SystemLibraryModule, is BinaryModule, is ProvidedLibraryModule:
428+
case is SystemLibraryModule, is BinaryModule:
429429
break
430430
default:
431431
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
}

0 commit comments

Comments
 (0)