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, 'ARFLAGS=' + toolchain.arflags,
'RANLIB=' + toolchain.ranlib, 'RANLIB=' + toolchain.ranlib,
'STRIP=' + toolchain.strip, 'STRIP=' + toolchain.strip,
'--host=' + toolchain.arch, '--host=' + toolchain.host_triplet,
'--prefix=' + toolchain.install_prefix, '--prefix=' + toolchain.install_prefix,
'--disable-silent-rules', '--disable-silent-rules',
] ]

View File

@ -24,10 +24,10 @@ def __write_cmake_toolchain_file(f: TextIO, toolchain: AnyToolchain) -> None:
f.write(f""" f.write(f"""
set(CMAKE_SYSTEM_NAME {cmake_system_name}) 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_C_COMPILER_TARGET {toolchain.host_triplet})
set(CMAKE_CXX_COMPILER_TARGET {toolchain.actual_arch}) set(CMAKE_CXX_COMPILER_TARGET {toolchain.host_triplet})
set(CMAKE_C_FLAGS_INIT "{toolchain.cflags} {toolchain.cppflags}") set(CMAKE_C_FLAGS_INIT "{toolchain.cflags} {toolchain.cppflags}")
set(CMAKE_CXX_FLAGS_INIT "{toolchain.cxxflags} {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' cpu = 'arm64-v8a'
else: else:
cpu_family = 'x86' cpu_family = 'x86'
if 'x86_64' in toolchain.arch: if 'x86_64' in toolchain.host_triplet:
cpu = 'x86_64' cpu = 'x86_64'
else: else:
cpu = 'i686' cpu = 'i686'

View File

@ -53,7 +53,7 @@ class OpenSSLProject(MakeProject):
'aarch64-apple-darwin': 'darwin64-arm64-cc', 'aarch64-apple-darwin': 'darwin64-arm64-cc',
} }
openssl_arch = openssl_archs[toolchain.arch] openssl_arch = openssl_archs[toolchain.host_triplet]
configure = [ configure = [
'./Configure', './Configure',

View File

@ -38,9 +38,9 @@ class AndroidNdkToolchain:
# select the NDK target # select the NDK target
abi_info = android_abis[android_abi] 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.tarball_path = tarball_path
self.src_path = src_path self.src_path = src_path
@ -51,12 +51,11 @@ class AndroidNdkToolchain:
install_prefix = os.path.join(arch_path, 'root') install_prefix = os.path.join(arch_path, 'root')
self.arch = arch self.host_triplet = host_triplet
self.actual_arch = arch
self.install_prefix = install_prefix self.install_prefix = install_prefix
llvm_path = os.path.join(ndk_path, 'toolchains', 'llvm', 'prebuilt', build_arch) 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 = '-Os -g'
common_flags += ' ' + abi_info['cflags'] common_flags += ' ' + abi_info['cflags']
@ -118,24 +117,23 @@ class AndroidNdkToolchain:
class MingwToolchain: class MingwToolchain:
def __init__(self, top_path: str, 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): tarball_path, src_path, build_path, install_prefix):
self.arch = arch self.host_triplet = host_triplet
self.actual_arch = arch
self.tarball_path = tarball_path self.tarball_path = tarball_path
self.src_path = src_path self.src_path = src_path
self.build_path = build_path self.build_path = build_path
self.install_prefix = install_prefix self.install_prefix = install_prefix
toolchain_bin = os.path.join(toolchain_path, 'bin') toolchain_bin = os.path.join(toolchain_path, 'bin')
self.cc = os.path.join(toolchain_bin, arch + '-gcc') self.cc = os.path.join(toolchain_bin, host_triplet + '-gcc')
self.cxx = os.path.join(toolchain_bin, arch + '-g++') self.cxx = os.path.join(toolchain_bin, host_triplet + '-g++')
self.ar = os.path.join(toolchain_bin, arch + '-ar') self.ar = os.path.join(toolchain_bin, host_triplet + '-ar')
self.arflags = 'rcs' self.arflags = 'rcs'
self.ranlib = os.path.join(toolchain_bin, arch + '-ranlib') self.ranlib = os.path.join(toolchain_bin, host_triplet + '-ranlib')
self.nm = os.path.join(toolchain_bin, arch + '-nm') self.nm = os.path.join(toolchain_bin, host_triplet + '-nm')
self.strip = os.path.join(toolchain_bin, arch + '-strip') self.strip = os.path.join(toolchain_bin, host_triplet + '-strip')
self.windres = os.path.join(toolchain_bin, arch + '-windres') self.windres = os.path.join(toolchain_bin, host_triplet + '-windres')
common_flags = '-O2 -g' common_flags = '-O2 -g'
@ -156,10 +154,10 @@ class MingwToolchain:
# enable it. # enable it.
self.cppflags += ' -D_FORTIFY_SOURCE=0' 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_armv7 = self.is_arm and 'armv7' in self.cflags
self.is_aarch64 = arch == 'aarch64' self.is_aarch64 = host_triplet == 'aarch64'
self.is_windows = 'mingw32' in arch self.is_windows = 'mingw32' in host_triplet
self.is_android = False self.is_android = False
self.is_darwin = False self.is_darwin = False