Introduce MixedMixin
We will need to create "mixed linkage" library for other arch than native. It is better to move associated code in a separate part.
This commit is contained in:
parent
b6f49efcda
commit
31771fa35c
|
@ -28,7 +28,7 @@ class Libkiwix(Dependency):
|
|||
return '-Db_bitcode=true'
|
||||
if platformInfo.name == 'flatpak':
|
||||
return '--wrap-mode=nodownload'
|
||||
if platformInfo.name == 'native_mixed' and option('target') == 'libkiwix':
|
||||
if platformInfo.mixed and option('target') == 'libkiwix':
|
||||
return "-Dstatic-linkage=true"
|
||||
return ''
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class Libzim(Dependency):
|
|||
config_options.append("-Dstatic-linkage=true")
|
||||
if platformInfo.build == 'iOS':
|
||||
config_options.append("-Db_bitcode=true")
|
||||
if platformInfo.name == 'native_mixed' and option('target') == 'libzim':
|
||||
if platformInfo.mixed and option('target') == 'libzim':
|
||||
config_options.append("-Dstatic-linkage=true")
|
||||
if platformInfo.name == "flatpak":
|
||||
config_options.append("--wrap-mode=nodownload")
|
||||
|
|
|
@ -24,6 +24,7 @@ class PlatformInfo(metaclass=_MetaPlatform):
|
|||
all_running_platforms = {}
|
||||
toolchain_names = []
|
||||
configure_option = ""
|
||||
mixed = False
|
||||
libdir = None
|
||||
|
||||
@classmethod
|
||||
|
@ -128,3 +129,38 @@ class MetaPlatformInfo(PlatformInfo):
|
|||
platform = self.get_platform(platformName, targets)
|
||||
targetDefs += platform.add_targets(targetName, targets)
|
||||
return targetDefs
|
||||
|
||||
|
||||
|
||||
def MixedMixin(static_name):
|
||||
class MixedMixinClass:
|
||||
mixed = True
|
||||
|
||||
def add_targets(self, targetName, targets):
|
||||
print(targetName)
|
||||
if option('target') == targetName:
|
||||
return super().add_targets(targetName, targets)
|
||||
else:
|
||||
static_platform = self.get_platform(static_name, 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 self.name, dep
|
||||
return static_name, dep
|
||||
|
||||
|
||||
def get_env(self):
|
||||
env = super().get_env()
|
||||
static_platform = self.get_platform(static_name)
|
||||
static_buildEnv = static_platform.buildEnv
|
||||
static_install_dir = static_buildEnv.install_dir
|
||||
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])
|
||||
env['CPPFLAGS'] = " ".join(['-I'+pj(static_install_dir, 'include'), env['CPPFLAGS']])
|
||||
return env
|
||||
|
||||
return MixedMixinClass
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from .base import PlatformInfo
|
||||
from .base import PlatformInfo, MixedMixin
|
||||
|
||||
from kiwixbuild.utils import pj
|
||||
from kiwixbuild._global import option, neutralEnv
|
||||
|
@ -24,33 +24,7 @@ class NativeStatic(NativePlatformInfo):
|
|||
static = True
|
||||
compatible_hosts = ['fedora', 'debian']
|
||||
|
||||
class NativeMixed(NativePlatformInfo):
|
||||
class NativeMixed(MixedMixin('native_static'), NativePlatformInfo):
|
||||
name = 'native_mixed'
|
||||
static = False
|
||||
compatible_hosts = ['fedora', 'debian', 'Darwin']
|
||||
|
||||
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 get_env(self):
|
||||
env = super().get_env()
|
||||
static_platform = self.get_platform('native_static')
|
||||
static_buildEnv = static_platform.buildEnv
|
||||
static_install_dir = static_buildEnv.install_dir
|
||||
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])
|
||||
env['CPPFLAGS'] = " ".join(['-I'+pj(static_install_dir, 'include'), env['CPPFLAGS']])
|
||||
return env
|
||||
|
|
Loading…
Reference in New Issue