mirror of https://github.com/mpv-player/mpv
meson: do the macos sdk version comparison in meson
Since we can no longer rely on distuils for a version comparison, let's modify the macos-sdk-version script so it returns multiple potential versions to meson. Then use meson's built-in version comparison to pick the right one instead. This avoids the complication of needing certain python packages installed since everything simply uses stdlib functions.
This commit is contained in:
parent
50187264fa
commit
18885917a7
|
@ -1,24 +1,23 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# Logic copied from compiler_swift.py in the waf build. This checks for the sdk
|
||||
# path, the sdk version, and the sdk build version. The sdk path is returned
|
||||
# along with what is selected as the sdk version.
|
||||
# This checks for the sdk path, the sdk version, and
|
||||
# the sdk build version.
|
||||
|
||||
import re
|
||||
import os
|
||||
import string
|
||||
import sys
|
||||
from packaging import version
|
||||
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')
|
||||
build_version = '0.0'
|
||||
xcrun = which('xcrun')
|
||||
|
||||
if not xcrun:
|
||||
return sdk,sdk_version
|
||||
return sdk,sdk_version,build_version
|
||||
|
||||
if not sdk:
|
||||
sdk = check_output([xcrun, '--sdk', 'macosx', '--show-sdk-path'],
|
||||
|
@ -55,13 +54,7 @@ def find_macos_sdk():
|
|||
if not isinstance(sdk_version, str):
|
||||
sdk_version = '10.10.0'
|
||||
|
||||
# pick the higher version, always pick sdk over build if newer
|
||||
if version.parse(build_version) > version.parse(sdk_version):
|
||||
return sdk,build_version
|
||||
else:
|
||||
return sdk,sdk_version
|
||||
|
||||
return sdk,sdk_version
|
||||
return sdk,sdk_version,build_version
|
||||
|
||||
if __name__ == "__main__":
|
||||
sdk_info = find_macos_sdk()
|
||||
|
|
|
@ -1477,7 +1477,9 @@ 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()
|
||||
macos_sdk_version = macos_sdk_info[1]
|
||||
# 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]
|
||||
endif
|
||||
|
||||
if macos_sdk_path != ''
|
||||
|
|
Loading…
Reference in New Issue