Skip to content

Commit d9ba41d

Browse files
committed
Replace SWIFT_SDKS with SWIFT_CROSS_COMPILE_STDLIB_TARGETS
1 parent 2db3e7e commit d9ba41d

File tree

14 files changed

+425
-384
lines changed

14 files changed

+425
-384
lines changed

CMakeLists.txt

Lines changed: 217 additions & 129 deletions
Large diffs are not rendered by default.

benchmark/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ endforeach()
199199

200200
set(executable_targets)
201201

202-
if(SWIFT_SDKS)
202+
if(SWIFT_CONFIGURED_SDKS)
203203
set(IS_SWIFT_BUILD true)
204204
endif()
205205

benchmark/scripts/generate_harness/CMakeLists.txt_template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ endforeach()
137137

138138
set(executable_targets)
139139

140-
if(SWIFT_SDKS)
140+
if(SWIFT_CONFIGURED_SDKS)
141141
set(IS_SWIFT_BUILD true)
142142
endif()
143143

cmake/modules/AddSwift.cmake

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,9 +1034,9 @@ function(add_swift_library name)
10341034
set(SWIFTLIB_INSTALL_IN_COMPONENT dev)
10351035
endif()
10361036

1037-
# If target SDKs are not specified, build for all known SDKs.
1037+
# If target SDKs are not specified, build for all configured SDKs.
10381038
if("${SWIFTLIB_TARGET_SDKS}" STREQUAL "")
1039-
set(SWIFTLIB_TARGET_SDKS ${SWIFT_SDKS})
1039+
set(SWIFTLIB_TARGET_SDKS ${SWIFT_CONFIGURED_SDKS})
10401040
endif()
10411041

10421042
# All Swift code depends on the standard library, except for the standard
@@ -1083,12 +1083,13 @@ function(add_swift_library name)
10831083
# If we are building this library for targets, loop through the various
10841084
# SDKs building the variants of this library.
10851085
list_intersect(
1086-
"${SWIFTLIB_TARGET_SDKS}" "${SWIFT_SDKS}" SWIFTLIB_TARGET_SDKS)
1087-
if(SWIFTLIB_HOST_LIBRARY)
1086+
"${SWIFTLIB_TARGET_SDKS}" "${SWIFT_CONFIGURED_SDKS}" SWIFTLIB_TARGET_SDKS)
1087+
if(SWIFTLIB_HOST_LIBRARY AND NOT SWIFT_SKIP_HOST_STDLIB)
10881088
list_union(
10891089
"${SWIFTLIB_TARGET_SDKS}" "${SWIFT_HOST_VARIANT_SDK}"
10901090
SWIFTLIB_TARGET_SDKS)
10911091
endif()
1092+
10921093
foreach(sdk ${SWIFTLIB_TARGET_SDKS})
10931094
set(THIN_INPUT_TARGETS)
10941095

@@ -1245,7 +1246,6 @@ function(add_swift_library name)
12451246

12461247
# Determine the subdirectory where this library will be installed.
12471248
set(resource_dir_sdk_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
1248-
12491249
if("${resource_dir_sdk_subdir}" STREQUAL "")
12501250
message(FATAL_ERROR "internal error: the variable should be non-empty")
12511251
endif()
@@ -1538,7 +1538,7 @@ function(add_swift_target_executable name)
15381538
swiftCore)
15391539
endif()
15401540

1541-
foreach(sdk ${SWIFT_SDKS})
1541+
foreach(sdk ${SWIFT_CONFIGURED_SDKS})
15421542
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
15431543
set(VARIANT_SUFFIX "-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch}")
15441544
set(VARIANT_NAME "${name}${VARIANT_SUFFIX}")

cmake/modules/SwiftConfigureSDK.cmake

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Each element in this list is an SDK for which the various
44
# SWIFT_SDK_${name}_* variables are defined. Swift libraries will be
55
# built for each variant.
6-
set(SWIFT_CONFIGURED_SDKS)
6+
set(SWIFT_CONFIGURED_SDKS "")
77

