Skip to content

Commit 3aff8af

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 e3a2168 commit 3aff8af

File tree

157 files changed

+334
-235
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

+334
-235
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: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -184,20 +184,6 @@ let package = Package(
184184
),
185185
],
186186
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-
201187
// The `AppleProductTypes` target provides additional product types
202188
// to `Package.swift` manifests. Here we build a debug version of the
203189
// library; the bootstrap scripts build the deployable version.
@@ -213,19 +199,6 @@ let package = Package(
213199
.unsafeFlags(["-Xfrontend", "-module-link-name", "-Xfrontend", "AppleProductTypes"])
214200
]),
215201

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-
229202
.target(
230203
name: "SourceKitLSPAPI",
231204
dependencies: [
@@ -775,11 +748,41 @@ let package = Package(
775748
]
776749
),
777750

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

780782
.target(
781783
name: "CompilerPluginSupport",
782784
dependencies: ["PackageDescription"],
785+
path: "Sources/Runtimes/CompilerPluginSupport",
783786
exclude: ["CMakeLists.txt"],
784787
swiftSettings: commonExperimentalFeatures + [
785788
.unsafeFlags(["-package-description-version", "999.0"]),
@@ -789,19 +792,19 @@ let package = Package(
789792

790793
// MARK: Additional Test Dependencies
791794

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-
),
795+
.target(
796+
/** SwiftPM internal build test suite support library */
797+
name: "_InternalBuildTestSupport",
798+
dependencies: [
799+
"Build",
800+
"XCBuildSupport",
801+
"SwiftBuildSupport",
802+
"_InternalTestSupport"
803+
],
804+
swiftSettings: [
805+
.unsafeFlags(["-static"]),
806+
]
807+
),
805808

806809
.target(
807810
/** 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)