Skip to content

Commit 0186e80

Browse files
split the unsafeFlags-using manifest to a Swift 6.2 minimum version
1 parent 8ad5dcc commit 0186e80

File tree

2 files changed

+68
-11
lines changed

2 files changed

+68
-11
lines changed

Package.swift

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.7
1+
// swift-tools-version:6.2
22
/*
33
This source file is part of the Swift.org open source project
44

@@ -14,14 +14,6 @@ import class Foundation.ProcessInfo
1414

1515
let cmarkPackageName = ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil ? "swift-cmark" : "cmark"
1616

17-
// On non-Windows, do not include unsafe flags so SwiftPM allows tagged dependency usage.
18-
var markdownSwiftSettings: [SwiftSetting] = []
19-
#if os(Windows)
20-
markdownSwiftSettings.append(
21-
.unsafeFlags(["-Xcc", "-DCMARK_GFM_STATIC_DEFINE"], .when(platforms: [.windows]))
22-
)
23-
#endif
24-
2517
let package = Package(
2618
name: "swift-markdown",
2719
products: [
@@ -40,14 +32,15 @@ let package = Package(
4032
exclude: [
4133
"CMakeLists.txt"
4234
],
43-
swiftSettings: markdownSwiftSettings
35+
swiftSettings: [.unsafeFlags(["-Xcc", "-DCMARK_GFM_STATIC_DEFINE"], .when(platforms: [.windows]))]
4436
),
4537
.testTarget(
4638
name: "MarkdownTests",
4739
dependencies: ["Markdown"],
4840
resources: [.process("Visitors/Everything.md")]),
4941
.target(name: "CAtomic"),
50-
]
42+
],
43+
swiftLanguageModes: [.v5]
5144
)
5245

5346
// If the `SWIFTCI_USE_LOCAL_DEPS` environment variable is set,

[email protected]

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// swift-tools-version:5.7
2+
/*
3+
This source file is part of the Swift.org open source project
4+
5+
Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
6+
Licensed under Apache License v2.0 with Runtime Library Exception
7+
8+
See https://swift.org/LICENSE.txt for license information
9+
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
10+
*/
11+
12+
import PackageDescription
13+
import class Foundation.ProcessInfo
14+
15+
let cmarkPackageName = ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil ? "swift-cmark" : "cmark"
16+
17+
let package = Package(
18+
name: "swift-markdown",
19+
products: [
20+
.library(
21+
name: "Markdown",
22+
targets: ["Markdown"]),
23+
],
24+
targets: [
25+
.target(
26+
name: "Markdown",
27+
dependencies: [
28+
"CAtomic",
29+
.product(name: "cmark-gfm", package: cmarkPackageName),
30+
.product(name: "cmark-gfm-extensions", package: cmarkPackageName),
31+
],
32+
exclude: [
33+
"CMakeLists.txt"
34+
]
35+
),
36+
.testTarget(
37+
name: "MarkdownTests",
38+
dependencies: ["Markdown"],
39+
resources: [.process("Visitors/Everything.md")]),
40+
.target(name: "CAtomic"),
41+
]
42+
)
43+
44+
// If the `SWIFTCI_USE_LOCAL_DEPS` environment variable is set,
45+
// we're building in the Swift.org CI system alongside other projects in the Swift toolchain and
46+
// we can depend on local versions of our dependencies instead of fetching them remotely.
47+
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
48+
// Building standalone, so fetch all dependencies remotely.
49+
package.dependencies += [
50+
.package(url: "https://github.com/swiftlang/swift-cmark.git", branch: "gfm"),
51+
]
52+
53+
// SwiftPM command plugins are only supported by Swift version 5.6 and later.
54+
#if swift(>=5.6)
55+
package.dependencies += [
56+
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.1.0"),
57+
]
58+
#endif
59+
} else {
60+
// Building in the Swift.org CI system, so rely on local versions of dependencies.
61+
package.dependencies += [
62+
.package(path: "../cmark"),
63+
]
64+
}

0 commit comments

Comments
 (0)