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.'
|
'Select another target platform, or change your host system.'
|
||||||
).format(target_platform, self.distname))
|
).format(target_platform, self.distname))
|
||||||
sys.exit(-1)
|
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):
|
def setup_toolchains(self):
|
||||||
toolchain_names = self.platform_info.toolchains
|
toolchain_names = self.platform_info.toolchains
|
||||||
|
|
|
@ -20,7 +20,7 @@ class AndroidPlatformInfo(PlatformInfo):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "android"
|
return "android"
|
||||||
|
|
||||||
def get_cross_config(self, host):
|
def get_cross_config(self):
|
||||||
return {
|
return {
|
||||||
'extra_libs': [],
|
'extra_libs': [],
|
||||||
'extra_cflags': [],
|
'extra_cflags': [],
|
||||||
|
|
|
@ -5,7 +5,7 @@ class ArmhfPlatformInfo(PlatformInfo):
|
||||||
def __init__(self, name, static):
|
def __init__(self, name, static):
|
||||||
super().__init__(name, 'armhf', static, ['armhf_toolchain'], ['fedora', 'debian'])
|
super().__init__(name, 'armhf', static, ['armhf_toolchain'], ['fedora', 'debian'])
|
||||||
|
|
||||||
def get_cross_config(self, host):
|
def get_cross_config(self):
|
||||||
return {
|
return {
|
||||||
'extra_libs': [],
|
'extra_libs': [],
|
||||||
'extra_cflags': [],
|
'extra_cflags': [],
|
||||||
|
|
|
@ -6,7 +6,7 @@ class I586PlatformInfo(PlatformInfo):
|
||||||
def __init__(self, name, static):
|
def __init__(self, name, static):
|
||||||
super().__init__(name, 'i586', static, ['linux_i586_toolchain'], ['fedora', 'debian'])
|
super().__init__(name, 'i586', static, ['linux_i586_toolchain'], ['fedora', 'debian'])
|
||||||
|
|
||||||
def get_cross_config(self, host):
|
def get_cross_config(self):
|
||||||
return {
|
return {
|
||||||
'extra_libs': ['-m32', '-march=i586', '-mno-sse'],
|
'extra_libs': ['-m32', '-march=i586', '-mno-sse'],
|
||||||
'extra_cflags': ['-m32', '-march=i586', '-mno-sse'],
|
'extra_cflags': ['-m32', '-march=i586', '-mno-sse'],
|
||||||
|
|
|
@ -29,8 +29,9 @@ class iOSPlatformInfo(PlatformInfo):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "iOS"
|
return "iOS"
|
||||||
|
|
||||||
def get_cross_config(self, host):
|
def get_cross_config(self):
|
||||||
return {
|
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_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++'],
|
'extra_cflags': ['-fembed-bitcode', '-isysroot', self.root_path, '-arch', self.arch, '-miphoneos-version-min=9.0', '-stdlib=libc++'],
|
||||||
'host_machine': {
|
'host_machine': {
|
||||||
|
|
|
@ -5,7 +5,7 @@ class NativePlatformInfo(PlatformInfo):
|
||||||
def __init__(self, name, static, hosts):
|
def __init__(self, name, static, hosts):
|
||||||
super().__init__(name, 'native', static, [], hosts)
|
super().__init__(name, 'native', static, [], hosts)
|
||||||
|
|
||||||
def get_cross_config(self, host):
|
def get_cross_config(self):
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,18 +2,12 @@ from .base import PlatformInfo
|
||||||
|
|
||||||
|
|
||||||
class Win32PlatformInfo(PlatformInfo):
|
class Win32PlatformInfo(PlatformInfo):
|
||||||
|
extra_libs = ['-lwinmm', '-lws2_32', '-lshlwapi', '-lrpcrt4', '-lmsvcr90', '-liphlpapi']
|
||||||
def __init__(self, name, static):
|
def __init__(self, name, static):
|
||||||
super().__init__(name, 'win32', static, ['mingw32_toolchain'], ['fedora', 'debian'])
|
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):
|
def get_cross_config(self):
|
||||||
root_paths = {
|
|
||||||
'fedora': '/usr/i686-w64-mingw32/sys-root/mingw',
|
|
||||||
'debian': '/usr/i686-w64-mingw32'
|
|
||||||
}
|
|
||||||
self.root_path = root_paths[host]
|
|
||||||
return {
|
return {
|
||||||
'root_path': self.root_path,
|
|
||||||
'extra_libs': self.extra_libs,
|
'extra_libs': self.extra_libs,
|
||||||
'extra_cflags': ['-DWIN32'],
|
'extra_cflags': ['-DWIN32'],
|
||||||
'host_machine': {
|
'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_dyn', False)
|
||||||
Win32PlatformInfo('win32_static', True)
|
Win32PlatformInfo('win32_static', True)
|
||||||
|
|
|
@ -3,5 +3,5 @@ SET(CMAKE_SYSTEM_NAME {host_machine[system]})
|
||||||
SET(CMAKE_C_COMPILER "{toolchain.binaries[CC]}")
|
SET(CMAKE_C_COMPILER "{toolchain.binaries[CC]}")
|
||||||
SET(CMAKE_CXX_COMPILER "{toolchain.binaries[CXX]}")
|
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):
|
class mingw32_toolchain(Toolchain):
|
||||||
name = 'mingw32'
|
name = 'mingw32'
|
||||||
arch_full = 'i686-w64-mingw32'
|
arch_full = 'i686-w64-mingw32'
|
||||||
|
extra_libs = ['-lwinmm', '-lws2_32', '-lshlwapi', '-lrpcrt4', '-lmsvcr90', '-liphlpapi']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def root_path(self):
|
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
|
@property
|
||||||
def binaries(self):
|
def binaries(self):
|
||||||
|
@ -41,3 +46,10 @@ class mingw32_toolchain(Toolchain):
|
||||||
def set_compiler(self, env):
|
def set_compiler(self, env):
|
||||||
for k, v in self.binaries.items():
|
for k, v in self.binaries.items():
|
||||||
env[k] = v
|
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