DISTRHO Plugin Framework
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.

135 lines
4.0KB

  1. #!/bin/bash
  2. # the realpath function is not available on some systems
  3. if ! which realpath &>/dev/null; then
  4. function realpath() {
  5. [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
  6. }
  7. fi
  8. set -e
  9. DPF_UTILS_DIR="$(dirname $(realpath ${0}))"
  10. # can be overridden by environment variables
  11. WELCOME_TXT=${WELCOME_TXT:=${DPF_UTILS_DIR}/plugin.pkg/welcome.txt.in}
  12. if [ -d bin ]; then
  13. cd bin
  14. elif [ -d build/bin ]; then
  15. cd build/bin
  16. else
  17. echo "Please run this script from the root folder"
  18. exit
  19. fi
  20. NAME="$(basename $(git rev-parse --show-toplevel))"
  21. SNAME="$(echo ${NAME} | tr -d ' ' | tr '/' '-')"
  22. SKIP_START="<!--"
  23. SKIP_END="-->"
  24. rm -rf pkg
  25. mkdir pkg
  26. ENABLE_AU=$(find . -maxdepth 1 -name '*.component' -print -quit | grep -q '.component' && echo 1 || echo)
  27. if [ -n "${ENABLE_AU}" ]; then
  28. mkdir pkg/au
  29. cp -RL *.component pkg/au/
  30. pkgbuild \
  31. --identifier "studio.kx.distrho.plugins.${SNAME}.components" \
  32. --install-location "/Library/Audio/Plug-Ins/Components/" \
  33. --root "${PWD}/pkg/au/" \
  34. ../dpf-${SNAME}-components.pkg
  35. else
  36. SKIP_AU_START="${SKIP_START}"
  37. SKIP_AU_END="${SKIP_END}"
  38. fi
  39. ENABLE_CLAP=$(find . -maxdepth 1 -name '*.clap' -print -quit | grep -q '.clap' && echo 1 || echo)
  40. if [ -n "${ENABLE_CLAP}" ]; then
  41. mkdir pkg/clap
  42. cp -RL *.clap pkg/clap/
  43. pkgbuild \
  44. --identifier "studio.kx.distrho.plugins.${SNAME}.clapbundles" \
  45. --install-location "/Library/Audio/Plug-Ins/CLAP/" \
  46. --root "${PWD}/pkg/clap/" \
  47. ../dpf-${SNAME}-clapbundles.pkg
  48. else
  49. SKIP_CLAP_START="${SKIP_START}"
  50. SKIP_CLAP_END="${SKIP_END}"
  51. fi
  52. ENABLE_LV2=$(find . -maxdepth 1 -name '*.lv2' -print -quit | grep -q '.lv2' && echo 1 || echo)
  53. if [ -n "${ENABLE_LV2}" ]; then
  54. mkdir pkg/lv2
  55. cp -RL *.lv2 pkg/lv2/
  56. pkgbuild \
  57. --identifier "studio.kx.distrho.plugins.${SNAME}.lv2bundles" \
  58. --install-location "/Library/Audio/Plug-Ins/LV2/" \
  59. --root "${PWD}/pkg/lv2/" \
  60. ../dpf-${SNAME}-lv2bundles.pkg
  61. else
  62. SKIP_LV2_START="${SKIP_START}"
  63. SKIP_LV2_END="${SKIP_END}"
  64. fi
  65. ENABLE_VST2=$(find . -maxdepth 1 -name '*.vst' -print -quit | grep -q '.vst' && echo 1 || echo)
  66. if [ -n "${ENABLE_VST2}" ]; then
  67. mkdir pkg/vst2
  68. cp -RL *.vst pkg/vst2/
  69. pkgbuild \
  70. --identifier "studio.kx.distrho.plugins.${SNAME}.vst2bundles" \
  71. --install-location "/Library/Audio/Plug-Ins/VST/" \
  72. --root "${PWD}/pkg/vst2/" \
  73. ../dpf-${SNAME}-vst2bundles.pkg
  74. else
  75. SKIP_VST2_START="${SKIP_START}"
  76. SKIP_VST2_END="${SKIP_END}"
  77. fi
  78. ENABLE_VST3=$(find . -maxdepth 1 -name '*.vst3' -print -quit | grep -q '.vst3' && echo 1 || echo)
  79. if [ -n "${ENABLE_VST3}" ]; then
  80. mkdir pkg/vst3
  81. cp -RL *.vst3 pkg/vst3/
  82. pkgbuild \
  83. --identifier "studio.kx.distrho.plugins.${SNAME}.vst3bundles" \
  84. --install-location "/Library/Audio/Plug-Ins/VST3/" \
  85. --root "${PWD}/pkg/vst3/" \
  86. ../dpf-${SNAME}-vst3bundles.pkg
  87. else
  88. SKIP_VST3_START="${SKIP_START}"
  89. SKIP_VST3_END="${SKIP_END}"
  90. fi
  91. cd ..
  92. mkdir -p build
  93. sed -e "s|@name@|${NAME}|" "${WELCOME_TXT}" > build/welcome.txt
  94. sed -e "s|@builddir@|${PWD}/build|" \
  95. -e "s|@skip_au_start@|${SKIP_AU_START}|" \
  96. -e "s|@skip_clap_start@|${SKIP_CLAP_START}|" \
  97. -e "s|@skip_lv2_start@|${SKIP_LV2_START}|" \
  98. -e "s|@skip_vst2_start@|${SKIP_VST2_START}|" \
  99. -e "s|@skip_vst3_start@|${SKIP_VST3_START}|" \
  100. -e "s|@skip_au_end@|${SKIP_AU_END}|" \
  101. -e "s|@skip_clap_end@|${SKIP_CLAP_END}|" \
  102. -e "s|@skip_lv2_end@|${SKIP_LV2_END}|" \
  103. -e "s|@skip_vst2_end@|${SKIP_VST2_END}|" \
  104. -e "s|@skip_vst3_end@|${SKIP_VST3_END}|" \
  105. -e "s|@aubundleref@|dpf-${SNAME}-components.pkg|" \
  106. -e "s|@clapbundleref@|dpf-${SNAME}-clapbundles.pkg|" \
  107. -e "s|@lv2bundleref@|dpf-${SNAME}-lv2bundles.pkg|" \
  108. -e "s|@vst2bundleref@|dpf-${SNAME}-vst2bundles.pkg|" \
  109. -e "s|@vst3bundleref@|dpf-${SNAME}-vst3bundles.pkg|" \
  110. -e "s|@name@|${NAME}|g" \
  111. -e "s|@sname@|${SNAME}|g" \
  112. ${DPF_UTILS_DIR}/plugin.pkg/package.xml.in > build/package.xml
  113. productbuild \
  114. --distribution build/package.xml \
  115. --identifier "studio.kx.distrho.${SNAME}" \
  116. --package-path "${PWD}" \
  117. --version 0 \
  118. ${SNAME}-macOS.pkg