Add obs-browser support using obs-cef

Also reenable RPATHs and fix the global default patch, so only
obs-browser gets an RPATH (which it needs).
This commit is contained in:
Asahi Lina 2023-12-10 17:13:05 +09:00
parent f9ec70de56
commit 137b3941d6
3 changed files with 106 additions and 5 deletions

71
FindCEF.cmake Normal file
View File

@ -0,0 +1,71 @@
include(FindPackageHandleStandardArgs)
find_path(CEF_INCLUDE_DIR "obs-cef/cef_version.h" HINTS /usr/include)
find_library(
CEF_LIBRARY
NAMES libcef.so "Chromium Embedded Framework"
NO_DEFAULT_PATH
PATHS /usr/local/lib64/obs-cef /usr/lib64/obs-cef /usr/local/lib/obs-cef /usr/lib/obs-cef)
find_library(
CEFWRAPPER_LIBRARY
NAMES libcef_dll_wrapper.a
NO_DEFAULT_PATH
PATHS /usr/local/lib64/obs-cef /usr/lib64/obs-cef /usr/local/lib/obs-cef /usr/lib/obs-cef)
mark_as_advanced(CEFWRAPPER_LIBRARY CEFWRAPPER_LIBRARY_DEBUG)
if(NOT CEF_LIBRARY)
message(WARNING "Could NOT find Chromium Embedded Framework library (missing: CEF_LIBRARY)")
set(CEF_FOUND FALSE)
return()
endif()
if(NOT CEFWRAPPER_LIBRARY)
message(WARNING "Could NOT find Chromium Embedded Framework wrapper library (missing: CEFWRAPPER_LIBRARY)")
set(CEF_FOUND FALSE)
return()
endif()
message(STATUS "Found Chromium Embedded Framework: ${CEF_LIBRARY};${CEF_WRAPPER_LIBRARY}")
set(CEF_LIBRARIES ${CEF_LIBRARY} optimized ${CEFWRAPPER_LIBRARY})
if(CEFWRAPPER_LIBRARY_DEBUG)
list(APPEND CEF_LIBRARIES debug ${CEFWRAPPER_LIBRARY_DEBUG})
endif()
find_package_handle_standard_args(CEF DEFAULT_MSG CEF_LIBRARY CEFWRAPPER_LIBRARY CEF_INCLUDE_DIR)
mark_as_advanced(CEF_LIBRARY CEF_WRAPPER_LIBRARY CEF_LIBRARIES CEF_INCLUDE_DIR)
if(NOT TARGET CEF::Wrapper)
if(IS_ABSOLUTE "${CEF_LIBRARIES}")
add_library(CEF::Wrapper UNKNOWN IMPORTED)
add_library(CEF::Library UNKNOWN IMPORTED)
set_target_properties(CEF::Wrapper PROPERTIES IMPORTED_LOCATION ${CEFWRAPPER_LIBRARY})
set_target_properties(CEF::Library PROPERTIES IMPORTED_LOCATION ${CEF_LIBRARY})
if(DEFINED CEFWRAPPER_LIBRARY_DEBUG)
set_target_properties(CEF::Wrapper PROPERTIES IMPORTED_LOCATION_DEBUG ${CEFWRAPPER_LIBRARY_DEBUG})
endif()
else()
add_library(CEF::Wrapper INTERFACE IMPORTED)
add_library(CEF::Library INTERFACE IMPORTED)
set_target_properties(CEF::Wrapper PROPERTIES IMPORTED_LIBNAME ${CEFWRAPPER_LIBRARY})
set_target_properties(CEF::Library PROPERTIES IMPORTED_LIBNAME ${CEF_LIBRARY})
if(DEFINED CEFWRAPPER_LIBRARY_DEBUG)
set_target_properties(CEF::Wrapper PROPERTIES IMPORTED_LIBNAME_DEBUG ${CEFWRAPPER_LIBRARY_DEBUG})
endif()
endif()
set_target_properties(CEF::Wrapper PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CEF_INCLUDE_DIR}")
set_target_properties(CEF::Library PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CEF_INCLUDE_DIR}")
endif()

View File

