Merge pull request #337 from kiwix/new_arch

New arch armv7a
This commit is contained in:
Matthieu Gautier 2019-06-14 16:13:15 +02:00 committed by GitHub
commit af21b91fbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 53 deletions

View File

@ -87,8 +87,6 @@ platforms :
- android - android
- android_arm - android_arm
- android_arm64 - android_arm64
- android_mips
- android_mips64
- android_x86 - android_x86
- android_x86_64 - android_x86_64

View File

@ -64,12 +64,6 @@ $cmd = "./kiwix-build.py --target-platform android_x86 --android-custom-app $cus
$ENV{VERSION_CODE} = "3" . $version_code_base; $ENV{VERSION_CODE} = "3" . $version_code_base;
$cmd = "./kiwix-build.py --target-platform android_x86_64 --android-custom-app $custom_app --zim-file-size $zim_size kiwix-android-custom"; system $cmd; $cmd = "./kiwix-build.py --target-platform android_x86_64 --android-custom-app $custom_app --zim-file-size $zim_size kiwix-android-custom"; system $cmd;
$ENV{VERSION_CODE} = "4" . $version_code_base;
$cmd = "./kiwix-build.py --target-platform android_mips --android-custom-app $custom_app --zim-file-size $zim_size kiwix-android-custom"; system $cmd;
$ENV{VERSION_CODE} = "5" . $version_code_base;
$cmd = "./kiwix-build.py --target-platform android_mips64 --android-custom-app $custom_app --zim-file-size $zim_size kiwix-android-custom"; system $cmd;
# Sign apps # Sign apps
$cmd = "./TOOLCHAINS/android-sdk-r25.2.3/build-tools/25.0.2/apksigner sign -ks \"${keystore}\" --out signed_apks/app-${version_code_base}-release-signed.apk BUILD_android_arm/kiwix-android-custom_${custom_app}/app/build/outputs/apk/${custom_app}/release/app-${custom_app}-release-unsigned.apk"; $cmd = "./TOOLCHAINS/android-sdk-r25.2.3/build-tools/25.0.2/apksigner sign -ks \"${keystore}\" --out signed_apks/app-${version_code_base}-release-signed.apk BUILD_android_arm/kiwix-android-custom_${custom_app}/app/build/outputs/apk/${custom_app}/release/app-${custom_app}-release-unsigned.apk";
system $cmd; system $cmd;
@ -83,12 +77,6 @@ system $cmd;
$cmd = "./TOOLCHAINS/android-sdk-r25.2.3/build-tools/25.0.2/apksigner sign -ks \"${keystore}\" --out signed_apks/app-3${version_code_base}-release-signed.apk BUILD_android_x86_64/kiwix-android-custom_${custom_app}/app/build/outputs/apk/${custom_app}/release/app-${custom_app}-release-unsigned.apk"; $cmd = "./TOOLCHAINS/android-sdk-r25.2.3/build-tools/25.0.2/apksigner sign -ks \"${keystore}\" --out signed_apks/app-3${version_code_base}-release-signed.apk BUILD_android_x86_64/kiwix-android-custom_${custom_app}/app/build/outputs/apk/${custom_app}/release/app-${custom_app}-release-unsigned.apk";
system $cmd; system $cmd;
$cmd = "./TOOLCHAINS/android-sdk-r25.2.3/build-tools/25.0.2/apksigner sign -ks \"${keystore}\" --out signed_apks/app-4${version_code_base}-release-signed.apk BUILD_android_mips/kiwix-android-custom_${custom_app}/app/build/outputs/apk/${custom_app}/release/app-${custom_app}-release-unsigned.apk";
system $cmd;
$cmd = "./TOOLCHAINS/android-sdk-r25.2.3/build-tools/25.0.2/apksigner sign -ks \"${keystore}\" --out signed_apks/app-5${version_code_base}-release-signed.apk BUILD_android_mips64/kiwix-android-custom_${custom_app}/app/build/outputs/apk/${custom_app}/release/app-${custom_app}-release-unsigned.apk";
system $cmd;
# Upload # Upload
$cmd = "./build_custom_app.py --step publish --custom-app ${custom_app} --google-api-key ${api_key} --zim-path content.zim --apks-dir signed_apks --content-version-code ${content_version_code}"; $cmd = "./build_custom_app.py --step publish --custom-app ${custom_app} --google-api-key ${api_key} --zim-path content.zim --apks-dir signed_apks --content-version-code ${content_version_code}";

