Skip to content

Commit 8945865

Browse files
committed
Allow swift-corelibs-foundation to use unsafeFlags when used as a dependency
Tagged dependencies don't currently allow use of `unsafeFlags` but we need to temporarily lift that requirement for `swift-corelibs-foundation` that depends on C flags. In the future this would be removed in favor of a more general mechanism for "safe" flags.
1 parent f529dae commit 8945865

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

Sources/Workspace/Workspace+Manifests.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,16 @@ extension Workspace {
141141
let dependency = dependency.dependency
142142
switch dependency.state {
143143
case .sourceControlCheckout(let checkout):
144-
if checkout.isBranchOrRevisionBased {
145-
result.insert(dependency.packageRef)
144+
let packageRef = dependency.packageRef
145+
146+
if checkout.isBranchOrRevisionBased
147+
// FIXME: Remove this once we have a general mechanism
148+
// for passing "safe" flags.
149+
|| packageRef.identity == .plain("swift-corelibs-foundation")
150+
{
151+
result.insert(packageRef)
146152
}
153+
147154
case .registryDownload, .edited, .custom:
148155
continue
149156
case .fileSystem:

Tests/WorkspaceTests/WorkspaceTests.swift

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5590,6 +5590,48 @@ final class WorkspaceTests: XCTestCase {
55905590
}
55915591
}
55925592

5593+
func testUnsafeFlagsInFoundation() throws {
5594+
let sandbox = AbsolutePath("/tmp/ws/")
5595+
let fs = InMemoryFileSystem()
5596+
5597+
let workspace = try MockWorkspace(
5598+
sandbox: sandbox,
5599+
fileSystem: fs,
5600+
roots: [
5601+
MockPackage(
5602+
name: "Test",
5603+
targets: [
5604+
MockTarget(name: "Test",
5605+
dependencies: [
5606+
.product(name: "Foundation",
5607+
package: "swift-corelibs-foundation")
5608+
]),
5609+
],
5610+
products: [],
5611+
dependencies: [
5612+
.sourceControl(path: "swift-corelibs-foundation", requirement: .upToNextMajor(from: "1.0.0")),
5613+
]
5614+
),
5615+
],
5616+
packages: [
5617+
MockPackage(
5618+
name: "swift-corelibs-foundation",
5619+
targets: [
5620+
MockTarget(name: "Foundation", settings: [.init(tool: .swift, kind: .unsafeFlags(["-F", "/tmp"]))]),
5621+
],
5622+
products: [
5623+
MockProduct(name: "Foundation", targets: ["Foundation"])
5624+
],
5625+
versions: ["1.0.0", nil]
5626+
)
5627+
]
5628+
)
5629+
5630+
try workspace.checkPackageGraph(roots: ["Test"]) { _, diagnostics in
5631+
XCTAssertNoDiagnostics(diagnostics)
5632+
}
5633+
}
5634+
55935635
func testEditDependencyHadOverridableConstraints() throws {
55945636
let sandbox = AbsolutePath("/tmp/ws/")
55955637
let fs = InMemoryFileSystem()

0 commit comments

Comments
 (0)