From ef9755eff52bbe081e24c38791b97b5d7b3847d1 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 12 Jun 2019 16:57:02 +0200 Subject: [PATCH 1/3] Remove android mips platforms Also correctly rename Android classes. --- README.md | 2 -- build_custom_app.pl | 12 ------------ kiwixbuild/dependencies/android_ndk.py | 2 +- kiwixbuild/platforms/android.py | 18 +++--------------- 4 files changed, 4 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index b1f8a6c..2bc99cd 100644 --- a/README.md +++ b/README.md @@ -87,8 +87,6 @@ platforms : - android - android_arm - android_arm64 -- android_mips -- android_mips64 - android_x86 - android_x86_64 diff --git a/build_custom_app.pl b/build_custom_app.pl index 83d244f..18acdec 100755 --- a/build_custom_app.pl +++ b/build_custom_app.pl @@ -64,12 +64,6 @@ $cmd = "./kiwix-build.py --target-platform android_x86 --android-custom-app $cus $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; -$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 $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; @@ -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"; 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 $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}"; diff --git a/kiwixbuild/dependencies/android_ndk.py b/kiwixbuild/dependencies/android_ndk.py index fa2b00e..4fbd239 100644 --- a/kiwixbuild/dependencies/android_ndk.py +++ b/kiwixbuild/dependencies/android_ndk.py @@ -27,7 +27,7 @@ class android_ndk(Dependency): @property 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 def platform(self): diff --git a/kiwixbuild/platforms/android.py b/kiwixbuild/platforms/android.py index 5777b29..7e8245a 100644 --- a/kiwixbuild/platforms/android.py +++ b/kiwixbuild/platforms/android.py @@ -85,32 +85,20 @@ class AndroidArm(AndroidPlatformInfo): arch_full = 'arm-linux-androideabi' abi = 'armeabi' -class AndroidArm(AndroidPlatformInfo): +class AndroidArm64(AndroidPlatformInfo): name = 'android_arm64' arch = 'arm64' arch_full = 'aarch64-linux-android' cpu = 'aarch64' abi = 'arm64-v8a' -class AndroidArm(AndroidPlatformInfo): - name = 'android_mips' - arch = abi = 'mips' - arch_full = 'mipsel-linux-android' - cpu = 'mipsel' - -class AndroidArm(AndroidPlatformInfo): - name = 'android_mips64' - arch = abi = 'mips64' - arch_full = 'mips64el-linux-android' - cpu = 'mips64el' - -class AndroidArm(AndroidPlatformInfo): +class AndroidX86(AndroidPlatformInfo): name = 'android_x86' arch = abi = 'x86' arch_full = 'i686-linux-android' cpu = 'i686' -class AndroidArm(AndroidPlatformInfo): +class AndroidX8664(AndroidPlatformInfo): name = 'android_x86_64' arch = cpu = abi = 'x86_64' arch_full = 'x86_64-linux-android' From 4868128551f43e0b3cd1c38585e7968f1d902749 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 12 Jun 2019 17:34:32 +0200 Subject: [PATCH 2/3] Build for armeabi-v7a. The main thing is to add the `-march` option when needed. Ie, '-march=armv7-a` for arm. Other compiler (arm64, x86, ...) don't support the march option so we must not provide it. --- kiwixbuild/platforms/android.py | 66 +++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/kiwixbuild/platforms/android.py b/kiwixbuild/platforms/android.py index 7e8245a..0441a1a 100644 --- a/kiwixbuild/platforms/android.py +++ b/kiwixbuild/platforms/android.py @@ -12,32 +12,44 @@ class AndroidPlatformInfo(PlatformInfo): def __str__(self): return "android" - def binaries(self, install_path): - 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')) - ) + @property + def binaries_name(self): + arch_full = self.arch_full + return { + 'CC': '{}-{}'.format(arch_full, 'gcc'), + 'CXX': '{}-{}'.format(arch_full, 'g++'), + 'AR': '{}-{}'.format(arch_full, 'ar'), + 'STRIP': '{}-{}'.format(arch_full, 'strip'), + '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) - for k,v in binaries} + for k,v in self.binaries_name.items()} @property def ndk_builder(self): return get_target_step('android-ndk', self.name) + @property + def install_path(self): + return self.ndk_builder.install_path + 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 { 'exec_wrapper_def': '', - 'install_path': install_path, - 'binaries': self.binaries(install_path), - 'root_path': pj(install_path, 'sysroot'), - 'extra_libs': ['-llog'], - 'extra_cflags': ['-I{}'.format(pj(self.buildEnv.install_dir, 'include'))], + 'install_path': self.install_path, + 'binaries': self.binaries(), + 'root_path': pj(self.install_path, 'sysroot'), + 'extra_libs': extra_libs, + 'extra_cflags': extra_cflags, 'host_machine': { 'system': 'Android', 'lsystem': 'android', @@ -49,14 +61,15 @@ class AndroidPlatformInfo(PlatformInfo): } def get_bin_dir(self): - return [pj(self.ndk_builder.install_path, 'bin')] + return [pj(self.install_path, 'bin')] 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['CFLAGS'] = '-fPIC -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 --sysroot={} '.format(root_path) + env['CFLAGS'] - env['CXXFLAGS'] = '-fPIC -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 --sysroot={} '.format(root_path) + env['CXXFLAGS'] - env['LDFLAGS'] = '--sysroot={} '.format(root_path) + env['LDFLAGS'] + 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, march) + env['CXXFLAGS'] + env['LDFLAGS'] = '--sysroot={} {} '.format(root_path, march) + env['LDFLAGS'] #env['CFLAGS'] = ' -fPIC -D_FILE_OFFSET_BITS=64 -O3 '+env['CFLAGS'] #env['CXXFLAGS'] = (' -D__OPTIMIZE__ -fno-strict-aliasing ' # ' -DU_HAVE_NL_LANGINFO_CODESET=0 ' @@ -65,7 +78,7 @@ class AndroidPlatformInfo(PlatformInfo): env['NDK_DEBUG'] = '0' def set_compiler(self, env): - binaries = self.binaries(self.ndk_builder.install_path) + binaries = self.binaries() for k,v in binaries.items(): env[k] = v @@ -83,7 +96,9 @@ class AndroidArm(AndroidPlatformInfo): name = 'android_arm' arch = cpu = 'arm' arch_full = 'arm-linux-androideabi' - abi = 'armeabi' + abi = 'armeabi-v7a' + march = 'armv7-a' + class AndroidArm64(AndroidPlatformInfo): name = 'android_arm64' @@ -92,17 +107,20 @@ class AndroidArm64(AndroidPlatformInfo): cpu = 'aarch64' abi = 'arm64-v8a' + class AndroidX86(AndroidPlatformInfo): name = 'android_x86' arch = abi = 'x86' arch_full = 'i686-linux-android' cpu = 'i686' + class AndroidX8664(AndroidPlatformInfo): name = 'android_x86_64' arch = cpu = abi = 'x86_64' arch_full = 'x86_64-linux-android' + class Android(MetaPlatformInfo): name = "android" toolchain_names = ['android-sdk', 'gradle'] From 4810b0240c86893f76d6a4f163476fc3ee34ad1c Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Fri, 14 Jun 2019 11:39:19 +0200 Subject: [PATCH 3/3] Flush the log file. This is to avoid mangling between the kiwix-build log (env variables, ...) and the command log. --- kiwixbuild/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kiwixbuild/utils.py b/kiwixbuild/utils.py index 8109863..0f2844a 100644 --- a/kiwixbuild/utils.py +++ b/kiwixbuild/utils.py @@ -245,6 +245,8 @@ def run_command(command, cwd, context, buildEnv=None, env=None, input=None, cros for k, v in env.items(): print(" {} : {!r}".format(k, v), file=log) + if log: + log.flush() kwargs = dict() if input: kwargs['stdin'] = subprocess.PIPE