1
0

build-macos.sh 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. "-a, --architecture : Specify build architecture (default: x86_64, alternative: arm64)\n" \
  61. "-d, --skip-dependency-checks : Skip dependency checks (default: off)\n" \
  62. "-b, --bundle : Create relocatable application bundle (default: off)\n" \
  63. "-p, --package : Create distributable disk image (default: off)\n" \
  64. "-c, --codesign : Codesign OBS and all libraries (default: ad-hoc only)\n" \
  65. "-n, --notarize : Notarize OBS (default: off)\n" \
  66. "--xcode : Create Xcode build environment instead of Ninja\n" \
  67. "--build-dir : Specify alternative build directory (default: build)\n"
  68. }
  69. print_deprecation() {
  70. echo -e "DEPRECATION ERROR:\n" \
  71. "The '${1}' switch has been deprecated!\n"
  72. if [ "${1}" = "-s" ]; then
  73. echo -e "The macOS build script system has changed:\n" \
  74. " - To configure and build OBS, run the script 'CI/macos/02_build_obs.sh'\n" \
  75. " - To bundle OBS into a relocatable application bundle, run the script 'CI/macos/02_build_obs.sh --bundle\n" \
  76. " - To package OBS, run the script 'CI/macos/03_package_obs.sh'\n" \
  77. " - To notarize OBS, run the script 'CI/macos/03_package_obs.sh --notarize'\n"
  78. fi
  79. }
  80. obs-build-main() {
  81. while true; do
  82. case "${1}" in
  83. -h | --help ) print_usage; exit 0 ;;
  84. -q | --quiet ) export QUIET=TRUE; shift ;;
  85. -v | --verbose ) export VERBOSE=TRUE; shift ;;
  86. -a | --architecture ) ARCH="${2}"; shift 2 ;;
  87. -d | --skip-dependency-checks ) SKIP_DEP_CHECKS=TRUE; shift ;;
  88. -p | --package ) PACKAGE=TRUE; shift ;;
  89. -c | --codesign ) CODESIGN=TRUE; shift ;;
  90. -n | --notarize ) NOTARIZE=TRUE; PACKAGE=TRUE CODESIGN=TRUE; shift ;;
  91. -b | --bundle ) BUNDLE=TRUE; shift ;;
  92. --xcode ) XCODE=TRUE; shift ;;
  93. --build-dir ) BUILD_DIR="${2}"; shift 2 ;;
  94. -s ) print_deprecation ${1}; exit 1 ;;
  95. -- ) shift; break ;;
  96. * ) break ;;
  97. esac
  98. done
  99. ensure_dir "${CHECKOUT_DIR}"
  100. check_archs
  101. check_macos_version
  102. step "Fetching OBS tags..."
  103. /usr/bin/git fetch origin --tags
  104. GIT_BRANCH=$(/usr/bin/git rev-parse --abbrev-ref HEAD)
  105. GIT_HASH=$(/usr/bin/git rev-parse --short HEAD)
  106. GIT_TAG=$(/usr/bin/git describe --tags --abbrev=0)
  107. if [ "${BUILD_FOR_DISTRIBUTION}" ]; then
  108. VERSION_STRING="${GIT_TAG}"
  109. else
  110. VERSION_STRING="${GIT_TAG}-${GIT_HASH}"
  111. fi
  112. if [ "${ARCH}" = "arm64" ]; then
  113. FILE_NAME="obs-studio-${VERSION_STRING}-macOS-Apple.dmg"
  114. elif [ "${ARCH}" = "universal" ]; then
  115. FILE_NAME="obs-studio-${VERSION_STRING}-macOS.dmg"
  116. else
  117. FILE_NAME="obs-studio-${VERSION_STRING}-macOS-Intel.dmg"
  118. fi
  119. if [ -z "${SKIP_DEP_CHECKS}" ]; then
  120. install_dependencies
  121. fi
  122. build_obs
  123. if [ "${BUNDLE}" ]; then
  124. bundle_obs
  125. fi
  126. if [ "${PACKAGE}" ]; then
  127. package_obs
  128. fi
  129. if [ "${NOTARIZE}" ]; then
  130. notarize_obs
  131. fi
  132. cleanup
  133. }
  134. obs-build-main $*