View File

@ -27,7 +27,7 @@ class android_ndk(Dependency):
@property @property
def api(self): def api(self):
return '21' if self.arch in ('arm64', 'mips64', 'x86_64') else '14' return '21' if self.arch in ('arm64', 'x86_64') else '14'
@property @property
def platform(self): def platform(self):

View File

@ -12,32 +12,44 @@ class AndroidPlatformInfo(PlatformInfo):
def __str__(self): def __str__(self):
return "android" return "android"
def binaries(self, install_path): @property
binaries = ((k,'{}-{}'.format(self.arch_full, v)) def binaries_name(self):
for k, v in (('CC', 'gcc'), arch_full = self.arch_full
('CXX', 'g++'), return {
('AR', 'ar'), 'CC': '{}-{}'.format(arch_full, 'gcc'),
('STRIP', 'strip'), 'CXX': '{}-{}'.format(arch_full, 'g++'),
('WINDRES', 'windres'), 'AR': '{}-{}'.format(arch_full, 'ar'),
('RANLIB', 'ranlib'), 'STRIP': '{}-{}'.format(arch_full, 'strip'),
('LD', 'ld')) 'RANLIB': '{}-{}'.format(arch_full, 'ranlib'),
) 'LD': '{}-{}'.format(arch_full, 'ld')
}
def binaries(self):
install_path = self.install_path
return {k:pj(install_path, 'bin', v) return {k:pj(install_path, 'bin', v)
for k,v in binaries} for k,v in self.binaries_name.items()}
@property @property
def ndk_builder(self): def ndk_builder(self):
return get_target_step('android-ndk', self.name) return get_target_step('android-ndk', self.name)
@property
def install_path(self):
return self.ndk_builder.install_path
def get_cross_config(self): def get_cross_config(self):
install_path = self.ndk_builder.install_path extra_libs = ['-llog']
extra_cflags = ['-I{}'.format(pj(self.buildEnv.install_dir, 'include'))]
if hasattr(self, 'march'):
extra_libs.append('-march={}'.format(self.march))
extra_cflags.append('-march={}'.format(self.march))
return { return {
'exec_wrapper_def': '', 'exec_wrapper_def': '',
'install_path': install_path, 'install_path': self.install_path,
'binaries': self.binaries(install_path), 'binaries': self.binaries(),
'root_path': pj(install_path, 'sysroot'), 'root_path': pj(self.install_path, 'sysroot'),
'extra_libs': ['-llog'], 'extra_libs': extra_libs,
'extra_cflags': ['-I{}'.format(pj(self.buildEnv.install_dir, 'include'))], 'extra_cflags': extra_cflags,
'host_machine': { 'host_machine': {
'system': 'Android', 'system': 'Android',
'lsystem': 'android', 'lsystem': 'android',
@ -49,14 +61,15 @@ class AndroidPlatformInfo(PlatformInfo):
} }
def get_bin_dir(self): def get_bin_dir(self):
return [pj(self.ndk_builder.install_path, 'bin')] return [pj(self.install_path, 'bin')]
def set_env(self, env): def set_env(self, env):
root_path = pj(self.ndk_builder.install_path, 'sysroot') root_path = pj(self.install_path, 'sysroot')
march = '-march={}'.format(self.march) if hasattr(self,'march') else ''
env['PKG_CONFIG_LIBDIR'] = pj(root_path, 'lib', 'pkgconfig') env['PKG_CONFIG_LIBDIR'] = pj(root_path, 'lib', 'pkgconfig')
env['CFLAGS'] = '-fPIC -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 --sysroot={} '.format(root_path) + env['CFLAGS'] env['CFLAGS'] = '-fPIC -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 --sysroot={} {} '.format(root_path, march) + env['CFLAGS']
env['CXXFLAGS'] = '-fPIC -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 --sysroot={} '.format(root_path) + env['CXXFLAGS'] env['CXXFLAGS'] = '-fPIC -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 --sysroot={} {} '.format(root_path, march) + env['CXXFLAGS']
env['LDFLAGS'] = '--sysroot={} '.format(root_path) + env['LDFLAGS'] env['LDFLAGS'] = '--sysroot={} {} '.format(root_path, march) + env['LDFLAGS']
#env['CFLAGS'] = ' -fPIC -D_FILE_OFFSET_BITS=64 -O3 '+env['CFLAGS'] #env['CFLAGS'] = ' -fPIC -D_FILE_OFFSET_BITS=64 -O3 '+env['CFLAGS']
#env['CXXFLAGS'] = (' -D__OPTIMIZE__ -fno-strict-aliasing ' #env['CXXFLAGS'] = (' -D__OPTIMIZE__ -fno-strict-aliasing '
# ' -DU_HAVE_NL_LANGINFO_CODESET=0 ' # ' -DU_HAVE_NL_LANGINFO_CODESET=0 '
@ -65,7 +78,7 @@ class AndroidPlatformInfo(PlatformInfo):
env['NDK_DEBUG'] = '0' env['NDK_DEBUG'] = '0'
def set_compiler(self, env): def set_compiler(self, env):
binaries = self.binaries(self.ndk_builder.install_path) binaries = self.binaries()
for k,v in binaries.items(): for k,v in binaries.items():
env[k] = v env[k] = v
@ -83,38 +96,31 @@ class AndroidArm(AndroidPlatformInfo):
name = 'android_arm' name = 'android_arm'
arch = cpu = 'arm' arch = cpu = 'arm'
arch_full = 'arm-linux-androideabi' arch_full = 'arm-linux-androideabi'
abi = 'armeabi' abi = 'armeabi-v7a'
march = 'armv7-a'
class AndroidArm(AndroidPlatformInfo):
class AndroidArm64(AndroidPlatformInfo):
name = 'android_arm64' name = 'android_arm64'
arch = 'arm64' arch = 'arm64'
arch_full = 'aarch64-linux-android' arch_full = 'aarch64-linux-android'
cpu = 'aarch64' cpu = 'aarch64'
abi = 'arm64-v8a' abi = 'arm64-v8a'
class AndroidArm(AndroidPlatformInfo):
name = 'android_mips'
arch = abi = 'mips'
arch_full = 'mipsel-linux-android'
cpu = 'mipsel'
class AndroidArm(AndroidPlatformInfo): class AndroidX86(AndroidPlatformInfo):
name = 'android_mips64'
arch = abi = 'mips64'
arch_full = 'mips64el-linux-android'
cpu = 'mips64el'
class AndroidArm(AndroidPlatformInfo):
name = 'android_x86' name = 'android_x86'
arch = abi = 'x86' arch = abi = 'x86'
arch_full = 'i686-linux-android' arch_full = 'i686-linux-android'
cpu = 'i686' cpu = 'i686'
class AndroidArm(AndroidPlatformInfo):
class AndroidX8664(AndroidPlatformInfo):
name = 'android_x86_64' name = 'android_x86_64'
arch = cpu = abi = 'x86_64' arch = cpu = abi = 'x86_64'
arch_full = 'x86_64-linux-android' arch_full = 'x86_64-linux-android'
class Android(MetaPlatformInfo): class Android(MetaPlatformInfo):
name = "android" name = "android"
toolchain_names = ['android-sdk', 'gradle'] toolchain_names = ['android-sdk', 'gradle']

View File

@ -245,6 +245,8 @@ def run_command(command, cwd, context, buildEnv=None, env=None, input=None, cros
for k, v in env.items(): for k, v in env.items():
print(" {} : {!r}".format(k, v), file=log) print(" {} : {!r}".format(k, v), file=log)
if log:
log.flush()
kwargs = dict() kwargs = dict()
if input: if input:
kwargs['stdin'] = subprocess.PIPE kwargs['stdin'] = subprocess.PIPE