From 3e835d0c74d5a45c41d2f332729ab98662958b5e Mon Sep 17 00:00:00 2001 From: Chris Li Date: Fri, 3 Mar 2017 16:02:21 -0500 Subject: [PATCH 1/3] Add a patch for macOS native dyn --- kiwix-build.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kiwix-build.py b/kiwix-build.py index a37019e..f56de7c 100755 --- a/kiwix-build.py +++ b/kiwix-build.py @@ -109,6 +109,9 @@ PACKAGE_NAME_MAPPERS = { 'COMMON': _debian_common + ['default-jdk'], 'ctpp2c': ['ctpp2-utils'], }, + 'Darwin_native_dyn': { + 'COMMON': ['autoconf', 'automake', 'libtool', 'cmake', 'pkg-config'], + }, } @@ -455,6 +458,9 @@ class BuildEnv: elif self.distname in ('debian', 'Ubuntu'): package_installer = 'sudo apt-get install {}' package_checker = 'LANG=C dpkg -s {} 2>&1 | grep Status | grep "ok installed" 1>/dev/null 2>&1' + elif self.distname == 'Darwin': + package_installer = 'brew install {}' + package_checker = 'brew list -1 | grep -q {}' mapper_name = "{host}_{target}".format( host=self.distname, target=self.platform_info) From c40cce4f82196b298d025ad271ec315d99b42d47 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Wed, 21 Jun 2017 17:00:58 -0400 Subject: [PATCH 2/3] Add a patch for iOS cross-platform static --- kiwix-build.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kiwix-build.py b/kiwix-build.py index f56de7c..0586ef1 100755 --- a/kiwix-build.py +++ b/kiwix-build.py @@ -112,6 +112,9 @@ PACKAGE_NAME_MAPPERS = { 'Darwin_native_dyn': { 'COMMON': ['autoconf', 'automake', 'libtool', 'cmake', 'pkg-config'], }, + 'Darwin_iOS_static': { + 'COMMON': ['autoconf', 'automake', 'libtool', 'cmake', 'pkg-config'], + }, } @@ -197,6 +200,11 @@ class AndroidTargetInfo(TargetInfo): }, } +class iOSTargetInfo(TargetInfo): + def __init__(self, arch): + super().__init__('iOS', True, ['iOS_sdk']) + self.arch = arch + class BuildEnv: target_platforms = { @@ -212,6 +220,7 @@ class BuildEnv: 'android_mips64': AndroidTargetInfo('mips64'), 'android_x86': AndroidTargetInfo('x86'), 'android_x86_64': AndroidTargetInfo('x86_64'), + 'iOS_arm64': iOSTargetInfo('arm64'), } def __init__(self, options, targetsDict): @@ -311,6 +320,9 @@ class BuildEnv: self.cmake_crossfile = self._gen_crossfile('cmake_cross_file.txt') self.meson_crossfile = self._gen_crossfile('meson_cross_file.txt') + def setup_iOS(self): + pass + def __getattr__(self, name): return getattr(self.options, name) @@ -828,6 +840,10 @@ class armhf_toolchain(Toolchain): env['CXX'] = self.binaries['CXX'] +class iOS_sdk(Toolchain): + pass + + class Builder: def __init__(self, options): self.options = options From a9eaa7135728aa15cfe503ba4aebd986dce745fe Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 11 Jul 2017 17:21:55 +0200 Subject: [PATCH 3/3] Check that target platform is compatible with current host. Not all target platform can be compiled on all platform. For instance, all `static` target or `win32`, `armhf` and `android` targets cannot be compiled on macOS. Simply check that the current host is supported by TargetInfo and exit nicely if needed. --- kiwix-build.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/kiwix-build.py b/kiwix-build.py index 0586ef1..a2b8428 100755 --- a/kiwix-build.py +++ b/kiwix-build.py @@ -125,10 +125,11 @@ def which(name): class TargetInfo: - def __init__(self, build, static, toolchains): + def __init__(self, build, static, toolchains, hosts=None): self.build = build self.static = static self.toolchains = toolchains + self.compatible_hosts = hosts def __str__(self): return "{}_{}".format(self.build, 'static' if self.static else 'dyn') @@ -179,7 +180,8 @@ class AndroidTargetInfo(TargetInfo): } def __init__(self, arch): - super().__init__('android', True, ['android_ndk', 'android_sdk']) + super().__init__('android', True, ['android_ndk', 'android_sdk'], + hosts=['fedora', 'debian']) self.arch = arch self.arch_full, self.cpu, self.abi = self.__arch_infos[arch] @@ -202,18 +204,25 @@ class AndroidTargetInfo(TargetInfo): class iOSTargetInfo(TargetInfo): def __init__(self, arch): - super().__init__('iOS', True, ['iOS_sdk']) + super().__init__('iOS', True, ['iOS_sdk'], + hosts=['Darwin']) self.arch = arch class BuildEnv: target_platforms = { - 'native_dyn': TargetInfo('native', False, []), - 'native_static': TargetInfo('native', True, []), - 'win32_dyn': TargetInfo('win32', False, ['mingw32_toolchain']), - 'win32_static': TargetInfo('win32', True, ['mingw32_toolchain']), - 'armhf_dyn': TargetInfo('armhf', False, ['armhf_toolchain']), - 'armhf_static': TargetInfo('armhf', True, ['armhf_toolchain']), + 'native_dyn': TargetInfo('native', False, [], + hosts=['fedora', 'debian', 'Darwin']), + 'native_static': TargetInfo('native', True, [], + hosts=['fedora', 'debian']), + 'win32_dyn': TargetInfo('win32', False, ['mingw32_toolchain'], + hosts=['fedora', 'debian']), + 'win32_static': TargetInfo('win32', True, ['mingw32_toolchain'], + hosts=['fedora', 'debian']), + 'armhf_dyn': TargetInfo('armhf', False, ['armhf_toolchain'], + hosts=['fedora', 'debian']), + 'armhf_static': TargetInfo('armhf', True, ['armhf_toolchain'], + hosts=['fedora', 'debian']), 'android_arm': AndroidTargetInfo('arm'), 'android_arm64': AndroidTargetInfo('arm64'), 'android_mips': AndroidTargetInfo('mips'), @@ -281,6 +290,11 @@ class BuildEnv: def setup_build(self, target_platform): self.platform_info = self.target_platforms[target_platform] + if self.distname not in self.platform_info.compatible_hosts: + print(('ERROR: The target {} cannot be build on host {}.\n' + 'Select another target platform, or change your host system.' + ).format(target_platform, self.distname)) + sys.exit(-1) self.cross_config = self.platform_info.get_cross_config(self.distname) def setup_toolchains(self):