python/build/toolchain: add is_android, is_darwin

This commit is contained in:
Max Kellermann 2023-09-26 14:46:59 +02:00
parent a0892b852e
commit 48cc76f114
3 changed files with 7 additions and 3 deletions

View File

@ -15,7 +15,7 @@ def __write_cmake_compiler(f: TextIO, language: str, compiler: str) -> None:
print(f'set(CMAKE_{language}_COMPILER {compiler})', file=f)
def __write_cmake_toolchain_file(f: TextIO, toolchain: AnyToolchain) -> None:
if '-darwin' in toolchain.actual_arch:
if toolchain.is_darwin:
cmake_system_name = 'Darwin'
elif toolchain.is_windows:
cmake_system_name = 'Windows'
@ -65,7 +65,7 @@ def configure(toolchain: AnyToolchain, src: str, build: str, args: list[str]=[],
# looking for libraries on the build host (TODO: fix this
# properly); but we must not do that on Android because the NDK
# has a sysroot already
if '-android' not in toolchain.actual_arch and '-darwin' not in toolchain.actual_arch:
if not toolchain.is_android and not toolchain.is_darwin:
cross_args.append('-DCMAKE_SYSROOT=' + toolchain.install_prefix)
os.makedirs(build, exist_ok=True)

View File

@ -63,7 +63,7 @@ pkgconfig = '{toolchain.pkg_config}'
root = '{toolchain.install_prefix}'
""")
if 'android' in toolchain.arch:
if toolchain.is_android:
f.write("""
# Keep Meson from executing Android-x86 test binariees
needs_exe_wrapper = true

View File

@ -91,6 +91,8 @@ class AndroidNdkToolchain:
self.is_armv7 = self.is_arm and 'armv7' in self.cflags
self.is_aarch64 = ndk_arch == 'arm64'
self.is_windows = False
self.is_android = True
self.is_darwin = False
libstdcxx_flags = ''
libstdcxx_cxxflags = ''
@ -162,6 +164,8 @@ class MingwToolchain:
self.is_armv7 = self.is_arm and 'armv7' in self.cflags
self.is_aarch64 = arch == 'aarch64'
self.is_windows = 'mingw32' in arch
self.is_android = False
self.is_darwin = False
self.env = dict(os.environ)