From a413c5f064bd0ab1f845963f41e2c71e17a92ae4 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 22 May 2018 17:26:43 +0200 Subject: [PATCH] Fix root_path lookup in cmake_cross_file generation. Sometime the root_path is dependent of the target platform and sometime not. But sometime dependent of the build arch :/ [TODO] We should move the cross_file generation to the PlatformInfo class. --- kiwixbuild/buildenv.py | 2 +- kiwixbuild/platforms/android.py | 2 +- kiwixbuild/platforms/armhf.py | 2 +- kiwixbuild/platforms/i586.py | 2 +- kiwixbuild/platforms/ios.py | 3 ++- kiwixbuild/platforms/native.py | 2 +- kiwixbuild/platforms/win32.py | 17 ++--------------- kiwixbuild/templates/cmake_ios_cross_file.txt | 2 +- kiwixbuild/toolchains/mingw32.py | 14 +++++++++++++- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/kiwixbuild/buildenv.py b/kiwixbuild/buildenv.py index 8be045f..c742519 100644 --- a/kiwixbuild/buildenv.py +++ b/kiwixbuild/buildenv.py @@ -147,7 +147,7 @@ class BuildEnv: 'Select another target platform, or change your host system.' ).format(target_platform, self.distname)) sys.exit(-1) - self.cross_config = self.platform_info.get_cross_config(self.distname) + self.cross_config = self.platform_info.get_cross_config() def setup_toolchains(self): toolchain_names = self.platform_info.toolchains diff --git a/kiwixbuild/platforms/android.py b/kiwixbuild/platforms/android.py index 8ce6963..6caa326 100644 --- a/kiwixbuild/platforms/android.py +++ b/kiwixbuild/platforms/android.py @@ -20,7 +20,7 @@ class AndroidPlatformInfo(PlatformInfo): def __str__(self): return "android" - def get_cross_config(self, host): + def get_cross_config(self): return { 'extra_libs': [], 'extra_cflags': [], diff --git a/kiwixbuild/platforms/armhf.py b/kiwixbuild/platforms/armhf.py index 111fce6..742d3cd 100644 --- a/kiwixbuild/platforms/armhf.py +++ b/kiwixbuild/platforms/armhf.py @@ -5,7 +5,7 @@ class ArmhfPlatformInfo(PlatformInfo): def __init__(self, name, static): super().__init__(name, 'armhf', static, ['armhf_toolchain'], ['fedora', 'debian']) - def get_cross_config(self, host): + def get_cross_config(self): return { 'extra_libs': [], 'extra_cflags': [], diff --git a/kiwixbuild/platforms/i586.py b/kiwixbuild/platforms/i586.py index 3073a46..262c97d 100644 --- a/kiwixbuild/platforms/i586.py +++ b/kiwixbuild/platforms/i586.py @@ -6,7 +6,7 @@ class I586PlatformInfo(PlatformInfo): def __init__(self, name, static): super().__init__(name, 'i586', static, ['linux_i586_toolchain'], ['fedora', 'debian']) - def get_cross_config(self, host): + def get_cross_config(self): return { 'extra_libs': ['-m32', '-march=i586', '-mno-sse'], 'extra_cflags': ['-m32', '-march=i586', '-mno-sse'], diff --git a/kiwixbuild/platforms/ios.py b/kiwixbuild/platforms/ios.py index af8b4e4..86a9b55 100644 --- a/kiwixbuild/platforms/ios.py +++ b/kiwixbuild/platforms/ios.py @@ -29,8 +29,9 @@ class iOSPlatformInfo(PlatformInfo): def __str__(self): return "iOS" - def get_cross_config(self, host): + def get_cross_config(self): return { + 'root_path': self.root_path, 'extra_libs': ['-fembed-bitcode', '-isysroot', self.root_path, '-arch', self.arch, '-miphoneos-version-min=9.0', '-stdlib=libc++'], 'extra_cflags': ['-fembed-bitcode', '-isysroot', self.root_path, '-arch', self.arch, '-miphoneos-version-min=9.0', '-stdlib=libc++'], 'host_machine': { diff --git a/kiwixbuild/platforms/native.py b/kiwixbuild/platforms/native.py index 4701ebe..9a23b10 100644 --- a/kiwixbuild/platforms/native.py +++ b/kiwixbuild/platforms/native.py @@ -5,7 +5,7 @@ class NativePlatformInfo(PlatformInfo): def __init__(self, name, static, hosts): super().__init__(name, 'native', static, [], hosts) - def get_cross_config(self, host): + def get_cross_config(self): return {} diff --git a/kiwixbuild/platforms/win32.py b/kiwixbuild/platforms/win32.py index c33b68e..5d6b643 100644 --- a/kiwixbuild/platforms/win32.py +++ b/kiwixbuild/platforms/win32.py @@ -2,18 +2,12 @@ from .base import PlatformInfo class Win32PlatformInfo(PlatformInfo): + extra_libs = ['-lwinmm', '-lws2_32', '-lshlwapi', '-lrpcrt4', '-lmsvcr90', '-liphlpapi'] def __init__(self, name, static): super().__init__(name, 'win32', static, ['mingw32_toolchain'], ['fedora', 'debian']) - self.extra_libs = ['-lwinmm', '-lws2_32', '-lshlwapi', '-lrpcrt4', '-lmsvcr90', '-liphlpapi'] - def get_cross_config(self, host): - root_paths = { - 'fedora': '/usr/i686-w64-mingw32/sys-root/mingw', - 'debian': '/usr/i686-w64-mingw32' - } - self.root_path = root_paths[host] + def get_cross_config(self): return { - 'root_path': self.root_path, 'extra_libs': self.extra_libs, 'extra_cflags': ['-DWIN32'], 'host_machine': { @@ -26,12 +20,5 @@ class Win32PlatformInfo(PlatformInfo): } } - def get_bin_dir(self): - return [pj(self.root_path, 'bin')] - - def set_env(self, env): - env['PKG_CONFIG_LIBDIR'] = pj(self.root_path, 'lib', 'pkgconfig') - env['LIBS'] = " ".join(self.extra_libs) + " " +env['LIBS'] - Win32PlatformInfo('win32_dyn', False) Win32PlatformInfo('win32_static', True) diff --git a/kiwixbuild/templates/cmake_ios_cross_file.txt b/kiwixbuild/templates/cmake_ios_cross_file.txt index feaefa1..7ceaa46 100644 --- a/kiwixbuild/templates/cmake_ios_cross_file.txt +++ b/kiwixbuild/templates/cmake_ios_cross_file.txt @@ -3,5 +3,5 @@ SET(CMAKE_SYSTEM_NAME {host_machine[system]}) SET(CMAKE_C_COMPILER "{toolchain.binaries[CC]}") SET(CMAKE_CXX_COMPILER "{toolchain.binaries[CXX]}") -SET(CMAKE_FIND_ROOT_PATH {toolchain.root_path}) +SET(CMAKE_FIND_ROOT_PATH {root_path}) diff --git a/kiwixbuild/toolchains/mingw32.py b/kiwixbuild/toolchains/mingw32.py index 873507e..7da1283 100644 --- a/kiwixbuild/toolchains/mingw32.py +++ b/kiwixbuild/toolchains/mingw32.py @@ -9,10 +9,15 @@ pj = os.path.join class mingw32_toolchain(Toolchain): name = 'mingw32' arch_full = 'i686-w64-mingw32' + extra_libs = ['-lwinmm', '-lws2_32', '-lshlwapi', '-lrpcrt4', '-lmsvcr90', '-liphlpapi'] @property def root_path(self): - return self.buildEnv.cross_config['root_path'] + root_paths = { + 'fedora': '/usr/i686-w64-mingw32/sys-root/mingw', + 'debian': '/usr/i686-w64-mingw32' + } + return root_paths[self.neutralEnv.distname] @property def binaries(self): @@ -41,3 +46,10 @@ class mingw32_toolchain(Toolchain): def set_compiler(self, env): for k, v in self.binaries.items(): env[k] = v + + def get_bin_dir(self): + return [pj(self.root_path, 'bin')] + + def set_env(self, env): + env['PKG_CONFIG_LIBDIR'] = pj(self.root_path, 'lib', 'pkgconfig') + env['LIBS'] = " ".join(self.extra_libs) + " " +env['LIBS']