python/build/toolchain: rename `arch` to `host_triplet`

This commit is contained in:
Max Kellermann 2023-09-26 15:19:39 +02:00
parent 9a5eac4ea9
commit da7f32bddb
5 changed files with 22 additions and 24 deletions

View File

@ -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',
]

View File

@ -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}")

View File

@ -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'

View File

@ -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',

View File

@ -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