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.
This commit is contained in:
Matthieu Gautier 2019-02-04 11:04:19 +01:00
parent 1b2b3efb54
commit c9210bb0e0
1 changed files with 33 additions and 0 deletions

View File

@ -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])