01_install_dependencies.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #!/bin/bash
  2. ##############################################################################
  3. # Linux dependency management function
  4. ##############################################################################
  5. #
  6. # This script file can be included in build scripts for Linux or run directly
  7. #
  8. ##############################################################################
  9. # Halt on errors
  10. set -eE
  11. install_obs-studio() {
  12. if [ -n "${OBS_BRANCH}" ]; then
  13. CHECKOUT_REF="${OBS_BRANCH}"
  14. else
  15. CHECKOUT_REF="tags/${OBS_VERSION:-${CI_OBS_VERSION}}"
  16. fi
  17. ensure_dir "${OBS_BUILD_DIR}"
  18. if [ ! -d "${OBS_BUILD_DIR}/.git" ]; then
  19. git clone --recursive https://github.com/obsproject/obs-studio "$(pwd)"
  20. git fetch origin --tags
  21. git checkout ${CHECKOUT_REF} -b obs-plugin-build
  22. else
  23. if ! git show-ref --verify --quiet refs/heads/obs-plugin-build; then
  24. git checkout ${CHECKOUT_REF} -b obs-plugin-build
  25. else
  26. git checkout obs-plugin-build
  27. fi
  28. fi
  29. }
  30. install_linux_dependencies() {
  31. sudo dpkg --add-architecture amd64
  32. sudo apt-get -qq update
  33. sudo apt-get install -y \
  34. build-essential \
  35. ninja-build \
  36. clang \
  37. clang-format \
  38. qtbase5-dev \
  39. libqt5svg5-dev \
  40. libqt5x11extras5-dev \
  41. qtbase5-private-dev \
  42. libwayland-dev \
  43. libavcodec-dev \
  44. libavdevice-dev \
  45. libavfilter-dev \
  46. libavformat-dev \
  47. libavutil-dev \
  48. libswresample-dev \
  49. libswscale-dev \
  50. libx264-dev \
  51. libjansson-dev \
  52. libpulse-dev \
  53. libx11-dev \
  54. libx11-xcb-dev \
  55. libmbedtls-dev \
  56. libgl1-mesa-dev \
  57. pkg-config \
  58. libcurl4-openssl-dev
  59. if ! type cmake &>/dev/null; then
  60. sudo apt-get install -y cmake
  61. fi
  62. }
  63. install_dependencies() {
  64. status "Installing build dependencies"
  65. trap "caught_error 'install_dependencies'" ERR
  66. BUILD_DEPS=(
  67. "obs-studio ${OBS_VERSION:-${CI_OBS_VERSION}}"
  68. )
  69. install_linux_dependencies
  70. for DEPENDENCY in "${BUILD_DEPS[@]}"; do
  71. set -- ${DEPENDENCY}
  72. trap "caught_error ${DEPENDENCY}" ERR
  73. FUNC_NAME="install_${1}"
  74. ${FUNC_NAME} ${2} ${3}
  75. done
  76. }
  77. install-dependencies-standalone() {
  78. CHECKOUT_DIR="$(git rev-parse --show-toplevel)"
  79. if [ -f "${CHECKOUT_DIR}/CI/include/build_environment.sh" ]; then
  80. source "${CHECKOUT_DIR}/CI/include/build_environment.sh"
  81. fi
  82. PRODUCT_NAME="${PRODUCT_NAME:-obs-plugin}"
  83. DEPS_BUILD_DIR="${CHECKOUT_DIR}/../obs-build-dependencies"
  84. OBS_BUILD_DIR="${CHECKOUT_DIR}/../obs-studio"
  85. source "${CHECKOUT_DIR}/CI/include/build_support.sh"
  86. source "${CHECKOUT_DIR}/CI/include/build_support_linux.sh"
  87. status "Setting up plugin build dependencies"
  88. install_dependencies
  89. }
  90. print_usage() {
  91. echo -e "Usage: ${0}\n" \
  92. "-h, --help : Print this help\n" \
  93. "-q, --quiet : Suppress most build process output\n" \
  94. "-v, --verbose : Enable more verbose build process output\n"
  95. }
  96. install-dependencies-main() {
  97. if [ -z "${_RUN_OBS_BUILD_SCRIPT}" ]; then
  98. while true; do
  99. case "${1}" in
  100. -h | --help ) print_usage; exit 0 ;;
  101. -q | --quiet ) export QUIET=TRUE; shift ;;
  102. -v | --verbose ) export VERBOSE=TRUE; shift ;;
  103. -- ) shift; break ;;
  104. * ) break ;;
  105. esac
  106. done
  107. install-dependencies-standalone
  108. fi
  109. }
  110. install-dependencies-main $*