Skip to content

Commit a2f9002

Browse files
committed
[Runtimes][CMake] Add Distributed to Supplemental build
Leave it inert for now, as this would relies on a few find modules that are not available at the moment. Addresses rdar://151389005
1 parent 33c1c27 commit a2f9002

File tree

3 files changed

+148
-0
lines changed

3 files changed

+148
-0
lines changed

Runtimes/Resync.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ copy_files("" "Core" FILES "Info.plist.in")
9999
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/Synchronization/Info.plist.in")
100100
copy_files("" "Supplemental/Synchronization" FILES "Info.plist.in")
101101

102+
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/Distributed/Info.plist.in")
103+
copy_files("" "Supplemental/Distributed" FILES "Info.plist.in")
104+
102105
# Platform Overlays
103106

104107
# Copy magic linker symbols
@@ -175,3 +178,7 @@ copy_library_sources(_CUnicode "Sources" "Supplemental/StringProcessing/_StringP
175178
ROOT "${StringProcessing_ROOT_DIR}/swift-experimental-string-processing")
176179
copy_library_sources(RegexBuilder "Sources" "Supplemental/StringProcessing"
177180
ROOT "${StringProcessing_ROOT_DIR}/swift-experimental-string-processing")
181+
182+
copy_library_sources("Distributed" "public" "Supplemental")
183+
copy_files(swift/runtime Supplemental/Distributed FILES CMakeConfig.h.in ROOT ${CMAKE_CURRENT_LIST_DIR}/../include)
184+
copy_library_sources(include "" "Supplemental/Distributed")

