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.

341 lines
12KB

  1. #!/bin/bash
  2. set -e
  3. cd $(dirname ${0})
  4. PAWPAW_ROOT="${PWD}"
  5. # ---------------------------------------------------------------------------------------------------------------------
  6. # check target
  7. target="${1}"
  8. if [ -z "${target}" ]; then
  9. echo "usage: ${0} <target>"
  10. exit 1
  11. fi
  12. # ---------------------------------------------------------------------------------------------------------------------
  13. # run bootstrap dependencies
  14. ./bootstrap-common.sh "${target}"
  15. # ---------------------------------------------------------------------------------------------------------------------
  16. # source setup code
  17. source setup/check_target.sh
  18. source setup/env.sh
  19. source setup/functions.sh
  20. source setup/versions.sh
  21. # ---------------------------------------------------------------------------------------------------------------------
  22. # qt package suffix changes depending on the version
  23. if [ "${QT5_MVERSION}" = "5.12" ]; then
  24. qtsuffix="-everywhere-src"
  25. else
  26. qtsuffix="-opensource-src"
  27. fi
  28. # ---------------------------------------------------------------------------------------------------------------------
  29. # custom functions for qt handling
  30. function download_qt() {
  31. local name="${1}"
  32. local dlfile="${PAWPAW_DOWNLOADDIR}/${name}${qtsuffix}-${QT5_VERSION}.tar.xz"
  33. local dlfolder="${PAWPAW_BUILDDIR}/${name}${qtsuffix}-${QT5_VERSION}"
  34. if [ ! -f "${dlfile}" ]; then
  35. dlurl="https://download.qt.io/archive/qt/${QT5_MVERSION}/${QT5_VERSION}/submodules/${name}${qtsuffix}-${QT5_VERSION}.tar.xz"
  36. curl -L "${dlurl}" -o "${dlfile}"
  37. fi
  38. if [ ! -d "${dlfolder}" ]; then
  39. mkdir "${dlfolder}"
  40. tar -xf "${dlfile}" -C "${dlfolder}" --strip-components=1
  41. fi
  42. }
  43. function build_qt_conf() {
  44. local name="${1}"
  45. local extraconfrules="${2}"
  46. local pkgdir="${PAWPAW_BUILDDIR}/${name}${qtsuffix}-${QT5_VERSION}"
  47. unset AR
  48. unset CC
  49. unset CXX
  50. unset LD
  51. unset STRIP
  52. unset CFLAGS
  53. unset CPPFLAGS
  54. unset CXXFLAGS
  55. unset LDFLAGS
  56. export PKG_CONFIG="${TARGET_PKG_CONFIG}"
  57. export PKG_CONFIG_LIBDIR="${TARGET_PKG_CONFIG_PATH}"
  58. export PKG_CONFIG_PATH="${TARGET_PKG_CONFIG_PATH}"
  59. export PKG_CONFIG_SYSROOT_DIR="/"
  60. if [ -d "${PAWPAW_ROOT}/patches/${name}" ]; then
  61. for p in $(ls "${PAWPAW_ROOT}/patches/${name}/" | grep "\.patch" | sort); do
  62. if [ ! -f "${pkgdir}/.stamp_applied_${p}" ]; then
  63. patch -p1 -d "${pkgdir}" -i "${PAWPAW_ROOT}/patches/${name}/${p}"
  64. touch "${pkgdir}/.stamp_applied_${p}"
  65. fi
  66. done
  67. fi
  68. if [ -d "${PAWPAW_ROOT}/patches/${name}/${PAWPAW_TARGET}" ]; then
  69. for p in $(ls "${PAWPAW_ROOT}/patches/${name}/${PAWPAW_TARGET}/" | grep "\.patch" | sort); do
  70. if [ ! -f "${pkgdir}/.stamp_applied_${p}" ]; then
  71. patch -p1 -d "${pkgdir}" -i "${PAWPAW_ROOT}/patches/${name}/${PAWPAW_TARGET}/${p}"
  72. touch "${pkgdir}/.stamp_applied_${p}"
  73. fi
  74. done
  75. fi
  76. if [ ! -f "${pkgdir}/.stamp_configured" ]; then
  77. pushd "${pkgdir}"
  78. ./configure ${extraconfrules}
  79. touch .stamp_configured
  80. popd
  81. fi
  82. if [ ! -f "${pkgdir}/.stamp_built" ]; then
  83. pushd "${pkgdir}"
  84. # NOTE: Qt win32 builds are very verbose, too many warnings, which makes CI build fail
  85. if [ "${WIN32}" -eq 1 ] && [ -n "${TRAVIS_BUILD_DIR}" ]; then
  86. make ${MAKE_ARGS} 2>/dev/null
  87. else
  88. make ${MAKE_ARGS}
  89. fi
  90. touch .stamp_built
  91. popd
  92. fi
  93. if [ ! -f "${pkgdir}/.stamp_installed" ]; then
  94. pushd "${pkgdir}"
  95. make ${MAKE_ARGS} -j 1 install
  96. if [ "${WIN32}" -eq 1 ]; then
  97. sed -i -e "s|d ||" ${PAWPAW_PREFIX}/lib/pkgconfig/Qt5*.pc
  98. fi
  99. touch .stamp_installed
  100. popd
  101. fi
  102. unset PKG_CONFIG
  103. unset PKG_CONFIG_LIBDIR
  104. unset PKG_CONFIG_PATH
  105. unset PKG_CONFIG_SYSROOT_DIR
  106. }
  107. # ---------------------------------------------------------------------------------------------------------------------
  108. # NOTE: on CI, qt build takes too long on macos-universal target, download and use premade builds
  109. if [ -n "${TRAVIS_BUILD_DIR}" ] && [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  110. mkdir -p "${PAWPAW_BUILDDIR}/qtbase${qtsuffix}-${QT5_VERSION}"
  111. touch "${PAWPAW_BUILDDIR}/qtbase${qtsuffix}-${QT5_VERSION}/.stamp_configured"
  112. touch "${PAWPAW_BUILDDIR}/qtbase${qtsuffix}-${QT5_VERSION}/.stamp_built"
  113. touch "${PAWPAW_BUILDDIR}/qtbase${qtsuffix}-${QT5_VERSION}/.stamp_installed"
  114. touch "${PAWPAW_BUILDDIR}/qtbase${qtsuffix}-${QT5_VERSION}/.stamp_applied_01_force-10.12-universal-build.patch"
  115. mkdir -p "${PAWPAW_BUILDDIR}/qtmacextras${qtsuffix}-${QT5_VERSION}"
  116. touch "${PAWPAW_BUILDDIR}/qtmacextras${qtsuffix}-${QT5_VERSION}/.stamp_configured"
  117. touch "${PAWPAW_BUILDDIR}/qtmacextras${qtsuffix}-${QT5_VERSION}/.stamp_built"
  118. touch "${PAWPAW_BUILDDIR}/qtmacextras${qtsuffix}-${QT5_VERSION}/.stamp_installed"
  119. mkdir -p "${PAWPAW_BUILDDIR}/qtsvg${qtsuffix}-${QT5_VERSION}"
  120. touch "${PAWPAW_BUILDDIR}/qtsvg${qtsuffix}-${QT5_VERSION}/.stamp_configured"
  121. touch "${PAWPAW_BUILDDIR}/qtsvg${qtsuffix}-${QT5_VERSION}/.stamp_built"
  122. touch "${PAWPAW_BUILDDIR}/qtsvg${qtsuffix}-${QT5_VERSION}/.stamp_installed"
  123. mkdir -p "${PAWPAW_BUILDDIR}/qttools${qtsuffix}-${QT5_VERSION}"
  124. touch "${PAWPAW_BUILDDIR}/qttools${qtsuffix}-${QT5_VERSION}/.stamp_configured"
  125. touch "${PAWPAW_BUILDDIR}/qttools${qtsuffix}-${QT5_VERSION}/.stamp_built"
  126. touch "${PAWPAW_BUILDDIR}/qttools${qtsuffix}-${QT5_VERSION}/.stamp_installed"
  127. pushd "${PAWPAW_DIR}/targets"
  128. curl -L "https://falktx.com/data/pawpaw-qt-macos-universal.tar.xz" -o "pawpaw-qt-macos-universal.tar.xz" --fail
  129. tar xvf pawpaw-qt-macos-universal.tar.xz
  130. popd
  131. fi
  132. # ---------------------------------------------------------------------------------------------------------------------
  133. # qt config
  134. # base
  135. qtbase_conf_args="-opensource -confirm-license"
  136. qtbase_conf_args+=" -c++std"
  137. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  138. qtbase_conf_args+=" c++14"
  139. else
  140. qtbase_conf_args+=" c++11"
  141. fi
  142. # qtbase_conf_args+=" -optimized-qmake"
  143. qtbase_conf_args+=" -optimize-size"
  144. qtbase_conf_args+=" -release -strip"
  145. # qtbase_conf_args+=" -static"
  146. qtbase_conf_args+=" -shared"
  147. qtbase_conf_args+=" -silent"
  148. # qtbase_conf_args+=" -verbose"
  149. # build type
  150. qtbase_conf_args+=" -make libs"
  151. qtbase_conf_args+=" -make tools"
  152. qtbase_conf_args+=" -gui"
  153. qtbase_conf_args+=" -widgets"
  154. # paths
  155. qtbase_conf_args+=" -prefix ${PAWPAW_PREFIX}"
  156. qtbase_conf_args+=" -headerdir ${PAWPAW_PREFIX}/include/qt5"
  157. qtbase_conf_args+=" -libexecdir ${PAWPAW_PREFIX}/libexec"
  158. qtbase_conf_args+=" -plugindir ${PAWPAW_PREFIX}/lib/qt5/plugins"
  159. # enable optimizations (sse2 only)
  160. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  161. # TODO SSE2 and NEON
  162. qtbase_conf_args+=" -no-sse2"
  163. else
  164. qtbase_conf_args+=" -sse2"
  165. fi
  166. qtbase_conf_args+=" -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 -no-avx -no-avx2 -no-avx512"
  167. # enable some basic stuff
  168. qtbase_conf_args+=" -opengl desktop"
  169. qtbase_conf_args+=" -qt-doubleconversion"
  170. qtbase_conf_args+=" -qt-pcre"
  171. qtbase_conf_args+=" -qt-sqlite"
  172. # disable examples and tests
  173. qtbase_conf_args+=" -nomake examples"
  174. qtbase_conf_args+=" -nomake tests"
  175. qtbase_conf_args+=" -no-compile-examples"
  176. # disable a couple of things
  177. qtbase_conf_args+=" -no-cups"
  178. qtbase_conf_args+=" -no-dbus"
  179. qtbase_conf_args+=" -no-directfb"
  180. qtbase_conf_args+=" -no-eglfs"
  181. qtbase_conf_args+=" -no-evdev"
  182. qtbase_conf_args+=" -no-eventfd"
  183. qtbase_conf_args+=" -no-journald"
  184. qtbase_conf_args+=" -no-glib"
  185. qtbase_conf_args+=" -no-gtk"
  186. qtbase_conf_args+=" -no-icu"
  187. qtbase_conf_args+=" -no-inotify"
  188. qtbase_conf_args+=" -no-libinput"
  189. qtbase_conf_args+=" -no-libproxy"
  190. qtbase_conf_args+=" -no-mtdev"
  191. qtbase_conf_args+=" -no-openssl"
  192. qtbase_conf_args+=" -no-pch"
  193. qtbase_conf_args+=" -no-sctp"
  194. qtbase_conf_args+=" -no-securetransport"
  195. qtbase_conf_args+=" -no-syslog"
  196. qtbase_conf_args+=" -no-tslib"
  197. if [ "${QT5_MVERSION}" = "5.9" ]; then
  198. qtbase_conf_args+=" -no-xinput2"
  199. qtbase_conf_args+=" -no-xkbcommon-evdev"
  200. qtbase_conf_args+=" -no-xkbcommon-x11"
  201. fi
  202. # font stuff
  203. qtbase_conf_args+=" -qt-freetype"
  204. qtbase_conf_args+=" -no-fontconfig"
  205. qtbase_conf_args+=" -no-harfbuzz"
  206. # supported image formats
  207. qtbase_conf_args+=" -qt-libjpeg"
  208. qtbase_conf_args+=" -qt-libpng"
  209. qtbase_conf_args+=" -no-gif"
  210. qtbase_conf_args+=" -no-ico"
  211. # use pkg-config
  212. qtbase_conf_args+=" -pkg-config"
  213. qtbase_conf_args+=" -force-pkg-config"
  214. # platform specific
  215. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  216. if [ "${LINUX}" -eq 1 ]; then
  217. qtbase_conf_args+=" -xplatform linux-g++"
  218. elif [ "${MACOS}" -eq 1 ]; then
  219. qtbase_conf_args+=" -xplatform macx-clang"
  220. elif [ "${WIN32}" -eq 1 ]; then
  221. qtbase_conf_args+=" -xplatform win32-g++"
  222. fi
  223. qtbase_conf_args+=" -device-option CROSS_COMPILE=${TOOLCHAIN_PREFIX_}"
  224. else
  225. if [ "${LINUX}" -eq 1 ]; then
  226. qtbase_conf_args+=" -platform linux-g++"
  227. elif [ "${MACOS}" -eq 1 ]; then
  228. qtbase_conf_args+=" -platform macx-clang"
  229. elif [ "${WIN32}" -eq 1 ]; then
  230. qtbase_conf_args+=" -platform win32-g++"
  231. fi
  232. fi
  233. # platform specific
  234. if [ "${LINUX}" -eq 1 ]; then
  235. qtbase_conf_args+=" -qpa xcb"
  236. qtbase_conf_args+=" -qt-xcb"
  237. qtbase_conf_args+=" -xcb-xlib"
  238. elif [ "${MACOS}" -eq 1 ]; then
  239. qtbase_conf_args+=" -qpa cocoa"
  240. elif [ "${WIN32}" -eq 1 ]; then
  241. qtbase_conf_args+=" -qpa windows"
  242. fi
  243. # zlib
  244. if [ "${MACOS}" -eq 1 ]; then
  245. qtbase_conf_args+=" -system-zlib"
  246. else
  247. qtbase_conf_args+=" -qt-zlib"
  248. fi
  249. # ---------------------------------------------------------------------------------------------------------------------
  250. # qt build
  251. download_qt qtbase
  252. if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  253. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/common/macx.conf" 's/QMAKE_APPLE_DEVICE_ARCHS = x86_64/QMAKE_APPLE_DEVICE_ARCHS = arm64 x86_64/'
  254. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/common/macx.conf" 's/QT_MAC_SDK_VERSION_MIN = 10.13/QT_MAC_SDK_VERSION_MIN = 10.12/'
  255. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/common/macx.conf" 's/QT_MAC_SDK_VERSION_MAX = 10.15/QT_MAC_SDK_VERSION_MAX = 10.12/'
  256. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/features/toolchain.prf" 's/-arch $$QMAKE_APPLE_DEVICE_ARCHS/-arch arm64/'
  257. elif [ "${MACOS}" -eq 1 ]; then
  258. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/macx-clang/qmake.conf" 's/10.10/10.8/'
  259. fi
  260. if [ "${WIN32}" -eq 1 ]; then
  261. patch_file qtbase${qtsuffix} ${QT5_VERSION} "mkspecs/win32-g++/qmake.conf" 's/= -shared/= -static -shared/'
  262. patch_file qtbase${qtsuffix} ${QT5_VERSION} "src/plugins/platforms/direct2d/direct2d.pro" 's/-lVersion/-lversion/'
  263. fi
  264. build_qt_conf qtbase "${qtbase_conf_args}"
  265. if [ "${MACOS}" -eq 1 ] && [ ! -e "${PAWPAW_PREFIX}/include/qt5/QtWidgets" ]; then
  266. ln -sfv ${PAWPAW_PREFIX}/lib/QtCore.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtCore
  267. ln -sfv ${PAWPAW_PREFIX}/lib/QtGui.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtGui
  268. ln -sfv ${PAWPAW_PREFIX}/lib/QtWidgets.framework/Headers ${PAWPAW_PREFIX}/include/qt5/QtWidgets
  269. fi
  270. # ---------------------------------------------------------------------------------------------------------------------
  271. # qtmacextras
  272. if [ "${MACOS}" -eq 1 ]; then
  273. download_qt qtmacextras
  274. build_qmake qtmacextras${qtsuffix} ${QT5_VERSION}
  275. fi
  276. # ---------------------------------------------------------------------------------------------------------------------
  277. # qtsvg
  278. download_qt qtsvg
  279. build_qmake qtsvg${qtsuffix} ${QT5_VERSION}
  280. # ---------------------------------------------------------------------------------------------------------------------
  281. # qttools (host only, thus not needed if cross-compiling)
  282. if [ "${CROSS_COMPILING}" -eq 0 ]; then
  283. download_qt qttools
  284. build_qmake qttools${qtsuffix} ${QT5_VERSION}
  285. fi
  286. # ---------------------------------------------------------------------------------------------------------------------