Cross-Platform build scripts for audio plugins
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.

140 lines
4.9KB

  1. #!/bin/bash
  2. set -e
  3. cd $(dirname ${0})
  4. PAWPAW_ROOT="${PWD}"
  5. # ---------------------------------------------------------------------------------------------------------------------
  6. target="${1}"
  7. if [ -z "${target}" ]; then
  8. echo "usage: ${0} <target> <plugin1> ..."
  9. exit 1
  10. fi
  11. shift
  12. VERSION=$(cat VERSION)
  13. # ---------------------------------------------------------------------------------------------------------------------
  14. source setup/check_target.sh
  15. source setup/env.sh
  16. # ---------------------------------------------------------------------------------------------------------------------
  17. function download_and_install_innosetup {
  18. local dlfile="${PAWPAW_DOWNLOADDIR}/innosetup-6.0.5.exe"
  19. local pkgdir="${PAWPAW_BUILDDIR}/innosetup-6.0.5"
  20. if [ ! -f "${dlfile}" ]; then
  21. # FIXME proper dl version
  22. curl -L https://jrsoftware.org/download.php/is.exe?site=2 -o "${dlfile}"
  23. fi
  24. if [ ! -d "${pkgdir}"/drive_c ]; then
  25. env WINEARCH="${PAWPAW_TARGET}" WINEDLLOVERRIDES="mscoree,mshtml=" WINEPREFIX="${pkgdir}" wineboot -u
  26. fi
  27. if [ ! -f "${pkgdir}"/drive_c/InnoSeup/ISCC.exe ]; then
  28. env WINEARCH="${PAWPAW_TARGET}" WINEPREFIX="${pkgdir}" wine "${dlfile}" /allusers /dir=C:\\InnoSeup /nocancel /norestart /verysilent
  29. fi
  30. }
  31. function create_innosetup_exe {
  32. local pkgdir="${PAWPAW_BUILDDIR}/innosetup-6.0.5"
  33. local iscc="${pkgdir}/drive_c/InnoSeup/ISCC.exe"
  34. echo "#define VERSION \"${VERSION}\"" > /tmp/pawpaw/version.iss
  35. env WINEARCH="${PAWPAW_TARGET}" WINEPREFIX="${pkgdir}" wine "${iscc}" "setup/inno/${PAWPAW_TARGET}.iss"
  36. }
  37. # ---------------------------------------------------------------------------------------------------------------------
  38. rm -rf /tmp/pawpaw
  39. mkdir /tmp/pawpaw
  40. if [ "${WIN32}" -eq 1 ]; then
  41. download_and_install_innosetup
  42. touch /tmp/pawpaw/components.iss
  43. touch /tmp/pawpaw/lv2bundles.iss
  44. PAWPAW_WINE_LV2DIR="Z:$(echo ${PAWPAW_PREFIX} | tr -t '/' '\\')\\lib\\lv2\\"
  45. elif [ "${MACOS}" -eq 1 ] && [ "${MACOS_OLD}" -eq 0 ]; then
  46. touch /tmp/pawpaw/choices.xml
  47. touch /tmp/pawpaw/outlines.xml
  48. fi
  49. # ---------------------------------------------------------------------------------------------------------------------
  50. for plugin in ${@}; do
  51. pfile="${PAWPAW_ROOT}/plugins/${plugin}.json"
  52. if [ ! -e "${pfile}" ]; then
  53. echo "Requested plugin file '${pfile}' does not exist"
  54. exit 2
  55. fi
  56. name=$(jq -crM .name ${pfile})
  57. sname=$(echo ${name} | tr -ds '-' '_')
  58. description=$(jq -crM .description ${description})
  59. lv2bundles=($(jq -crM .lv2bundles[] ${pfile}))
  60. if [ "${WIN32}" -eq 1 ]; then
  61. echo "Name: ${sname}; Description: \"${name}\"; Types: full;" >> /tmp/pawpaw/components.iss
  62. elif [ "${MACOS}" -eq 1 ] && [ "${MACOS_OLD}" -eq 0 ]; then
  63. echo " <choice id=\"studio.kx.distrho.pawpaw.${sname}\" title=\"${name}\" description=\"${description}\" visible=\"true\">" >> /tmp/pawpaw/choices.xml
  64. echo " <line choice=\"studio.kx.distrho.pawpaw.${sname}\"/>" >> /tmp/pawpaw/outlines.xml
  65. fi
  66. for lv2bundle in ${lv2bundles[@]}; do
  67. if [ "${WIN32}" -eq 1 ]; then
  68. echo "Source: \"${PAWPAW_WINE_LV2DIR}${lv2bundle}\\*\"; DestDir: \"{commoncf}\\LV2\\${lv2bundle}\"; Components: ${sname}; Flags: recursesubdirs" >> /tmp/pawpaw/lv2bundles.iss
  69. elif [ "${MACOS}" -eq 1 ] && [ "${MACOS_OLD}" -eq 0 ]; then
  70. bundleref="pawpaw-bundle-${sname}-${lv2bundle}.pkg"
  71. echo " <pkg-ref id=\"studio.kx.distrho.pawpaw.${sname}_${lv2bundle}\" version=\"0\">${bundleref}</pkg-ref>" >> /tmp/pawpaw/choices.xml
  72. pkgbuild \
  73. --identifier "studio.kx.distrho.pawpaw.${sname}_${lv2bundle}" \
  74. --install-location "/Library/Audio/Plug-Ins/LV2/${lv2bundle}/" \
  75. --root "${PAWPAW_PREFIX}/lib/lv2/${lv2bundle}/" \
  76. "setup/macos/${bundleref}"
  77. fi
  78. done
  79. if [ "${MACOS}" -eq 1 ] && [ "${MACOS_OLD}" -eq 0 ]; then
  80. echo " </choice>" >> /tmp/pawpaw/choices.xml
  81. fi
  82. done
  83. if [ "${WIN32}" -eq 1 ]; then
  84. create_innosetup_exe
  85. elif [ "${MACOS}" -eq 1 ] && [ "${MACOS_OLD}" -eq 0 ]; then
  86. pushd setup/macos
  87. python -c "
  88. with open('package.xml.in', 'r') as fh:
  89. packagexml = fh.read()
  90. with open('/tmp/pawpaw/choices.xml', 'r') as fh:
  91. choicesxml = fh.read().strip()
  92. with open('/tmp/pawpaw/outlines.xml', 'r') as fh:
  93. outlinesxml = fh.read().strip()
  94. print(packagexml.replace('@CURDIR@','${PWD}').replace('@CHOICES@',choicesxml).replace('@OUTLINES@',outlinesxml))" > package.xml
  95. productbuild \
  96. --distribution package.xml \
  97. --identifier studio.kx.distrho.pawpaw \
  98. --package-path "${PWD}" \
  99. --version ${VERSION} \
  100. PawPaw-macOS-v${VERSION}.pkg
  101. rm package.xml pawpaw-bundle-*
  102. popd
  103. fi
  104. rm -rf /tmp/pawpaw
  105. # ---------------------------------------------------------------------------------------------------------------------