Skip to content

Commit 86f887c

Browse files
committed
Runtime: extract a Runtime subdirectory for SPM
Re-organise the "runtime" components (i.e. the Package Manifest runtime) into a separate directory. Introduce a separate CMake project for the build of this runtime to allow building the SPM tool with one version of the Swift runtime and the SPM Manifest Runtime witih a separate Swift runtime.
1 parent 96d689a commit 86f887c

File tree

157 files changed

+331
-234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+331
-234
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ project(SwiftPM LANGUAGES C Swift)
1818

1919
option(BUILD_SHARED_LIBS "Build shared libraries by default" YES)
2020
option(FIND_PM_DEPS "Search for all external Package Manager dependencies" YES)
21+
option(SwiftPM_ENABLE_RUNTIME "Build the runtime" YES)
2122

2223
set(CMAKE_Swift_LANGUAGE_VERSION 5)
2324
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)

Package.swift

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ let swiftPMProduct = (
8080
"LLBuildManifest",
8181
"SourceKitLSPAPI",
8282
"SPMLLBuild",
83+
"SwiftBuildSupport",
8384
]
8485
)
8586

@@ -184,20 +185,6 @@ let package = Package(
184185
),
185186
],
186187
targets: [
187-
// The `PackageDescription` target provides the API that is available
188-
// to `Package.swift` manifests. Here we build a debug version of the
189-
// library; the bootstrap scripts build the deployable version.
190-
.target(
191-
name: "PackageDescription",
192-
exclude: ["CMakeLists.txt"],
193-
swiftSettings: commonExperimentalFeatures + [
194-
.define("USE_IMPL_ONLY_IMPORTS"),
195-
.unsafeFlags(["-package-description-version", "999.0"]),
196-
.unsafeFlags(["-enable-library-evolution"]),
197-
],
198-
linkerSettings: packageLibraryLinkSettings
199-
),
200-
201188
// The `AppleProductTypes` target provides additional product types
202189
// to `Package.swift` manifests. Here we build a debug version of the
203190
// library; the bootstrap scripts build the deployable version.
@@ -213,19 +200,6 @@ let package = Package(
213200
.unsafeFlags(["-Xfrontend", "-module-link-name", "-Xfrontend", "AppleProductTypes"])
214201
]),
215202

