From da7f32bddb20e44291f5bea3fad31113e4be03cb Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 26 Sep 2023 15:19:39 +0200 Subject: [PATCH] python/build/toolchain: rename `arch` to `host_triplet` --- python/build/autotools.py | 2 +- python/build/cmake.py | 6 +++--- python/build/meson.py | 2 +- python/build/openssl.py | 2 +- python/build/toolchain.py | 34 ++++++++++++++++------------------ 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/python/build/autotools.py b/python/build/autotools.py index a99aa5d4f..bf5d94a58 100644 --- a/python/build/autotools.py +++ b/python/build/autotools.py @@ -58,7 +58,7 @@ class AutotoolsProject(MakeProject): 'ARFLAGS=' + toolchain.arflags, 'RANLIB=' + toolchain.ranlib, 'STRIP=' + toolchain.strip, - '--host=' + toolchain.arch, + '--host=' + toolchain.host_triplet, '--prefix=' + toolchain.install_prefix, '--disable-silent-rules', ] diff --git a/python/build/cmake.py b/python/build/cmake.py index 53db47ddf..e48f4771e 100644 --- a/python/build/cmake.py +++ b/python/build/cmake.py @@ -24,10 +24,10 @@ def __write_cmake_toolchain_file(f: TextIO, toolchain: AnyToolchain) -> None: f.write(f""" set(CMAKE_SYSTEM_NAME {cmake_system_name}) -set(CMAKE_SYSTEM_PROCESSOR {toolchain.actual_arch.split('-', 1)[0]}) +set(CMAKE_SYSTEM_PROCESSOR {toolchain.host_triplet.split('-', 1)[0]}) -set(CMAKE_C_COMPILER_TARGET {toolchain.actual_arch}) -set(CMAKE_CXX_COMPILER_TARGET {toolchain.actual_arch}) +set(CMAKE_C_COMPILER_TARGET {toolchain.host_triplet}) +set(CMAKE_CXX_COMPILER_TARGET {toolchain.host_triplet}) set(CMAKE_C_FLAGS_INIT "{toolchain.cflags} {toolchain.cppflags}") set(CMAKE_CXX_FLAGS_INIT "{toolchain.cxxflags} {toolchain.cppflags}") diff --git a/python/build/meson.py b/python/build/meson.py index b6517d33b..43a52188e 100644 --- a/python/build/meson.py +++ b/python/build/meson.py @@ -30,7 +30,7 @@ def make_cross_file(toolchain: AnyToolchain) -> str: cpu = 'arm64-v8a' else: cpu_family = 'x86' - if 'x86_64' in toolchain.arch: + if 'x86_64' in toolchain.host_triplet: cpu = 'x86_64' else: cpu = 'i686' diff --git a/python/build/openssl.py b/python/build/openssl.py index 953220ec9..245a0d983 100644 --- a/python/build/openssl.py +++ b/python/build/openssl.py @@ -53,7 +53,7 @@ class OpenSSLProject(MakeProject): 'aarch64-apple-darwin': 'darwin64-arm64-cc', } - openssl_arch = openssl_archs[toolchain.arch] + openssl_arch = openssl_archs[toolchain.host_triplet] configure = [ './Configure', diff --git a/python/build/toolchain.py b/python/build/toolchain.py index bfde287f5..70ea5289b 100644 --- a/python/build/toolchain.py +++ b/python/build/toolchain.py @@ -38,9 +38,9 @@ class AndroidNdkToolchain: # select the NDK target abi_info = android_abis[android_abi] - arch = abi_info['arch'] + host_triplet = abi_info['arch'] - arch_path = os.path.join(lib_path, arch) + arch_path = os.path.join(lib_path, host_triplet) self.tarball_path = tarball_path self.src_path = src_path @@ -51,12 +51,11 @@ class AndroidNdkToolchain: install_prefix = os.path.join(arch_path, 'root') - self.arch = arch - self.actual_arch = arch + self.host_triplet = host_triplet self.install_prefix = install_prefix llvm_path = os.path.join(ndk_path, 'toolchains', 'llvm', 'prebuilt', build_arch) - llvm_triple = arch + android_api_level + llvm_triple = host_triplet + android_api_level common_flags = '-Os -g' common_flags += ' ' + abi_info['cflags'] @@ -118,24 +117,23 @@ class AndroidNdkToolchain: class MingwToolchain: def __init__(self, top_path: str, - toolchain_path, arch, x64: bool, + toolchain_path, host_triplet, x64: bool, tarball_path, src_path, build_path, install_prefix): - self.arch = arch - self.actual_arch = arch + self.host_triplet = host_triplet self.tarball_path = tarball_path self.src_path = src_path self.build_path = build_path self.install_prefix = install_prefix toolchain_bin = os.path.join(toolchain_path, 'bin') - self.cc = os.path.join(toolchain_bin, arch + '-gcc') - self.cxx = os.path.join(toolchain_bin, arch + '-g++') - self.ar = os.path.join(toolchain_bin, arch + '-ar') + self.cc = os.path.join(toolchain_bin, host_triplet + '-gcc') + self.cxx = os.path.join(toolchain_bin, host_triplet + '-g++') + self.ar = os.path.join(toolchain_bin, host_triplet + '-ar') self.arflags = 'rcs' - self.ranlib = os.path.join(toolchain_bin, arch + '-ranlib') - self.nm = os.path.join(toolchain_bin, arch + '-nm') - self.strip = os.path.join(toolchain_bin, arch + '-strip') - self.windres = os.path.join(toolchain_bin, arch + '-windres') + self.ranlib = os.path.join(toolchain_bin, host_triplet + '-ranlib') + self.nm = os.path.join(toolchain_bin, host_triplet + '-nm') + self.strip = os.path.join(toolchain_bin, host_triplet + '-strip') + self.windres = os.path.join(toolchain_bin, host_triplet + '-windres') common_flags = '-O2 -g' @@ -156,10 +154,10 @@ class MingwToolchain: # enable it. self.cppflags += ' -D_FORTIFY_SOURCE=0' - self.is_arm = arch.startswith('arm') + self.is_arm = host_triplet.startswith('arm') self.is_armv7 = self.is_arm and 'armv7' in self.cflags - self.is_aarch64 = arch == 'aarch64' - self.is_windows = 'mingw32' in arch + self.is_aarch64 = host_triplet == 'aarch64' + self.is_windows = 'mingw32' in host_triplet self.is_android = False self.is_darwin = False