2021-10-21 15:20:43 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2023-10-29 16:15:44 +00:00
|
|
|
# This checks for the sdk path, the sdk version, and
|
|
|
|
# the sdk build version.
|
2021-10-21 15:20:43 +00:00
|
|
|
|
|
|
|
import os
|
2023-11-07 20:47:30 +00:00
|
|
|
import subprocess
|
2021-10-21 15:20:43 +00:00
|
|
|
import sys
|
|
|
|
from shutil import which
|
|
|
|
from subprocess import check_output
|
|
|
|
|
2024-09-21 10:47:30 +00:00
|
|
|
|
2021-10-21 15:20:43 +00:00
|
|
|
def find_macos_sdk():
|
2024-09-15 00:55:28 +00:00
|
|
|
sdk = os.environ.get("MACOS_SDK", "")
|
|
|
|
sdk_version = os.environ.get("MACOS_SDK_VERSION", "0.0")
|
|
|
|
xcrun = which("xcrun")
|
|
|
|
xcodebuild = which("xcodebuild")
|
2021-10-21 15:20:43 +00:00
|
|
|
|
|
|
|
if not xcrun:
|
2023-11-07 20:47:30 +00:00
|
|
|
return sdk,sdk_version
|
2021-10-21 15:20:43 +00:00
|
|
|
|
|
|
|
if not sdk:
|
2024-09-15 00:55:28 +00:00
|
|
|
sdk = check_output([xcrun, "--sdk", "macosx", "--show-sdk-path"],
|
2021-10-21 15:20:43 +00:00
|
|
|
encoding="UTF-8")
|
2022-05-12 15:12:31 +00:00
|
|
|
|
2021-10-21 15:20:43 +00:00
|
|
|
# find macOS SDK paths and version
|
2024-09-15 00:55:28 +00:00
|
|
|
if sdk_version == "0.0":
|
|
|
|
sdk_version = check_output([xcrun, "--sdk", "macosx", "--show-sdk-version"],
|
2021-10-21 15:20:43 +00:00
|
|
|
encoding="UTF-8")
|
|
|
|
|
2023-11-07 20:47:30 +00:00
|
|
|
# use xcode tools when installed, still necessary for xcode versions <12.0
|
|
|
|
try:
|
2024-09-15 00:43:15 +00:00
|
|
|
sdk_version = check_output(
|
2024-09-15 00:55:28 +00:00
|
|
|
[xcodebuild, "-sdk", "macosx", "-version", "ProductVersion"],
|
2024-09-15 00:43:15 +00:00
|
|
|
encoding="UTF-8",
|
2024-09-21 10:58:14 +00:00
|
|
|
stderr=subprocess.DEVNULL,
|
2024-09-15 00:43:15 +00:00
|
|
|
)
|
2024-09-13 17:22:05 +00:00
|
|
|
except Exception:
|
2023-11-07 20:47:30 +00:00
|
|
|
pass
|
2021-10-21 15:20:43 +00:00
|
|
|
|
|
|
|
if not isinstance(sdk_version, str):
|
2024-09-15 00:55:28 +00:00
|
|
|
sdk_version = "10.10.0"
|
2021-10-21 15:20:43 +00:00
|
|
|
|
2023-11-07 20:47:30 +00:00
|
|
|
return sdk.strip(),sdk_version.strip()
|
2021-10-21 15:20:43 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
sdk_info = find_macos_sdk()
|
2024-09-15 00:55:28 +00:00
|
|
|
sys.stdout.write(",".join(sdk_info))
|