From c9210bb0e08de3677c5cc58714f05c17d8ddfabd Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Mon, 4 Feb 2019 11:04:19 +0100 Subject: [PATCH] Allow kiwix-build to build shared libs linked statically with deps. We need to be able to build libzim as shared lib while using all other dependencies statically (to not have libxapian.so, ... to distribute) This add a new platform (static=False) that make all dependencies being build in a static platform. --- kiwixbuild/platforms/native.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/kiwixbuild/platforms/native.py b/kiwixbuild/platforms/native.py index 069d9f2..3ceb53f 100644 --- a/kiwixbuild/platforms/native.py +++ b/kiwixbuild/platforms/native.py @@ -1,5 +1,8 @@ from .base import PlatformInfo +from kiwixbuild.utils import pj +from kiwixbuild._global import option + class NativePlatformInfo(PlatformInfo): build = 'native' @@ -14,3 +17,33 @@ class NativeStatic(NativePlatformInfo): name = 'native_static' static = True compatible_hosts = ['fedora', 'debian'] + +class NativeMixed(NativePlatformInfo): + name = 'native_mixed' + static = False + compatible_hosts = ['fedora', 'debian'] + + def add_targets(self, targetName, targets): + print(targetName) + if option('target') == targetName: + return super().add_targets(targetName, targets) + else: + static_platform = self.get_platform('native_static', targets) + return static_platform.add_targets(targetName, targets) + + def get_fully_qualified_dep(self, dep): + if isinstance(dep, tuple): + return dep + if option('target') == dep: + return 'native_mixed', dep + return 'native_static', dep + + def set_env(self, env): + super().set_env(env) + static_platform = self.get_platform('native_static') + static_buildEnv = static_platform.buildEnv + static_install_dir = static_buildEnv.install_dir + env['CPPFLAGS'] = " ".join(['-I'+pj(static_install_dir, 'include'), env['CPPFLAGS']]) + env['PATH'] = ':'.join([pj(static_install_dir, 'bin')] + [env['PATH']]) + pkgconfig_path = pj(static_install_dir, static_buildEnv.libprefix, 'pkgconfig') + env['PKG_CONFIG_PATH'] = ':'.join([env['PKG_CONFIG_PATH'], pkgconfig_path])