|
264 | 264 |
|
265 | 265 | lit.util.usePlatformSdkOnDarwin(config, lit_config)
|
266 | 266 |
|
267 |
| -# Maps a lit substitution name for the minimum target OS flag |
268 |
| -# to the macOS version that first contained the relevant feature. |
269 |
| -darwin_min_deployment_target_substitutions = { |
270 |
| - '%macos_min_target_10_11': '10.11', |
271 |
| - '%darwin_min_target_with_tls_support': '10.12', # TLS requires watchOS 3+ simulator |
272 |
| -} |
| 267 | +min_macos_deployment_target_substitutions = [ |
| 268 | + (10, 11), |
| 269 | + (10, 12), |
| 270 | +] |
| 271 | +# TLS requires watchOS 3+ |
| 272 | +config.substitutions.append( ('%darwin_min_target_with_tls_support', '%min_macos_deployment_target=10.12') ) |
273 | 273 |
|
274 | 274 | if config.host_os == 'Darwin':
|
275 |
| - def get_apple_platform_version_aligned_with(macos_version, apple_platform): |
276 |
| - """ |
277 |
| - Given a macOS version (`macos_version`) returns the corresponding version for |
278 |
| - the specified Apple platform if it exists. |
279 |
| -
|
280 |
| - `macos_version` - The macOS version as a string. |
281 |
| - `apple_platform` - The Apple platform name as a string. |
282 |
| -
|
283 |
| - Returns the corresponding version as a string if it exists, otherwise |
284 |
| - `None` is returned. |
285 |
| - """ |
286 |
| - m = re.match(r'^10\.(?P<min>\d+)(\.(?P<patch>\d+))?$', macos_version) |
287 |
| - if not m: |
288 |
| - raise Exception('Could not parse macOS version: "{}"'.format(macos_version)) |
289 |
| - ver_min = int(m.group('min')) |
290 |
| - ver_patch = m.group('patch') |
291 |
| - if ver_patch: |
292 |
| - ver_patch = int(ver_patch) |
293 |
| - else: |
294 |
| - ver_patch = 0 |
295 |
| - result_str = '' |
296 |
| - if apple_platform == 'osx': |
297 |
| - # Drop patch for now. |
298 |
| - result_str = '10.{}'.format(ver_min) |
299 |
| - elif apple_platform.startswith('ios') or apple_platform.startswith('tvos'): |
300 |
| - result_maj = ver_min - 2 |
301 |
| - if result_maj < 1: |
302 |
| - return None |
303 |
| - result_str = '{}.{}'.format(result_maj, ver_patch) |
304 |
| - elif apple_platform.startswith('watch'): |
305 |
| - result_maj = ver_min - 9 |
306 |
| - if result_maj < 1: |
307 |
| - return None |
308 |
| - result_str = '{}.{}'.format(result_maj, ver_patch) |
309 |
| - else: |
310 |
| - raise Exception('Unsuported apple platform "{}"'.format(apple_platform)) |
311 |
| - return result_str |
312 |
| - |
313 | 275 | osx_version = (10, 0, 0)
|
314 | 276 | try:
|
315 | 277 | osx_version = subprocess.check_output(["sw_vers", "-productVersion"],
|
@@ -341,29 +303,44 @@ def get_apple_platform_version_aligned_with(macos_version, apple_platform):
|
341 | 303 | except:
|
342 | 304 | pass
|
343 | 305 |
|
344 |
| - def get_apple_min_deploy_target_flag_aligned_with_osx(version): |
345 |
| - min_os_aligned_with_osx_v = get_apple_platform_version_aligned_with(version, config.apple_platform) |
346 |
| - min_os_aligned_with_osx_v_flag = '' |
347 |
| - if min_os_aligned_with_osx_v: |
348 |
| - min_os_aligned_with_osx_v_flag = '{flag}={version}'.format( |
349 |
| - flag=config.apple_platform_min_deployment_target_flag, |
350 |
| - version=min_os_aligned_with_osx_v) |
351 |
| - else: |
352 |
| - lit_config.warning('Could not find a version of {} that corresponds with macOS {}'.format( |
353 |
| - config.apple_platform, |
354 |
| - version)) |
355 |
| - return min_os_aligned_with_osx_v_flag |
356 |
| - |
357 |
| - for substitution, osx_version in darwin_min_deployment_target_substitutions.items(): |
358 |
| - config.substitutions.append( (substitution, get_apple_min_deploy_target_flag_aligned_with_osx(osx_version)) ) |
359 |
| - |
360 | 306 | # 32-bit iOS simulator is deprecated and removed in latest Xcode.
|
361 | 307 | if config.apple_platform == "iossim":
|
362 | 308 | if config.target_arch == "i386":
|
363 | 309 | config.unsupported = True
|
| 310 | + |
| 311 | + def get_macos_aligned_version(macos_vers): |
| 312 | + platform = config.apple_platform |
| 313 | + if platform == 'osx': |
| 314 | + return macos_vers |
| 315 | + |
| 316 | + macos_major, macos_minor = macos_vers |
| 317 | + assert macos_major >= 10 |
| 318 | + |
| 319 | + if macos_major == 10: # macOS 10.x |
| 320 | + major = macos_minor |
| 321 | + minor = 0 |
| 322 | + else: # macOS 11+ |
| 323 | + major = macos_major + 5 |
| 324 | + minor = macos_minor |
| 325 | + |
| 326 | + assert major >= 11 |
| 327 | + |
| 328 | + if platform.startswith('ios') or platform.startswith('tvos'): |
| 329 | + major -= 2 |
| 330 | + elif platform.startswith('watch'): |
| 331 | + major -= 9 |
| 332 | + else: |
| 333 | + lit_config.fatal("Unsupported apple platform '{}'".format(platform)) |
| 334 | + |
| 335 | + return (major, minor) |
| 336 | + |
| 337 | + for vers in min_macos_deployment_target_substitutions: |
| 338 | + flag = config.apple_platform_min_deployment_target_flag |
| 339 | + major, minor = get_macos_aligned_version(vers) |
| 340 | + config.substitutions.append( ('%%min_macos_deployment_target=%s.%s' % vers, '{}={}.{}'.format(flag, major, minor)) ) |
364 | 341 | else:
|
365 |
| - for substitution in darwin_min_deployment_target_substitutions.keys(): |
366 |
| - config.substitutions.append( (substitution, "") ) |
| 342 | + for vers in min_macos_deployment_target_substitutions: |
| 343 | + config.substitutions.append( ('%%min_macos_deployment_target=%s.%s' % vers, '') ) |
367 | 344 |
|
368 | 345 | if config.android:
|
369 | 346 | env = os.environ.copy()
|
|
0 commit comments