mirror of
https://github.com/mpv-player/mpv
synced 2025-03-19 18:05:21 +00:00
build: fix build with older command line tools
This commit is contained in:
parent
916f4146a7
commit
4a8bf91d4c
@ -6,7 +6,7 @@ from distutils.version import StrictVersion
|
|||||||
|
|
||||||
def __run(cmd):
|
def __run(cmd):
|
||||||
try:
|
try:
|
||||||
output = Utils.subprocess.check_output(cmd, universal_newlines=True)
|
output = Utils.subprocess.check_output(cmd, stderr=Utils.subprocess.STDOUT, universal_newlines=True)
|
||||||
return output.strip()
|
return output.strip()
|
||||||
except Exception:
|
except Exception:
|
||||||
return ""
|
return ""
|
||||||
@ -118,6 +118,7 @@ def __find_macos_sdk(ctx):
|
|||||||
ctx.start_msg('Checking for macOS SDK')
|
ctx.start_msg('Checking for macOS SDK')
|
||||||
sdk = None
|
sdk = None
|
||||||
sdk_build_version = None
|
sdk_build_version = None
|
||||||
|
sdk_version = None
|
||||||
|
|
||||||
#look for set macOS SDK paths and version in passed environment variables
|
#look for set macOS SDK paths and version in passed environment variables
|
||||||
if 'MACOS_SDK' in ctx.environ:
|
if 'MACOS_SDK' in ctx.environ:
|
||||||
@ -129,18 +130,37 @@ def __find_macos_sdk(ctx):
|
|||||||
if not sdk:
|
if not sdk:
|
||||||
sdk = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-path'])
|
sdk = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-path'])
|
||||||
if not ctx.env.MACOS_SDK_VERSION:
|
if not ctx.env.MACOS_SDK_VERSION:
|
||||||
|
#show-sdk-build-version: is not available on older command line tools, but return 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 = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-build-version' ])
|
sdk_build_version = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-build-version' ])
|
||||||
|
sdk_version = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-version' ])
|
||||||
|
|
||||||
if sdk:
|
if sdk:
|
||||||
ctx.end_msg(sdk)
|
ctx.end_msg(sdk)
|
||||||
ctx.env.MACOS_SDK = sdk
|
ctx.env.MACOS_SDK = sdk
|
||||||
|
build_version = '10.10.0'
|
||||||
|
|
||||||
if sdk_build_version and not ctx.env.MACOS_SDK_VERSION:
|
if not ctx.env.MACOS_SDK_VERSION:
|
||||||
verRe = re.compile("(\d+)(\D+)(\d+)")
|
#convert build version to a version string
|
||||||
version_parts = verRe.search(sdk_build_version)
|
#first 2 two digits are the major version, starting with 15 which is 10.11 (offset of 4)
|
||||||
major = int(version_parts.group(1))-4
|
#1 char is the minor version, A => 0, B => 1 and ongoing
|
||||||
minor = string.ascii_lowercase.index(version_parts.group(2).lower())
|
#las digits are bugfix version, which are nor relevant for us
|
||||||
ctx.env.MACOS_SDK_VERSION = '10.' + str(major) + '.' + str(minor)
|
#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)
|
||||||
|
|
||||||
|
if not isinstance(sdk_version, str):
|
||||||
|
sdk_version = '10.10.0'
|
||||||
|
|
||||||
|
#pick the higher version, always pick sdk over build if newer
|
||||||
|
if StrictVersion(build_version) > StrictVersion(sdk_version):
|
||||||
|
ctx.env.MACOS_SDK_VERSION = build_version
|
||||||
|
else:
|
||||||
|
ctx.env.MACOS_SDK_VERSION = sdk_version
|
||||||
else:
|
else:
|
||||||
ctx.end_msg(False)
|
ctx.end_msg(False)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user