Skip to content

Commit 50c958b

Browse files
authored
Allow static linking of the SwiftPMDataModel target (#3520)
1 parent ddb749a commit 50c958b

File tree

1 file changed

+54
-59
lines changed

1 file changed

+54
-59
lines changed

Package.swift

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

26+
/** SwiftPMDataModel is the subset of SwiftPM product that includes just its data model.
27+
This allowis some clients (such as IDEs) that use SwiftPM's data model but not its build system
28+
to not have to depend on SwiftDriver, SwiftLLBuild, etc. We should probably have better names here,
29+
though that could break some clients.
30+
*/
31+
let swiftPMDataModelProduct = (
32+
name: "SwiftPMDataModel",
33+
targets: [
34+
"SourceControl",
35+
"PackageCollections",
36+
"PackageCollectionsModel",
37+
"PackageModel",
38+
"PackageLoading",
39+
"PackageGraph",
40+
"Xcodeproj",
41+
"Workspace",
42+
]
43+
)
44+
45+
/** The `libSwiftPM` set of interfaces to programatically work with Swift
46+
packages. `libSwiftPM` includes all of the SwiftPM code except the
47+
command line tools, while `libSwiftPMDataModel` includes only the data model.
48+
49+
NOTE: This API is *unstable* and may change at any time.
50+
*/
51+
let swiftPMProduct = (
52+
name: "SwiftPM",
53+
targets: swiftPMDataModelProduct.targets + [
54+
"SPMLLBuild",
55+
"LLBuildManifest",
56+
"Build",
57+
]
58+
)
59+
60+
/** An array of products which have two versions listed: one dynamically linked, the other with the
61+
automatic linking type with `-auto` suffix appended to product's name.
62+
*/
63+
let autoProducts = [swiftPMProduct, swiftPMDataModelProduct]
64+
2665
let package = Package(
2766
name: "SwiftPM",
2867
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-
68+
products:
69+
autoProducts.flatMap {
70+
[
71+
.library(
72+
name: $0.name,
73+
type: .dynamic,
74+
targets: $0.targets
75+
),
76+
.library(
77+
name: "\($0.name)-auto",
78+
targets: $0.targets
79+
)
80+
]
81+
} + [
8382
.library(
8483
name: "XCBuildSupport",
8584
targets: ["XCBuildSupport"]
8685
),
87-
8886
.library(
8987
name: "PackageDescription",
9088
type: .dynamic,
9189
targets: ["PackageDescription"]
9290
),
93-
9491
.library(
9592
name: "PackagePlugin",
9693
type: .dynamic,
9794
targets: ["PackagePlugin"]
9895
),
99-
10096
.library(
10197
name: "PackageCollectionsModel",
10298
targets: ["PackageCollectionsModel"]
10399
),
104-
105100
.library(
106101
name: "SwiftPMPackageCollections",
107102
targets: [
@@ -172,7 +167,7 @@ let package = Package(
172167
dependencies: ["SwiftToolsSupport-auto", "Basics", "PackageLoading", "PackageModel", "SourceControl"]),
173168

174169
// MARK: Package Collections
175-
170+
176171
.target(
177172
/** Package collections models */
178173
name: "PackageCollectionsModel",

0 commit comments

Comments
 (0)