03_build_plugin.sh 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/bin/bash
  2. ##############################################################################
  3. # macOS libobs plugin build 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. build_obs_plugin() {
  12. status "Build plugin ${PRODUCT_NAME}"
  13. trap "caught_error 'builds_obs_plugin'" ERR
  14. if [ "${CODESIGN}" ]; then
  15. read_codesign_ident
  16. fi
  17. ensure_dir "${CHECKOUT_DIR}"
  18. step "Configuring OBS plugin build system"
  19. check_ccache
  20. cmake -S . -B ${BUILD_DIR} -G Ninja ${CMAKE_CCACHE_OPTIONS} \
  21. -DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-${CI_MACOSX_DEPLOYMENT_TARGET}} \
  22. -DCMAKE_OSX_ARCHITECTURES="${CMAKE_ARCHS}" \
  23. -DOBS_CODESIGN_LINKER=${CODESIGN_LINKER:-OFF} \
  24. -DCMAKE_BUILD_TYPE=${BUILD_CONFIG} \
  25. -DOBS_BUNDLE_CODESIGN_IDENTITY="${CODESIGN_IDENT:--}" \
  26. -DCMAKE_PREFIX_PATH="${DEPS_BUILD_DIR}/obs-deps" \
  27. ${QUIET:+-Wno-deprecated -Wno-dev --log-level=ERROR}
  28. step "Building OBS plugin"
  29. cmake --build ${BUILD_DIR}
  30. }
  31. build-plugin-standalone() {
  32. CHECKOUT_DIR="$(/usr/bin/git rev-parse --show-toplevel)"
  33. if [ -f "${CHECKOUT_DIR}/CI/include/build_environment.sh" ]; then
  34. source "${CHECKOUT_DIR}/CI/include/build_environment.sh"
  35. fi
  36. PRODUCT_NAME="${PRODUCT_NAME:-obs-plugin}"
  37. DEPS_BUILD_DIR="${CHECKOUT_DIR}/../obs-build-dependencies"
  38. source "${CHECKOUT_DIR}/CI/include/build_support.sh"
  39. source "${CHECKOUT_DIR}/CI/include/build_support_macos.sh"
  40. check_macos_version
  41. check_archs
  42. build_obs_plugin
  43. }
  44. print_usage() {
  45. echo -e "Usage: ${0}\n" \
  46. "-h, --help : Print this help\n" \
  47. "-q, --quiet : Suppress most build process output\n" \
  48. "-v, --verbose : Enable more verbose build process output\n" \
  49. "-a, --architecture : Specify build architecture (default: x86_64, alternative: arm64)\n" \
  50. "-c, --codesign : Codesign OBS and all libraries (default: ad-hoc only)\n" \
  51. "--build-dir : Specify alternative build directory (default: build)\n"
  52. }
  53. build-plugin-main() {
  54. if [ -z "${_RUN_OBS_BUILD_SCRIPT}" ]; then
  55. while true; do
  56. case "${1}" in
  57. -h | --help ) print_usage; exit 0 ;;
  58. -q | --quiet ) export QUIET=TRUE; shift ;;
  59. -v | --verbose ) export VERBOSE=TRUE; shift ;;
  60. -c | --codesign ) CODESIGN=TRUE; shift ;;
  61. -a | --architecture ) ARCH="${2}"; shift 2 ;;
  62. --build-dir ) BUILD_DIR="${2}"; shift 2 ;;
  63. -- ) shift; break ;;
  64. * ) break ;;
  65. esac
  66. done
  67. build-plugin-standalone
  68. fi
  69. }
  70. build-plugin-main $*