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.

build-plugins.sh 6.2KB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. # TODO check that bootstrap.sh has been run
  13. # ---------------------------------------------------------------------------------------------------------------------
  14. source setup/check_target.sh
  15. source setup/env.sh
  16. source setup/functions.sh
  17. source setup/versions.sh
  18. # ---------------------------------------------------------------------------------------------------------------------
  19. LV2DIR="${PAWPAW_PREFIX}/lib/lv2"
  20. if [ "${WIN32}" -eq 1 ] && [ -n "${EXE_WRAPPER}" ] && [ ! -d "${WINEPREFIX}" ]; then
  21. wineboot -u
  22. fi
  23. function validate_lv2_bundles() {
  24. local lv2bundles=(${@})
  25. rm -rf /tmp/pawpaw-plugin-check
  26. mkdir /tmp/pawpaw-plugin-check
  27. # FIXME lv2 validation fails on base64 with newlines
  28. cp -r "${LV2DIR}/${lv2bundles[0]}" /tmp/pawpaw-plugin-check/
  29. #for lv2bundle in ${lv2bundles[@]}; do
  30. # cp -r "${LV2DIR}/${lv2bundle}" /tmp/pawpaw-plugin-check/
  31. #done
  32. env LANG=C LV2_PATH="${LV2DIR}" PATH="${PAWPAW_PREFIX}/bin:${PATH}" WINEDEBUG=-all \
  33. APP_EXT="${APP_EXT}" EXE_WRAPPER="${EXE_WRAPPER}" PAWPAW_PREFIX="${PAWPAW_PREFIX}" \
  34. "${PAWPAW_PREFIX}/bin/lv2_validate" \
  35. "${LV2DIR}/kx-*/*.ttl" \
  36. "${LV2DIR}/mod.lv2/*.ttl" \
  37. "${LV2DIR}/modgui.lv2/*.ttl" \
  38. "/tmp/pawpaw-plugin-check/*/*.ttl" 1>&2
  39. local ret=$?
  40. if [ "${CROSS_COMPILING}" -eq 0 ] || [ -n "${EXE_WRAPPER}" ]; then
  41. env LANG=C LV2_PATH=/tmp/pawpaw-plugin-check WINEDEBUG=-all \
  42. ${EXE_WRAPPER} \
  43. "${PAWPAW_PREFIX}/bin/lv2ls${APP_EXT}" | tr -d '\r'
  44. fi
  45. rm -rf /tmp/pawpaw-plugin-check
  46. return ${ret}
  47. }
  48. function validate_lv2_plugin() {
  49. local lv2plugin="${1}"
  50. local carlaenv="CARLA_BRIDGE_DUMMY=1"
  51. if [ "${WIN64}" -eq 1 ]; then
  52. carlaenv+=" CARLA_BRIDGE_TESTING=win64"
  53. elif [ "${WIN32}" -eq 1 ]; then
  54. carlaenv+=" CARLA_BRIDGE_TESTING=win32"
  55. else
  56. carlaenv+=" CARLA_BRIDGE_TESTING=native"
  57. fi
  58. env LANG=C LV2_PATH="${LV2DIR}" WINEDEBUG=-all ${carlaenv} \
  59. "${PAWPAW_PREFIX}/bin/carla-single" lv2 "${lv2plugin}" 1>/dev/null
  60. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  61. env LANG=C LV2_PATH="${LV2DIR}" ${carlaenv} \
  62. arch -arch x86_64 "${PAWPAW_PREFIX}/bin/carla-single" lv2 "${lv2plugin}" 1>/dev/null
  63. fi
  64. }
  65. # ---------------------------------------------------------------------------------------------------------------------
  66. exitcode=0
  67. for plugin in ${@}; do
  68. pfile="${PAWPAW_ROOT}/plugins/${plugin}.json"
  69. if [ ! -e "${pfile}" ]; then
  70. echo "Requested plugin file '${pfile}' does not exist"
  71. exit 2
  72. fi
  73. name=$(jq -crM .name ${pfile})
  74. version=$(jq -crM .version ${pfile})
  75. buildtype=$(jq -crM .buildtype ${pfile})
  76. dlbaseurl=$(jq -crM .dlbaseurl ${pfile})
  77. lv2bundles=($(jq -crM .lv2bundles[] ${pfile}))
  78. # optional args
  79. buildargs=$(echo -e $(jq -ecrM .buildargs ${pfile} || echo '\n\n') | tail -n 1)
  80. dlext=$(echo -e $(jq -ecrM .dlext ${pfile} || echo '\n\n') | tail -n 1)
  81. dlmethod=$(echo -e $(jq -ecrM .dlmethod ${pfile} || echo '\n\n') | tail -n 1)
  82. dlname=$(echo -e $(jq -ecrM .dlname ${pfile} || echo '\n\n') | tail -n 1)
  83. combinedbundles=$(echo -e $(jq -ecrM .combinedbundles ${pfile} || echo '\n\n') | tail -n 1)
  84. download "${name}" "${version}" "${dlbaseurl}" "${dlext}" "${dlmethod}" "${dlname}"
  85. case ${buildtype} in
  86. "autoconf")
  87. build_autoconf "${name}" "${version}" "${buildargs}"
  88. ;;
  89. "conf")
  90. build_conf "${name}" "${version}" "${buildargs}"
  91. ;;
  92. "cmake")
  93. build_cmake "${name}" "${version}" "${buildargs}"
  94. ;;
  95. "make")
  96. build_make "${name}" "${version}" "${buildargs}"
  97. ;;
  98. "meson")
  99. build_meson "${name}" "${version}" "${buildargs}"
  100. ;;
  101. "waf")
  102. build_waf "${name}" "${version}" "${buildargs}"
  103. ;;
  104. esac
  105. # check if plugin needs validation
  106. pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"
  107. if [ -f "${pkgdir}/.stamp_verified" ]; then
  108. continue
  109. fi
  110. # cannot run validation on certain setups
  111. if [ "${CROSS_COMPILING}" -eq 1 ] && [ -z "${EXE_WRAPPER}" ]; then
  112. continue
  113. fi
  114. # validate all bundles
  115. validationfail=0
  116. if [ "${combinedbundles}" = "true" ]; then
  117. lv2bundle=${lv2bundles[0]}
  118. echo -n "Validating ${lv2bundle}... "
  119. if [ ! -f "${LV2DIR}/${lv2bundle}/manifest.ttl" ]; then
  120. echo "manifest.ttl file missing"
  121. exitcode=1
  122. validationfail=1
  123. continue
  124. fi
  125. echo
  126. # lv2 metadata validation
  127. lv2plugins=($(validate_lv2_bundles ${lv2bundles[@]}))
  128. # lv2 plugin count
  129. echo "Found ${#lv2plugins[@]} plugin(s)"
  130. # real host test
  131. for lv2plugin in ${lv2plugins[@]}; do
  132. echo -n "Verifying ${lv2plugin}... "
  133. validate_lv2_plugin ${lv2plugin}
  134. echo "ok"
  135. done
  136. else
  137. for lv2bundle in ${lv2bundles[@]}; do
  138. echo -n "Validating ${lv2bundle}... "
  139. if [ ! -f "${LV2DIR}/${lv2bundle}/manifest.ttl" ]; then
  140. echo "manifest.ttl file missing"
  141. exitcode=1
  142. validationfail=1
  143. continue
  144. fi
  145. echo
  146. # lv2 metadata validation
  147. lv2plugins=($(validate_lv2_bundles "${lv2bundle}"))
  148. # lv2 plugin count
  149. echo "Found ${#lv2plugins[@]} plugin(s)"
  150. # real host test
  151. for lv2plugin in ${lv2plugins[@]}; do
  152. echo -n "Verifying ${lv2plugin}... "
  153. validate_lv2_plugin ${lv2plugin}
  154. echo "ok"
  155. done
  156. done
  157. fi
  158. if [ "${validationfail}" -eq 0 ]; then
  159. touch "${pkgdir}/.stamp_verified"
  160. fi
  161. done
  162. exit ${exitcode}
  163. # ---------------------------------------------------------------------------------------------------------------------