Add MacOs arch

On top of the native platform (which may still use to compile for macos on macos)
we add a specific MacOs arch.
This commit is contained in:
ChrisLi 2021-10-11 15:12:09 -04:00 committed by Matthieu Gautier
parent c36fe74c81
commit 82569620f2
1 changed files with 41 additions and 17 deletions

View File

@ -5,15 +5,15 @@ from kiwixbuild.utils import pj, xrun_find
from .base import PlatformInfo, MetaPlatformInfo from .base import PlatformInfo, MetaPlatformInfo
class iOSPlatformInfo(PlatformInfo): class ApplePlatformInfo(PlatformInfo):
build = 'iOS' build = 'iOS'
static = True static = True
compatible_hosts = ['Darwin'] compatible_hosts = ['Darwin']
min_iphoneos_version = '11.0'
arch = None arch = None
arch_full = None host = None
target = None target = None
sdk_name = None sdk_name = None
min_iphoneos_version = None
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
@ -35,7 +35,7 @@ class iOSPlatformInfo(PlatformInfo):
self.buildEnv.meson_crossfile = self._gen_crossfile('meson_ios_cross_file.txt', 'meson_cross_file.txt') self.buildEnv.meson_crossfile = self._gen_crossfile('meson_ios_cross_file.txt', 'meson_cross_file.txt')
def get_cross_config(self): def get_cross_config(self):
return { config = {
'root_path': self.root_path, 'root_path': self.root_path,
'binaries': self.binaries, 'binaries': self.binaries,
'exe_wrapper_def': '', 'exe_wrapper_def': '',
@ -44,7 +44,6 @@ class iOSPlatformInfo(PlatformInfo):
'-isysroot', self.root_path, '-isysroot', self.root_path,
'-arch', self.arch, '-arch', self.arch,
'-target', self.target, '-target', self.target,
'-miphoneos-version-min={}'.format(self.min_iphoneos_version),
'-stdlib=libc++' '-stdlib=libc++'
], ],
'extra_cflags': [ 'extra_cflags': [
@ -52,7 +51,6 @@ class iOSPlatformInfo(PlatformInfo):
'-isysroot', self.root_path, '-isysroot', self.root_path,
'-arch', self.arch, '-arch', self.arch,
'-target', self.target, '-target', self.target,
'-miphoneos-version-min={}'.format(self.min_iphoneos_version),
'-stdlib=libc++', '-stdlib=libc++',
'-I{}'.format(pj(self.buildEnv.install_dir, 'include')) '-I{}'.format(pj(self.buildEnv.install_dir, 'include'))
], ],
@ -65,22 +63,28 @@ class iOSPlatformInfo(PlatformInfo):
'abi': '' 'abi': ''
} }
} }
if self.min_iphoneos_version:
config['extra_libs'].append('-miphoneos-version-min={}'.format(self.min_iphoneos_version))
config['extra_cflags'].append('-miphoneos-version-min={}'.format(self.min_iphoneos_version))
return config
def get_env(self): def get_env(self):
env = super().get_env() env = super().get_env()
env['MACOSX_DEPLOYMENT_TARGET'] = '10.13' env['MACOSX_DEPLOYMENT_TARGET'] = '10.15'
return env return env
def set_comp_flags(self, env): def set_comp_flags(self, env):
super().set_comp_flags(env) super().set_comp_flags(env)
env['CFLAGS'] = ' '.join([ cflags = [
'-fembed-bitcode', '-fembed-bitcode',
'-isysroot {}'.format(self.root_path), '-isysroot {}'.format(self.root_path),
'-arch {}'.format(self.arch), '-arch {}'.format(self.arch),
'-miphoneos-version-min={}'.format(self.min_iphoneos_version),
'-target {}'.format(self.target), '-target {}'.format(self.target),
env['CFLAGS'], env['CFLAGS'],
]) ]
if self.min_iphoneos_version:
cflags.append('-miphoneos-version-min={}'.format(self.min_iphoneos_version))
env['CFLAGS'] = ' '.join(cflags)
env['CXXFLAGS'] = ' '.join([ env['CXXFLAGS'] = ' '.join([
env['CFLAGS'], env['CFLAGS'],
'-stdlib=libc++', '-stdlib=libc++',
@ -109,34 +113,54 @@ class iOSPlatformInfo(PlatformInfo):
@property @property
def configure_option(self): def configure_option(self):
return '--host={}'.format(self.arch_full) return '--host={}'.format(self.host)
class iOSArm64(iOSPlatformInfo): class iOSArm64(ApplePlatformInfo):
name = 'iOS_arm64' name = 'iOS_arm64'
arch = cpu = 'arm64' arch = cpu = 'arm64'
arch_full = 'arm-apple-darwin' host = 'arm-apple-darwin'
target = 'aarch64-apple-ios' target = 'aarch64-apple-ios'
sdk_name = 'iphoneos' sdk_name = 'iphoneos'
min_iphoneos_version = '13.0'
class iOSx64(iOSPlatformInfo): class iOSx64(ApplePlatformInfo):
name = 'iOS_x86_64' name = 'iOS_x86_64'
arch = cpu = 'x86_64' arch = cpu = 'x86_64'
arch_full = 'x86_64-apple-darwin' host = 'x86_64-apple-darwin'
target = 'x86_64-apple-ios' target = 'x86_64-apple-ios'
sdk_name = 'iphonesimulator' sdk_name = 'iphonesimulator'
min_iphoneos_version = '13.0'
class iOSMacABI(iOSPlatformInfo): class iOSMacABI(ApplePlatformInfo):
name = 'iOS_Mac_ABI' name = 'iOS_Mac_ABI'
arch = cpu = 'x86_64' arch = cpu = 'x86_64'
arch_full = 'x86_64-apple-darwin' host = 'x86_64-apple-darwin'
target = 'x86_64-apple-ios13.0-macabi' target = 'x86_64-apple-ios13.0-macabi'
sdk_name = 'macosx' sdk_name = 'macosx'
min_iphoneos_version = '13.0' min_iphoneos_version = '13.0'
class macOSArm64(ApplePlatformInfo):
name = 'macOS_arm64'
arch = cpu = 'arm64'
host = 'aarch64-apple-darwin'
target = 'arm64-apple-macos11'
sdk_name = 'macosx'
min_iphoneos_version = None
class macOSx64(ApplePlatformInfo):
name = 'macOS_x86_64'
arch = cpu = 'x86_64'
host = 'x86_64-apple-darwin'
target = 'x86_64-apple-macos10.12'
sdk_name = 'macosx'
min_iphoneos_version = None
class IOS(MetaPlatformInfo): class IOS(MetaPlatformInfo):
name = "iOS_multi" name = "iOS_multi"
compatible_hosts = ['Darwin'] compatible_hosts = ['Darwin']