mirror of
https://github.com/mpv-player/mpv
synced 2024-12-28 18:12:22 +00:00
1c98ab6239
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
47 lines
1.3 KiB
Python
Executable File
47 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
# This checks for the sdk path, the sdk version, and
|
|
# the sdk build version.
|
|
|
|
import re
|
|
import os
|
|
import string
|
|
import subprocess
|
|
import sys
|
|
from shutil import which
|
|
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')
|
|
xcrun = which('xcrun')
|
|
xcodebuild = which('xcodebuild')
|
|
|
|
if not xcrun:
|
|
return sdk,sdk_version
|
|
|
|
if not sdk:
|
|
sdk = check_output([xcrun, '--sdk', 'macosx', '--show-sdk-path'],
|
|
encoding="UTF-8")
|
|
|
|
# find macOS SDK paths and version
|
|
if sdk_version == '0.0':
|
|
sdk_version = check_output([xcrun, '--sdk', 'macosx', '--show-sdk-version'],
|
|
encoding="UTF-8")
|
|
|
|
# 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.strip(),sdk_version.strip()
|
|
|
|
if __name__ == "__main__":
|
|
sdk_info = find_macos_sdk()
|
|
sys.stdout.write(','.join(sdk_info))
|