Skip to content

Commit

Permalink
[build] Respect DEPLOYMENT_VERSION_{IOS|TVOS|WATCHOS} for Swift sou…
Browse files Browse the repository at this point in the history
…rces

See swiftlang#69512

rdar://117699474
  • Loading branch information
egorzhdan committed Nov 6, 2023
1 parent ad30745 commit f8b5143
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions stdlib/cmake/modules/AddSwiftStdlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,9 @@ function(add_swift_target_library_single target name)
ENABLE_LTO "${SWIFTLIB_SINGLE_ENABLE_LTO}"
INSTALL_IN_COMPONENT "${install_in_component}"
DEPLOYMENT_VERSION_OSX ${SWIFTLIB_SINGLE_DEPLOYMENT_VERSION_OSX}
DEPLOYMENT_VERSION_IOS ${SWIFTLIB_SINGLE_DEPLOYMENT_VERSION_IOS}
DEPLOYMENT_VERSION_TVOS ${SWIFTLIB_SINGLE_DEPLOYMENT_VERSION_TVOS}
DEPLOYMENT_VERSION_WATCHOS ${SWIFTLIB_SINGLE_DEPLOYMENT_VERSION_WATCHOS}
MACCATALYST_BUILD_FLAVOR "${SWIFTLIB_SINGLE_MACCATALYST_BUILD_FLAVOR}"
${BOOTSTRAPPING_arg})
add_swift_source_group("${SWIFTLIB_SINGLE_EXTERNAL_SOURCES}")
Expand Down
21 changes: 18 additions & 3 deletions stdlib/cmake/modules/SwiftSource.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function(handle_swift_sources
sourcesvar externalvar name)
cmake_parse_arguments(SWIFTSOURCES
"IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY;EMBED_BITCODE;STATIC;NO_LINK_NAME;IS_FRAGILE;ONLY_SWIFTMODULE"
"SDK;ARCHITECTURE;INSTALL_IN_COMPONENT;DEPLOYMENT_VERSION_OSX;MACCATALYST_BUILD_FLAVOR;BOOTSTRAPPING"
"SDK;ARCHITECTURE;INSTALL_IN_COMPONENT;DEPLOYMENT_VERSION_OSX;DEPLOYMENT_VERSION_IOS;DEPLOYMENT_VERSION_TVOS;DEPLOYMENT_VERSION_WATCHOS;MACCATALYST_BUILD_FLAVOR;BOOTSTRAPPING"
"DEPENDS;COMPILE_FLAGS;MODULE_NAME;MODULE_DIR;ENABLE_LTO"
${ARGN})
translate_flag(${SWIFTSOURCES_IS_MAIN} "IS_MAIN" IS_MAIN_arg)
Expand Down Expand Up @@ -159,6 +159,9 @@ function(handle_swift_sources
${ONLY_SWIFTMODULE_arg}
INSTALL_IN_COMPONENT "${SWIFTSOURCES_INSTALL_IN_COMPONENT}"
DEPLOYMENT_VERSION_OSX ${SWIFTSOURCES_DEPLOYMENT_VERSION_OSX}
DEPLOYMENT_VERSION_IOS ${SWIFTSOURCES_DEPLOYMENT_VERSION_IOS}
DEPLOYMENT_VERSION_TVOS ${SWIFTSOURCES_DEPLOYMENT_VERSION_TVOS}
DEPLOYMENT_VERSION_WATCHOS ${SWIFTSOURCES_DEPLOYMENT_VERSION_WATCHOS}
MACCATALYST_BUILD_FLAVOR "${SWIFTSOURCES_MACCATALYST_BUILD_FLAVOR}")
set("${dependency_target_out_var_name}" "${dependency_target}" PARENT_SCOPE)
set("${dependency_module_target_out_var_name}" "${module_dependency_target}" PARENT_SCOPE)
Expand Down Expand Up @@ -226,7 +229,7 @@ function(_add_target_variant_swift_compile_flags
cmake_parse_arguments(
VARIANT # prefix
"" # options
"MACCATALYST_BUILD_FLAVOR;DEPLOYMENT_VERSION_OSX" # single-value args
"MACCATALYST_BUILD_FLAVOR;DEPLOYMENT_VERSION_OSX;DEPLOYMENT_VERSION_IOS;DEPLOYMENT_VERSION_TVOS;DEPLOYMENT_VERSION_WATCHOS" # single-value args
"" # multi-value args
${ARGN})

Expand All @@ -240,6 +243,15 @@ function(_add_target_variant_swift_compile_flags
if("${sdk}" STREQUAL "OSX" AND DEFINED VARIANT_DEPLOYMENT_VERSION_OSX)
set(sdk_deployment_version ${VARIANT_DEPLOYMENT_VERSION_OSX})
endif()
if("${sdk}" STREQUAL "IOS" AND DEFINED VARIANT_DEPLOYMENT_VERSION_IOS)
set(sdk_deployment_version ${VARIANT_DEPLOYMENT_VERSION_IOS})
endif()
if("${sdk}" STREQUAL "TVOS" AND DEFINED VARIANT_DEPLOYMENT_VERSION_TVOS)
set(sdk_deployment_version ${VARIANT_DEPLOYMENT_VERSION_TVOS})
endif()
if("${sdk}" STREQUAL "WATCHOS" AND DEFINED VARIANT_DEPLOYMENT_VERSION_WATCHOS)
set(sdk_deployment_version ${VARIANT_DEPLOYMENT_VERSION_WATCHOS})
endif()

get_target_triple(target target_variant "${sdk}" "${arch}"
MACCATALYST_BUILD_FLAVOR "${VARIANT_MACCATALYST_BUILD_FLAVOR}"
Expand Down Expand Up @@ -387,7 +399,7 @@ function(_compile_swift_files
dependency_sibgen_target_out_var_name)
cmake_parse_arguments(SWIFTFILE
"IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY;EMBED_BITCODE;STATIC;IS_FRAGILE;ONLY_SWIFTMODULE"
"OUTPUT;MODULE_NAME;INSTALL_IN_COMPONENT;DEPLOYMENT_VERSION_OSX;MACCATALYST_BUILD_FLAVOR;BOOTSTRAPPING"
"OUTPUT;MODULE_NAME;INSTALL_IN_COMPONENT;DEPLOYMENT_VERSION_OSX;DEPLOYMENT_VERSION_IOS;DEPLOYMENT_VERSION_TVOS;DEPLOYMENT_VERSION_WATCHOS;MACCATALYST_BUILD_FLAVOR;BOOTSTRAPPING"
"SOURCES;FLAGS;DEPENDS;SDK;ARCHITECTURE;OPT_FLAGS;MODULE_DIR"
${ARGN})

Expand Down Expand Up @@ -461,6 +473,9 @@ function(_compile_swift_files
"${SWIFT_STDLIB_ASSERTIONS}"
swift_flags
DEPLOYMENT_VERSION_OSX ${SWIFTFILE_DEPLOYMENT_VERSION_OSX}
DEPLOYMENT_VERSION_IOS ${SWIFTFILE_DEPLOYMENT_VERSION_IOS}
DEPLOYMENT_VERSION_TVOS ${SWIFTFILE_DEPLOYMENT_VERSION_TVOS}
DEPLOYMENT_VERSION_WATCHOS ${SWIFTFILE_DEPLOYMENT_VERSION_WATCHOS}
MACCATALYST_BUILD_FLAVOR "${maccatalyst_build_flavor}"
)

Expand Down

0 comments on commit f8b5143

Please sign in to comment.