mirror of https://github.com/mpv-player/mpv
TOOLS/macos-sdk-version: remove legacy sdk version retrieval
older macOS dev tools were inconsistent with the way how SDK versions were returned, some truncated the minor versions. in those cases the SDK version had to be retrieved through the SDK build version. recently the scheme for the SDK build version changed that our heuristic for converting it to an SDK version produced wrong version strings. the stride of the minor version changed from 1 to 2, so SDK versions ended up higher than they actually were. furthermore macOS 11 was hardcoded. since Xcode 12 Apple fixed the SDK version retrieval and it is no longer truncated when using Xcode as dev tools. Xcode 12 is also the latest supported version on macOS 10.15, which is also our oldest supported version. we can remove the old SDK build version conversation and use the Xcode only tool to retrieve the SDK version in the case Xcode is used as dev tools. furthermore this als keeps support for Xcode 11 where the problem wasn't fixed yet, but is still a supported version on macOS 10.15. Fixes #9907
This commit is contained in:
parent
b4e14b9420
commit
1c98ab6239
|
@ -6,6 +6,7 @@
|
|||
import re
|
||||
import os
|
||||
import string
|
||||
import subprocess
|
||||
import sys
|
||||
from shutil import which
|
||||
from subprocess import check_output
|
||||
|
@ -13,11 +14,11 @@ from subprocess import check_output
|
|||
def find_macos_sdk():
|
||||
sdk = os.environ.get('MACOS_SDK', '')
|
||||
sdk_version = os.environ.get('MACOS_SDK_VERSION', '0.0')
|
||||
build_version = '0.0'
|
||||
xcrun = which('xcrun')
|
||||
xcodebuild = which('xcodebuild')
|
||||
|
||||
if not xcrun:
|
||||
return sdk,sdk_version,build_version
|
||||
return sdk,sdk_version
|
||||
|
||||
if not sdk:
|
||||
sdk = check_output([xcrun, '--sdk', 'macosx', '--show-sdk-path'],
|
||||
|
@ -25,36 +26,20 @@ def find_macos_sdk():
|
|||
|
||||
# find macOS SDK paths and version
|
||||
if sdk_version == '0.0':
|
||||
# show-sdk-build-version: is not available on older command line tools, but returns a build version (eg 17A360)
|
||||
# show-sdk-version: is always available, but on older dev tools it's only the major version
|
||||
sdk_build_version = check_output([xcrun, '--sdk', 'macosx',
|
||||
'--show-sdk-build-version'], encoding="UTF-8")
|
||||
|
||||
sdk_version = check_output([xcrun, '--sdk', 'macosx', '--show-sdk-version'],
|
||||
encoding="UTF-8")
|
||||
|
||||
if sdk:
|
||||
build_version = '10.10.0'
|
||||
|
||||
# convert build version to a version string
|
||||
# first 2 two digits are the major version, starting with 15 which is 10.11 (offset of 4)
|
||||
# 1 char is the minor version, A => 0, B => 1 and ongoing
|
||||
# last digits are bugfix version, which are not relevant for us
|
||||
# eg 16E185 => 10.12.4, 17A360 => 10.13, 18B71 => 10.14.1
|
||||
if sdk_build_version and isinstance(sdk_build_version, str):
|
||||
verRe = re.compile("(\d+)(\D+)(\d+)")
|
||||
version_parts = verRe.search(sdk_build_version)
|
||||
major = int(version_parts.group(1)) - 4
|
||||
minor = string.ascii_lowercase.index(version_parts.group(2).lower())
|
||||
build_version = '10.' + str(major) + '.' + str(minor)
|
||||
# from 20 onwards macOS 11.0 starts
|
||||
if int(version_parts.group(1)) >= 20:
|
||||
build_version = '11.' + str(minor)
|
||||
# use xcode tools when installed, still necessary for xcode versions <12.0
|
||||
try:
|
||||
sdk_version = check_output([xcodebuild, '-sdk', 'macosx', '-version', 'ProductVersion'],
|
||||
encoding="UTF-8", stderr=subprocess.DEVNULL)
|
||||
except:
|
||||
pass
|
||||
|
||||
if not isinstance(sdk_version, str):
|
||||
sdk_version = '10.10.0'
|
||||
|
||||
return sdk,sdk_version,build_version
|
||||
return sdk.strip(),sdk_version.strip()
|
||||
|
||||
if __name__ == "__main__":
|
||||
sdk_info = find_macos_sdk()
|
||||
|
|
|
@ -1464,10 +1464,8 @@ macos_sdk_path = ''
|
|||
macos_sdk_version = '0.0'
|
||||
if darwin and macos_sdk_version_py.found()
|
||||
macos_sdk_info = run_command(macos_sdk_version_py, check: true).stdout().split(',')
|
||||
macos_sdk_path = macos_sdk_info[0].strip()
|
||||
# Always pick whichever version is higher.
|
||||
macos_sdk_version = macos_sdk_info[1].version_compare('>' + macos_sdk_info[2]) ? \
|
||||
macos_sdk_info[1] : macos_sdk_info[2]
|
||||
macos_sdk_path = macos_sdk_info[0]
|
||||
macos_sdk_version = macos_sdk_info[1]
|
||||
endif
|
||||
|
||||
if macos_sdk_path != ''
|
||||
|
|
Loading…
Reference in New Issue