Skip to content

Commit d4df98b

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

File tree

1 file changed

+55
-59
lines changed

1 file changed

+55
-59
lines changed

Package.swift

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

26+
/** A list of products which have two versions listed: one dynamically linked, the other with the
27+
automatic linking type with `-auto` suffix appended to product's name.
28+
*/
29+
let autoProducts = [
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+
(
36+
name: "SwiftPM",
37+
targets: [
38+
"SourceControl",
39+
"SPMLLBuild",
40+
"PackageCollections",
41+
"PackageCollectionsModel",
42+
"LLBuildManifest",
43+
"PackageModel",
44+
"PackageLoading",
45+
"PackageGraph",
46+
"Build",
47+
"Xcodeproj",
48+
"Workspace"
49+
]
50+
),
51+
(
52+
name: "SwiftPMDataModel",
53+
targets: [
54+
"SourceControl",
55+
"PackageCollections",
56+
"PackageCollectionsModel",
57+
"PackageModel",
58+
"PackageLoading",
59+
"PackageGraph",
60+
"Xcodeproj",
61+
"Workspace"
62+
]
63+
)
64+
]
65+
2666
let package = Package(
2767
name: "SwiftPM",
2868
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-
69+
products:
70+
autoProducts.flatMap {
71+
[
72+
.library(
73+
name: $0.name,
74+
type: .dynamic,
75+
targets: $0.targets
76+
),
77+
.library(
78+
name: "\($0.name)-auto",
79+
targets: $0.targets
80+
)
81+
]
82+
} + [
8383
.library(
8484
name: "XCBuildSupport",
8585
targets: ["XCBuildSupport"]
8686
),
87-
8887
.library(
8988
name: "PackageDescription",
9089
type: .dynamic,
9190
targets: ["PackageDescription"]
9291
),
93-
9492
.library(
9593
name: "PackagePlugin",
9694
type: .dynamic,
9795
targets: ["PackagePlugin"]
9896
),
99-
10097
.library(
10198
name: "PackageCollectionsModel",
10299
targets: ["PackageCollectionsModel"]
103100
),
104-
105101
.library(
106102
name: "SwiftPMPackageCollections",
107103
targets: [
@@ -172,7 +168,7 @@ let package = Package(
172168
dependencies: ["SwiftToolsSupport-auto", "Basics", "PackageLoading", "PackageModel", "SourceControl"]),
173169

174170
// MARK: Package Collections
175-
171+
176172
.target(
177173
/** Package collections models */
178174
name: "PackageCollectionsModel",

0 commit comments

Comments
 (0)