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.

154 lines
5.2KB

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