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.
This commit is contained in:
parent
98ebba65f6
commit
a413c5f064
|
@ -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
|
||||
|
|
|
@ -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': [],
|
||||
|
|
|
@ -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': [],
|
||||
|
|
|
@ -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'],
|
||||
|
|
|
@ -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': {
|
||||
|
|
|
@ -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 {}
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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})
|
||||
|
||||
|
|
|
@ -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']
|
||||
|
|
Loading…
Reference in New Issue