Skip to content

Commit 5cb3585

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 6f3360b commit 5cb3585

File tree

153 files changed

+291
-221
lines changed

Some content is hidden

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

153 files changed

+291
-221
lines changed

Package.swift

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,6 @@ let package = Package(
185185
),
186186
],
187187
targets: [
188-
// The `PackageDescription` target provides the API that is available
189-
// to `Package.swift` manifests. Here we build a debug version of the
190-
// library; the bootstrap scripts build the deployable version.
191-
.target(
192-
name: "PackageDescription",
193-
exclude: ["CMakeLists.txt"],
194-
swiftSettings: commonExperimentalFeatures + [
195-
.define("USE_IMPL_ONLY_IMPORTS"),
196-
.unsafeFlags(["-package-description-version", "999.0"]),
197-
.unsafeFlags(["-enable-library-evolution"]),
198-
],
199-
linkerSettings: packageLibraryLinkSettings
200-
),
201-
202188
// The `AppleProductTypes` target provides additional product types
203189
// to `Package.swift` manifests. Here we build a debug version of the
204190
// library; the bootstrap scripts build the deployable version.
@@ -214,19 +200,6 @@ let package = Package(
214200
.unsafeFlags(["-Xfrontend", "-module-link-name", "-Xfrontend", "AppleProductTypes"])
215201
]),
216202

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

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/Runtime/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/Runtime/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+
779781
// MARK: Support for Swift macros, should eventually move to a plugin-based solution
780782

781783
.target(
782784
name: "CompilerPluginSupport",
783785
dependencies: ["PackageDescription"],
786+
path: "Sources/Runtime/CompilerPluginSupport",
784787
exclude: ["CMakeLists.txt"],
785788
swiftSettings: commonExperimentalFeatures + [
786789
.unsafeFlags(["-package-description-version", "999.0"]),

Sources/CMakeLists.txt

Lines changed: 0 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)

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+
../Runtime/PackageDescription/PackageDescriptionSerialization.swift

Sources/PackagePlugin/CMakeLists.txt

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

Sources/Runtime/CMakeLists.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# This source file is part of the Swift open source project
2+
#
3+
# Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
4+
# Licensed under Apache License v2.0 with Runtime Library Exception
5+
#
6+
# See http://swift.org/LICENSE.txt for license information
7+
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8+
9+
cmake_minimum_required(VERSION 3.29)
10+
11+
if(POLICY CMP0157 AND CMAKE_Swift_COMPILER_USE_OLD_DRIVER)
12+
cmake_policy(SET CMP0157 OLD)
13+
endif()
14+
15+
project(SwiftPMRuntime
16+
LANGUAGES Swift)
17+
18+
# TODO(compnerd) C is being enabled as a workaround for `GNUInstallDirs` not
19+
# being aware of Swift-only projects. Remove this once that is updated and we
20+
# have updated to a newer CMake minimum version.
21+
enable_language(C)
22+
include(GNUInstallDirs)
23+
24+
set(CMAKE_INSTALL_NAME_DIR "@rpath")
25+
set(CMAKE_INSTALL_RPATH "$ORIGIN/../../$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>")
26+
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
27+
set(CMAKE_POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS})
28+
set(CMAKE_Swift_LANGUAGE_VERSION 5)
29+
set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
30+
31+
set(SwiftPMRuntime_ENABLE_LIBRARY_EVOLUTION YES)
32+
add_compile_options(-enable-library-evolution)
33+
34+
add_compile_options(-package-description-version 999.0)
35+
36+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
37+
include(PlatformInfo)
38+
include(EmitSwiftInterface)
39+
include(InstallSwiftInterface)
40+
41+
find_package(Foundation)
42+
43+
add_subdirectory(PackageDescription)
44+
add_subdirectory(CompilerPluginSupport)
45+
add_subdirectory(PackagePlugin)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This source file is part of the Swift open source project
2+
#
3+
# Copyright (c) 2023 Apple Inc. and the Swift project authors
4+
# Licensed under Apache License v2.0 with Runtime Library Exception
5+
#
6+
# See http://swift.org/LICENSE.txt for license information
7+
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8+
9+
add_library(CompilerPluginSupport SHARED
10+
TargetExtensions.swift)
11+
12+
target_link_libraries(CompilerPluginSupport PRIVATE
13+
PackageDescription)
14+
15+
if(APPLE)
16+
target_link_options(CompilerPluginSupport PRIVATE
17+
"SHELL:-Xlinker -install_name -Xlinker @rpath/CompilerPluginSupport.dylib")
18+
else()
19+
target_link_libraries(CompilerPluginSupport PRIVATE
20+
Foundation)
21+
endif()
22+
23+
install(TARGETS CompilerPluginSupport
24+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/swift/pm/ManifestAPI
25+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/swift/pm/ManifestAPI
26+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
27+
28+
set(SwiftPMRuntime_INSTALL_SWIFTMODULEDIR
29+
${CMAKE_INSTALL_LIBDIR}/swift/pm/ManifestAPI)
30+
emit_swift_interface(CompilerPluginSupport)
31+
install_swift_interface(CompilerPluginSupport)
File renamed without changes.

0 commit comments

Comments
 (0)