Files
kiwix-build/kiwixbuild/dependencies/kiwix_lib.py
Matthieu Gautier fb07b58812 Fix recompilation of the CI of meson project.
We were assuming that meson project correspond to our projects and so we
were always building them, even if they were already compiled.
(This way, a simple `kiwix-build` is enough to recompile the WIP code of
our project).

However, on the CI, we do not archive the source code/build directory in
the base deps archive. So when we try to compile, the compile step of
meson projects fails because the source are not here.
We have a small workaround for pugixml but as zstd is also meson, it is
time to do something correct.

By default, all projects now try to skip if a build is already present.
Our projects are marked as `force_build` and so, they do not try to skip.
2020-04-06 19:15:40 +02:00

94 lines
3.4 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import shutil, os
from .base import (
Dependency,
GitClone,
MesonBuilder,
GradleBuilder)
from kiwixbuild.utils import pj, copy_tree
from kiwixbuild._global import option, get_target_step, neutralEnv
class Kiwixlib(Dependency):
name = "kiwix-lib"
force_build = True
class Source(GitClone):
git_remote = "https://github.com/kiwix/kiwix-lib.git"
git_dir = "kiwix-lib"
class Builder(MesonBuilder):
dependencies = ["pugixml", "libzim", "zlib", "lzma", "libcurl", "libmicrohttpd", "icu4c", "mustache"]
strip_option = ''
@property
def configure_option(self):
platformInfo = self.buildEnv.platformInfo
if platformInfo.build == 'android':
return '-Dwrapper=android'
if platformInfo.build == 'iOS':
return '-Db_bitcode=true'
if platformInfo.name == 'flatpak':
return '--wrap-mode=nodownload'
return ''
@property
def library_type(self):
if self.buildEnv.platformInfo.build == 'android':
return 'shared'
return super().library_type
class KiwixlibApp(Dependency):
name = "kiwix-lib-app"
force_build = True
class Source(Kiwixlib.Source):
name = "kiwix-lib"
class Builder(GradleBuilder):
dependencies = ["kiwix-lib"]
gradle_target = "assembleRelease writePom"
@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