Skip to content

Commit 7dd4894

Browse files
committed
Allow static linking of the SwiftPMDataModel target
1 parent b0e0388 commit 7dd4894

File tree

1 file changed

+48
-59
lines changed

1 file changed

+48
-59
lines changed

Package.swift

Lines changed: 48 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -23,85 +23,74 @@ if let deploymentTarget = ProcessInfo.processInfo.environment["SWIFTPM_MACOS_DEP
2323
macOSPlatform = .macOS(.v10_15)
2424
}
2525

26+
let swiftPMDataModelProduct = (
27+
name: "SwiftPMDataModel",
28+
targets: [
29+
"SourceControl",
30+
"PackageCollections",
31+
"PackageCollectionsModel",
32+
"PackageModel",
33+
"PackageLoading",
34+
"PackageGraph",
35+
"Xcodeproj",
36+
"Workspace",
37+
]
38+
)
39+
40+
// The `libSwiftPM` set of interfaces to programatically work with Swift
41+
// packages. `libSwiftPM` includes all of the SwiftPM code except the
42+
// command line tools, while `libSwiftPMDataModel` includes only the data model.
43+
//
44+
// NOTE: This API is *unstable* and may change at any time.
45+
let swiftPMProduct = (
46+
name: "SwiftPM",
47+
targets: swiftPMDataModelProduct.targets + [
48+
"SPMLLBuild",
49+
"LLBuildManifest",
50+
"Build",
51+
]
52+
)
53+
54+
/** An array of products which have two versions listed: one dynamically linked, the other with the
55+
automatic linking type with `-auto` suffix appended to product's name.
56+
*/
57+
let autoProducts = [swiftPMProduct, swiftPMDataModelProduct]
58+
2659
let package = Package(
2760
name: "SwiftPM",
2861
platforms: [macOSPlatform],
29-
products: [
30-
// The `libSwiftPM` set of interfaces to programatically work with Swift
31-
// packages. `libSwiftPM` includes all of the SwiftPM code except the
32-
// command line tools, while `libSwiftPMDataModel` includes only the data model.
33-
//
34-
// NOTE: This API is *unstable* and may change at any time.
35-
.library(
36-
name: "SwiftPM",
37-
type: .dynamic,
38-
targets: [
39-
"SourceControl",
40-
"SPMLLBuild",
41-
"PackageCollections",
42-
"PackageCollectionsModel",
43-
"LLBuildManifest",
44-
"PackageModel",
45-
"PackageLoading",
46-
"PackageGraph",
47-
"Build",
48-
"Xcodeproj",
49-
"Workspace"
50-
]
51-
),
52-
.library(
53-
name: "SwiftPM-auto",
54-
targets: [
55-
"SourceControl",
56-
"SPMLLBuild",
57-
"LLBuildManifest",
58-
"PackageCollections",
59-
"PackageCollectionsModel",
60-
"PackageModel",
61-
"PackageLoading",
62-
"PackageGraph",
63-
"Build",
64-
"Xcodeproj",
65-
"Workspace"
66-
]
67-
),
68-
.library(
69-
name: "SwiftPMDataModel",
70-
type: .dynamic,
71-
targets: [
72-
"SourceControl",
73-
"PackageCollections",
74-
"PackageCollectionsModel",
75-
"PackageModel",
76-
"PackageLoading",
77-
"PackageGraph",
78-
"Xcodeproj",
79-
"Workspace"
80-
]
81-
),
82-
62+
products:
63+
autoProducts.flatMap {
64+
[
65+
.library(
66+
name: $0.name,
67+
type: .dynamic,
68+
targets: $0.targets
69+
),
70+
.library(
71+
name: "\($0.name)-auto",
72+
targets: $0.targets
73+
)
74+
]
75+
} + [
8376
.library(
8477
name: "XCBuildSupport",
8578
targets: ["XCBuildSupport"]
8679
),
87-
8880
.library(
8981
name: "PackageDescription",
9082
type: .dynamic,
9183
targets: ["PackageDescription"]
9284
),
93-
9485
.library(
9586
name: "PackagePlugin",
9687
type: .dynamic,
9788
targets: ["PackagePlugin"]
9889
),
99-
10090
.library(
10191
name: "PackageCollectionsModel",
10292
targets: ["PackageCollectionsModel"]
10393
),
104-
10594
.library(
10695
name: "SwiftPMPackageCollections",
10796
targets: [
@@ -172,7 +161,7 @@ let package = Package(
172161
dependencies: ["SwiftToolsSupport-auto", "Basics", "PackageLoading", "PackageModel", "SourceControl"]),
173162

174163
// MARK: Package Collections
175-
164+
176165
.target(
177166
/** Package collections models */
178167
name: "PackageCollectionsModel",

0 commit comments

Comments
 (0)