commit
7d62d16154
|
@ -19,6 +19,8 @@ env:
|
|||
- PLATFORM="native_static"
|
||||
- PLATFORM="win32_dyn"
|
||||
- PLATFORM="win32_static"
|
||||
- PLATFORM="armhf_dyn"
|
||||
- PLATFORM="armhf_static"
|
||||
- PLATFORM="android_arm"
|
||||
- PLATFORM="android_arm64"
|
||||
- PLATFORM="android_mips"
|
||||
|
|
100
kiwix-build.py
100
kiwix-build.py
|
@ -9,7 +9,7 @@ import platform
|
|||
from collections import OrderedDict
|
||||
|
||||
from dependencies import Dependency
|
||||
from dependency_utils import ReleaseDownload, Builder
|
||||
from dependency_utils import ReleaseDownload, Builder, GitClone
|
||||
from utils import (
|
||||
pj,
|
||||
remove_duplicates,
|
||||
|
@ -60,6 +60,12 @@ PACKAGE_NAME_MAPPERS = {
|
|||
'libmicrohttpd': None, # ['mingw32-libmicrohttpd-static'] packaging dependecy seems buggy, and some static lib are name libfoo.dll.a and
|
||||
# gcc cannot found them.
|
||||
},
|
||||
'fedora_armhf_static': {
|
||||
'COMMON': ['cmake', 'automake', 'ccache']
|
||||
},
|
||||
'fedora_armhf_dyn': {
|
||||
'COMMON': ['cmake', 'automake', 'ccache']
|
||||
},
|
||||
'fedora_android': {
|
||||
'COMMON': ['gcc-c++', 'cmake', 'automake', 'ccache', 'java-1.8.0-openjdk-devel']
|
||||
},
|
||||
|
@ -82,6 +88,12 @@ PACKAGE_NAME_MAPPERS = {
|
|||
'debian_win32_static': {
|
||||
'COMMON': ['g++-mingw-w64-i686', 'gcc-mingw-w64-i686', 'gcc-mingw-w64-base', 'mingw-w64-tools', 'cmake', 'ccache']
|
||||
},
|
||||
'debian_armhf_static': {
|
||||
'COMMON': ['cmake', 'automake', 'ccache']
|
||||
},
|
||||
'debian_armhf_dyn': {
|
||||
'COMMON': ['cmake', 'automake', 'ccache']
|
||||
},
|
||||
'debian_android': {
|
||||
'COMMON': ['automake', 'gcc', 'cmake', 'ccache', 'default-jdk']
|
||||
},
|
||||
|
@ -103,7 +115,7 @@ class TargetInfo:
|
|||
def __str__(self):
|
||||
return "{}_{}".format(self.build, 'static' if self.static else 'dyn')
|
||||
|
||||
def get_cross_env(self, host):
|
||||
def get_cross_config(self, host):
|
||||
if self.build == 'native':
|
||||
return {}
|
||||
elif self.build == 'win32':
|
||||
|
@ -116,13 +128,25 @@ class TargetInfo:
|
|||
'extra_libs': ['-lwinmm', '-lws2_32', '-lshlwapi', '-lrpcrt4', '-lmsvcr90'],
|
||||
'extra_cflags': ['-DWIN32'],
|
||||
'host_machine': {
|
||||
'system': 'windows',
|
||||
'system': 'Windows',
|
||||
'lsystem': 'windows',
|
||||
'cpu_family': 'x86',
|
||||
'cpu': 'i686',
|
||||
'endian': 'little'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
elif self.build == 'armhf':
|
||||
return {
|
||||
'extra_libs': [],
|
||||
'extra_cflags': [],
|
||||
'host_machine': {
|
||||
'system': 'linux',
|
||||
'lsystem': 'linux',
|
||||
'cpu_family': 'arm',
|
||||
'cpu': 'armhf',
|
||||
'endian': 'little'
|
||||
}
|
||||
}
|
||||
|
||||
class AndroidTargetInfo(TargetInfo):
|
||||
__arch_infos = {
|
||||
|
@ -142,12 +166,13 @@ class AndroidTargetInfo(TargetInfo):
|
|||
def __str__(self):
|
||||
return "android"
|
||||
|
||||
def get_cross_env(self, host):
|
||||
def get_cross_config(self, host):
|
||||
return {
|
||||
'extra_libs': [],
|
||||
'extra_cflags': [],
|
||||
'host_machine': {
|
||||
'system': 'Android',
|
||||
'lsystem': 'android',
|
||||
'cpu_family': self.arch,
|
||||
'cpu': self.cpu,
|
||||
'endian': 'little'
|
||||
|
@ -161,6 +186,8 @@ class BuildEnv:
|
|||
'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']),
|
||||
'android_arm': AndroidTargetInfo('arm'),
|
||||
'android_arm64': AndroidTargetInfo('arm64'),
|
||||
'android_mips': AndroidTargetInfo('mips'),
|
||||
|
@ -227,7 +254,7 @@ class BuildEnv:
|
|||
|
||||
def setup_build(self, target_platform):
|
||||
self.platform_info = platform_info = self.target_platforms[target_platform]
|
||||
self.cross_env = self.platform_info.get_cross_env(self.distname)
|
||||
self.cross_config = self.platform_info.get_cross_config(self.distname)
|
||||
|
||||
def setup_toolchains(self):
|
||||
toolchain_names = self.platform_info.toolchains
|
||||
|
@ -248,7 +275,7 @@ class BuildEnv:
|
|||
template = f.read()
|
||||
content = template.format(
|
||||
toolchain=self.toolchains[0],
|
||||
**self.cross_env
|
||||
**self.cross_config
|
||||
)
|
||||
with open(crossfile, 'w') as outfile:
|
||||
outfile.write(content)
|
||||
|
@ -262,6 +289,10 @@ class BuildEnv:
|
|||
self.cmake_crossfile = self._gen_crossfile('cmake_android_cross_file.txt')
|
||||
self.meson_crossfile = self._gen_crossfile('meson_cross_file.txt')
|
||||
|
||||
def setup_armhf(self):
|
||||
self.cmake_crossfile = self._gen_crossfile('cmake_cross_file.txt')
|
||||
self.meson_crossfile = self._gen_crossfile('meson_cross_file.txt')
|
||||
|
||||
def __getattr__(self, name):
|
||||
return getattr(self.options, name)
|
||||
|
||||
|
@ -322,9 +353,9 @@ class BuildEnv:
|
|||
|
||||
bin_dirs = []
|
||||
if cross_compile_env:
|
||||
for k, v in self.cross_env.get('env', {}).items():
|
||||
for k, v in self.cross_config.get('env', {}).items():
|
||||
if k.startswith('_format_'):
|
||||
v = v.format(**self.cross_env)
|
||||
v = v.format(**self.cross_config)
|
||||
k = k[8:]
|
||||
env[k] = v
|
||||
for toolchain in self.toolchains:
|
||||
|
@ -545,7 +576,7 @@ class mingw32_toolchain(Toolchain):
|
|||
|
||||
@property
|
||||
def root_path(self):
|
||||
return self.buildEnv.cross_env['root_path']
|
||||
return self.buildEnv.cross_config['root_path']
|
||||
|
||||
@property
|
||||
def binaries(self):
|
||||
|
@ -572,7 +603,7 @@ class mingw32_toolchain(Toolchain):
|
|||
env['PKG_CONFIG_LIBDIR'] = pj(self.root_path, 'lib', 'pkgconfig')
|
||||
env['CFLAGS'] = " -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 "+env['CFLAGS']
|
||||
env['CXXFLAGS'] = " -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 "+env['CXXFLAGS']
|
||||
env['LIBS'] = " ".join(self.buildEnv.cross_env['extra_libs']) + " " +env['LIBS']
|
||||
env['LIBS'] = " ".join(self.buildEnv.cross_config['extra_libs']) + " " +env['LIBS']
|
||||
|
||||
|
||||
class android_ndk(Toolchain):
|
||||
|
@ -750,6 +781,49 @@ class android_sdk(Toolchain):
|
|||
env['ANDROID_HOME'] = self.builder.install_path
|
||||
|
||||
|
||||
class armhf_toolchain(Toolchain):
|
||||
name = 'armhf'
|
||||
arch_full = 'arm-linux-gnueabihf'
|
||||
|
||||
class Source(GitClone):
|
||||
git_remote = "https://github.com/raspberrypi/tools"
|
||||
git_dir = "raspberrypi-tools"
|
||||
|
||||
@property
|
||||
def root_path(self):
|
||||
return pj(self.source_path, 'arm-bcm2708', 'gcc-linaro-arm-linux-gnueabihf-raspbian-x64')
|
||||
|
||||
@property
|
||||
def binaries(self):
|
||||
binaries = ((k,'{}-{}'.format(self.arch_full, v))
|
||||
for k, v in (('CC', 'gcc'),
|
||||
('CXX', 'g++'),
|
||||
('AR', 'ar'),
|
||||
('STRIP', 'strip'),
|
||||
('WINDRES', 'windres'),
|
||||
('RANLIB', 'ranlib'),
|
||||
('LD', 'ld'))
|
||||
)
|
||||
return {k:pj(self.root_path, 'bin', v)
|
||||
for k,v in binaries}
|
||||
|
||||
@property
|
||||
def configure_option(self):
|
||||
return '--host={}'.format(self.arch_full)
|
||||
|
||||
def get_bin_dir(self):
|
||||
return [pj(self.root_path, 'bin')]
|
||||
|
||||
def set_env(self, env):
|
||||
env['CC'] = self.binaries['CC']
|
||||
env['CXX'] = self.binaries['CXX']
|
||||
|
||||
env['PKG_CONFIG_LIBDIR'] = pj(self.root_path, 'lib', 'pkgconfig')
|
||||
env['CFLAGS'] = " -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 "+env['CFLAGS']
|
||||
env['CXXFLAGS'] = " -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 "+env['CXXFLAGS']
|
||||
env['LIBS'] = " ".join(self.buildEnv.cross_config['extra_libs']) + " " +env['LIBS']
|
||||
|
||||
|
||||
class Builder:
|
||||
def __init__(self, options):
|
||||
self.options = options
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SET(CMAKE_SYSTEM_NAME Windows)
|
||||
SET(CMAKE_SYSTEM_PROCESSOR x86)
|
||||
SET(CMAKE_SYSTEM_NAME {host_machine[system]})
|
||||
SET(CMAKE_SYSTEM_PROCESSOR {host_machine[cpu_family]})
|
||||
|
||||
# specify the cross compiler
|
||||
SET(CMAKE_C_COMPILER "{toolchain.binaries[CC]}")
|
||||
|
|
|
@ -14,5 +14,5 @@ cpp_args = {extra_cflags!r}
|
|||
[host_machine]
|
||||
cpu_family = '{host_machine[cpu_family]}'
|
||||
cpu = '{host_machine[cpu]}'
|
||||
system = '{host_machine[system]}'
|
||||
system = '{host_machine[lsystem]}'
|
||||
endian = '{host_machine[endian]}'
|
||||
|
|
|
@ -71,6 +71,14 @@ EOF
|
|||
tar -czf "${NIGHTLY_ARCHIVES_DIR}/$ARCHIVE_NAME" $FILES_LIST
|
||||
)
|
||||
;;
|
||||
armhf_static)
|
||||
ARCHIVE_NAME="kiwix-tools_armhf_$(date +%Y-%m-%d).tar.gz"
|
||||
FILES_LIST="kiwix-install kiwix-manage kiwix-read kiwix-search kiwix-serve"
|
||||
(
|
||||
cd ${BASE_DIR}/INSTALL/bin
|
||||
tar -czf "${NIGHTLY_ARCHIVES_DIR}/$ARCHIVE_NAME" $FILES_LIST
|
||||
)
|
||||
;;
|
||||
android_*)
|
||||
APK_NAME="kiwix-${PLATFORM}"
|
||||
cp ${BASE_DIR}/kiwix-android/app/build/outputs/apk/app-kiwix-debug.apk ${NIGHTLY_ARCHIVES_DIR}/${APK_NAME}-debug.apk
|
||||
|
|
Loading…
Reference in New Issue