New build-helper: qemu

This commit is contained in:
John 2019-10-19 15:25:45 +02:00 committed by John Zimmermann
parent 387cf14520
commit f4273541b8
4 changed files with 13 additions and 8 deletions

View File

@ -944,6 +944,11 @@ additional paths to be searched when linking target binaries to be introspected.
`qemu-<target_arch>-static` when running the target binary. You can for example specify `qemu-<target_arch>-static` when running the target binary. You can for example specify
`GIR_EXTRA_OPTIONS="-strace"` to see a trace of what happens when running that binary. `GIR_EXTRA_OPTIONS="-strace"` to see a trace of what happens when running that binary.
- 'qemu' sets additional variables for the `cmake` and `meson` build styles to allow
executing cross-compiled binaries inside qemu.
It sets `CMAKE_CROSSCOMPILING_EMULATOR` for cmake and `exe_wrapper` for meson
to `qemu-<target_arch>-static` and `QEMU_LD_PREFIX` to `XBPS_CROSS_BASE`
<a id="functions"></a> <a id="functions"></a>
### Functions ### Functions

View File

@ -0,0 +1,6 @@
if [ "$CROSS_BUILD" ]; then
export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
if [[ $hostmakedepends != *"qemu-user-static"* ]]; then
hostmakedepends+=" qemu-user-static"
fi
fi

View File

@ -2,7 +2,6 @@
# This helper is for templates using cmake. # This helper is for templates using cmake.
# #
do_configure() { do_configure() {
export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
local cmake_args= local cmake_args=
[ ! -d ${cmake_builddir:=build} ] && mkdir -p ${cmake_builddir} [ ! -d ${cmake_builddir:=build} ] && mkdir -p ${cmake_builddir}
cd ${cmake_builddir} cd ${cmake_builddir}
@ -51,7 +50,7 @@ _EOF
cmake_args+=" -DCMAKE_INSTALL_LIBDIR=lib" cmake_args+=" -DCMAKE_INSTALL_LIBDIR=lib"
fi fi
if [ "${hostmakedepends}" != "${hostmakedepends/qemu-user-static/}" ]; then if [[ $build_helper = *"qemu"* ]]; then
echo "SET(CMAKE_CROSSCOMPILING_EMULATOR /usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static)" \ echo "SET(CMAKE_CROSSCOMPILING_EMULATOR /usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static)" \
>> cross_${XBPS_CROSS_TRIPLET}.cmake >> cross_${XBPS_CROSS_TRIPLET}.cmake
fi fi
@ -66,7 +65,6 @@ _EOF
} }
do_build() { do_build() {
export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
: ${make_cmd:=make} : ${make_cmd:=make}
cd ${cmake_builddir:=build} cd ${cmake_builddir:=build}
@ -94,7 +92,6 @@ do_check() {
} }
do_install() { do_install() {
export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
: ${make_cmd:=make} : ${make_cmd:=make}
: ${make_install_target:=install} : ${make_install_target:=install}

View File

@ -69,7 +69,7 @@ cpu_family = '${_MESON_CPU_FAMILY}'
cpu = '${_MESON_TARGET_CPU}' cpu = '${_MESON_TARGET_CPU}'
endian = '${_MESON_TARGET_ENDIAN}' endian = '${_MESON_TARGET_ENDIAN}'
EOF EOF
if [ "${hostmakedepends}" != "${hostmakedepends/qemu-user-static/}" ]; then if [[ $build_helper = *"qemu"* ]]; then
sed -e "/\[binaries\]/ a exe_wrapper = '/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static'" \ sed -e "/\[binaries\]/ a exe_wrapper = '/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static'" \
-i ${meson_crossfile} -i ${meson_crossfile}
fi fi
@ -82,7 +82,6 @@ do_configure() {
: ${meson_cmd:=meson} : ${meson_cmd:=meson}
: ${meson_builddir:=build} : ${meson_builddir:=build}
: ${meson_crossfile:=xbps_meson.cross} : ${meson_crossfile:=xbps_meson.cross}
export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
if [ "$CROSS_BUILD" ]; then if [ "$CROSS_BUILD" ]; then
configure_args+=" --cross-file=${meson_crossfile}" configure_args+=" --cross-file=${meson_crossfile}"
@ -135,7 +134,6 @@ do_build() {
: ${make_cmd:=ninja} : ${make_cmd:=ninja}
: ${make_build_target:=all} : ${make_build_target:=all}
: ${meson_builddir:=build} : ${meson_builddir:=build}
export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
${make_cmd} -C ${meson_builddir} ${makejobs} ${make_build_args} ${make_build_target} ${make_cmd} -C ${meson_builddir} ${makejobs} ${make_build_args} ${make_build_target}
} }
@ -152,7 +150,6 @@ do_install() {
: ${make_cmd:=ninja} : ${make_cmd:=ninja}
: ${make_install_target:=install} : ${make_install_target:=install}
: ${meson_builddir:=build} : ${meson_builddir:=build}
export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
DESTDIR=${DESTDIR} ${make_cmd} -C ${meson_builddir} ${make_install_args} ${make_install_target} DESTDIR=${DESTDIR} ${make_cmd} -C ${meson_builddir} ${make_install_args} ${make_install_target}
} }