diff --git a/aedi/state.py b/aedi/state.py index b33fd997..7923f9f9 100644 --- a/aedi/state.py +++ b/aedi/state.py @@ -18,6 +18,7 @@ import hashlib import os +import re import shutil import subprocess import typing @@ -69,6 +70,13 @@ class BuildState: def sdk_path(self) -> Path: 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: return self.platform.c_compiler if self.platform else None diff --git a/aedi/target/base.py b/aedi/target/base.py index 6024cb5f..52567414 100644 --- a/aedi/target/base.py +++ b/aedi/target/base.py @@ -82,10 +82,8 @@ class BuildTarget(Target): if os_version and os_version < self.os_version[state.architecture()]: raise RuntimeError('Minimum OS version requirement is not met') - sdk_path = state.sdk_path() - if sdk_path: - match = re.search(r'/MacOSX(\d+.\d+).sdk', str(sdk_path), re.IGNORECASE) - if match and StrictVersion(match[1]) < self.sdk_version[state.architecture()]: + if sdk_version := state.sdk_version(): + if sdk_version < self.sdk_version[state.architecture()]: raise RuntimeError('Minimum SDK version requirement is not met') os.makedirs(state.build_path, exist_ok=True)