216-
// The `PackagePlugin` target provides the API that is available to
217-
// plugin scripts. Here we build a debug version of the library; the
218-
// bootstrap scripts build the deployable version.
219-
.target(
220-
name: "PackagePlugin",
221-
exclude: ["CMakeLists.txt"],
222-
swiftSettings: commonExperimentalFeatures + [
223-
.unsafeFlags(["-package-description-version", "999.0"]),
224-
.unsafeFlags(["-enable-library-evolution"]),
225-
],
226-
linkerSettings: packageLibraryLinkSettings
227-
),
228-
229203
.target(
230204
name: "SourceKitLSPAPI",
231205
dependencies: [
@@ -775,11 +749,41 @@ let package = Package(
775749
]
776750
),
777751

752+
// The `PackageDescription` target provides the API that is available
753+
// to `Package.swift` manifests. Here we build a debug version of the
754+
// library; the bootstrap scripts build the deployable version.
755+
.target(
756+
name: "PackageDescription",
757+
path: "Sources/Runtimes/PackageDescription",
758+
exclude: ["CMakeLists.txt"],
759+
swiftSettings: commonExperimentalFeatures + [
760+
.define("USE_IMPL_ONLY_IMPORTS"),
761+
.unsafeFlags(["-package-description-version", "999.0"]),
762+
.unsafeFlags(["-enable-library-evolution"]),
763+
],
764+
linkerSettings: packageLibraryLinkSettings
765+
),
766+
767+
// The `PackagePlugin` target provides the API that is available to
768+
// plugin scripts. Here we build a debug version of the library; the
769+
// bootstrap scripts build the deployable version.
770+
.target(
771+
name: "PackagePlugin",
772+
path: "Sources/Runtimes/PackagePlugin",
773+
exclude: ["CMakeLists.txt"],
774+
swiftSettings: commonExperimentalFeatures + [
775+
.unsafeFlags(["-package-description-version", "999.0"]),
776+
.unsafeFlags(["-enable-library-evolution"]),
777+
],
778+
linkerSettings: packageLibraryLinkSettings
779+
),
780+
778781
// MARK: Support for Swift macros, should eventually move to a plugin-based solution
779782

780783
.target(
781784
name: "CompilerPluginSupport",
782785
dependencies: ["PackageDescription"],
786+
path: "Sources/Runtimes/CompilerPluginSupport",
783787
exclude: ["CMakeLists.txt"],
784788
swiftSettings: commonExperimentalFeatures + [
785789
.unsafeFlags(["-package-description-version", "999.0"]),
@@ -789,19 +793,19 @@ let package = Package(
789793

790794
// MARK: Additional Test Dependencies
791795

792-
.target(
793-
/** SwiftPM internal build test suite support library */
794-
name: "_InternalBuildTestSupport",
795-
dependencies: [
796-
"Build",
797-
"XCBuildSupport",
798-
"SwiftBuildSupport",
799-
"_InternalTestSupport"
800-
],
801-
swiftSettings: [
802-
.unsafeFlags(["-static"]),
803-
]
804-
),
796+
.target(
797+
/** SwiftPM internal build test suite support library */
798+
name: "_InternalBuildTestSupport",
799+
dependencies: [
800+
"Build",
801+
"XCBuildSupport",
802+
"SwiftBuildSupport",
803+
"_InternalTestSupport"
804+
],
805+
swiftSettings: [
806+
.unsafeFlags(["-static"]),
807+
]
808+
),
805809

806810
.target(
807811
/** SwiftPM internal test suite support library */

Sources/CMakeLists.txt

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,16 @@ add_subdirectory(Basics)
1313
add_subdirectory(BinarySymbols)
1414
add_subdirectory(Build)
1515
add_subdirectory(Commands)
16-
add_subdirectory(CompilerPluginSupport)
1716
add_subdirectory(CoreCommands)
1817
add_subdirectory(DriverSupport)
1918
add_subdirectory(LLBuildManifest)
2019
add_subdirectory(PackageCollections)
2120
add_subdirectory(PackageCollectionsModel)
2221
add_subdirectory(PackageCollectionsSigning)
23-
add_subdirectory(PackageDescription)
2422
add_subdirectory(PackageFingerprint)
2523
add_subdirectory(PackageGraph)
2624
add_subdirectory(PackageLoading)
2725
add_subdirectory(PackageModel)
28-
add_subdirectory(PackagePlugin)
2926
add_subdirectory(PackageRegistry)
3027
add_subdirectory(PackageRegistryCommand)
3128
add_subdirectory(PackageSigning)
@@ -48,3 +45,29 @@ add_subdirectory(Workspace)
4845
add_subdirectory(XCBuildSupport)
4946
add_subdirectory(SwiftBuildSupport)
5047
add_subdirectory(tsan_utils)
48+
49+
if(SwiftPM_ENABLE_RUNTIME)
50+
add_subdirectory(Runtimes)
51+
# NOTE: maintain the custom output directory for the ManifestAPI modules to
52+
# allow the boostrap scripts to continue functioning as they have historically.
53+
# This is unnecessary with the split runtime build, but is left here to
54+
# minimize disruption.
55+
set_target_properties(CompilerPluginSupport PROPERTIES
56+
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI
57+
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI
58+
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI
59+
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI
60+
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI)
61+
set_target_properties(PackageDescription PROPERTIES
62+
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI
63+
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI
64+
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI
65+
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI
66+
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI)
67+
set_target_properties(PackagePlugin PROPERTIES
68+
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/pm/PluginAPI
69+
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/PluginAPI
70+
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/PluginAPI
71+
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/PluginAPI
72+
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/PluginAPI)
73+
endif()

Sources/CompilerPluginSupport/CMakeLists.txt

Lines changed: 0 additions & 50 deletions
This file was deleted.

Sources/PackageDescription/CMakeLists.txt

Lines changed: 0 additions & 65 deletions
This file was deleted.

Sources/PackageDescription/ContextModel.swift

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../PackageDescription/PackageDescriptionSerialization.swift
1+
../Runtimes/PackageDescription/PackageDescriptionSerialization.swift

Sources/PackagePlugin/CMakeLists.txt

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)