Do not hardcode binary's name in templates.

This may change from on host platform to another. Use the cross_env.
This commit is contained in:
Matthieu Gautier 2017-02-06 17:33:39 +01:00
parent 2451c35d79
commit b205526bb2
4 changed files with 20 additions and 15 deletions

View File

@ -27,6 +27,8 @@ CROSS_ENV = {
'cpp' : 'i686-w64-mingw32-g++', 'cpp' : 'i686-w64-mingw32-g++',
'ar' : 'i686-w64-mingw32-ar', 'ar' : 'i686-w64-mingw32-ar',
'strip' : 'i686-w64-mingw32-strip', 'strip' : 'i686-w64-mingw32-strip',
'windres' : 'i686-w64-mingw32-windres',
'ranlib' : 'i686-w64-mingw32-ranlib',
'pkgconfig' : 'i686-w64-mingw32-pkg-config', 'pkgconfig' : 'i686-w64-mingw32-pkg-config',
'exe_wrapper' : 'wine' 'exe_wrapper' : 'wine'
}, },
@ -101,6 +103,9 @@ class Which():
output = subprocess.check_output(command, shell=True) output = subprocess.check_output(command, shell=True)
return output[:-1].decode() return output[:-1].decode()
def __format__(self, format_spec):
return getattr(self, format_spec)
def remove_duplicates(iterable, key_function=None): def remove_duplicates(iterable, key_function=None):
seen = set() seen = set()
if key_function is None: if key_function is None:
@ -230,7 +235,7 @@ class BuildEnv:
template = f.read() template = f.read()
content = template.format( content = template.format(
which=Which(), which=Which(),
root_path=self.cross_env['root_path'] **self.cross_env
) )
with open(crossfile, 'w') as outfile: with open(crossfile, 'w') as outfile:
outfile.write(content) outfile.write(content)

View File

@ -1,4 +1,4 @@
#!/usr/bin/sh #!/bin/sh
if test -z "$PATH_ORIG" ; then if test -z "$PATH_ORIG" ; then
@ -10,10 +10,10 @@ PATH="{root_path}/bin:$PATH_ORIG"; export PATH;
HOST_CC=gcc; export HOST_CC; HOST_CC=gcc; export HOST_CC;
unset PKG_CONFIG_PATH; unset PKG_CONFIG_PATH;
CC={which.i686-w64-mingw32-gcc}; export CC CC={which:{binaries[c]}}; export CC
AR={which.i686-w64-mingw32-ar}; export AR AR={which:{binaries[ar]}}; export AR
CXX={which.i686-w64-mingw32-g++}; export CXX CXX={which:{binaries[cpp]}}; export CXX
STRIP={which.i686-w64-mingw32-strip}; export STRIP STRIP={which:{binaries[strip]}}; export STRIP
CFLAGS=" -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4"; export CFLAGS; CFLAGS=" -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4"; export CFLAGS;
CXXFLAGS=" -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4"; export CXXFLAGS; CXXFLAGS=" -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4"; export CXXFLAGS;

View File

@ -2,11 +2,11 @@ SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_SYSTEM_PROCESSOR x86) SET(CMAKE_SYSTEM_PROCESSOR x86)
# specify the cross compiler # specify the cross compiler
SET(CMAKE_C_COMPILER {which.i686-w64-mingw32-gcc}) SET(CMAKE_C_COMPILER {which:{binaries[c]}})
SET(CMAKE_CXX_COMPILER {which.i686-w64-mingw32-g++}) SET(CMAKE_CXX_COMPILER {which:{binaries[cpp]}})
SET(CMAKE_RC_COMPILER {which.i686-w64-mingw32-windres}) SET(CMAKE_RC_COMPILER {which:{binaries[windres]}})
SET(CMAKE_AR:FILEPATH {which.i686-w64-mingw32-ar}) SET(CMAKE_AR:FILEPATH {which:{binaries[ar]}})
SET(CMAKE_RANLIB:FILEPATH {which.i686-w64-mingw32-ranlib}) SET(CMAKE_RANLIB:FILEPATH {which:{binaries[ranlib]}})
# where is the target environment # where is the target environment
SET(CMAKE_FIND_ROOT_PATH {root_path}) SET(CMAKE_FIND_ROOT_PATH {root_path})

View File

@ -1,9 +1,9 @@
[binaries] [binaries]
pkgconfig = 'pkg-config' pkgconfig = 'pkg-config'
c = '{which.i686-w64-mingw32-gcc}' c = '{which:{binaries[c]}}'
ar = '{which.i686-w64-mingw32-ar}' ar = '{which:{binaries[ar]}}'
cpp = '{which.i686-w64-mingw32-g++}' cpp = '{which:{binaries[cpp]}}'
strip = '{which.i686-w64-mingw32-strip}' strip = '{which:{binaries[strip]}}'
exe_wrapper = 'wine' exe_wrapper = 'wine'
[properties] [properties]