aedi: add sdk_version() method to build state

This commit is contained in:
alexey.lysiuk 2021-09-12 10:19:16 +03:00
parent e3289f88ba
commit 0ec387c33e
2 changed files with 10 additions and 4 deletions

View file

@ -18,6 +18,7 @@
import hashlib import hashlib
import os import os
import re
import shutil import shutil
import subprocess import subprocess
import typing import typing
@ -69,6 +70,13 @@ class BuildState:
def sdk_path(self) -> Path: def sdk_path(self) -> Path:
return self.platform.sdk_path if self.platform else None return self.platform.sdk_path if self.platform else None
def sdk_version(self) -> typing.Union[StrictVersion, None]:
if sdk_path := self.sdk_path():
if match := re.search(r'/MacOSX(\d+.\d+).sdk', str(sdk_path), re.IGNORECASE):
return StrictVersion(match[1])
return None
def c_compiler(self) -> Path: def c_compiler(self) -> Path:
return self.platform.c_compiler if self.platform else None return self.platform.c_compiler if self.platform else None

View file

@ -82,10 +82,8 @@ class BuildTarget(Target):
if os_version and os_version < self.os_version[state.architecture()]: if os_version and os_version < self.os_version[state.architecture()]:
raise RuntimeError('Minimum OS version requirement is not met') raise RuntimeError('Minimum OS version requirement is not met')
sdk_path = state.sdk_path() if sdk_version := state.sdk_version():
if sdk_path: if sdk_version < self.sdk_version[state.architecture()]:
match = re.search(r'/MacOSX(\d+.\d+).sdk', str(sdk_path), re.IGNORECASE)
if match and StrictVersion(match[1]) < self.sdk_version[state.architecture()]:
raise RuntimeError('Minimum SDK version requirement is not met') raise RuntimeError('Minimum SDK version requirement is not met')
os.makedirs(state.build_path, exist_ok=True) os.makedirs(state.build_path, exist_ok=True)