Skip to content

Commit 2e22eb1

Browse files
committed
Remove VFSOverlayBuilder type as it is no longer needed
1 parent 11102fb commit 2e22eb1

File tree

2 files changed

+58
-74
lines changed

2 files changed

+58
-74
lines changed

Sources/Basics/VFSOverlay.swift

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

60-
#if swift(>=5.4)
6160
public convenience init(
6261
name: String,
63-
@VFSOverlayBuilder contents: () -> [VFSOverlay.Resource]
62+
contents: () -> [VFSOverlay.Resource]
6463
) {
6564
self.init(name: name, contents: contents())
6665
}
67-
#endif
6866

6967
public override func encode(to encoder: Encoder) throws {
7068
var container = encoder.container(keyedBy: CodingKeys.self)
@@ -98,25 +96,3 @@ public struct VFSOverlay: Encodable {
9896
try JSONEncoder.makeWithDefaults(prettified: false).encode(path: path, fileSystem: fileSystem, self)
9997
}
10098
}
101-
102-
// TODO(ncooke3): Is gating this API necessary?
103-
#if swift(>=5.4)
104-
@resultBuilder
105-
public struct VFSOverlayBuilder {
106-
public static func buildBlock(_ components: [VFSOverlay.Resource]...) -> [VFSOverlay.Resource] {
107-
return components.flatMap { $0 }
108-
}
109-
110-
public static func buildExpression(_ expression: VFSOverlay.Resource) -> [VFSOverlay.Resource] {
111-
return [expression]
112-
}
113-
114-
public static func buildExpression(_ expression: [VFSOverlay.Resource]) -> [VFSOverlay.Resource] {
115-
return expression
116-
}
117-
118-
public static func buildOptional(_ components: [VFSOverlay.Resource]?) -> [VFSOverlay.Resource] {
119-
return components ?? []
120-
}
121-
}
122-
#endif

Sources/Build/BuildPlan.swift

