01_install_dependencies.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. check_and_fetch "https://github.com/obsproject/obs-deps/releases/download/${1}/macos-deps-${1}-universal.tar.xz" "${2}"
  16. mkdir -p obs-deps
  17. step "Unpack..."
  18. /usr/bin/tar -xf "./macos-deps-${1}-universal.tar.xz" -C ./obs-deps
  19. /usr/bin/xattr -r -d com.apple.quarantine ./obs-deps
  20. }
  21. install_qt-deps() {
  22. status "Set up precompiled dependency Qt v${1}"
  23. ensure_dir "${DEPS_BUILD_DIR}"
  24. step "Download..."
  25. check_and_fetch "https://github.com/obsproject/obs-deps/releases/download/${1}/macos-deps-qt-${1}-universal.tar.xz" "${2}"
  26. mkdir -p obs-deps
  27. step "Unpack..."
  28. /usr/bin/tar -xf "./macos-deps-qt-${1}-universal.tar.xz" -C ./obs-deps
  29. /usr/bin/xattr -r -d com.apple.quarantine ./obs-deps
  30. }
  31. install_obs-studio() {
  32. if [ "${OBS_BRANCH}" ]; then
  33. CHECKOUT_REF="${OBS_BRANCH}"
  34. else
  35. CHECKOUT_REF="tags/${OBS_VERSION:-${CI_OBS_VERSION}}"
  36. fi
  37. ensure_dir "${OBS_BUILD_DIR}"
  38. if [ ! -d "${OBS_BUILD_DIR}/.git" ]; then
  39. /usr/bin/git clone --recursive https://github.com/obsproject/obs-studio "$(pwd)"
  40. /usr/bin/git fetch origin --tags
  41. /usr/bin/git checkout ${CHECKOUT_REF} -b obs-plugin-build
  42. else
  43. if ! /usr/bin/git show-ref --verify --quiet refs/heads/obs-plugin-build; then
  44. /usr/bin/git checkout ${CHECKOUT_REF} -b obs-plugin-build
  45. else
  46. /usr/bin/git checkout obs-plugin-build
  47. fi
  48. fi
  49. }
  50. install_dependencies() {
  51. status "Installing Homebrew dependencies"
  52. trap "caught_error 'install_dependencies'" ERR
  53. BUILD_DEPS=(
  54. "obs-deps ${MACOS_DEPS_VERSION:-${CI_DEPS_VERSION}} ${MACOS_DEPS_HASH:-${CI_DEPS_HASH}}"
  55. "qt-deps ${MACOS_DEPS_VERSION:-${CI_DEPS_VERSION}} ${QT_HASH:-${CI_QT_HASH}}"
  56. "obs-studio ${OBS_VERSION:-${CI_OBS_VERSION}}"
  57. )
  58. install_homebrew_deps
  59. for DEPENDENCY in "${BUILD_DEPS[@]}"; do
  60. set -- ${DEPENDENCY}
  61. trap "caught_error ${DEPENDENCY}" ERR
  62. FUNC_NAME="install_${1}"
  63. ${FUNC_NAME} ${2} ${3}
  64. done
  65. }
  66. install-dependencies-standalone() {
  67. CHECKOUT_DIR="$(/usr/bin/git rev-parse --show-toplevel)"
  68. if [ -f "${CHECKOUT_DIR}/CI/include/build_environment.sh" ]; then
  69. source "${CHECKOUT_DIR}/CI/include/build_environment.sh"
  70. fi
  71. PRODUCT_NAME="${PRODUCT_NAME:-obs-plugin}"
  72. DEPS_BUILD_DIR="${CHECKOUT_DIR}/../obs-build-dependencies"
  73. OBS_BUILD_DIR="${CHECKOUT_DIR}/../obs-studio"
  74. source "${CHECKOUT_DIR}/CI/include/build_support.sh"
  75. source "${CHECKOUT_DIR}/CI/include/build_support_macos.sh"
  76. status "Setting up plugin build dependencies"
  77. check_macos_version
  78. check_archs
  79. install_dependencies
  80. }
  81. print_usage() {
  82. echo -e "Usage: ${0}\n" \
  83. "-h, --help : Print this help\n" \
  84. "-q, --quiet : Suppress most build process output\n" \
  85. "-v, --verbose : Enable more verbose build process output\n" \
  86. "-a, --architecture : Specify build architecture (default: universal, alternative: x86_64, arm64)\n"
  87. }
  88. install-dependencies-main() {
  89. if [ -z "${_RUN_OBS_BUILD_SCRIPT}" ]; then
  90. while true; do
  91. case "${1}" in
  92. -h | --help ) print_usage; exit 0 ;;
  93. -q | --quiet ) export QUIET=TRUE; shift ;;
  94. -v | --verbose ) export VERBOSE=TRUE; shift ;;
  95. -a | --architecture ) ARCH="${2}"; shift 2 ;;
  96. -- ) shift; break ;;
  97. * ) break ;;
  98. esac
  99. done
  100. install-dependencies-standalone
  101. fi
  102. }
  103. install-dependencies-main $*