01_install_dependencies.sh 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. # with the -s/--standalone switch
  8. #
  9. ##############################################################################
  10. # Halt on errors
  11. set -eE
  12. install_build-deps() {
  13. shift
  14. status "Install OBS build dependencies"
  15. trap "caught_error 'install_build-deps'" ERR
  16. sudo apt-get install --no-install-recommends -y $@
  17. }
  18. install_obs-deps() {
  19. shift
  20. status "Install OBS dependencies"
  21. trap "caught_error 'install_obs-deps'" ERR
  22. if [ -z "${DISABLE_PIPEWIRE}" ]; then
  23. sudo apt-get install --no-install-recommends -y $@ libpipewire-0.3-dev
  24. else
  25. sudo apt-get install --no-install-recommends -y $@
  26. fi
  27. }
  28. install_qt5-deps() {
  29. shift
  30. status "Install Qt5 dependencies"
  31. trap "caught_error 'install_qt5-deps'" ERR
  32. sudo apt-get install --no-install-recommends -y $@
  33. }
  34. install_qt6-deps() {
  35. shift
  36. status "Install Qt6 dependencies"
  37. trap "caught_error 'install_qt6-deps'" ERR
  38. _QT6_AVAILABLE="$(sudo apt-cache madison ${1})"
  39. if [ "${_QT6_AVAILABLE}" ]; then
  40. sudo apt-get install --no-install-recommends -y $@
  41. fi
  42. }
  43. install_cef() {
  44. shift
  45. status "Setup for dependency CEF v${1}"
  46. ensure_dir "${DEPS_BUILD_DIR}"
  47. if [ "${CI}" -a "${RESTORED_CEF}" ]; then
  48. _SKIP=TRUE
  49. elif [ -d "${DEPS_BUILD_DIR}/cef_binary_${1}_linux64" -a -f "${DEPS_BUILD_DIR}/cef_binary_${1}_linux64/build/libcef_dll_wrapper/libcef_dll_wrapper.a" ]; then
  50. _SKIP=TRUE
  51. fi
  52. if [ -z "${_SKIP}" ]; then
  53. step "Download..."
  54. ${CURLCMD:-curl -O} https://cdn-fastly.obsproject.com/downloads/cef_binary_${1}_linux64.tar.bz2
  55. step "Unpack..."
  56. tar -xf cef_binary_${1}_linux64.tar.bz2
  57. else
  58. step "Found existing Chromium Embedded Framework and loader library..."
  59. fi
  60. }
  61. install_plugin-deps() {
  62. shift
  63. status "Install plugin dependencies"
  64. trap "caught_error 'install_plugin-deps'" ERR
  65. sudo apt-get install --no-install-recommends -y $@
  66. }
  67. install_dependencies() {
  68. status "Set up apt"
  69. trap "caught_error 'install_dependencies'" ERR
  70. BUILD_DEPS=(
  71. "build-deps cmake ninja-build pkg-config clang clang-format build-essential curl ccache"
  72. "obs-deps libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libswresample-dev \
  73. libswscale-dev libx264-dev libcurl4-openssl-dev libmbedtls-dev libgl1-mesa-dev libjansson-dev \
  74. libluajit-5.1-dev python3-dev libx11-dev libxcb-randr0-dev libxcb-shm0-dev libxcb-xinerama0-dev \
  75. libxcb-composite0-dev libxinerama-dev libxcb1-dev libx11-xcb-dev libxcb-xfixes0-dev swig libcmocka-dev \
  76. libpci-dev libxss-dev libglvnd-dev libgles2-mesa libgles2-mesa-dev libwayland-dev libxkbcommon-dev"
  77. "qt5-deps qtbase5-dev qtbase5-private-dev libqt5svg5-dev qtwayland5"
  78. "qt6-deps qt6-base-dev qt6-base-private-dev libqt6svg6-dev qt6-wayland"
  79. "cef ${LINUX_CEF_BUILD_VERSION:-${CI_LINUX_CEF_VERSION}}"
  80. "plugin-deps libasound2-dev libfdk-aac-dev libfontconfig-dev libfreetype6-dev libjack-jackd2-dev \
  81. libpulse-dev libsndio-dev libspeexdsp-dev libudev-dev libv4l-dev libva-dev libvlc-dev libdrm-dev \
  82. nlohmann-json3-dev libwebsocketpp-dev libasio-dev"
  83. )
  84. sudo apt-get -qq update
  85. for DEPENDENCY in "${BUILD_DEPS[@]}"; do
  86. set -- ${DEPENDENCY}
  87. trap "caught_error ${DEPENDENCY}" ERR
  88. FUNC_NAME="install_${1}"
  89. ${FUNC_NAME} ${@}
  90. done
  91. }
  92. install-dependencies-standalone() {
  93. CHECKOUT_DIR="$(/usr/bin/git rev-parse --show-toplevel)"
  94. PRODUCT_NAME="OBS-Studio"
  95. DEPS_BUILD_DIR="${CHECKOUT_DIR}/../obs-build-dependencies"
  96. source "${CHECKOUT_DIR}/CI/include/build_support.sh"
  97. source "${CHECKOUT_DIR}/CI/include/build_support_linux.sh"
  98. status "Setup of OBS build dependencies"
  99. install_dependencies
  100. }
  101. print_usage() {
  102. echo -e "Usage: ${0}\n" \
  103. "-h, --help : Print this help\n" \
  104. "-q, --quiet : Suppress most build process output\n" \
  105. "-v, --verbose : Enable more verbose build process output\n" \
  106. "--disable-pipewire : Disable building with PipeWire support (default: off)\n"
  107. }
  108. install-dependencies-main() {
  109. if [ -z "${_RUN_OBS_BUILD_SCRIPT}" ]; then
  110. while true; do
  111. case "${1}" in
  112. -h | --help ) print_usage; exit 0 ;;
  113. -q | --quiet ) export QUIET=TRUE; shift ;;
  114. -v | --verbose ) export VERBOSE=TRUE; shift ;;
  115. --disable-pipewire ) DISABLE_PIPEWIRE=TRUE; shift ;;
  116. -- ) shift; break ;;
  117. * ) break ;;
  118. esac
  119. done
  120. install-dependencies-standalone
  121. fi
  122. }
  123. install-dependencies-main $*