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.

56 lines
1.7KB

  1. #!/bin/bash
  2. set -e
  3. gen="${1}"
  4. dir="${2}"
  5. lib="${3}"
  6. # meson does not support MESON_EXE_WRAPPER for post-build commands, only for tests
  7. # do a whole dance to try to replicate expected behaviour
  8. if [ -z "${MESON_EXE_WRAPPER}" ]; then
  9. fileout="$(file "${gen}")"
  10. if echo "${fileout}" | grep -q "Mach-O"; then
  11. MESON_EXE_WRAPPER=""
  12. elif echo "${fileout}" | grep -q "PE32 executable.*Intel 80386"; then
  13. MESON_EXE_WRAPPER="wine"
  14. elif echo "${fileout}" | grep -q "PE32+ executable.*x86-64"; then
  15. MESON_EXE_WRAPPER="wine64"
  16. elif echo "${fileout}" | grep -q "ARM aarch64"; then
  17. if [ "$(uname -m)" != "aarch64" ]; then
  18. MESON_EXE_WRAPPER="qemu-aarch64-static"
  19. fi
  20. elif echo "${fileout}" | grep -q "ARM"; then
  21. if [ "$(uname -m)" != "arm" ] && [ "$(uname -m)" != "armv7l" ]; then
  22. MESON_EXE_WRAPPER="qemu-arm-static -L /usr/lib/arm-linux-gnueabihf"
  23. fi
  24. elif echo "${fileout}" | grep -q "Intel 80386"; then
  25. if [ "$(uname -m)" != "i386" ] && [ "$(uname -m)" != "i686" ] && [ "$(uname -m)" != "x86_64" ]; then
  26. MESON_EXE_WRAPPER="qemu-i386-static -L /usr/lib/i386-linux-gnu"
  27. fi
  28. elif echo "${fileout}" | grep -q "RISC-V"; then
  29. if [ "$(uname -m)" != "riscv64" ]; then
  30. MESON_EXE_WRAPPER="qemu-riscv64-static -L /usr/lib/riscv64-linux-gnu"
  31. fi
  32. elif echo "${fileout}" | grep -q "x86-64"; then
  33. if [ "$(uname -m)" != "x86_64" ]; then
  34. MESON_EXE_WRAPPER="qemu-x86_64-static -L /usr/lib/x86_64-linux-gnu"
  35. fi
  36. else
  37. echo "unrecognized file output: ${fileout}"
  38. exit 1
  39. fi
  40. fi
  41. mkdir -p "${dir}"
  42. cd "${dir}"
  43. exec ${MESON_EXE_WRAPPER} "${gen}" "${lib}"