Build the kiwix-lib android "application" in kiwix-build.
This is not a real application as it is dependency for kiwix-android. But it a app in the sens that it is packaged for android build system.
This commit is contained in:
parent
4c342c5b9d
commit
3a1cd6ddb2
|
@ -1,8 +1,12 @@
|
||||||
|
import shutil, os
|
||||||
|
|
||||||
from .base import (
|
from .base import (
|
||||||
Dependency,
|
Dependency,
|
||||||
GitClone,
|
GitClone,
|
||||||
MesonBuilder)
|
MesonBuilder,
|
||||||
from kiwixbuild._global import neutralEnv
|
GradleBuilder)
|
||||||
|
from kiwixbuild.utils import pj, copy_tree
|
||||||
|
from kiwixbuild._global import option, get_target_step, neutralEnv
|
||||||
|
|
||||||
class Kiwixlib(Dependency):
|
class Kiwixlib(Dependency):
|
||||||
name = "kiwix-lib"
|
name = "kiwix-lib"
|
||||||
|
@ -28,3 +32,56 @@ class Kiwixlib(Dependency):
|
||||||
if self.buildEnv.platformInfo.build == 'android':
|
if self.buildEnv.platformInfo.build == 'android':
|
||||||
return 'shared'
|
return 'shared'
|
||||||
return super().library_type
|
return super().library_type
|
||||||
|
|
||||||
|
|
||||||
|
class KiwixlibApp(Dependency):
|
||||||
|
name = "kiwix-lib-app"
|
||||||
|
|
||||||
|
Source = Kiwixlib.Source
|
||||||
|
|
||||||
|
class Builder(GradleBuilder):
|
||||||
|
dependencies = ["kiwix-lib"]
|
||||||
|
gradle_target = "assembleRelease"
|
||||||
|
|
||||||
|
@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 _configure(self, context):
|
||||||
|
try:
|
||||||
|
shutil.rmtree(self.build_path)
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
if not os.path.exists(self.build_path):
|
||||||
|
shutil.copytree(pj(self.source_path, 'android-kiwix-lib-publisher'), self.build_path, symlinks=True)
|
||||||
|
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, 'kiwixLibAndroid', 'src', 'main'))
|
||||||
|
|
||||||
|
# The ICU dat file should be embedded with the kiwix-lib application
|
||||||
|
# but for now it is package with kiwix-android app and use there.
|
||||||
|
# We must fix this at a time (before we update the icu version).
|
||||||
|
# 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
|
||||||
|
|
|
@ -131,7 +131,7 @@ class Android(MetaPlatformInfo):
|
||||||
return ['android_{}'.format(arch) for arch in option('android_arch')]
|
return ['android_{}'.format(arch) for arch in option('android_arch')]
|
||||||
|
|
||||||
def add_targets(self, targetName, targets):
|
def add_targets(self, targetName, targets):
|
||||||
if targetName not in ('kiwix-android', 'kiwix-android-custom'):
|
if targetName not in ('kiwix-android', 'kiwix-android-custom', 'kiwix-lib-app'):
|
||||||
return super().add_targets(targetName, targets)
|
return super().add_targets(targetName, targets)
|
||||||
else:
|
else:
|
||||||
return AndroidPlatformInfo.add_targets(self, targetName, targets)
|
return AndroidPlatformInfo.add_targets(self, targetName, targets)
|
||||||
|
|
Loading…
Reference in New Issue