#!/usr/bin/env bash # Build the pinned OBS runtime for Linux and assemble the bundle Clipbin ships. # # Only libobs and an allowlist of official OBS plugins enter the bundle. The # Windows bundle uses the official OBS release binaries instead (see # scripts/obs/fetch-windows.ps1) so the signed Game Capture hooks stay intact. set -euo pipefail script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=versions.env source "${script_dir}/versions.env" cache_dir="${CLIPBIN_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/clipbin}" source_dir="${cache_dir}/obs-studio-${OBS_VERSION}" build_dir="${cache_dir}/obs-build-${OBS_VERSION}" stage_dir="${cache_dir}/obs-stage-${OBS_VERSION}" bundle_dir="${CLIPBIN_OBS_RUNTIME:-${script_dir}/../../target/obs-runtime/linux-x86_64}" # Official plugins the recorder uses: capture, audio, hardware encoders and the # FFmpeg muxer. obs-outputs (RTMP, native MP4) is built but not shipped. plugins=(linux-capture linux-pipewire linux-pulseaudio obs-ffmpeg obs-nvenc) # OBS 32.0 does not build against mbedtls 4. Arch ships 3.x as mbedtls3. extra_cmake_args=() if [[ -d /usr/lib/mbedtls3/cmake/MbedTLS ]]; then extra_cmake_args+=(-DMbedTLS_DIR=/usr/lib/mbedtls3/cmake/MbedTLS) fi if [[ ! -d "${source_dir}" ]]; then git clone --depth 1 --branch "${OBS_VERSION}" --recurse-submodules --shallow-submodules \ https://github.com/obsproject/obs-studio.git "${source_dir}" fi actual_commit="$(git -C "${source_dir}" rev-parse HEAD)" if [[ "${actual_commit}" != "${OBS_COMMIT}" ]]; then echo "OBS source is at ${actual_commit}, expected ${OBS_COMMIT} (${OBS_VERSION})" >&2 exit 1 fi cmake -S "${source_dir}" -B "${build_dir}" -G Ninja \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_INSTALL_PREFIX="${stage_dir}" \ -DENABLE_RELOCATABLE=ON \ -DENABLE_PORTABLE_CONFIG=ON \ -DENABLE_FRONTEND=OFF \ -DENABLE_UI=OFF \ -DENABLE_BROWSER=OFF \ -DENABLE_WEBSOCKET=OFF \ -DENABLE_WEBRTC=OFF \ -DENABLE_SCRIPTING=OFF \ -DENABLE_VLC=OFF \ -DENABLE_AJA=OFF \ -DENABLE_DECKLINK=OFF \ -DENABLE_VST=OFF \ -DENABLE_QSV11=OFF \ -DENABLE_LIBFDK=OFF \ -DENABLE_JACK=OFF \ -DENABLE_SNDIO=OFF \ -DENABLE_OSS=OFF \ -DENABLE_V4L2=OFF \ -DENABLE_VIRTUALCAM=OFF \ -DENABLE_NEW_MPEGTS_OUTPUT=OFF \ -DENABLE_PIPEWIRE=ON \ -DENABLE_WAYLAND=ON \ -DENABLE_PULSEAUDIO=ON \ -DENABLE_NVENC=ON \ -DENABLE_HEVC=ON \ "${extra_cmake_args[@]}" cmake --build "${build_dir}" rm -rf "${stage_dir}" cmake --install "${build_dir}" # The bundle keeps OBS's relocatable install layout: binaries in bin/ (OBS # looks for obs-ffmpeg-mux next to the running executable), libraries in lib/, # and plugins in lib/obs-plugins/ so their $ORIGIN/.. runpath resolves libobs. rm -rf "${bundle_dir}" mkdir -p "${bundle_dir}/bin" "${bundle_dir}/lib/obs-plugins" "${bundle_dir}/lib/pkgconfig" \ "${bundle_dir}/share/obs/obs-plugins" cp -a "${stage_dir}/bin/obs-ffmpeg-mux" "${bundle_dir}/bin/" cp -a "${stage_dir}"/lib/libobs.so* "${stage_dir}"/lib/libobs-opengl.so* "${bundle_dir}/lib/" cp -a "${stage_dir}/share/obs/libobs" "${bundle_dir}/share/obs/libobs" for plugin in "${plugins[@]}"; do cp -a "${stage_dir}/lib/obs-plugins/${plugin}.so" "${bundle_dir}/lib/obs-plugins/" if [[ -d "${stage_dir}/share/obs/obs-plugins/${plugin}" ]]; then cp -a "${stage_dir}/share/obs/obs-plugins/${plugin}" "${bundle_dir}/share/obs/obs-plugins/" fi done # Lets the libobs crate link against this runtime instead of a system OBS. sed -e 's|^prefix=.*|prefix=${pcfiledir}/../..|' \ "${stage_dir}/lib/pkgconfig/libobs.pc" > "${bundle_dir}/lib/pkgconfig/libobs.pc" cat > "${bundle_dir}/VERSION" <