Skip to content

Commit b53ab2e

Browse files
committed
Resolve TODO about VFSOverlay API
1 parent 9fee448 commit b53ab2e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Sources/Basics/VFSOverlay.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,14 @@ public struct VFSOverlay: Encodable {
5757
super.init(name: name, type: "directory")
5858
}
5959

60-
// TODO(ncooke3): Do we need to wrap this in `#if swift(>=5.4)`?
60+
#if swift(>=5.4)
6161
public convenience init(
6262
name: String,
6363
@VFSOverlayBuilder contents: () -> [VFSOverlay.Resource]
6464
) {
6565
self.init(name: name, contents: contents())
6666
}
67+
#endif
6768

6869
public override func encode(to encoder: Encoder) throws {
6970
var container = encoder.container(keyedBy: CodingKeys.self)
@@ -98,7 +99,7 @@ public struct VFSOverlay: Encodable {
9899
}
99100
}
100101

101-
// TODO(ncooke3): Do we need to wrap this in `#if swift(>=5.4)`?
102+
#if swift(>=5.4)
102103
@resultBuilder
103104
public struct VFSOverlayBuilder {
104105
public static func buildBlock(_ components: [VFSOverlay.Resource]...) -> [VFSOverlay.Resource] {
@@ -117,3 +118,4 @@ public struct VFSOverlayBuilder {
117118
return components ?? []
118119
}
119120
}
121+
#endif

Sources/Build/BuildPlan.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,7 @@ public final class MixedTargetBuildDescription {
15331533
self.moduleMap = customModuleMapPath
15341534
self.allProductHeadersOverlay = productDirectory.appending(component: allProductHeadersFilename)
15351535

1536+
#if swift(>=5.4)
15361537
try VFSOverlay(roots: [
15371538
VFSOverlay.Directory(name: customModuleMapPath.parentDirectory.pathString) {
15381539
VFSOverlay.File(
@@ -1550,6 +1551,7 @@ public final class MixedTargetBuildDescription {
15501551
}
15511552
}
15521553
]).write(to: self.allProductHeadersOverlay!, fileSystem: fileSystem)
1554+
#endif
15531555

15541556
// When the mixed target does not have a custom module map, one will be
15551557
// generated as a product for use by clients.
@@ -1572,6 +1574,7 @@ public final class MixedTargetBuildDescription {
15721574
// If an umbrella header was generated, it needs to be
15731575
// overlayed within the public headers directory.
15741576
self.allProductHeadersOverlay = productDirectory.appending(component: allProductHeadersFilename)
1577+
#if swift(>=5.4)
15751578
try VFSOverlay(roots: [
15761579
VFSOverlay.Directory(name: mixedTarget.clangTarget.includeDir.pathString) {
15771580
VFSOverlay.Directory(name: mixedTarget.c99name) {
@@ -1582,6 +1585,7 @@ public final class MixedTargetBuildDescription {
15821585
}
15831586
}
15841587
]).write(to: self.allProductHeadersOverlay!, fileSystem: fileSystem)
1588+
#endif
15851589
} else {
15861590
// Else, no product overlay is needed.
15871591
self.allProductHeadersOverlay = nil
@@ -1638,6 +1642,7 @@ public final class MixedTargetBuildDescription {
16381642
}
16391643

16401644
let allProductHeadersPath = intermediatesDirectory.appending(component: allProductHeadersFilename)
1645+
#if swift(>=5.4)
16411646
try VFSOverlay(roots: [
16421647
VFSOverlay.Directory(name: rootOverlayResourceDirectory.pathString) {
16431648
// Redirect the `module.modulemap` to the modified
@@ -1663,8 +1668,10 @@ public final class MixedTargetBuildDescription {
16631668
}
16641669
}
16651670
]).write(to: allProductHeadersPath, fileSystem: fileSystem)
1671+
#endif
16661672

16671673
let unextendedModuleMapOverlayPath = intermediatesDirectory.appending(component: unextendedModuleOverlayFilename)
1674+
#if swift(>=5.4)
16681675
try VFSOverlay(roots: [
16691676
VFSOverlay.Directory(name: rootOverlayResourceDirectory.pathString) {
16701677
// Redirect the `module.modulemap` to the *unextended*
@@ -1675,6 +1682,7 @@ public final class MixedTargetBuildDescription {
16751682
)
16761683
}
16771684
]).write(to: unextendedModuleMapOverlayPath, fileSystem: fileSystem)
1685+
#endif
16781686

16791687
// 4. Tie everything together by passing build flags.
16801688

0 commit comments

Comments
 (0)