Skip to content

Commit 9c6493f

Browse files
authored
Make PackageModel resources optional (swiftlang#7348)
swiftlang#7337 is breaking toolchain builds, so we should pass `SKIP_RESOURCE_SUPPORT` by default to avoid that.
1 parent a0b25d3 commit 9c6493f

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Package.swift

+15-3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ automatic linking type with `-auto` suffix appended to product's name.
7373
*/
7474
let autoProducts = [swiftPMProduct, swiftPMDataModelProduct]
7575

76+
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+
7689
let package = Package(
7790
name: "SwiftPM",
7891
platforms: [
@@ -218,9 +231,8 @@ let package = Package(
218231
name: "PackageModel",
219232
dependencies: ["Basics"],
220233
exclude: ["CMakeLists.txt", "README.md"],
221-
resources: [
222-
.copy("InstalledLibrariesSupport/provided-libraries.json"),
223-
]
234+
resources: packageModelResources,
235+
swiftSettings: packageModelResourcesSettings
224236
),
225237

226238
.target(

Sources/PackageModel/UserToolchain.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ public final class UserToolchain: Toolchain {
545545
if let customProvidedLibraries {
546546
self.providedLibraries = customProvidedLibraries
547547
} else {
548-
// When building with CMake, we need to skip resource support.
548+
// When building with CMake or `swift build --build-system xcode`, we need to skip resource support.
549549
#if SKIP_RESOURCE_SUPPORT
550550
let path = self.swiftCompilerPath.parentDirectory.parentDirectory.appending(components: ["share", "pm", "provided-libraries.json"])
551551
#else

0 commit comments

Comments
 (0)