Run meson test when possible.

To run unit-test (meson) on cross-compilation, we need a wrapper to run
the binary (wine, qemu, ...), but:

- We have no emulator for android (we have one for the system, but we can't
  simply run a binary)
- With dynamic compilation, it seems pretty complex to configure them
  correctly.
- For mingw32 compilation, `wine` need to be correctly configured to
  find dll from the system mingw32 installation.
This commit is contained in:
Matthieu Gautier 2017-09-12 16:26:15 +02:00
parent 9ab444521c
commit 4997017be2
4 changed files with 62 additions and 3 deletions

View File

@ -210,6 +210,8 @@ class Builder:
self.command('pre_build_script', self._pre_build_script) self.command('pre_build_script', self._pre_build_script)
self.command('configure', self._configure) self.command('configure', self._configure)
self.command('compile', self._compile) self.command('compile', self._compile)
if hasattr(self, '_test'):
self.command('test', self._test)
self.command('install', self._install) self.command('install', self._install)
if hasattr(self, '_post_build_script'): if hasattr(self, '_post_build_script'):
self.command('post_build_script', self._post_build_script) self.command('post_build_script', self._post_build_script)
@ -340,6 +342,15 @@ class MesonBuilder(Builder):
command = "{} -v".format(self.buildEnv.ninja_command) command = "{} -v".format(self.buildEnv.ninja_command)
self.buildEnv.run_command(command, self.build_path, context) self.buildEnv.run_command(command, self.build_path, context)
def _test(self, context):
if ( self.buildEnv.platform_info.build == 'android'
or (self.buildEnv.platform_info.build != 'native'
and not self.buildEnv.platform_info.static)
):
raise SkipCommand()
command = "{} --verbose".format(self.buildEnv.mesontest_command)
self.buildEnv.run_command(command, self.build_path, context)
def _install(self, context): def _install(self, context):
command = "{} -v install".format(self.buildEnv.ninja_command) command = "{} -v install".format(self.buildEnv.ninja_command)
self.buildEnv.run_command(command, self.build_path, context) self.buildEnv.run_command(command, self.build_path, context)

View File

