Skip to content

Commit 1828be2

Browse files
authored
Update macro API (#6459)
We're amending SE-0394 to allow Swift/linker settings as well as plugin dependencies. This updates the implementation to match.
1 parent fd02ab4 commit 1828be2

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

Sources/CompilerPluginSupport/TargetExtensions.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ public extension Target {
2020
dependencies: [Dependency] = [],
2121
path: String? = nil,
2222
exclude: [String] = [],
23-
sources: [String]? = nil
23+
sources: [String]? = nil,
24+
swiftSettings: [SwiftSetting]? = nil,
25+
linkerSettings: [LinkerSetting]? = nil,
26+
plugins: [PluginUsage]? = nil
2427
) -> Target {
2528
return Target(name: name,
2629
group: group,
@@ -29,6 +32,9 @@ public extension Target {
2932
exclude: exclude,
3033
sources: sources,
3134
publicHeadersPath: nil,
32-
type: .macro)
35+
type: .macro,
36+
swiftSettings: swiftSettings,
37+
linkerSettings: linkerSettings,
38+
plugins: plugins)
3339
}
3440
}

Sources/PackageDescription/Target.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,7 @@ public final class Target {
347347
providers == nil &&
348348
pluginCapability == nil &&
349349
cSettings == nil &&
350-
cxxSettings == nil &&
351-
swiftSettings == nil &&
352-
linkerSettings == nil &&
353-
plugins == nil
350+
cxxSettings == nil
354351
)
355352
}
356353
}

Sources/PackageModel/Manifest/TargetDescription.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,6 @@ public struct TargetDescription: Equatable, Encodable, Sendable {
230230
if pkgConfig != nil { throw Error.disallowedPropertyInTarget(targetName: name, propertyName: "pkgConfig") }
231231
if providers != nil { throw Error.disallowedPropertyInTarget(targetName: name, propertyName: "providers") }
232232
if pluginCapability != nil { throw Error.disallowedPropertyInTarget(targetName: name, propertyName: "pluginCapability") }
233-
if !settings.isEmpty { throw Error.disallowedPropertyInTarget(targetName: name, propertyName: "settings") }
234-
if pluginUsages != nil { throw Error.disallowedPropertyInTarget(targetName: name, propertyName: "pluginUsages") }
235233
}
236234

237235
self.name = name

Tests/PackageLoadingTests/PD_Next_LoadingTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class PackageDescriptionNextLoadingTests: PackageDescriptionLoadingTests {
4747
4848
let package = Package(name: "MyPackage",
4949
targets: [
50-
.macro(name: "MyMacro"),
50+
.macro(name: "MyMacro", swiftSettings: [.define("BEST")], linkerSettings: [.linkedLibrary("best")]),
5151
]
5252
)
5353
"""

0 commit comments

Comments
 (0)