|
258 | 258 | lit.util.usePlatformSdkOnDarwin(config, lit_config)
|
259 | 259 |
|
260 | 260 | if config.host_os == 'Darwin':
|
| 261 | + def get_apple_platform_version_aligned_with(macos_version, apple_platform): |
| 262 | + """ |
| 263 | + Given a macOS version (`macos_version`) returns the corresponding version for |
| 264 | + the specified Apple platform if it exists. |
| 265 | +
|
| 266 | + `macos_version` - The macOS version as a string. |
| 267 | + `apple_platform` - The Apple platform name as a string. |
| 268 | +
|
| 269 | + Returns the corresponding version as a string if it exists, otherwise |
| 270 | + `None` is returned. |
| 271 | + """ |
| 272 | + m = re.match(r'^10\.(?P<min>\d+)(\.(?P<patch>\d+))?$', macos_version) |
| 273 | + if not m: |
| 274 | + raise Exception('Could not parse macOS version: "{}"'.format(macos_version)) |
| 275 | + ver_min = int(m.group('min')) |
| 276 | + ver_patch = m.group('patch') |
| 277 | + if ver_patch: |
| 278 | + ver_patch = int(ver_patch) |
| 279 | + else: |
| 280 | + ver_patch = 0 |
| 281 | + result_str = '' |
| 282 | + if apple_platform == 'osx': |
| 283 | + # Drop patch for now. |
| 284 | + result_str = '10.{}'.format(ver_min) |
| 285 | + elif apple_platform.startswith('ios') or apple_platform.startswith('tvos'): |
| 286 | + result_maj = ver_min - 2 |
| 287 | + if result_maj < 1: |
| 288 | + return None |
| 289 | + result_str = '{}.{}'.format(result_maj, ver_patch) |
| 290 | + elif apple_platform.startswith('watch'): |
| 291 | + result_maj = ver_min - 9 |
| 292 | + if result_maj < 1: |
| 293 | + return None |
| 294 | + result_str = '{}.{}'.format(result_maj, ver_patch) |
| 295 | + else: |
| 296 | + raise Exception('Unsuported apple platform "{}"'.format(apple_platform)) |
| 297 | + return result_str |
| 298 | + |
261 | 299 | osx_version = (10, 0, 0)
|
262 | 300 | try:
|
263 | 301 | osx_version = subprocess.check_output(["sw_vers", "-productVersion"])
|
|
288 | 326 | except:
|
289 | 327 | pass
|
290 | 328 |
|
291 |
| - config.substitutions.append( ("%macos_min_target_10_11", "-mmacosx-version-min=10.11") ) |
292 |
| - |
293 |
| - isIOS = config.apple_platform != "osx" |
| 329 | + min_os_aligned_with_osx_10_11 = get_apple_platform_version_aligned_with('10.11', config.apple_platform) |
| 330 | + min_os_aligned_with_osx_10_11_flag = '' |
| 331 | + if min_os_aligned_with_osx_10_11: |
| 332 | + min_os_aligned_with_osx_10_11_flag = '{flag}={version}'.format( |
| 333 | + flag=config.apple_platform_min_deployment_target_flag, |
| 334 | + version=min_os_aligned_with_osx_10_11) |
| 335 | + else: |
| 336 | + lit_config.warning('Could not find a version of {} that corresponds with macOS 10.11'.format(config.apple_platform)) |
| 337 | + config.substitutions.append( ("%macos_min_target_10_11", min_os_aligned_with_osx_10_11_flag) ) |
294 | 338 | # rdar://problem/22207160
|
295 |
| - config.substitutions.append( ("%darwin_min_target_with_full_runtime_arc_support", |
296 |
| - "-miphoneos-version-min=9.0" if isIOS else "-mmacosx-version-min=10.11") ) |
| 339 | + config.substitutions.append( ("%darwin_min_target_with_full_runtime_arc_support", min_os_aligned_with_osx_10_11_flag) ) |
297 | 340 |
|
298 | 341 | # 32-bit iOS simulator is deprecated and removed in latest Xcode.
|
299 | 342 | if config.apple_platform == "iossim":
|
|
0 commit comments