diff --git a/kiwixbuild/__init__.py b/kiwixbuild/__init__.py index bb7d6c0..144fdff 100644 --- a/kiwixbuild/__init__.py +++ b/kiwixbuild/__init__.py @@ -48,35 +48,15 @@ def parse_args(): help=("Specify the architecture to build for ios application/libraries.\n" "Can be specified several times to build for several architectures.\n" "If not specified, all architectures will be build.")) - subgroup = parser.add_argument_group('custom app', - description="Android custom app specific options") - subgroup.add_argument('--android-custom-app', - help="The custom android app to build") - subgroup.add_argument('--zim-file-url', - help="The url of the zim file to download") - subgroup.add_argument('--zim-file-size', - help="The size of the zim file.") options = parser.parse_args() - if options.target == 'kiwix-android-custom': - err = False - if not options.android_custom_app: - print("You need to specify ANDROID_CUSTOM_APP if you " - "want to build a kiwix-android-custom target") - err = True - if not options.zim_file_url and not options.zim_file_size: - print("You need to specify ZIM_FILE_SIZEĀ or ZIM_FILE_URL if you " - "want to build a kiwix-android-custom target") - err = True - if err: - sys.exit(1) if not options.android_arch: options.android_arch = ['arm', 'arm64', 'x86', 'x86_64'] if not options.ios_arch: options.ios_arch = ['armv7', 'arm64', 'i386', 'x86_64'] if not options.target_platform: - if options.target in ('kiwix-android', 'kiwix-android-custom'): + if options.target in ('kiwix-lib-app',): options.target_platform = 'android' else: options.target_platform = 'native_dyn' diff --git a/kiwixbuild/dependencies/__init__.py b/kiwixbuild/dependencies/__init__.py index 240100d..7464bd9 100644 --- a/kiwixbuild/dependencies/__init__.py +++ b/kiwixbuild/dependencies/__init__.py @@ -11,8 +11,6 @@ from . import ( icu4c, ios_fat_lib, mustache, - kiwix_android, - kiwix_custom_app, kiwix_desktop, kiwix_lib, kiwix_tools, diff --git a/kiwixbuild/dependencies/kiwix_android.py b/kiwixbuild/dependencies/kiwix_android.py deleted file mode 100644 index 4a2de5b..0000000 --- a/kiwixbuild/dependencies/kiwix_android.py +++ /dev/null @@ -1,64 +0,0 @@ -import shutil, os - -from .base import ( - Dependency, - GitClone, - GradleBuilder) - -from kiwixbuild.utils import pj, copy_tree -from kiwixbuild._global import option, get_target_step - -class KiwixAndroid(Dependency): - name = "kiwix-android" - - class Source(GitClone): - git_remote = "https://github.com/kiwix/kiwix-android" - git_dir = "kiwix-android" - - class Builder(GradleBuilder): - dependencies = ["kiwix-lib"] - - @classmethod - def get_dependencies(cls, platformInfo, allDeps): - if not allDeps: - return super().get_dependencies(platformInfo, allDeps) - else: - deps = [('android_{}'.format(arch), 'kiwix-lib') - for arch in option('android_arch')] - return deps - - def build(self): - if option('target') == 'kiwix-android-custom': - print("SKIP") - else: - super().build() - - def _configure(self, context): - if not os.path.exists(self.build_path): - shutil.copytree(self.source_path, self.build_path, symlinks=True) - try: - shutil.rmtree(pj(self.build_path, 'kiwixlib', 'src', 'main')) - except FileNotFoundError: - pass - for arch in option('android_arch'): - try: - kiwix_builder = get_target_step('kiwix-lib', 'android_{}'.format(arch)) - except KeyError: - pass - else: - copy_tree(pj(kiwix_builder.buildEnv.install_dir, 'kiwix-lib'), - pj(self.build_path, 'kiwixlib', 'src', 'main')) - os.makedirs( - pj(self.build_path, 'app', 'src', 'main', 'assets', 'icu'), - exist_ok=True) - for arch in option('android_arch'): - try: - kiwix_builder = get_target_step('kiwix-lib', 'android_{}'.format(arch)) - except KeyError: - pass - else: - shutil.copy2(pj(kiwix_builder.buildEnv.install_dir, 'share', 'icu', '58.2', - 'icudt58l.dat'), - pj(self.build_path, 'app', 'src', 'main', 'assets', - 'icu', 'icudt58l.dat')) - break diff --git a/kiwixbuild/dependencies/kiwix_custom_app.py b/kiwixbuild/dependencies/kiwix_custom_app.py deleted file mode 100644 index 75883cf..0000000 --- a/kiwixbuild/dependencies/kiwix_custom_app.py +++ /dev/null @@ -1,120 +0,0 @@ -import shutil, os, json -from urllib.parse import urlparse - -from .base import ( - Dependency, - GitClone, - GradleBuilder) - -from kiwixbuild.utils import Remotefile, pj, copy_tree, SkipCommand, run_command -from kiwixbuild._global import option, get_target_step - -class KiwixCustomApp(Dependency): - name = "kiwix-android-custom" - - class Source(GitClone): - git_remote = "https://github.com/kiwix/kiwix-android-custom" - git_dir = "kiwix-android-custom" - - class Builder(GradleBuilder): - dependencies = ["kiwix-android", "kiwix-lib"] - - @property - def gradle_target(self): - return "assemble{}".format(option('android_custom_app')) - - @property - def gradle_option(self): - template = ("-i -P customDir={customDir}" - " -P zim_file_size={zim_size}" - " -P version_code={version_code}" - " -P version_name={version_name}" - " -P content_version_code={content_version_code}") - return template.format( - customDir=pj(self.build_path, 'custom'), - zim_size=self._get_zim_size(), - version_code=os.environ['VERSION_CODE'], - version_name=os.environ['VERSION_NAME'], - content_version_code=os.environ['CONTENT_VERSION_CODE']) - - @property - def build_path(self): - return pj(self.buildEnv.build_dir, "{}_{}".format(self.target.full_name(), option('android_custom_app'))) - - @property - def custom_build_path(self): - return pj(self.build_path, 'custom', option('android_custom_app')) - - def _get_zim_size(self): - try: - zim_size = option('zim_file_size') - except AttributeError: - with open(pj(self.source_path, option('android_custom_app'), 'info.json')) as f: - app_info = json.load(f) - zim_size = os.path.getsize(pj(self.custom_build_path, app_info['zim_file'])) - return zim_size - - def build(self): - self.command('configure', self._configure) - self.command('download_zim', self._download_zim) - self.command('compile', self._compile) - - def _download_zim(self, context): - zim_url = option('zim_file_url') - if zim_url is None: - raise SkipCommand() - with open(pj(self.source_path, option('android_custom_app'), 'info.json')) as f: - app_info = json.load(f) - zim_url = app_info.get('zim_url', zim_url) - out_filename = urlparse(zim_url).path - out_filename = os.path.basename(out_filename) - zim_file = Remotefile(out_filename, '', zim_url) - self.buildEnv.download(zim_file) - shutil.copy(pj(self.buildEnv.archive_dir, out_filename), - pj(self.custom_build_path, app_info['zim_file'])) - - def _configure(self, context): - # Copy kiwix-android in build dir. - kiwix_android_source = get_target_step('kiwix-android', 'source') - if not os.path.exists(self.build_path): - shutil.copytree(kiwix_android_source.source_path, self.build_path) - - # Copy kiwix-lib application in build dir - try: - shutil.rmtree(pj(self.build_path, 'kiwixlib', 'src', 'main')) - except FileNotFoundError: - pass - for arch in option('android_arch'): - try: - kiwix_builder = get_target_step('kiwix-lib', 'android_{}'.format(arch)) - except KeyError: - pass - else: - copy_tree(pj(kiwix_builder.buildEnv.install_dir, 'kiwix-lib'), - pj(self.build_path, 'kiwixlib', 'src', 'main')) - os.makedirs( - pj(self.build_path, 'app', 'src', 'main', 'assets', 'icu'), - exist_ok=True) - for arch in option('android_arch'): - try: - kiwix_builder = get_target_step('kiwix-lib', 'android_{}'.format(arch)) - except KeyError: - pass - else: - shutil.copy2(pj(kiwix_builder.buildEnv.install_dir, 'share', 'icu', '58.2', - 'icudt58l.dat'), - pj(self.build_path, 'app', 'src', 'main', 'assets', - 'icu', 'icudt58l.dat')) - break - # Generate custom directory - try: - shutil.rmtree(pj(self.build_path, 'custom')) - except FileNotFoundError: - pass - os.makedirs(pj(self.build_path, 'custom')) - command = "./gen-custom-android-directory.py {custom_name} --output-dir {custom_dir}" - command = command.format( - custom_name=option('android_custom_app'), - custom_dir=pj(self.build_path, 'custom', option('android_custom_app')) - ) - run_command(command, self.source_path, context, buildEnv=self.buildEnv) diff --git a/kiwixbuild/platforms/android.py b/kiwixbuild/platforms/android.py index 0de2066..c7e0b0e 100644 --- a/kiwixbuild/platforms/android.py +++ b/kiwixbuild/platforms/android.py @@ -131,7 +131,7 @@ class Android(MetaPlatformInfo): return ['android_{}'.format(arch) for arch in option('android_arch')] def add_targets(self, targetName, targets): - if targetName not in ('kiwix-android', 'kiwix-android-custom', 'kiwix-lib-app'): + if targetName not in ('kiwix-lib-app',): return super().add_targets(targetName, targets) else: return AndroidPlatformInfo.add_targets(self, targetName, targets) diff --git a/travis/compile_all.py b/travis/compile_all.py index 025ded7..f28e9e8 100755 --- a/travis/compile_all.py +++ b/travis/compile_all.py @@ -91,7 +91,7 @@ def run_kiwix_build(target, platform, command.append('--hide-progress') if platform == 'flatpak' or platform.startswith('win32_'): command.append('--assume-packages-installed') - if target == 'kiwix-android' and platform.startswith('android_'): + if target == 'kiwix-lib-app' and platform.startswith('android_'): command.extend(['--target-platform', 'android', '--android-arch', platform[8:]]) elif platform == 'android': command.extend(['--target-platform', 'android'])