Skip to content

Commit 4dbef25

Browse files
authored
Add macros to 5.9 tools-version (#6472)
SE-0394 has been accepted, so we're making macros available as part of the 5.9 tools-version.
1 parent 4b5eac3 commit 4dbef25

File tree

4 files changed

+42
-20
lines changed

4 files changed

+42
-20
lines changed

Sources/CompilerPluginSupport/TargetExtensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@_spi(PackageDescriptionInternal) import PackageDescription
1414

1515
public extension Target {
16-
@available(_PackageDescription, introduced: 999.0)
16+
@available(_PackageDescription, introduced: 5.9)
1717
static func macro(
1818
name: String,
1919
dependencies: [Dependency] = [],

Sources/Workspace/InitPackage.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,7 @@ public final class InitPackage {
342342
// Create a tools version with current version but with patch set to zero.
343343
// We do this to avoid adding unnecessary constraints to patch versions, if
344344
// the package really needs it, they should add it manually.
345-
let version = packageType == .macro ? ToolsVersion.vNext
346-
: InitPackage.newPackageToolsVersion.zeroedPatch
345+
let version = InitPackage.newPackageToolsVersion.zeroedPatch
347346

348347
// Write the current tools version.
349348
try ToolsVersionSpecificationWriter.rewriteSpecification(
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift open source project
4+
//
5+
// Copyright (c) 2023 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import Basics
14+
import PackageLoading
15+
import PackageModel
16+
import SPMTestSupport
17+
import XCTest
18+
19+
class PackageDescription5_9LoadingTests: PackageDescriptionLoadingTests {
20+
override var toolsVersion: ToolsVersion {
21+
.v5_9
22+
}
23+
24+
func testMacroTargets() throws {
25+
let content = """
26+
import CompilerPluginSupport
27+
import PackageDescription
28+
29+
let package = Package(name: "MyPackage",
30+
targets: [
31+
.macro(name: "MyMacro", swiftSettings: [.define("BEST")], linkerSettings: [.linkedLibrary("best")]),
32+
]
33+
)
34+
"""
35+
36+
let observability = ObservabilitySystem.makeForTesting()
37+
let (_, diagnostics) = try loadAndValidateManifest(content, observabilityScope: observability.topScope)
38+
XCTAssertEqual(diagnostics.count, 0, "unexpected diagnostics: \(diagnostics)")
39+
}
40+
}

Tests/PackageLoadingTests/PD_Next_LoadingTests.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,4 @@ class PackageDescriptionNextLoadingTests: PackageDescriptionLoadingTests {
3939
}
4040
}
4141
}
42-
43-
func testMacroTargets() throws {
44-
let content = """
45-
import CompilerPluginSupport
46-
import PackageDescription
47-
48-
let package = Package(name: "MyPackage",
49-
targets: [
50-
.macro(name: "MyMacro", swiftSettings: [.define("BEST")], linkerSettings: [.linkedLibrary("best")]),
51-
]
52-
)
53-
"""
54-
55-
let observability = ObservabilitySystem.makeForTesting()
56-
let (_, diagnostics) = try loadAndValidateManifest(content, observabilityScope: observability.topScope)
57-
XCTAssertEqual(diagnostics.count, 0, "unexpected diagnostics: \(diagnostics)")
58-
}
5942
}

0 commit comments

Comments
 (0)