@ -17,6 +17,13 @@
# x264 is not in Fedora
%bcond_with x264
%ifarch x86_64 aarch64
# OBS-CEF is only available on x86_64 and aarch64
%bcond_without cef
%else
%bcond_with cef
%endif
%if "%{__isa_bits}" == "64"
%global lib64_suffix ()(64bit)
%endif
@ -24,6 +31,8 @@
%global obswebsocket_version 5.3.3
%global obsbrowser_commit e397df52e70392ebb9146e0ab6317c0d1a30bce4
%global cef_version 5060
#global commit ad859a3f66daac0d30eebcc9b07b0c2004fb6040
#global snapdate 202303261743
@ -31,7 +40,7 @@
Name: obs-studio
Version: 30.0.0
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Open Broadcaster Software Studio
# OBS itself is GPL-2.0-or-later, while various plugin dependencies are of various other licenses
@ -44,6 +53,9 @@ Source0: https://github.com/obsproject/obs-studio/archive/%{commit}/%{nam
Source0: https://github.com/obsproject/obs-studio/archive/%{version_no_tilde}/%{name}-%{version_no_tilde}.tar.gz
%endif
Source1: https://github.com/obsproject/obs-websocket/archive/%{obswebsocket_version}/obs-websocket-%{obswebsocket_version}.tar.gz
Source2: https://github.com/obsproject/obs-browser/archive/%{obsbrowser_commit}/obs-browser-%{obsbrowser_commit}.tar.gz
# CMake snippets for finding systemwide obs-cef
Source3: FindCEF.cmake
# Backports from upstream
@ -93,6 +105,9 @@ BuildRequires: libxkbcommon-devel
BuildRequires: luajit-devel
%endif
BuildRequires: mbedtls-devel
%if %{with cef}
BuildRequires: obs-cef-devel
%endif
%if %{with vpl}
BuildRequires: oneVPL-devel
%endif
@ -128,6 +143,9 @@ Recommends: libopenh264.so.%{openh264_soversion}%{?lib64_suffix}
%if %{with x264}
Requires: x264
%endif
%if %{with cef}
Requires: (obs-cef%{?_isa} with obs-cef(abi) = %{cef_version})
%endif
# Ensure QtWayland is installed when libwayland-client is installed
Requires: (qt6-qtwayland%{?_isa} if libwayland-client%{?_isa})
@ -185,6 +203,7 @@ Header files for Open Broadcaster Software
%setup -q -n %{name}-%{?snapdate:%{commit}}%{!?snapdate:%{version_no_tilde}}
# Prepare plugins/obs-websocket
tar -xf %{SOURCE1} -C plugins/obs-websocket --strip-components=1
tar -xf %{SOURCE2} -C plugins/obs-browser --strip-components=1
%autopatch -p1
# rpmlint reports E: hardcoded-library-path
@ -192,10 +211,16 @@ tar -xf %{SOURCE1} -C plugins/obs-websocket --strip-components=1
sed -e 's|OBS_MULTIARCH_SUFFIX|LIB_SUFFIX|g' -i cmake/Modules/ObsHelpers.cmake
# Kill rpath settings
sed -e '\|set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${OBS_LIBRARY_DESTINATION}")|d' -i cmake/Modules/ObsHelpers_Linux.cmake
sed -e '/CMAKE_INSTALL_RPATH/d' -i cmake/Modules/ObsDefaults_Linux.cmake
# touch the missing submodules
touch plugins/obs-browser/CMakeLists.txt
# Fix FindCEF to use systemwide obs-cef
cp %{SOURCE3} cmake/Modules/FindCEF.cmake
# Fix include paths
sed -e 's,include/,obs-cef/,g' -i plugins/obs-browser/{cef-headers.hpp,browser-scheme.cpp}
# Remove obs-cef install
sed -e '/setup_target_browser(/d' -i cmake/Modules/ObsHelpers.cmake
# Fix obs-browser rpath setting
sed -e 's,INSTALL_RPATH ".*",INSTALL_RPATH "%{_libdir}/obs-cef/",' -i plugins/obs-browser/cmake/{os-linux,legacy}.cmake
%if ! %{with x264}
# disable x264 plugin
@ -243,8 +268,9 @@ cp plugins/obs-qsv11/obs-qsv11-LICENSE.txt .fedora-rpm/licenses/plugins/
%build
%cmake -DOBS_VERSION_OVERRIDE=%{version_no_tilde} \
-DUNIX_STRUCTURE=1 -GNinja \
-DCMAKE_SKIP_RPATH=1 \
%if ! %{with cef}
-DBUILD_BROWSER=OFF \
%endif
%if ! %{with vlc}
-DENABLE_VLC=OFF \
%endif
@ -307,6 +333,9 @@ appstream-util validate-relax --nonet %{buildroot}%{_datadir}/metainfo/*.appdata
%changelog
* Sun Dec 10 2023 Asahi Lina <lina@asahilina.net> - 30.0.0-3
- Add obs-browser support using obs-cef
* Wed Nov 29 2023 Jan Grulich <jgrulich@redhat.com> - 30.0.0-2
- Rebuild (qt6)

View File

@ -1,2 +1,3 @@
SHA512 (obs-studio-30.0.0.tar.gz) = a99ec286dddea46e95a90b16b52bfb8033ce017faae039128509c561fef9bc71e02a9e55d1fee428c456dc48ce03ba7939e2488eaec35f791116ab4dfd1f34d0
SHA512 (obs-websocket-5.3.3.tar.gz) = 5726bd81a366940ab3b33f4997d5d66e8ff1bb7d456a6fbb1ebddbcc0bc847026294f74908b06460a358488abe9bf7372ff5076c48d06714813295cfbf6f4ad8
SHA512 (obs-browser-e397df52e70392ebb9146e0ab6317c0d1a30bce4.tar.gz) = a9b9406ff9371b40ef3257bf51cceac02ff6e0a38864c7b656d9b4c1072eb322cad385f25ee8cac179b401482c59c93bd35a4b8ff1274b449fec2393dd53473d