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.

72 lines
2.2KB

  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"
  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"
  27. fi
  28. elif echo "${fileout}" | grep -q "RISC-V"; then
  29. if [ "$(uname -m)" != "riscv64" ]; then
  30. MESON_EXE_WRAPPER="qemu-riscv64-static"
  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"
  35. fi
  36. elif echo "${fileout}" | grep -q "64-bit LSB.*PowerPC"; then
  37. if [ "$(uname -m)" != "ppc64le" ]; then
  38. MESON_EXE_WRAPPER="qemu-ppc64le-static"
  39. fi
  40. elif echo "${fileout}" | grep -q "64-bit MSB.*PowerPC"; then
  41. if [ "$(uname -m)" != "ppc64" ]; then
  42. MESON_EXE_WRAPPER="qemu-ppc64-static"
  43. fi
  44. elif echo "${fileout}" | grep -q "32-bit MSB.*PowerPC"; then
  45. if [ "$(uname -m)" != "ppc" ] && [ "$(uname -m)" != "ppc64" ]; then
  46. MESON_EXE_WRAPPER="qemu-ppc-static"
  47. fi
  48. else
  49. echo "unrecognized file output: ${fileout}"
  50. exit 1
  51. fi
  52. fi
  53. mkdir -p "${dir}"
  54. cd "${dir}"
  55. cp -v "${lib}" .
  56. exec ${MESON_EXE_WRAPPER} "${gen}" "./$(basename ${lib})"