88
# Report the given SDK to the user.
99
function(_report_sdk prefix)
@@ -61,6 +61,22 @@ macro(configure_sdk_darwin
6161
# Note: this has to be implemented as a macro because it sets global
6262
# variables.
6363

64+
# Because we calculate our own triple, we need to validate
65+
# architectures here.
66+
67+
set(OSX_VALID_ARCHITECTURES "x86_64")
68+
set(IOS_VALID_ARCHITECTURES "armv7;armv7s;arm64")
69+
set(TVOS_VALID_ARCHITECTURES "arm64")
70+
set(WATCHOS_VALID_ARCHITECTURES "armv7k")
71+
set(IOS_SIMULATOR_VALID_ARCHITECTURES "i386;x86_64")
72+
set(TVOS_SIMULATOR_VALID_ARCHITECTURES "x86_64")
73+
set(WATCHOS_SIMULATOR_VALID_ARCHITECTURES "i386")
74+
75+
list_subtract("${architectures}" "${${prefix}_VALID_ARCHITECTURES}" invalid_archs)
76+
if(invalid_archs)
77+
message(FATAL_ERROR "${invalid_archs} are not recognised architectures for ${name}")
78+
endif()
79+
6480
# Find the SDK
6581
set(SWIFT_SDK_${prefix}_PATH "" CACHE PATH "Path to the ${name} SDK")
6682

@@ -104,6 +120,8 @@ macro(configure_sdk_darwin
104120

105121
# Add this to the list of known SDKs.
106122
list(APPEND SWIFT_CONFIGURED_SDKS "${prefix}")
123+
set(SWIFT_CONFIGURED_SDKS "${SWIFT_CONFIGURED_SDKS}" CACHE STRING
124+
"The SDKs which have been configured to build")
107125

108126
_report_sdk("${prefix}")
109127
endmacro()
@@ -127,6 +145,8 @@ macro(configure_sdk_unix
127145

128146
# Add this to the list of known SDKs.
129147
list(APPEND SWIFT_CONFIGURED_SDKS "${prefix}")
148+
set(SWIFT_CONFIGURED_SDKS "${SWIFT_CONFIGURED_SDKS}" CACHE STRING
149+
"The SDKs which have been configured to build")
130150

131151
_report_sdk("${prefix}")
132152
endmacro()

stdlib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ else()
1111
endif()
1212

1313
add_custom_target(swift-stdlib-all)
14-
foreach(SDK ${SWIFT_SDKS})
14+
foreach(SDK ${SWIFT_CONFIGURED_SDKS})
1515
add_custom_target("swift-stdlib-${SWIFT_SDK_${SDK}_LIB_SUBDIR}")
1616
add_custom_target("swift-test-stdlib-${SWIFT_SDK_${SDK}_LIB_SUBDIR}")
1717
foreach(ARCH ${SWIFT_SDK_${SDK}_ARCHITECTURES})

stdlib/private/SwiftReflectionTest/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ add_swift_library(swiftSwiftReflectionTest SHARED IS_STDLIB
33
SWIFT_MODULE_DEPENDS Darwin
44
INSTALL_IN_COMPONENT stdlib-experimental)
55

6-
foreach(SDK ${SWIFT_SDKS})
6+
foreach(SDK ${SWIFT_CONFIGURED_SDKS})
77
foreach(ARCH ${SWIFT_SDK_${SDK}_ARCHITECTURES})
88
set(VARIANT_SUFFIX "-${SWIFT_SDK_${SDK}_LIB_SUBDIR}-${ARCH}")
99
add_dependencies(

stdlib/public/Platform/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ add_swift_library(${swift_platform_name} IS_SDK_OVERLAY
2929
${swift_platform_flags})
3030

3131
set(glibc_modulemap_target_list)
32-
foreach(sdk ${SWIFT_SDKS})
32+
foreach(sdk ${SWIFT_CONFIGURED_SDKS})
3333
if("${sdk}" STREQUAL "LINUX" OR
3434
"${sdk}" STREQUAL "FREEBSD" OR
3535
"${sdk}" STREQUAL "ANDROID" OR

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ if(PYTHONINTERP_FOUND)
139139
only_long
140140
)
141141

142-
foreach(SDK ${SWIFT_SDKS})
142+
foreach(SDK ${SWIFT_CONFIGURED_SDKS})
143143
foreach(ARCH ${SWIFT_SDK_${SDK}_ARCHITECTURES})
144144
# Configure variables for this subdirectory.
145145
set(VARIANT_SUFFIX "-${SWIFT_SDK_${SDK}_LIB_SUBDIR}-${ARCH}")

utils/SwiftBuildSupport.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ def get_preset_options(substitutions, preset_file_names, preset_name):
142142
diagnostics.fatal("missing option(s) for preset '" + preset_name +
143143
"': " + ", ".join(missing_opts))
144144

145-
# Migrate 'swift-sdks' parameter to 'stdlib-deployment-targets'
145+
# Migrate 'swift-sdks' parameter to
146+
# 'cross-compile-stdlib-deployment-targets'
146147
for opt in build_script_impl_opts:
147148
if opt.startswith("--swift-sdks"):
148149
sdks_to_configure = opt.split("=")[1].split(";")
@@ -164,8 +165,10 @@ def get_preset_options(substitutions, preset_file_names, preset_name):
164165
tgts += StdlibDeploymentTarget.AppleWatch.targets
165166
elif sdk == "WATCHOS_SIMULATOR":
166167
tgts += StdlibDeploymentTarget.AppleWatchSimulator.targets
168+
tgts = [x for x in tgts
169+
if x != StdlibDeploymentTarget.host_target()]
167170

168-
build_script_opts.append("--stdlib-deployment-targets=" +
171+
build_script_opts.append("--cross-compile-stdlib-deployment-targets=" +
169172
" ".join([tgt.name for tgt in tgts]))
170173
# Filter the swift-sdks parameter
171174
build_script_impl_opts = [opt for opt in build_script_impl_opts

0 commit comments

Comments
 (0)