Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Fixtures/PIFBuilder/PackageWithSDKSpecialization/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// swift-tools-version: 6.2

import PackageDescription

let package = Package(
name: "PackageWithSDKSpecialization",
platforms: [ .macOS("10.15.foo") ],
products: [
.library(
name: "PackageWithSDKSpecialization",
targets: ["PackageWithSDKSpecialization"]),
],
targets: [
.target(
name: "PackageWithSDKSpecialization",
dependencies: []
),
.target(
name: "Executable",
dependencies: ["PackageWithSDKSpecialization"]
),
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("Hello, world!")
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
struct PackageWithSDKSpecialization {
var text = "Hello, World!"
}
4 changes: 2 additions & 2 deletions Sources/SwiftBuildSupport/PackagePIFBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ public final class PackagePIFBuilder {
log(.warning, "Ignoring options '\(platformOptions.joined(separator: " "))' specified for unknown platform \(platform.name)")
continue
}
settings[.SPECIALIZATION_SDK_OPTIONS, pifPlatform]?.append(contentsOf: platformOptions)
settings[.SPECIALIZATION_SDK_OPTIONS, pifPlatform] = (settings[.SPECIALIZATION_SDK_OPTIONS, pifPlatform] ?? []) + platformOptions
}

let deviceFamilyIDs: Set<Int> = self.delegate.deviceFamilyIDs()
Expand All @@ -607,7 +607,7 @@ public final class PackagePIFBuilder {
} catch {
preconditionFailure("Unhandled arm64e platform: \(error)")
}
settings[.ARCHS, pifPlatform]?.append(contentsOf: ["arm64e"])
settings[.ARCHS, pifPlatform] = (settings[.ARCHS, pifPlatform] ?? []) + ["arm64e"]
}
}

Expand Down
26 changes: 26 additions & 0 deletions Tests/SwiftBuildSupportTests/PIFBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@ extension SwiftBuildSupport.PIF.Project {
throw StringError("Multiple targets named \(name) in PIF project")
}
}

fileprivate func buildConfig(named name: String) throws -> SwiftBuild.ProjectModel.BuildConfig {
let matchingConfigs = underlying.buildConfigs.filter {
$0.name == name
}
if matchingConfigs.isEmpty {
throw StringError("No config named \(name) in PIF project")
} else if matchingConfigs.count > 1 {
throw StringError("Multiple configs named \(name) in PIF project")
} else {
return matchingConfigs[0]
}
}
}

extension SwiftBuild.ProjectModel.BaseTarget {
Expand Down Expand Up @@ -177,6 +190,19 @@ struct PIFBuilderTests {
}
}

@Test func packageWithInternal() async throws {
try await withGeneratedPIF(fromFixture: "PIFBuilder/PackageWithSDKSpecialization") { pif, observabilitySystem in
let errors = observabilitySystem.diagnostics.filter { $0.severity == .error }
#expect(errors.isEmpty, "Expected no errors during PIF generation, but got: \(errors)")

let releaseConfig = try pif.workspace
.project(named: "PackageWithSDKSpecialization")
.buildConfig(named: "Release")

#expect(releaseConfig.settings[.SPECIALIZATION_SDK_OPTIONS, .macOS] == ["foo"])
}
}

@Test func pluginWithBinaryTargetDependency() async throws {
try await withGeneratedPIF(fromFixture: "Miscellaneous/Plugins/BinaryTargetExePlugin") { pif, observabilitySystem in
// Verify that PIF generation succeeds for a package with a plugin that depends on a binary target
Expand Down