File: setup_obs

package info (click to toggle)
obs-downstream-keyer 0.3.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 560 kB
  • sloc: cpp: 1,957; ansic: 390; makefile: 24
file content (122 lines) | stat: -rwxr-xr-x 3,815 bytes parent folder | download | duplicates (38)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
autoload -Uz log_error log_info log_status

if (( ! ${+buildspec_file} )) {
  log_error "'buildspec_file' not set. Please set before running ${0}."
  return 2
}

if (( ! ${+commands[git]} )) {
  log_error 'git not found. Please install git.'
  return 2
}

if (( ! ${+commands[jq]} )) {
  log_error 'jq not found. Please install jq.'
  return 2
}

if (( ! ${+project_root} )) {
  log_error "'project_root' not set. Please set before running ${0}."
  return 2
}

if (( ! ${+target} )) {
  log_error "'target' not set. Please set before running ${0}."
  return 2
}

log_info 'Setting up OBS-Studio...'

local obs_version
local obs_repo
local obs_branch
local obs_hash

read -r obs_version obs_repo obs_branch obs_hash <<< \
  "$(jq -r --arg key "obs-studio" \
     '.dependencies[$key] | {version, repository, branch, hash} | join(" ")' \
     ${buildspec_file})"

if [[ -z ${obs_version} ]] {
  log_error "No obs-studio version found in buildspec.json"
  return 2
}

pushd
mkcd ${project_root:h}/obs-studio

if (( ! (${skips[(Ie)all]} + ${skips[(Ie)unpack]}) )) {
  if [[ -d .git ]] {
    git config advice.detachedHead false
    git config remote.pluginbuild.url "${obs_repo:-https://github.com/obsproject/obs-studio.git}"
    git config remote.pluginbuild.fetch "+refs/heads/${obs_branch:-master}:refs/remotes/origin/${obs_branch:-master}"

    git rev-parse -q --verify "${obs_hash}^{commit}" > /dev/null || git fetch pluginbuild
    git checkout ${obs_branch:-master} -B ${product_name}
    git reset --hard "${obs_hash}"
    log_status 'Found existing obs-studio repository.'
  } else {
    git clone "${obs_repo:-https://github.com/obsproject/obs-studio.git}" "${PWD}"
    git config advice.detachedHead false
    git checkout -f "${obs_hash}" --
    git checkout ${obs_branch:-master} -b ${product_name}
    log_status 'obs-studio checked out.'
  }

  git submodule foreach --recursive git submodule sync
  git submodule update --init --recursive
}

if (( ! (${skips[(Ie)all]} + ${skips[(Ie)build]}) )) {
  log_info 'Configuring obs-studio...'

  local -a cmake_args=(
    -DCMAKE_BUILD_TYPE=${BUILD_CONFIG:-Release}
    -DQT_VERSION=${QT_VERSION}
    -DENABLE_PLUGINS=OFF
    -DENABLE_UI=OFF
    -DENABLE_SCRIPTING=OFF
    -DCMAKE_INSTALL_PREFIX="${project_root:h}/obs-build-dependencies/plugin-deps-${OBS_DEPS_VERSION}-qt${QT_VERSION}-${target##*-}"
    -DCMAKE_PREFIX_PATH="${project_root:h}/obs-build-dependencies/plugin-deps-${OBS_DEPS_VERSION}-qt${QT_VERSION}-${target##*-}"
  )

  if (( _loglevel == 0 )) cmake_args+=(-Wno_deprecated -Wno-dev --log-level=ERROR)
  if (( _loglevel > 2 )) cmake_args+=(--debug-output)

  local num_procs

  case ${target} {
    macos-*)
      autoload -Uz read_codesign
      if (( ${+CODESIGN} )) {
        read_codesign
      }

      cmake_args+=(
        -DCMAKE_OSX_ARCHITECTURES=${${target##*-}//universal/x86_64;arm64}
        -DCMAKE_OSX_DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET:-10.15}
        -DOBS_CODESIGN_LINKER=ON
        -DOBS_BUNDLE_CODESIGN_IDENTITY="${CODESIGN_IDENT:--}"
      )
      num_procs=$(( $(sysctl -n hw.ncpu) + 1 ))
      ;;
    linux-*)
      cmake_args+=(
        -DENABLE_PIPEWIRE=OFF
      )
      num_procs=$(( $(nproc) + 1 ))
      ;;
  }

  log_debug "Attempting to configure OBS with CMake arguments: ${cmake_args}"
  cmake -S . -B plugin_build_${target##*-} -G ${generator} ${cmake_args}

  log_info 'Building libobs and obs-frontend-api...'
  local -a cmake_args=()
  if (( _loglevel > 1 )) cmake_args+=(--verbose)
  if [[ ${generator} == 'Unix Makefiles' ]] cmake_args+=(--parallel ${num_procs})
  cmake --build plugin_build_${target##*-} --config ${BUILD_CONFIG:-Release} ${cmake_args} -t obs-frontend-api
  cmake --install plugin_build_${target##*-} --config ${BUILD_CONFIG:-Release} --component obs_libraries ${cmake_args}
}

popd