-
Notifications
You must be signed in to change notification settings - Fork 179
Expand file tree
/
Copy pathPackage.swift
More file actions
220 lines (202 loc) · 8.01 KB
/
Copy pathPackage.swift
File metadata and controls
220 lines (202 loc) · 8.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
// swift-tools-version:6.0
/*
This source file is part of the Swift.org open source project
Copyright (c) 2021-2026 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception
See https://swift.org/LICENSE.txt for license information
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
*/
import PackageDescription
import class Foundation.ProcessInfo
func swiftSettings(_ languageMode: SwiftLanguageMode) -> [SwiftSetting] {
var settings: [SwiftSetting] = [
.unsafeFlags(["-Xfrontend", "-warn-long-expression-type-checking=1000"], .when(configuration: .debug)),
.swiftLanguageMode(languageMode),
.enableUpcomingFeature("ExistentialAny"), // SE-0335: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0335-existential-any.md
.enableUpcomingFeature("InternalImportsByDefault"), // SE-0409: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0409-access-level-on-imports.md
]
// Some upcoming language features are enabled by default in the Swift 6 language mode and warn if they're redundantly explicitly enabled.
switch languageMode {
case .v4, .v4_2, .v5:
settings.append(
.enableUpcomingFeature("ConciseMagicFile") // SE-0274: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0274-magic-file.md
)
default:
break
}
return settings
}
let package = Package(
name: "SwiftDocC",
platforms: [
.macOS(.v13),
.iOS(.v16)
],
products: [
.library(
name: "SwiftDocC",
targets: ["SwiftDocC"]
),
.executable(
name: "docc",
targets: ["docc"]
)
],
targets: [
// SwiftDocC library
.target(
name: "SwiftDocC",
dependencies: [
.target(name: "DocCCommon"),
.target(name: "DocCHTML"),
.product(name: "Markdown", package: "swift-markdown"),
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
.product(name: "CLMDB", package: "swift-lmdb"),
.product(name: "Crypto", package: "swift-crypto"),
],
exclude: ["CMakeLists.txt"],
swiftSettings: swiftSettings(.v5)
),
.testTarget(
name: "SwiftDocCTests",
dependencies: [
.target(name: "SwiftDocC"),
.target(name: "DocCCommon"),
.target(name: "DocCTestUtilities"),
],
resources: [
.copy("Test Resources"),
.copy("Test Bundles"),
.copy("Converter/Converter Fixtures"),
.copy("Rendering/Rendering Fixtures"),
],
swiftSettings: swiftSettings(.v5)
),
// Command-line tool library
.target(
name: "DocCCommandLine",
dependencies: [
.target(name: "SwiftDocC"),
.target(name: "DocCCommon"),
.product(name: "NIOHTTP1", package: "swift-nio", condition: .when(platforms: [.macOS, .iOS, .linux, .android])),
.product(name: "ArgumentParser", package: "swift-argument-parser")
],
exclude: ["CMakeLists.txt"],
swiftSettings: swiftSettings(.v5)
),
.testTarget(
name: "DocCCommandLineTests",
dependencies: [
.target(name: "DocCCommandLine"),
.target(name: "SwiftDocC"),
.target(name: "DocCCommon"),
.target(name: "DocCTestUtilities"),
],
resources: [
.copy("Test Resources"),
.copy("Test Bundles"),
],
swiftSettings: swiftSettings(.v5)
),
// Test utility library
.target(
name: "DocCTestUtilities",
dependencies: [
.target(name: "SwiftDocC"),
.target(name: "DocCCommon"),
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
],
swiftSettings: swiftSettings(.v5)
),
// Command-line tool
.executableTarget(
name: "docc",
dependencies: [
.target(name: "DocCCommandLine"),
],
exclude: ["CMakeLists.txt"],
swiftSettings: swiftSettings(.v5)
),
// A few common types and core functionality that's useable by all other targets.
.target(
name: "DocCCommon",
dependencies: [
// This target shouldn't have any local dependencies so that all other targets can depend on it.
// Dependencies on SymbolKit and Markdown are find to add if they're needed for any functionality.
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
],
exclude: ["CMakeLists.txt"],
swiftSettings: swiftSettings(.v6)
),
.testTarget(
name: "DocCCommonTests",
dependencies: [
.target(name: "DocCCommon"),
.target(name: "DocCTestUtilities"),
],
swiftSettings: swiftSettings(.v6)
),
.target(
name: "DocCHTML",
dependencies: [
.target(name: "DocCCommon"),
.product(name: "Markdown", package: "swift-markdown"),
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
],
exclude: ["CMakeLists.txt"],
swiftSettings: swiftSettings(.v6)
),
.testTarget(
name: "DocCHTMLTests",
dependencies: [
.target(name: "DocCHTML"),
.target(name: "SwiftDocC"),
.product(name: "Markdown", package: "swift-markdown"),
.target(name: "DocCTestUtilities"),
],
swiftSettings: swiftSettings(.v6)
),
// Test app for DocCCommandLine
.executableTarget(
name: "signal-test-app",
dependencies: [
.target(name: "DocCCommandLine"),
],
path: "Tests/signal-test-app",
swiftSettings: swiftSettings(.v5)
),
.executableTarget(
name: "generate-symbol-graph",
dependencies: [
.target(name: "SwiftDocC"),
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
],
swiftSettings: swiftSettings(.v5)
),
]
)
// If the `SWIFTCI_USE_LOCAL_DEPS` environment variable is set,
// we're building in the Swift.org CI system alongside other projects in the Swift toolchain and
// we can depend on local versions of our dependencies instead of fetching them remotely.
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
// Building standalone, so fetch all dependencies remotely.
package.dependencies += [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.92.2"),
.package(url: "https://github.com/swiftlang/swift-markdown.git", branch: "main"),
.package(url: "https://github.com/swiftlang/swift-lmdb.git", branch: "main"),
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.2"),
.package(url: "https://github.com/swiftlang/swift-docc-symbolkit.git", branch: "main"),
.package(url: "https://github.com/apple/swift-crypto.git", from: "3.0.0"),
.package(url: "https://github.com/swiftlang/swift-docc-plugin.git", from: "1.2.0"),
]
} else {
// Building in the Swift.org CI system, so rely on local versions of dependencies.
package.dependencies += [
.package(path: "../swift-nio"),
.package(path: "../swift-markdown"),
.package(path: "../swift-lmdb"),
.package(path: "../swift-argument-parser"),
.package(path: "../swift-docc-symbolkit"),
.package(path: "../swift-crypto"),
]
}