01_install_dependencies.sh 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. #!/bin/bash
  2. ##############################################################################
  3. # macOS dependency management function
  4. ##############################################################################
  5. #
  6. # This script file can be included in build scripts for macOS or run directly.
  7. #
  8. ##############################################################################
  9. # Halt on errors
  10. set -eE
  11. install_obs-deps() {
  12. status "Set up precompiled macOS OBS dependencies v${1}"
  13. ensure_dir "${DEPS_BUILD_DIR}"
  14. step "Download..."
  15. ${CURLCMD:-curl} https://github.com/obsproject/obs-deps/releases/download/${1}/macos-deps-${1}.tar.gz
  16. step "Unpack..."
  17. /usr/bin/tar -xf "./macos-deps-${1}.tar.gz" -C /tmp
  18. }
  19. install_qt-deps() {
  20. status "Set up precompiled dependency Qt v${1}"
  21. ensure_dir "${DEPS_BUILD_DIR}"
  22. step "Download..."
  23. ${CURLCMD:-curl} https://github.com/obsproject/obs-deps/releases/download/${2}/macos-qt-${1}-${2}.tar.gz
  24. step "Unpack..."
  25. /usr/bin/tar -xf ./macos-qt-${1}-${2}.tar.gz -C /tmp
  26. /usr/bin/xattr -r -d com.apple.quarantine /tmp/obsdeps
  27. }
  28. install_vlc() {
  29. status "Set up dependency VLC v${1}"
  30. ensure_dir "${DEPS_BUILD_DIR}"
  31. unset _SKIP
  32. if [ "${CI}" -a "${RESTORED_VLC}" ]; then
  33. _SKIP=TRUE
  34. elif [ -d "${DEPS_BUILD_DIR}/vlc-${1}" -a -f "${DEPS_BUILD_DIR}/vlc-${1}/include/vlc/vlc.h" ]; then
  35. _SKIP=TRUE
  36. fi
  37. if [ -z "${_SKIP}" ]; then
  38. step "Download..."
  39. check_and_fetch "https://downloads.videolan.org/vlc/${1}/vlc-${1}.tar.xz" "${2}"
  40. step "Unpack..."
  41. /usr/bin/tar -xf vlc-${1}.tar.xz
  42. else
  43. step "Found existing VLC..."
  44. fi
  45. }
  46. install_sparkle() {
  47. status "Set up dependency Sparkle v${1}"
  48. ensure_dir "${DEPS_BUILD_DIR}"
  49. unset _SKIP
  50. if [ "${CI}" -a "${RESTORED_SPARKLE}" ]; then
  51. _SKIP=TRUE
  52. elif [ -d "${DEPS_BUILD_DIR}/sparkle/Sparkle.framework" -a -f "${DEPS_BUILD_DIR}/sparkle/Sparkle.framework/Sparkle" ]; then
  53. _SKIP=TRUE
  54. fi
  55. if [ -z "${_SKIP}" ]; then
  56. step "Download..."
  57. ${CURLCMD:-curl} https://github.com/sparkle-project/Sparkle/releases/download/${1}/Sparkle-${1}.tar.xz
  58. step "Unpack..."
  59. ensure_dir "${DEPS_BUILD_DIR}/sparkle"
  60. /usr/bin/tar -xf ../Sparkle-${1}.tar.xz
  61. else
  62. step "Found existing Sparkle Framework..."
  63. fi
  64. }
  65. install_cef() {
  66. status "Set up dependency CEF v${1}"
  67. ensure_dir "${DEPS_BUILD_DIR}"
  68. unset _SKIP
  69. if [ "${CI}" -a "${RESTORED_CEF}" ]; then
  70. _SKIP=TRUE
  71. elif [ -d "${DEPS_BUILD_DIR}/cef_binary_${1}_macos_${ARCH:-x86_64}" -a -f "${DEPS_BUILD_DIR}/cef_binary_${1}_macos_${ARCH:-x86_64}/build/libcef_dll_wrapper/libcef_dll_wrapper.a" ]; then
  72. _SKIP=TRUE
  73. fi
  74. if [ -z "${_SKIP}" ]; then
  75. step "Download..."
  76. ${CURLCMD:-curl} https://cdn-fastly.obsproject.com/downloads/cef_binary_${1}_macos_${ARCH:-x86_64}.tar.xz
  77. step "Unpack..."
  78. /usr/bin/tar -xf cef_binary_${1}_macos_${ARCH:-x86_64}.tar.xz
  79. cd cef_binary_${1}_macos_${ARCH:-x86_64}
  80. step "Fix tests..."
  81. /usr/bin/sed -i '.orig' '/add_subdirectory(tests\/ceftests)/d' ./CMakeLists.txt
  82. /usr/bin/sed -E -i '' 's/"10.(9|10)"/"'${MACOSX_DEPLOYMENT_TARGET:-${CI_MACOSX_DEPLOYMENT_TARGET}}'"/' ./cmake/cef_variables.cmake
  83. step "Run CMake..."
  84. check_ccache
  85. cmake ${CCACHE_OPTIONS} ${QUIET:+-Wno-deprecated -Wno-dev --log-level=ERROR} \
  86. -S . -B build \
  87. -G Ninja \
  88. -DPROJECT_ARCH=${CMAKE_ARCHS:-x86_64} \
  89. -DCEF_COMPILER_FLAGS="-Wno-deprecated-copy" \
  90. -DCMAKE_BUILD_TYPE=Release \
  91. -DCMAKE_CXX_FLAGS="-std=c++11 -stdlib=libc++ -Wno-deprecated-declarations -Wno-unknown-warning-option" \
  92. -DCMAKE_EXE_LINKER_FLAGS="-std=c++11 -stdlib=libc++" \
  93. -DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-${CI_MACOSX_DEPLOYMENT_TARGET}}
  94. step "Build CEF v${1}..."
  95. cmake --build build
  96. mkdir -p build/libcef_dll
  97. else
  98. step "Found existing Chromium Embedded Framework and loader library..."
  99. fi
  100. }
  101. install_dependencies() {
  102. status "Install Homebrew dependencies"
  103. trap "caught_error 'install_dependencies'" ERR
  104. BUILD_DEPS=(
  105. "obs-deps ${MACOS_DEPS_VERSION:-${CI_DEPS_VERSION}}"
  106. "qt-deps ${QT_VERSION:-${CI_QT_VERSION}} ${MACOS_DEPS_VERSION:-${CI_DEPS_VERSION}}"
  107. "cef ${MACOS_CEF_BUILD_VERSION:-${CI_MACOS_CEF_VERSION}}"
  108. "vlc ${VLC_VERSION:-${CI_VLC_VERSION}}"
  109. "sparkle ${SPARKLE_VERSION:-${CI_SPARKLE_VERSION}}"
  110. )
  111. install_homebrew_deps
  112. for DEPENDENCY in "${BUILD_DEPS[@]}"; do
  113. set -- ${DEPENDENCY}
  114. trap "caught_error ${DEPENDENCY}" ERR
  115. FUNC_NAME="install_${1}"
  116. ${FUNC_NAME} ${2} ${3}
  117. done
  118. }
  119. install-dependencies-standalone() {
  120. CHECKOUT_DIR="$(/usr/bin/git rev-parse --show-toplevel)"
  121. PRODUCT_NAME="OBS-Studio"
  122. DEPS_BUILD_DIR="${CHECKOUT_DIR}/../obs-build-dependencies"
  123. source "${CHECKOUT_DIR}/CI/include/build_support.sh"
  124. source "${CHECKOUT_DIR}/CI/include/build_support_macos.sh"
  125. status "Setup of OBS build dependencies"
  126. check_macos_version
  127. check_archs
  128. install_dependencies
  129. }
  130. print_usage() {
  131. echo -e "Usage: ${0}\n" \
  132. "-h, --help : Print this help\n" \
  133. "-q, --quiet : Suppress most build process output\n" \
  134. "-v, --verbose : Enable more verbose build process output\n" \
  135. "-a, --architecture : Specify build architecture (default: x86_64, alternative: arm64)\n"
  136. }
  137. install-dependencies-main() {
  138. if [ -z "${_RUN_OBS_BUILD_SCRIPT}" ]; then
  139. while true; do
  140. case "${1}" in
  141. -h | --help ) print_usage; exit 0 ;;
  142. -q | --quiet ) export QUIET=TRUE; shift ;;
  143. -v | --verbose ) export VERBOSE=TRUE; shift ;;
  144. -a | --architecture ) ARCH="${2}"; shift 2 ;;
  145. -- ) shift; break ;;
  146. * ) break ;;
  147. esac
  148. done
  149. install-dependencies-standalone
  150. fi
  151. }
  152. install-dependencies-main $*