build-macos.sh 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #!/bin/bash
  2. ##############################################################################
  3. # macOS build script
  4. ##############################################################################
  5. #
  6. # This script contains all steps necessary to:
  7. #
  8. # * Build OBS with all default plugins and dependencies
  9. # * Create a macOS application bundle
  10. # * Codesign the macOS application bundle
  11. # * Package a macOS installation image
  12. # * Notarize macOS application bundle and/or installation image
  13. #
  14. # Parameters:
  15. # -h, --help : Print usage help
  16. # -q, --quiet : Suppress most build process output
  17. # -v, --verbose : Enable more verbose build process output
  18. # -d, --skip-dependency-checks : Skip dependency checks (default: off)
  19. # -b, --bundle : Create relocatable application bundle
  20. # (default: off)
  21. # -p, --package : Create distributable disk image
  22. # (default: off)
  23. # -c, --codesign : Codesign OBS and all libraries
  24. # (default: ad-hoc only)
  25. # -n, --notarize : Notarize OBS (default: off)
  26. # --xcode : Create Xcode build environment instead
  27. # of Ninja
  28. # --build-dir : Specify alternative build directory
  29. # (default: build)"
  30. # Environment Variables (optional):
  31. #
  32. # MACOS_DEPS_VERSION : Precompiled macOS dependencies version
  33. # MACOS_CEF_BUILD_VERSION : Chromium Embedded Framework version
  34. # VLC_VERSION : VLC version
  35. # SPARKLE_VERSION : Sparkle Framework version
  36. #
  37. ##############################################################################
  38. # Halt on errors
  39. set -eE
  40. ## SET UP ENVIRONMENT ##
  41. _RUN_OBS_BUILD_SCRIPT=TRUE
  42. PRODUCT_NAME="OBS-Studio"
  43. CHECKOUT_DIR="$(/usr/bin/git rev-parse --show-toplevel)"
  44. DEPS_BUILD_DIR="${CHECKOUT_DIR}/../obs-build-dependencies"
  45. source "${CHECKOUT_DIR}/CI/include/build_support.sh"
  46. source "${CHECKOUT_DIR}/CI/include/build_support_macos.sh"
  47. ## INSTALL DEPENDENCIES ##
  48. source "${CHECKOUT_DIR}/CI/macos/01_install_dependencies.sh"
  49. ## BUILD OBS ##
  50. source "${CHECKOUT_DIR}/CI/macos/02_build_obs.sh"
  51. ## PACKAGE OBS AND NOTARIZE ##
  52. source "${CHECKOUT_DIR}/CI/macos/03_package_obs.sh"
  53. ## MAIN SCRIPT FUNCTIONS ##
  54. print_usage() {
  55. echo "build-macos.sh - Build script for OBS-Studio"
  56. echo -e "Usage: ${0}\n" \
  57. "-h, --help : Print this help\n" \
  58. "-q, --quiet : Suppress most build process output\n" \
  59. "-v, --verbose : Enable more verbose build process output\n" \
  60. "-d, --skip-dependency-checks : Skip dependency checks (default: off)\n" \
  61. "-b, --bundle : Create relocatable application bundle (default: off)\n" \
  62. "-p, --package : Create distributable disk image (default: off)\n" \
  63. "-c, --codesign : Codesign OBS and all libraries (default: ad-hoc only)\n" \
  64. "-n, --notarize : Notarize OBS (default: off)\n" \
  65. "--xcode : Create Xcode build environment instead of Ninja\n" \
  66. "--build-dir : Specify alternative build directory (default: build)\n"
  67. }
  68. print_deprecation() {
  69. echo -e "DEPRECATION ERROR:\n" \
  70. "The '${1}' switch has been deprecated!\n"
  71. if [ "${1}" = "-s" ]; then
  72. echo -e "The macOS build script system has changed:\n" \
  73. " - To configure and build OBS, run the script 'CI/macos/02_build_obs.sh'\n" \
  74. " - To bundle OBS into a relocatable application bundle, run the script 'CI/macos/02_build_obs.sh --bundle\n" \
  75. " - To package OBS, run the script 'CI/macos/03_package_obs.sh'\n" \
  76. " - To notarize OBS, run the script 'CI/macos/03_package_obs.sh --notarize'\n"
  77. fi
  78. }
  79. obs-build-main() {
  80. while true; do
  81. case "${1}" in
  82. -h | --help ) print_usage; exit 0 ;;
  83. -q | --quiet ) export QUIET=TRUE; shift ;;
  84. -v | --verbose ) export VERBOSE=TRUE; shift ;;
  85. -d | --skip-dependency-checks ) SKIP_DEP_CHECKS=TRUE; shift ;;
  86. -p | --package ) PACKAGE=TRUE; shift ;;
  87. -c | --codesign ) CODESIGN=TRUE; shift ;;
  88. -n | --notarize ) NOTARIZE=TRUE; PACKAGE=TRUE CODESIGN=TRUE; shift ;;
  89. -b | --bundle ) BUNDLE=TRUE; shift ;;
  90. --xcode ) XCODE=TRUE; shift ;;
  91. --build-dir ) BUILD_DIR="${2}"; shift 2 ;;
  92. -s ) print_deprecation ${1}; exit 1 ;;
  93. -- ) shift; break ;;
  94. * ) break ;;
  95. esac
  96. done
  97. ensure_dir "${CHECKOUT_DIR}"
  98. check_archs
  99. check_macos_version
  100. step "Fetching OBS tags..."
  101. /usr/bin/git fetch origin --tags
  102. GIT_BRANCH=$(/usr/bin/git rev-parse --abbrev-ref HEAD)
  103. GIT_HASH=$(/usr/bin/git rev-parse --short HEAD)
  104. GIT_TAG=$(/usr/bin/git describe --tags --abbrev=0)
  105. if [ "${BUILD_FOR_DISTRIBUTION}" ]; then
  106. VERSION_STRING="${GIT_TAG}"
  107. else
  108. VERSION_STRING="${GIT_TAG}-${GIT_HASH}"
  109. fi
  110. if [ "${ARCH}" = "arm64" ]; then
  111. FILE_NAME="obs-studio-${VERSION_STRING}-macOS-Apple.dmg"
  112. elif [ "${ARCH}" = "universal" ]; then
  113. FILE_NAME="obs-studio-${VERSION_STRING}-macOS.dmg"
  114. else
  115. FILE_NAME="obs-studio-${VERSION_STRING}-macOS-Intel.dmg"
  116. fi
  117. if [ -z "${SKIP_DEP_CHECKS}" ]; then
  118. install_dependencies
  119. fi
  120. build_obs
  121. if [ "${BUNDLE}" ]; then
  122. bundle_obs
  123. fi
  124. if [ "${PACKAGE}" ]; then
  125. package_obs
  126. fi
  127. if [ "${NOTARIZE}" ]; then
  128. notarize_obs
  129. fi
  130. cleanup
  131. }
  132. obs-build-main $*