From a9ce8ee8c1be1d6c90a78cfee536acd43fac234e Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 5 Dec 2017 09:22:25 +0000 Subject: [PATCH] Add a `--make-dist` command to kiwix-build. If specified, kiwix-build will not "make/install" the target but make the dist archive (source). It will build dependencies, as the make dist will try to compile and test the target. --- dependency_utils.py | 15 +++++++++++++++ kiwix-build.py | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/dependency_utils.py b/dependency_utils.py index be00774..5326bd4 100644 --- a/dependency_utils.py +++ b/dependency_utils.py @@ -229,6 +229,12 @@ class Builder: if hasattr(self, '_post_build_script'): self.command('post_build_script', self._post_build_script) + def make_dist(self): + if hasattr(self, '_pre_build_script'): + self.command('pre_build_script', self._pre_build_script) + self.command('configure', self._configure) + self.command('make_dist', self._make_dist) + class MakeBuilder(Builder): configure_option = "" @@ -285,6 +291,11 @@ class MakeBuilder(Builder): ) self.buildEnv.run_command(command, self.build_path, context) + def _make_dist(self, context): + context.try_skip(self.build_path) + command = "make dist" + self.buildEnv.run_command(command, self.build_path, context) + class CMakeBuilder(MakeBuilder): def _configure(self, context): @@ -368,6 +379,10 @@ class MesonBuilder(Builder): command = "{} -v install".format(self.buildEnv.ninja_command) self.buildEnv.run_command(command, self.build_path, context) + def _make_dist(self, context): + command = "{} -v dist".format(self.buildEnv.ninja_command) + self.buildEnv.run_command(command, self.build_path, context) + class GradleBuilder(Builder): gradle_target = "build" diff --git a/kiwix-build.py b/kiwix-build.py index 8b28a88..eee3e19 100755 --- a/kiwix-build.py +++ b/kiwix-build.py @@ -942,9 +942,17 @@ class Builder: builders = (dep.builder for dep in self.targets.values() if (dep.builder and not dep.skip)) for builder in builders: + if self.options.make_dist and builder.name == self.options.targets: + continue print("build {} :".format(builder.name)) builder.build() + if self.options.make_dist: + dep = self.targets[self.options.targets] + builder = dep.builder + print("make dist {}:".format(builder.name)) + builder.make_dist() + def run(self): try: print("[INSTALL PACKAGES]") @@ -980,6 +988,8 @@ def parse_args(): help="Skip the source download part") parser.add_argument('--build-deps-only', action='store_true', help="Build only the dependencies of the specified targets.") + parser.add_argument('--make-dist', action='store_true', + help="Build distrubution (dist) source archive") parser.add_argument('--make-release', action='store_true', help="Build a release version") subgroup = parser.add_argument_group('advanced')