fix libdir name issue, copy tc libs for production targets

The following applies to mips32r2_uclibc_glibcxx_dyn target,
only:
  - libstdc++.so* tc libs are copied to INSTALL/lib/<full-arch>

  - i.e. there is an example showing how to copy other libs from
    the toolchain to supplement the installation files (in case
    they are found to be missing on a target machine)

  - if target already supplies libstdc++.so*, copied ones will be
    preferred for kiwix-tools binaries (when run from a non-std
    installation directory on the target), drawback in this case
    is extra space occupied by the lib, but the gain is less
    hazzle on target boxes that lack libstdc++.so*

  - comment or modify the lines in mips32r2.py accordingly to the
    setup of your mips target
This commit is contained in:
cm8 2018-06-24 04:25:08 +02:00
parent 4cbbf2325b
commit 2751616753
3 changed files with 39 additions and 18 deletions

View File

@ -100,6 +100,8 @@ class BuildEnv:
return os.path.isfile('/etc/debian_version')
def _detect_libdir(self):
if getattr(self.platformInfo, 'build', '').startswith('mips'):
return 'lib/' + self.platformInfo.arch_full
if self._is_debianlike():
try:
pc = subprocess.Popen(['dpkg-architecture', '-qDEB_HOST_MULTIARCH'],

View File

@ -25,7 +25,7 @@ SCRIPTPATH=`dirname $SCRIPT`
if test x"$BASENAME" != xrun-nonroot
then
for fullarch in "" mips-linux-gnu
for fullarch in "" ${ARCH_FULL:-mips-linux-gnu}
do for libdir in usr/lib lib
do LD_LIBRARY_PATH="${SCRIPTPATH%/bin}/$libdir/$fullarch:$LD_LIBRARY_PATH"
done

View File

@ -1,10 +1,20 @@
from .base import PlatformInfo
from .base import PlatformInfo, _SCRIPT_DIR
from kiwixbuild.utils import pj
from kiwixbuild._global import get_target_step
from os import makedirs, chmod
from shutil import copy
from .base import _SCRIPT_DIR
from re import sub as sed
from glob import glob
from os import makedirs, chmod, readlink, symlink
from os.path import basename, islink
from shutil import copy2
def copy(src, dst):
if islink(src):
linkto = readlink(src)
symlink(linkto, dst)
else:
copy2(src,dst)
class MIPS32R2PlatformInfo(PlatformInfo):
@ -94,18 +104,18 @@ class MIPS32R2PlatformInfo(PlatformInfo):
self.buildEnv.meson_crossfile = self._gen_crossfile('meson_cross_file.txt')
class MIPS32R2Dyn(MIPS32R2PlatformInfo):
name = 'mips32r2_dyn'
name = MIPS32R2PlatformInfo.build + '_dyn'
static = False
class MIPS32R2Static(MIPS32R2PlatformInfo):
name = 'mips32r2_static'
name = MIPS32R2PlatformInfo.build + '_static'
static = True
class MIPS32R2_UC_GCXXPlatformInfo(MIPS32R2PlatformInfo):
build = 'mips32r2_uclibc_gclibcxx' # "shared, heterogenous" (gnu c++ lib "on top of" uClibc)
build = 'mips32r2_uclibc_gclibcxx' # "shared, heterogeneous"
arch_full = 'mips-linux-uclibc'
@property
@ -122,26 +132,35 @@ class MIPS32R2_UC_GCXXPlatformInfo(MIPS32R2PlatformInfo):
env['CXXFLAGS'] = " -msoft-float -Os -pipe -Wa,--trap "+env['CXXFLAGS']
class MIPS32R2_UC_GCXXDyn(MIPS32R2_UC_GCXXPlatformInfo):
name = 'mips32r2_uclibc_gclibcxx_dyn'
name = MIPS32R2_UC_GCXXPlatformInfo.build + '_dyn'
static = False
def finalize_setup(self):
super().finalize_setup()
dest = pj(_SCRIPT_DIR, '..', '..', 'BUILD_'+self.name, 'INSTALL', 'bin')
makedirs(dest, mode=0o755, exist_ok=True)
dest = pj(dest, 'fixenv-run-in-nonstd-installdir.sh')
copy(pj(_SCRIPT_DIR, '..', 'patches', 'fixenv-run-in-nonstd-installdir.sh'), dest)
chmod(dest, 0o755)
d = pj(_SCRIPT_DIR, '..', '..', 'BUILD_'+self.name, 'INSTALL')
makedirs(pj(d, 'bin'), mode=0o755, exist_ok=True)
with open(pj(_SCRIPT_DIR, '..', 'patches', 'fixenv-nonstd-libdir.sh'), "r") as sources:
lines = sources.readlines()
with open(pj(d, 'bin', 'fixenv-nonstd-libdir'), "w") as sources:
for line in lines:
sources.write(sed(r'\$\{ARCH_FULL[^}]*\}', self.arch_full, line))
chmod(pj(d, 'bin', 'fixenv-nonstd-libdir'), 0o755)
d = pj(d, 'lib', self.arch_full)
makedirs(d, mode=0o755, exist_ok=True)
for f in glob(pj(self.tclibdir, 'libstdc++.so*')):
copy(f, pj(d, basename(f)))
class MIPS32R2_UC_GCXXStatic(MIPS32R2_UC_GCXXPlatformInfo):
name = 'mips32r2_uclibc_gclibcxx_static'
name = MIPS32R2_UC_GCXXPlatformInfo.build + '_static'
static = True
class MIPS32R2_UC_UCXXPlatformInfo(MIPS32R2_UC_GCXXPlatformInfo):
build = 'mips32r2_uclibc_uclibcxx' # "pure, homogenous"
build = 'mips32r2_uclibc_uclibcxx' # "pure, homogeneous"
def get_cross_config(self):
conf = super().get_cross_config()
@ -160,9 +179,9 @@ class MIPS32R2_UC_UCXXPlatformInfo(MIPS32R2_UC_GCXXPlatformInfo):
env['PATH'] = ':'.join([pj(self.tcbindir), env['PATH']])
class MIPS32R2_UC_UCXXDyn(MIPS32R2_UC_UCXXPlatformInfo):
name = 'mips32r2_uclibc_uclibcxx_dyn'
name = MIPS32R2_UC_UCXXPlatformInfo.build + '_dyn'
static = False
class MIPS32R2_UC_UCXXStatic(MIPS32R2_UC_UCXXPlatformInfo):
name = 'mips32r2_uclibc_uclibcxx_static'
name = MIPS32R2_UC_UCXXPlatformInfo.build + '_static'
static = True