build-macos.sh 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. #
  27. ##############################################################################
  28. # Halt on errors
  29. set -eE
  30. ## SET UP ENVIRONMENT ##
  31. _RUN_OBS_BUILD_SCRIPT=TRUE
  32. PRODUCT_NAME="OBS-Studio"
  33. CHECKOUT_DIR="$(/usr/bin/git rev-parse --show-toplevel)"
  34. DEPS_BUILD_DIR="${CHECKOUT_DIR}/../obs-build-dependencies"
  35. source "${CHECKOUT_DIR}/CI/include/build_support.sh"
  36. source "${CHECKOUT_DIR}/CI/include/build_support_macos.sh"
  37. ## INSTALL DEPENDENCIES ##
  38. source "${CHECKOUT_DIR}/CI/macos/01_install_dependencies.sh"
  39. ## BUILD OBS ##
  40. source "${CHECKOUT_DIR}/CI/macos/02_build_obs.sh"
  41. ## PACKAGE OBS AND NOTARIZE ##
  42. source "${CHECKOUT_DIR}/CI/macos/03_package_obs.sh"
  43. ## MAIN SCRIPT FUNCTIONS ##
  44. print_usage() {
  45. echo "build-macos.sh - Build script for OBS-Studio"
  46. echo -e "Usage: ${0}\n" \
  47. "-h, --help : Print this help\n" \
  48. "-q, --quiet : Suppress most build process output\n" \
  49. "-v, --verbose : Enable more verbose build process output\n" \
  50. "-a, --architecture : Specify build architecture (default: x86_64, alternative: arm64)\n" \
  51. "-d, --skip-dependency-checks : Skip dependency checks (default: off)\n" \
  52. "-b, --bundle : Create relocatable application bundle (default: off)\n" \
  53. "-p, --package : Create distributable disk image (default: off)\n" \
  54. "-c, --codesign : Codesign OBS and all libraries (default: ad-hoc only)\n" \
  55. "-n, --notarize : Notarize OBS (default: off)\n"
  56. }
  57. print_deprecation() {
  58. echo -e "DEPRECATION ERROR:\n" \
  59. "The '${1}' switch has been deprecated!\n"
  60. if [ "${1}" = "-s" ]; then
  61. echo -e "The macOS build script system has changed:\n" \
  62. " - To configure and build OBS, run the script 'CI/macos/02_build_obs.sh'\n" \
  63. " - To bundle OBS into a relocatable application bundle, run the script 'CI/macos/02_build_obs.sh --bundle\n" \
  64. " - To package OBS, run the script 'CI/macos/03_package_obs.sh'\n" \
  65. " - To notarize OBS, run the script 'CI/macos/03_package_obs.sh --notarize'\n"
  66. fi
  67. }
  68. obs-build-main() {
  69. while true; do
  70. case "${1}" in
  71. -h | --help ) print_usage; exit 0 ;;
  72. -q | --quiet ) export QUIET=TRUE; shift ;;
  73. -v | --verbose ) export VERBOSE=TRUE; shift ;;
  74. -a | --architecture ) ARCH="${2}"; shift 2 ;;
  75. -d | --skip-dependency-checks ) SKIP_DEP_CHECKS=TRUE; shift ;;
  76. -p | --package ) PACKAGE=TRUE; shift ;;
  77. -c | --codesign ) CODESIGN=TRUE; shift ;;
  78. -n | --notarize ) NOTARIZE=TRUE; PACKAGE=TRUE CODESIGN=TRUE; shift ;;
  79. -b | --bundle ) BUNDLE=TRUE; shift ;;
  80. -s ) print_deprecation ${1}; exit 1 ;;
  81. -- ) shift; break ;;
  82. * ) break ;;
  83. esac
  84. done
  85. ensure_dir "${CHECKOUT_DIR}"
  86. check_archs
  87. check_macos_version
  88. step "Fetching OBS tags..."
  89. /usr/bin/git fetch origin --tags
  90. GIT_BRANCH=$(/usr/bin/git rev-parse --abbrev-ref HEAD)
  91. GIT_HASH=$(/usr/bin/git rev-parse --short HEAD)
  92. GIT_TAG=$(/usr/bin/git describe --tags --abbrev=0)
  93. if [ "${BUILD_FOR_DISTRIBUTION}" ]; then
  94. VERSION_STRING="${GIT_TAG}"
  95. else
  96. VERSION_STRING="${GIT_TAG}-${GIT_HASH}"
  97. fi
  98. if [ "${ARCH}" = "arm64" ]; then
  99. FILE_NAME="obs-studio-${VERSION_STRING}-macOS-Apple.dmg"
  100. elif [ "${ARCH}" = "universal" ]; then
  101. FILE_NAME="obs-studio-${VERSION_STRING}-macOS.dmg"
  102. else
  103. FILE_NAME="obs-studio-${VERSION_STRING}-macOS-Intel.dmg"
  104. fi
  105. if [ -z "${SKIP_DEP_CHECKS}" ]; then
  106. install_dependencies
  107. fi
  108. build_obs
  109. if [ "${BUNDLE}" ]; then
  110. bundle_obs
  111. fi
  112. if [ "${PACKAGE}" ]; then
  113. package_obs
  114. fi
  115. if [ "${NOTARIZE}" ]; then
  116. notarize_obs
  117. fi
  118. cleanup
  119. }
  120. obs-build-main $*