Lines changed: 57 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,22 +1552,25 @@ public final class MixedTargetBuildDescription {
15521552
self.moduleMap = customModuleMapPath
15531553
self.allProductHeadersOverlay = productDirectory.appending(component: allProductHeadersFilename)
15541554

1555-
// TODO(ncooke3): Probably can remove the builder pattern now.
1556-
#if swift(>=5.4)
15571555
try VFSOverlay(roots: [
1558-
VFSOverlay.Directory(name: customModuleMapPath.parentDirectory.pathString) {
1559-
VFSOverlay.File(
1560-
name: moduleMapFilename,
1561-
externalContents: productModuleMapPath.pathString
1562-
)
1563-
1564-
VFSOverlay.File(
1565-
name: interopHeaderPath.basename,
1566-
externalContents: interopHeaderPath.pathString
1567-
)
1568-
}
1556+
VFSOverlay.Directory(
1557+
name: customModuleMapPath.parentDirectory.pathString,
1558+
contents: [
1559+
// Redirect the custom `module.modulemap` to the
1560+
// modified module map in the product directory.
1561+
VFSOverlay.File(
1562+
name: moduleMapFilename,
1563+
externalContents: productModuleMapPath.pathString
1564+
),
1565+
// Add a generated Swift header that redirects to the
1566+
// generated header in the build directory's root.
1567+
VFSOverlay.File(
1568+
name: interopHeaderPath.basename,
1569+
externalContents: interopHeaderPath.pathString
1570+
)
1571+
]
1572+
)
15691573
]).write(to: self.allProductHeadersOverlay, fileSystem: fileSystem)
1570-
#endif
15711574

15721575
// When the mixed target does not have a custom module map, one will be
15731576
// generated as a product for use by clients.
@@ -1587,16 +1590,19 @@ public final class MixedTargetBuildDescription {
15871590
self.moduleMap = productModuleMapPath
15881591
self.allProductHeadersOverlay = productDirectory.appending(component: allProductHeadersFilename)
15891592

1590-
#if swift(>=5.4)
15911593
try VFSOverlay(roots: [
1592-
VFSOverlay.Directory(name: mixedTarget.clangTarget.includeDir.pathString) {
1593-
VFSOverlay.File(
1594-
name: interopHeaderPath.basename,
1595-
externalContents: interopHeaderPath.pathString
1596-
)
1597-
}
1594+
VFSOverlay.Directory(
1595+
name: mixedTarget.clangTarget.includeDir.pathString,
1596+
contents: [
1597+
// Add a generated Swift header that redirects to the
1598+
// generated header in the build directory's root.
1599+
VFSOverlay.File(
1600+
name: interopHeaderPath.basename,
1601+
externalContents: interopHeaderPath.pathString
1602+
)
1603+
]
1604+
)
15981605
]).write(to: self.allProductHeadersOverlay, fileSystem: fileSystem)
1599-
#endif
16001606
}
16011607

16021608
// MARK: Generate intermediate artifacts used to build the target.
@@ -1650,38 +1656,40 @@ public final class MixedTargetBuildDescription {
16501656
}
16511657

16521658
let allProductHeadersPath = intermediatesDirectory.appending(component: allProductHeadersFilename)
1653-
#if swift(>=5.4)
16541659
try VFSOverlay(roots: [
1655-
VFSOverlay.Directory(name: rootOverlayResourceDirectory.pathString) {
1656-
// Redirect the `module.modulemap` to the modified
1657-
// module map in the intermediates directory.
1658-
VFSOverlay.File(
1659-
name: moduleMapFilename,
1660-
externalContents: intermediateModuleMapPath.pathString
1661-
)
1662-
// Add a generated Swift header that redirects to the
1663-
// generated header in the build directory's root.
1664-
VFSOverlay.File(
1665-
name: interopHeaderPath.basename,
1666-
externalContents: interopHeaderPath.pathString
1667-
)
1668-
}
1660+
VFSOverlay.Directory(
1661+
name: rootOverlayResourceDirectory.pathString,
1662+
contents: [
1663+
// Redirect the `module.modulemap` to the modified
1664+
// module map in the intermediates directory.
1665+
VFSOverlay.File(
1666+
name: moduleMapFilename,
1667+
externalContents: intermediateModuleMapPath.pathString
1668+
),
1669+
// Add a generated Swift header that redirects to the
1670+
// generated header in the build directory's root.
1671+
VFSOverlay.File(
1672+
name: interopHeaderPath.basename,
1673+
externalContents: interopHeaderPath.pathString
1674+
)
1675+
]
1676+
)
16691677
]).write(to: allProductHeadersPath, fileSystem: fileSystem)
1670-
#endif
16711678

16721679
let unextendedModuleMapOverlayPath = intermediatesDirectory.appending(component: unextendedModuleOverlayFilename)
1673-
#if swift(>=5.4)
16741680
try VFSOverlay(roots: [
1675-
VFSOverlay.Directory(name: rootOverlayResourceDirectory.pathString) {
1676-
// Redirect the `module.modulemap` to the *unextended*
1677-
// module map in the intermediates directory.
1678-
VFSOverlay.File(
1679-
name: moduleMapFilename,
1680-
externalContents: unextendedModuleMapPath.pathString
1681-
)
1682-
}
1681+
VFSOverlay.Directory(
1682+
name: rootOverlayResourceDirectory.pathString,
1683+
contents: [
1684+
// Redirect the `module.modulemap` to the *unextended*
1685+
// module map in the intermediates directory.
1686+
VFSOverlay.File(
1687+
name: moduleMapFilename,
1688+
externalContents: unextendedModuleMapPath.pathString
1689+
)
1690+
]
1691+
)
16831692
]).write(to: unextendedModuleMapOverlayPath, fileSystem: fileSystem)
1684-
#endif
16851693

16861694
// 4. Tie everything together by passing build flags.
16871695

@@ -1717,7 +1725,7 @@ public final class MixedTargetBuildDescription {
17171725
"-I", intermediatesDirectory.pathString
17181726
]
17191727

1720-
// If a generated umbrella header was created, add it's root directory
1728+
// If a generated umbrella header was created, add its root directory
17211729
// as a header search path. This will resolve its import within the
17221730
// generated interop header.
17231731
if let interopSupportDirectory = interopSupportDirectory {

0 commit comments

Comments
 (0)