@ -254,6 +254,7 @@ class BuildEnv:
self.meson_command = self._detect_meson() self.meson_command = self._detect_meson()
if not self.meson_command: if not self.meson_command:
sys.exit("ERROR: meson command not fount") sys.exit("ERROR: meson command not fount")
self.mesontest_command = "mesontest"
self.setup_build(options.target_platform) self.setup_build(options.target_platform)
self.setup_toolchains() self.setup_toolchains()
self.options = options self.options = options
@ -328,7 +329,7 @@ class BuildEnv:
def setup_android(self): def setup_android(self):
self.cmake_crossfile = self._gen_crossfile('cmake_android_cross_file.txt') self.cmake_crossfile = self._gen_crossfile('cmake_android_cross_file.txt')
self.meson_crossfile = self._gen_crossfile('meson_cross_file.txt') self.meson_crossfile = self._gen_crossfile('meson_android_cross_file.txt')
def setup_armhf(self): def setup_armhf(self):
self.cmake_crossfile = self._gen_crossfile('cmake_cross_file.txt') self.cmake_crossfile = self._gen_crossfile('cmake_cross_file.txt')
@ -428,12 +429,12 @@ class BuildEnv:
env['LD_LIBRARY_PATH'] = ':'.join([env['LD_LIBRARY_PATH'], env['LD_LIBRARY_PATH'] = ':'.join([env['LD_LIBRARY_PATH'],
pj(self.install_dir, 'lib'), pj(self.install_dir, 'lib'),
pj(self.install_dir, 'lib64') pj(self.install_dir, self.libprefix)
]) ])
env['CPPFLAGS'] = " ".join(['-I'+pj(self.install_dir, 'include'), env['CPPFLAGS']]) env['CPPFLAGS'] = " ".join(['-I'+pj(self.install_dir, 'include'), env['CPPFLAGS']])
env['LDFLAGS'] = " ".join(['-L'+pj(self.install_dir, 'lib'), env['LDFLAGS'] = " ".join(['-L'+pj(self.install_dir, 'lib'),
'-L'+pj(self.install_dir, 'lib64'), '-L'+pj(self.install_dir, self.libprefix),
env['LDFLAGS']]) env['LDFLAGS']])
return env return env
@ -547,6 +548,7 @@ class Toolchain(metaclass=_MetaToolchain):
all_toolchains = {} all_toolchains = {}
configure_option = "" configure_option = ""
cmake_option = "" cmake_option = ""
exec_wrapper_def = ""
Builder = None Builder = None
Source = None Source = None
@ -618,6 +620,16 @@ class mingw32_toolchain(Toolchain):
('RANLIB', 'ranlib')) ('RANLIB', 'ranlib'))
} }
@property
def exec_wrapper_def(self):
try:
which('wine')
except subprocess.CalledProcessError:
return ""
else:
return "exec_wrapper = 'wine'"
@property @property
def configure_option(self): def configure_option(self):
return '--host={}'.format(self.arch_full) return '--host={}'.format(self.arch_full)
@ -836,6 +848,15 @@ class armhf_toolchain(Toolchain):
return {k:pj(self.root_path, 'bin', v) return {k:pj(self.root_path, 'bin', v)
for k,v in binaries} for k,v in binaries}
@property
def exec_wrapper_def(self):
try:
which('qemu-arm')
except subprocess.CalledProcessError:
return ""
else:
return "exec_wrapper = 'qemu-arm'"
@property @property
def configure_option(self): def configure_option(self):
return '--host={}'.format(self.arch_full) return '--host={}'.format(self.arch_full)
@ -848,6 +869,13 @@ class armhf_toolchain(Toolchain):
env['CFLAGS'] = " -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 "+env['CFLAGS'] env['CFLAGS'] = " -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 "+env['CFLAGS']
env['CXXFLAGS'] = " -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 "+env['CXXFLAGS'] env['CXXFLAGS'] = " -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 "+env['CXXFLAGS']
env['LIBS'] = " ".join(self.buildEnv.cross_config['extra_libs']) + " " +env['LIBS'] env['LIBS'] = " ".join(self.buildEnv.cross_config['extra_libs']) + " " +env['LIBS']
env['QEMU_LD_PREFIX'] = pj(self.root_path, "arm-linux-gnueabihf", "libc")
env['QEMU_SET_ENV'] = "LD_LIBRARY_PATH={}".format(
':'.join([
pj(self.root_path, "arm-linux-gnueabihf", "lib"),
pj(self.buildEnv.install_dir, 'lib'),
pj(self.buildEnv.install_dir, self.buildEnv.libprefix)
]))
def set_compiler(self, env): def set_compiler(self, env):
env['CC'] = self.binaries['CC'] env['CC'] = self.binaries['CC']

View File

@ -0,0 +1,19 @@
[binaries]
pkgconfig = 'pkg-config'
c = '{toolchain.binaries[CC]}'
ar = '{toolchain.binaries[AR]}'
cpp = '{toolchain.binaries[CXX]}'
strip = '{toolchain.binaries[STRIP]}'
[properties]
c_link_args = {extra_libs!r}
cpp_link_args = {extra_libs!r}
c_args = {extra_cflags!r}
cpp_args = {extra_cflags!r}
android_abi = '{host_machine[abi]}'
[host_machine]
cpu_family = '{host_machine[cpu_family]}'
cpu = '{host_machine[cpu]}'
system = '{host_machine[lsystem]}'
endian = '{host_machine[endian]}'

View File

@ -4,6 +4,7 @@ c = '{toolchain.binaries[CC]}'
ar = '{toolchain.binaries[AR]}' ar = '{toolchain.binaries[AR]}'
cpp = '{toolchain.binaries[CXX]}' cpp = '{toolchain.binaries[CXX]}'
strip = '{toolchain.binaries[STRIP]}' strip = '{toolchain.binaries[STRIP]}'
{toolchain.exec_wrapper_def}
[properties] [properties]
c_link_args = {extra_libs!r} c_link_args = {extra_libs!r}