Skip to content

Commit 4666a41

Browse files
[CMAKE] Add Plist creation to swiftCore (#77960)
* update Resync to copy plist template * include Plist in linked library for Darwin platforms * only embedd plist on apple platforms * formatting fix
1 parent a7dcab5 commit 4666a41

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

Runtimes/Core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ include(DefaultSettings)
6868
include(EmitSwiftInterface)
6969
include(PlatformInfo)
7070
include(gyb)
71+
include(Plist)
7172

7273
include("${SwiftCore_VENDOR_MODULE_DIR}/Settings.cmake" OPTIONAL)
7374

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
function(generate_plist project_name project_version target)
2+
set(PLIST_INFO_PLIST "Info.plist")
3+
set(PLIST_INFO_NAME "${project_name}")
4+
5+
# Underscores aren't permitted in the bundle identifier.
6+
string(REPLACE "_" "" PLIST_INFO_UTI "com.apple.dt.runtime.${PLIST_INFO_NAME}")
7+
set(PLIST_INFO_VERSION "${project_version}")
8+
set(PLIST_INFO_BUILD_VERSION "${project_version}")
9+
10+
set(PLIST_INFO_PLIST_OUT "${PLIST_INFO_PLIST}")
11+
set(PLIST_INFO_PLIST_IN "${PROJECT_SOURCE_DIR}/${PLIST_INFO_PLIST}.in")
12+
13+
if(APPLE)
14+
target_link_options(${target} PRIVATE
15+
"SHELL:-Xlinker -sectcreate -Xlinker __TEXT -Xlinker __info_plist -Xlinker ${CMAKE_CURRENT_BINARY_DIR}/${PLIST_INFO_PLIST_OUT}")
16+
endif()
17+
18+
configure_file(
19+
"${PLIST_INFO_PLIST_IN}"
20+
"${PLIST_INFO_PLIST_OUT}"
21+
@ONLY
22+
NEWLINE_STYLE UNIX)
23+
24+
set_property(TARGET ${target} APPEND PROPERTY LINK_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${PLIST_INFO_PLIST_OUT}")
25+
26+
# If Application Extensions are enabled, pass the linker flag marking
27+
# the dylib as safe.
28+
if (CXX_SUPPORTS_FAPPLICATION_EXTENSION AND (NOT DISABLE_APPLICATION_EXTENSION))
29+
list(APPEND link_flags "-Wl,-application_extension")
30+
endif()
31+
endfunction()

Runtimes/Core/core/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Swift.swiftmodule"
347347
emit_swift_interface(swiftCore)
348348
install_swift_interface(swiftCore)
349349

350+
# Configure plist creation for Darwin platforms.
351+
generate_plist("${CMAKE_PROJECT_NAME}" "${CMAKE_PROJECT_VERSION}" swiftCore)
352+
350353
include("${SwiftCore_VENDOR_MODULE_DIR}/swiftCore.cmake" OPTIONAL)
351354

352355
# TODO: Embedded SwiftCore builds

Runtimes/Resync.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ copy_library_sources(include "" "Core")
5959
# Copy magic linker symbols
6060
copy_library_sources("linker-support" "" "Core")
6161

62+
# Copy Plist
63+
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Core/Info.plist.in")
64+
file(COPY_FILE
65+
"${StdlibSources}/Info.plist.in" # From
66+
"${CMAKE_CURRENT_LIST_DIR}/Core/Info.plist.in" # To
67+
RESULT _output
68+
ONLY_IF_DIFFERENT)
69+
if(_output)
70+
message(SEND_ERROR
71+
"Copy ${StdlibSources}/Info.plist.in] -> Core/Info.plist.in Failed: ${_output}")
72+
endif()
73+
6274
set(CoreLibs
6375
LLVMSupport
6476
SwiftShims

0 commit comments

Comments
 (0)