From c8c0192675b4adc285199db647988ec8ab0d3b28 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 29 May 2018 17:42:42 +0200 Subject: [PATCH] Simplify cross-compilation Now we can make reference to build step in another target platform, we can simplify cross-compilation fo libmagic and icu4c. --- kiwixbuild/dependencies/all_dependencies.py | 10 ++--- kiwixbuild/dependencies/icu4c.py | 41 +++++++-------------- kiwixbuild/dependencies/kiwix_lib.py | 7 +--- kiwixbuild/dependencies/libmagic.py | 39 +++++++------------- kiwixbuild/dependencies/libzim.py | 9 +---- kiwixbuild/dependencies/zimwriterfs.py | 8 +--- 6 files changed, 33 insertions(+), 81 deletions(-) diff --git a/kiwixbuild/dependencies/all_dependencies.py b/kiwixbuild/dependencies/all_dependencies.py index c55d727..3d55d29 100644 --- a/kiwixbuild/dependencies/all_dependencies.py +++ b/kiwixbuild/dependencies/all_dependencies.py @@ -12,13 +12,9 @@ class AllBaseDependencies(Dependency): class Builder(NoopBuilder): @classmethod def get_dependencies(cls, platformInfo): - base_deps = ['zlib', 'lzma', 'xapian-core', 'gumbo', 'pugixml', 'libmicrohttpd', 'libaria2'] - if platformInfo.build != 'native': - base_deps += ["icu4c_cross-compile"] - if platformInfo.build != 'win32': - base_deps += ["libmagic_cross-compile"] - else: - base_deps += ["icu4c", "libmagic"] + base_deps = ['zlib', 'lzma', 'xapian-core', 'gumbo', 'pugixml', 'libmicrohttpd', 'libaria2', 'icu4c'] + if platformInfo.build != 'win32': + base_deps += ["libmagic"] if (platformInfo.build != 'android' and neutralEnv('distname') != 'Darwin'): base_deps += ['ctpp2c', 'ctpp2'] diff --git a/kiwixbuild/dependencies/icu4c.py b/kiwixbuild/dependencies/icu4c.py index d9c8a0b..1ac58e1 100644 --- a/kiwixbuild/dependencies/icu4c.py +++ b/kiwixbuild/dependencies/icu4c.py @@ -25,36 +25,21 @@ class Icu(Dependency): class Builder(MakeBuilder): subsource_dir = "source" + @classmethod + def get_dependencies(cls, platformInfo): + plt = 'native_static' if platformInfo.static else 'native_dyn' + return [(plt, 'icu4c')] + @property def configure_option(self): options = "--disable-samples --disable-tests --disable-extras --disable-dyload --enable-rpath" - if self.buildEnv.platformInfo.build == 'android': + platformInfo = self.buildEnv.platformInfo + if platformInfo.build != 'native': + icu_native_builder = get_target_step( + 'icu4c', + 'native_static' if platformInfo.static else 'native_dyn') + options += " --with-cross-build={} --disable-tools".format( + icu_native_builder.build_path) + if platformInfo.build == 'android': options += " --with-data-packaging=archive" return options - - -class Icu_native(Icu): - name = "icu4c_native" - force_native_build = True - - class Builder(Icu.Builder): - @property - def build_path(self): - return super().build_path+"_native" - - def _install(self, context): - raise SkipCommand() - - -class Icu_cross_compile(Icu): - name = "icu4c_cross-compile" - - class Builder(Icu.Builder): - dependencies = ['icu4c_native'] - - @property - def configure_option(self): - icu_native_builder = get_target_step('icu4c_native', self.buildEnv.platformInfo.name) - return (super().configure_option - + " --with-cross-build={} --disable-tools" - ).format(icu_native_builder.build_path) diff --git a/kiwixbuild/dependencies/kiwix_lib.py b/kiwixbuild/dependencies/kiwix_lib.py index 120230d..8647264 100644 --- a/kiwixbuild/dependencies/kiwix_lib.py +++ b/kiwixbuild/dependencies/kiwix_lib.py @@ -14,14 +14,11 @@ class Kiwixlib(Dependency): class Builder(MesonBuilder): @classmethod def get_dependencies(cls, platformInfo): - base_dependencies = ["pugixml", "libzim", "zlib", "lzma", "libaria2"] + base_dependencies = ["pugixml", "libzim", "zlib", "lzma", "libaria2", "icu4c"] if (platformInfo.build != 'android' and neutralEnv('distname') != 'Darwin'): base_dependencies += ['ctpp2c', 'ctpp2'] - if platformInfo.build != 'native': - return base_dependencies + ["icu4c_cross-compile"] - else: - return base_dependencies + ["icu4c"] + return base_dependencies @property diff --git a/kiwixbuild/dependencies/libmagic.py b/kiwixbuild/dependencies/libmagic.py index ab0f88e..8c4d53a 100644 --- a/kiwixbuild/dependencies/libmagic.py +++ b/kiwixbuild/dependencies/libmagic.py @@ -6,10 +6,10 @@ from .base import ( MakeBuilder, ) -from kiwixbuild.utils import Remotefile, pj, Defaultdict, SkipCommand +from kiwixbuild.utils import Remotefile, pj, Defaultdict, SkipCommand, run_command from kiwixbuild._global import get_target_step -class LibMagicBase(Dependency): +class LibMagic(Dependency): name = "libmagic" class Source(ReleaseDownload): @@ -19,37 +19,24 @@ class LibMagicBase(Dependency): '1c52c8c3d271cd898d5511c36a68059cda94036111ab293f01f83c3525b737c6', 'https://fossies.org/linux/misc/file-5.33.tar.gz') - Builder = MakeBuilder + class Builder(MakeBuilder): - -class LibMagic_native(LibMagicBase): - name = "libmagic_native" - force_native_build = True - - class Builder(LibMagicBase.Builder): - static_configure_option = dynamic_configure_option = "--disable-shared --enable-static" - - @property - def build_path(self): - return super().build_path+"_native" - - def _install(self, context): - raise SkipCommand() - - -class LibMagic_cross_compile(LibMagicBase): - name = "libmagic_cross-compile" - - class Builder(LibMagicBase.Builder): - dependencies = ['libmagic_native'] + @classmethod + def get_dependencies(cls, platformInfo): + if platformInfo.build != 'native': + return [('native_static', 'libmagic')] + return [] def _compile(self, context): + platformInfo = self.buildEnv.platformInfo + if platformInfo.build == 'native': + return super()._compile(context) context.try_skip(self.build_path) command = "make -j4 {make_target} {make_option}".format( make_target=self.make_target, make_option=self.make_option ) - libmagic_native_builder = get_target_step('libmagic_native', self.buildEnv.platformInfo.name) + libmagic_native_builder = get_target_step('libmagic', 'native_static') env = Defaultdict(str, os.environ) env['PATH'] = ':'.join([pj(libmagic_native_builder.build_path, 'src'), env['PATH']]) - self.buildEnv.run_command(command, self.build_path, context, env=env) + run_command(command, self.build_path, context, buildEnv=self.buildEnv, env=env) diff --git a/kiwixbuild/dependencies/libzim.py b/kiwixbuild/dependencies/libzim.py index 3b0c19a..aa01108 100644 --- a/kiwixbuild/dependencies/libzim.py +++ b/kiwixbuild/dependencies/libzim.py @@ -12,11 +12,4 @@ class Libzim(Dependency): class Builder(MesonBuilder): test_option = "-t 8" - - @classmethod - def get_dependencies(cls, platformInfo): - base_dependencies = ['zlib', 'lzma', 'xapian-core'] - if platformInfo.build != 'native': - return base_dependencies + ["icu4c_cross-compile"] - else: - return base_dependencies + ["icu4c"] + dependencies = ['zlib', 'lzma', 'xapian-core', 'icu4c'] diff --git a/kiwixbuild/dependencies/zimwriterfs.py b/kiwixbuild/dependencies/zimwriterfs.py index 72cc92f..3ac977c 100644 --- a/kiwixbuild/dependencies/zimwriterfs.py +++ b/kiwixbuild/dependencies/zimwriterfs.py @@ -12,13 +12,7 @@ class Zimwriterfs(Dependency): release_git_ref = "1.1" class Builder(MesonBuilder): - @classmethod - def get_dependencies(cls, platformInfo): - base_dependencies = ['libzim', 'zlib', 'xapian-core', 'gumbo'] - if platformInfo.build != 'native': - return base_dependencies + ["icu4c_cross-compile", "libmagic_cross-compile"] - else: - return base_dependencies + ["icu4c", "libmagic"] + dependencies = ['libzim', 'zlib', 'xapian-core', 'gumbo', 'icu4c', 'libmagic'] @property def configure_option(self):