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.
This commit is contained in:
Matthieu Gautier 2020-04-06 17:49:35 +02:00
parent 3ea1bfd38e
commit fb07b58812
10 changed files with 17 additions and 10 deletions

View file

@ -148,12 +148,6 @@ def make_deps_archive(target=None, name=None, full=False):
files_to_archive += (HOME / "BUILD_native_static").glob("*/.*_ok")
files_to_archive += HOME.glob("BUILD_android*/**/.*_ok")
files_to_archive += SOURCE_DIR.glob("*/.*_ok")
files_to_archive += [
SOURCE_DIR / "pugixml-{}".format(base_deps_versions["pugixml"])
]
files_to_archive += HOME.glob(
"BUILD_*/pugixml-{}".format(base_deps_versions["pugixml"])
)
if PLATFORM_TARGET.startswith("armhf"):
files_to_archive += (SOURCE_DIR / "armhf").glob("*")
toolchains_subdirs = HOME.glob("BUILD_*/TOOLCHAINS/*/*")

View file

@ -21,6 +21,7 @@ class _MetaDependency(type):
class Dependency(metaclass=_MetaDependency):
all_deps = {}
force_build = False
force_native_build = False
@classmethod
@ -240,6 +241,8 @@ class Builder:
print(" {} {} : ".format(name, self.name), end="", flush=True)
log = pj(self._log_dir, 'cmd_{}_{}.log'.format(name, self.name))
context = Context(name, log, self.target.force_native_build)
if self.target.force_build:
context.no_skip = True
try:
start_time = time.time()
ret = function(*args, context=context)
@ -493,11 +496,13 @@ class MesonBuilder(Builder):
run_command(command, self.source_path, context, env=env)
def _compile(self, context):
context.try_skip(self.build_path)
command = "{} -v".format(neutralEnv('ninja_command'))
env = self.buildEnv.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=True)
run_command(command, self.build_path, context, env=env)
def _test(self, context):
context.try_skip(self.build_path)
if ( self.buildEnv.platformInfo.build == 'android'
or (self.buildEnv.platformInfo.build != 'native'
and not self.buildEnv.platformInfo.static)
@ -508,6 +513,7 @@ class MesonBuilder(Builder):
run_command(command, self.build_path, context, env=env)
def _install(self, context):
context.try_skip(self.build_path)
command = "{} -v install".format(neutralEnv('ninja_command'))
env = self.buildEnv.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=True)
run_command(command, self.build_path, context, env=env)
@ -536,6 +542,7 @@ class GradleBuilder(Builder):
shutil.copytree(self.source_path, self.build_path)
def _compile(self, context):
context.try_skip(self.build_path)
command = "./gradlew {gradle_target} {gradle_option}"
command = command.format(
gradle_target=self.gradle_target,

View file

@ -5,6 +5,7 @@ from .base import (
class KiwixDesktop(Dependency):
name = "kiwix-desktop"
force_build = True
class Source(GitClone):
git_remote = "https://github.com/kiwix/kiwix-desktop.git"

View file

@ -10,6 +10,7 @@ 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"
@ -39,6 +40,7 @@ class Kiwixlib(Dependency):
class KiwixlibApp(Dependency):
name = "kiwix-lib-app"
force_build = True
class Source(Kiwixlib.Source):
name = "kiwix-lib"

View file

@ -5,6 +5,7 @@ from .base import (
class KiwixTools(Dependency):
name = "kiwix-tools"
force_build = True
class Source(GitClone):
git_remote = "https://github.com/kiwix/kiwix-tools.git"

View file

@ -6,6 +6,7 @@ from kiwixbuild._global import option
class Libzim(Dependency):
name = "libzim"
force_build = True
class Source(GitClone):
git_remote = "https://github.com/openzim/libzim.git"

View file

@ -5,6 +5,7 @@ from .base import (
class ZimTools(Dependency):
name = "zim-tools"
force_build = True
class Source(GitClone):
git_remote = "https://github.com/openzim/zim-tools.git"

View file

@ -5,6 +5,7 @@ from .base import (
class Zimwriterfs(Dependency):
name = "zimwriterfs"
force_build = True
class Source(GitClone):
git_remote = "https://github.com/openzim/zimwriterfs.git"

View file

@ -187,8 +187,11 @@ class Context:
self.log_file = log_file
self.force_native_build = force_native_build
self.autoskip_file = None
self.no_skip = False
def try_skip(self, path, extra_name=""):
if self.no_skip:
return
if extra_name:
extra_name = "_{}".format(extra_name)
self.autoskip_file = pj(path, ".{}{}_ok".format(self.command_name, extra_name))

View file

@ -236,10 +236,6 @@ def make_deps_archive(target=None, name=None, full=False):
files_to_archive += (HOME/"BUILD_native_static").glob('*/.*_ok')
files_to_archive += HOME.glob('BUILD_android*/**/.*_ok')
files_to_archive += SOURCE_DIR.glob('*/.*_ok')
files_to_archive += [SOURCE_DIR/'pugixml-{}'.format(
base_deps_versions['pugixml'])]
files_to_archive += HOME.glob('BUILD_*/pugixml-{}'.format(
base_deps_versions['pugixml']))
if PLATFORM.startswith('armhf'):
files_to_archive += (SOURCE_DIR/'armhf').glob('*')
toolchains_subdirs = HOME.glob('**/TOOLCHAINS/*/*')