Runtimes/Supplemental/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,14 @@ if(SwiftRuntime_ENABLE_synchronization)
5959
CMAKE_ARGS
6060
${COMMON_OPTIONS})
6161
endif()
62+
63+
# Distributed
64+
if(SwiftRuntime_ENABLE_distributed)
65+
ExternalProject_Add(Distributed
66+
PREFIX "Distributed"
67+
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Distributed"
68+
INSTALL_DIR "${CMAKE_INSTALL_PREFIX}"
69+
INSTALL_COMMAND ""
70+
CMAKE_ARGS
71+
${COMMON_OPTIONS})
72+
endif()
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
cmake_minimum_required(VERSION 3.29)
2+
3+
if($ENV{BUILD_NUMBER})
4+
math(EXPR BUILD_NUMBER "$ENV{BUILD_NUMBER} % 65535")
5+
set(BUILD_NUMBER ".${BUILD_NUMBER}")
6+
endif()
7+
8+
project(SwiftDistributed
9+
LANGUAGES C CXX Swift
10+
VERSION 6.3.0${BUILD_NUMBER})
11+
12+
if(NOT PROJECT_IS_TOP_LEVEL)
13+
message(SEND_ERROR "Swift Distributed must build as a standalone project")
14+
endif()
15+
16+
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
17+
set(CMAKE_C_VISIBILITY_PRESET "hidden")
18+
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
19+
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
20+
21+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake/modules")
22+
23+
set(CMAKE_Swift_LANGUAGE_VERSION 5)
24+
25+
set(${PROJECT_NAME}_SWIFTC_SOURCE_DIR
26+
"${PROJECT_SOURCE_DIR}/../../../"
27+
CACHE FILEPATH "Path to the root source directory of the Swift compiler")
28+
29+
set(${PROJECT_NAME}_VENDOR_MODULE_DIR "${CMAKE_SOURCE_DIR}/../cmake/modules/vendor"
30+
CACHE FILEPATH "Location for private build system extension")
31+
32+
include(CxxStandard)
33+
include(SwiftCallingConventions)
34+
include(AvailabilityMacros)
35+
include(ResourceEmbedding)
36+
include(PlatformInfo)
37+
38+
find_package(SwiftCore)
39+
40+
include("${${PROJECT_NAME}_VENDOR_MODULE_DIR}/Settings.cmake" OPTIONAL)
41+
42+
option(${PROJECT_NAME}_ENABLE_LIBRARY_EVOLUTION "Generate ABI resilient runtime libraries"
43+
${SwiftCore_ENABLE_LIBRARY_EVOLUTION})
44+
45+
option(${PROJECT_NAME}_ENABLE_PRESPECIALIZATION "Enable generic metadata prespecialization"
46+
${SwiftCore_ENABLE_PRESPECIALIZATION})
47+
48+
include(CatalystSupport)
49+
include(EmitSwiftInterface)
50+
include(InstallSwiftInterface)
51+
52+
configure_file("CMakeConfig.h.in"
53+
"${PROJECT_BINARY_DIR}/include/swift/Runtime/CMakeConfig.h"
54+
ESCAPE_QUOTES @ONLY)
55+
56+
add_library(swiftDistributed
57+
DistributedActor.cpp
58+
DistributedActor.swift
59+
DistributedActorSystem.swift
60+
DistributedAssertions.swift
61+
DistributedDefaultExecutor.swift
62+
DistributedMacros.swift
63+
DistributedMetadata.swift
64+
LocalTestingDistributedActorSystem.swift)
65+
66+
target_compile_options(swiftDistributed PRIVATE
67+
"$<$<AND:$<BOOL:${${PROJECT_NAME}_ENABLE_LIBRARY_EVOLUTION}>,$<COMPILE_LANGUAGE:Swift>>:-enable-library-evolution>"
68+
"$<$<AND:$<BOOL:${${PROJECT_NAME}_ENABLE_PRESPECIALIZATION}>,$<COMPILE_LANGUAGE:Swift>>:SHELL:-Xfrontend -prespecialize-generic-metadata>"
69+
$<$<COMPILE_LANGUAGE:Swift>:-explicit-module-build>
70+
$<$<COMPILE_LANGUAGE:Swift>:-nostdlibimport>
71+
$<$<COMPILE_LANGUAGE:Swift>:-parse-stdlib>
72+
$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature AllowUnsafeAttribute>
73+
$<$<COMPILE_LANGUAGE:Swift>:-strict-memory-safety>
74+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-library-level api>"
75+
$<$<COMPILE_LANGUAGE:Swift>:-enforce-exclusivity=unchecked>
76+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -target-min-inlining-version -Xfrontend min>"
77+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -enable-lexical-lifetimes=false>"
78+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature NoncopyableGenerics2>"
79+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature SuppressedAssociatedTypes>"
80+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature SE427NoInferenceOnExtension>"
81+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature NonescapableTypes>"
82+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature LifetimeDependence>"
83+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature LifetimeDependenceMutableAccessors>"
84+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature MemberImportVisibility>"
85+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature InoutLifetimeDependence>")
86+
87+
set_target_properties(swiftDistributed PROPERTIES
88+
Swift_MODULE_NAME Distributed
89+
LINKER_LANGUAGE CXX)
90+
91+
if(APPLE AND BUILD_SHARED_LIBS)
92+
target_link_options(swiftDistributed PRIVATE "SHELL:-Xlinker -headerpad_max_install_names")
93+
endif()
94+
95+
target_compile_definitions(swiftDistributed PRIVATE
96+
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_TARGET_LIBRARY_NAME=swiftDistributed>)
97+
98+
target_include_directories(swiftDistributed PRIVATE
99+
# FIXME: Use of `swift/Runtime/...`, `swift/ABI/...`, and `swift/Demangling/...`
100+
"${${PROJECT_NAME}_SWIFTC_SOURCE_DIR}/include"
101+
# FIXME: grant access to `runtime/CMakeConfig.h` which should be available
102+
# through the swiftRuntime target.
103+
"${PROJECT_BINARY_DIR}/include"
104+
# For llvm/support headers
105+
"${PROJECT_SOURCE_DIR}/include")
106+
107+
target_link_libraries(swiftDistributed PRIVATE
108+
swiftShims
109+
swiftCore
110+
swift_Concurrency)
111+
# swiftDarwin/Libc/Platform
112+
# builtin_float
113+
114+
set(${PROJECT_NAME}_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>$<$<BOOL:${Supplemental_INSTALL_NESTED_SUBDIR}>:/${Supplemental_PLATFORM_SUBDIR}/${Supplemental_ARCH_SUBDIR}>" CACHE STRING "")
115+
set(${PROJECT_NAME}_INSTALL_SWIFTMODULEDIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>$<$<BOOL:${Supplemental_INSTALL_NESTED_SUBDIR}>:/${Supplemental_PLATFORM_SUBDIR}>" CACHE STRING "")
116+
117+
install(TARGETS swiftDistributed
118+
EXPORT SwiftDistributedTargets
119+
COMPONENT ${PROJECT_NAME}_runtime
120+
ARCHIVE DESTINATION "${${PROJECT_NAME}_INSTALL_LIBDIR}"
121+
LIBRARY DESTINATION "${${PROJECT_NAME}_INSTALL_LIBDIR}"
122+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
123+
emit_swift_interface(swiftDistributed)
124+
install_swift_interface(swiftDistributed)
125+
126+
# Configure plist creation for Darwin platforms.
127+
generate_plist("${CMAKE_PROJECT_NAME}" "${CMAKE_PROJECT_VERSION}" swiftDistributed)
128+
embed_manifest(swiftDistributed)
129+
130+
include("${${PROJECT_NAME}_VENDOR_MODULE_DIR}/swiftDistributed.cmake" OPTIONAL)

0 commit comments

Comments
 (0)