You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- #!/bin/bash
-
- set -e
-
- gen="${1}"
- dir="${2}"
- lib="${3}"
-
- # meson does not support MESON_EXE_WRAPPER for post-build commands, only for tests
- # do a whole dance to try to replicate expected behaviour
- if [ -z "${MESON_EXE_WRAPPER}" ]; then
- fileout="$(file "${gen}")"
- if echo "${fileout}" | grep -q "Mach-O"; then
- MESON_EXE_WRAPPER=""
-
- elif echo "${fileout}" | grep -q "PE32 executable.*Intel 80386"; then
- MESON_EXE_WRAPPER="wine"
-
- elif echo "${fileout}" | grep -q "PE32+ executable.*x86-64"; then
- MESON_EXE_WRAPPER="wine64"
-
- elif echo "${fileout}" | grep -q "ARM aarch64"; then
- if [ "$(uname -m)" != "aarch64" ]; then
- MESON_EXE_WRAPPER="qemu-aarch64-static"
- fi
-
- elif echo "${fileout}" | grep -q "ARM"; then
- if [ "$(uname -m)" != "arm" ] && [ "$(uname -m)" != "armv7l" ]; then
- MESON_EXE_WRAPPER="qemu-arm-static -L /usr/lib/arm-linux-gnueabihf"
- fi
-
- elif echo "${fileout}" | grep -q "Intel 80386"; then
- if [ "$(uname -m)" != "i386" ] && [ "$(uname -m)" != "i686" ] && [ "$(uname -m)" != "x86_64" ]; then
- MESON_EXE_WRAPPER="qemu-i386-static -L /usr/lib/i386-linux-gnu"
- fi
-
- elif echo "${fileout}" | grep -q "RISC-V"; then
- if [ "$(uname -m)" != "riscv64" ]; then
- MESON_EXE_WRAPPER="qemu-riscv64-static -L /usr/lib/riscv64-linux-gnu"
- fi
-
- elif echo "${fileout}" | grep -q "x86-64"; then
- if [ "$(uname -m)" != "x86_64" ]; then
- MESON_EXE_WRAPPER="qemu-x86_64-static -L /usr/lib/x86_64-linux-gnu"
- fi
-
- else
- echo "unrecognized file output: ${fileout}"
- exit 1
- fi
- fi
-
- mkdir -p "${dir}"
- cd "${dir}"
- exec ${MESON_EXE_WRAPPER} "${gen}" "${lib}"
|