ci: build the real OBS adapter on all three platforms
Two things: unbreak the Windows compile, and give macOS/Windows a libobs.
MSVC fix. test_json.cpp failed to compile on the Windows runner with
"a universal-character-name specifies an invalid character" and "illegal
escape sequence" -- MSVC still forms escape sequences and
universal-character-names INSIDE raw string literals, which it must not.
Every JSON input containing a backslash is now built by string concatenation
from a single kBS constant, which also sidesteps the separate murky corner of
translation phase 1 where a doubled backslash immediately followed by 'u' has
historically been treated inconsistently. Same 158 checks, no behaviour
change.
OBS SDK bootstrap for macOS/Windows. Adopts obsproject/obs-plugintemplate's
buildspec machinery -- buildspec.json plus cmake/common/buildspec_common.cmake
and cmake/{macos,windows}/buildspec.cmake -- so those two platforms get a real
libobs and build the actual plugin module instead of only the core library.
Linux is untouched and still uses Ubuntu's libobs-dev
(-DSTPLUGIN_BOOTSTRAP_OBS=OFF); the bootstrap only runs where there is no
system package.
Trimmed against upstream, each change recorded in the file that makes it:
- qt6 is dropped from dependencies_list on both platforms. The properties UI
is plain obs_properties_* and nothing here links Qt.
- The OBS sub-build builds and installs the `libobs` target, not
`obs-frontend-api`. Building the frontend API is what would drag Qt back in,
and this plugin never calls it.
- The sub-build is configured with ENABLE_UI=OFF and ENABLE_SCRIPTING=OFF as
well as upstream's ENABLE_FRONTEND=OFF: the pinned OBS predates
ENABLE_FRONTEND and gates its Qt-dependent UI on ENABLE_UI, so without this
it configures the whole OBS UI and demands Qt anyway.
- Only the Release configuration is built and installed, not Debug as well.
Nothing consumes a debug libobs and it doubles the slowest CI step.
- Only the dependency-acquisition modules are vendored. The template's
compilerconfig/defaults/helpers/xcode modules drive its own target and
bundle layout, which this project does not use.
obs-studio is pinned to 30.0.2, deliberately low: OBS refuses to load a module
built against a NEWER libobs than the one running it and accepts older ones, so
this pin IS the minimum OBS version users need. 30.0.2 is also exactly what
Ubuntu 24.04's libobs-dev ships, which puts all three platforms on one floor,
and it supports the modern CMake layout the bootstrap drives via
-DOBS_CMAKE_VERSION=3.0.0. prebuilt is obs-deps 2023-11-03 with the hashes
obs-studio 30.0.2's own buildspec.json publishes; the obs-studio source
archive hashes were computed from the GitHub tag archives.
The workflow also prints what was actually produced on each platform (ldd /
otool / dir over build/package) and uploads it as an artifact, so "does this
even link against libobs" is answered by CI output rather than assumed.
Verified locally: the Linux path is unchanged by all of this -- a fresh
configure still finds libobs-dev, and ctest is 6/6. The macOS and Windows
bootstrap can only be verified by CI; that is what this push is for.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RL8abRmgFXkVASHkkqiJbE
This commit is contained in:
@@ -0,0 +1,224 @@
|
||||
# Adapted from obsproject/obs-plugintemplate (cmake/common/buildspec_common.cmake,
|
||||
# master as of 2026-09-06). Deliberate changes from upstream, all recorded here
|
||||
# so a future re-sync knows what to keep:
|
||||
#
|
||||
# 1. _setup_obs_studio builds and installs the `libobs` target, not
|
||||
# `obs-frontend-api`. This plugin's properties UI is plain
|
||||
# obs_properties_* and it never touches the frontend API, so building it
|
||||
# would only drag Qt back in -- which is the whole point of dropping qt6
|
||||
# from dependencies_list.
|
||||
# 2. It passes -DENABLE_UI:BOOL=OFF and -DENABLE_SCRIPTING:BOOL=OFF as well
|
||||
# as upstream's -DENABLE_FRONTEND:BOOL=OFF. The pinned OBS (30.0.2)
|
||||
# predates the ENABLE_FRONTEND option and gates its Qt-dependent UI on
|
||||
# ENABLE_UI instead; without this the sub-build configures the whole
|
||||
# OBS UI and demands Qt.
|
||||
# 3. Only the Release configuration is built and installed. Upstream builds
|
||||
# Debug as well; nothing here consumes a debug libobs, and it doubles the
|
||||
# slowest step in CI.
|
||||
#
|
||||
|
||||
include_guard(GLOBAL)
|
||||
|
||||
# _check_deps_version: Checks for obs-deps VERSION file in prefix paths
|
||||
function(_check_deps_version version)
|
||||
set(found FALSE)
|
||||
|
||||
foreach(path IN LISTS CMAKE_PREFIX_PATH)
|
||||
if(EXISTS "${path}/share/obs-deps/VERSION")
|
||||
if(dependency STREQUAL qt6 AND NOT EXISTS "${path}/lib/cmake/Qt6/Qt6Config.cmake")
|
||||
set(found FALSE)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
file(READ "${path}/share/obs-deps/VERSION" _check_version)
|
||||
string(REPLACE "\n" "" _check_version "${_check_version}")
|
||||
string(REPLACE "-" "." _check_version "${_check_version}")
|
||||
string(REPLACE "-" "." version "${version}")
|
||||
|
||||
if(_check_version VERSION_EQUAL version)
|
||||
set(found TRUE)
|
||||
break()
|
||||
elseif(_check_version VERSION_LESS version)
|
||||
message(
|
||||
AUTHOR_WARNING
|
||||
"Older ${label} version detected in ${path}: \n"
|
||||
"Found ${_check_version}, require ${version}"
|
||||
)
|
||||
list(REMOVE_ITEM CMAKE_PREFIX_PATH "${path}")
|
||||
list(APPEND CMAKE_PREFIX_PATH "${path}")
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH})
|
||||
continue()
|
||||
else()
|
||||
message(
|
||||
AUTHOR_WARNING
|
||||
"Newer ${label} version detected in ${path}: \n"
|
||||
"Found ${_check_version}, require ${version}"
|
||||
)
|
||||
set(found TRUE)
|
||||
break()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
return(PROPAGATE found CMAKE_PREFIX_PATH)
|
||||
endfunction()
|
||||
|
||||
# _setup_obs_studio: Create obs-studio build project, then build libobs and obs-frontend-api
|
||||
function(_setup_obs_studio)
|
||||
if(NOT libobs_DIR)
|
||||
set(_is_fresh --fresh)
|
||||
endif()
|
||||
|
||||
if(OS_WINDOWS)
|
||||
set(_cmake_generator "${CMAKE_GENERATOR}")
|
||||
set(_cmake_arch "-A ${arch},version=${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
|
||||
set(_cmake_extra "-DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}")
|
||||
elseif(OS_MACOS)
|
||||
set(_cmake_generator "Xcode")
|
||||
set(_cmake_arch "-DCMAKE_OSX_ARCHITECTURES:STRING='arm64;x86_64'")
|
||||
set(_cmake_extra "-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
endif()
|
||||
|
||||
message(STATUS "Configure ${label} (${arch})")
|
||||
execute_process(
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" -S "${dependencies_dir}/${_obs_destination}" -B
|
||||
"${dependencies_dir}/${_obs_destination}/build_${arch}" -G ${_cmake_generator} "${_cmake_arch}"
|
||||
-DOBS_CMAKE_VERSION:STRING=3.0.0 -DENABLE_PLUGINS:BOOL=OFF -DENABLE_FRONTEND:BOOL=OFF
|
||||
-DENABLE_UI:BOOL=OFF -DENABLE_SCRIPTING:BOOL=OFF -DENABLE_BROWSER:BOOL=OFF
|
||||
-DOBS_VERSION_OVERRIDE:STRING=${_obs_version} "-DCMAKE_PREFIX_PATH='${CMAKE_PREFIX_PATH}'" ${_is_fresh}
|
||||
${_cmake_extra}
|
||||
RESULT_VARIABLE _process_result
|
||||
COMMAND_ERROR_IS_FATAL ANY
|
||||
)
|
||||
message(STATUS "Configure ${label} (${arch}) - done")
|
||||
|
||||
message(STATUS "Build ${label} (Release - ${arch})")
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_COMMAND}" --build build_${arch} --target libobs --config Release --parallel
|
||||
WORKING_DIRECTORY "${dependencies_dir}/${_obs_destination}"
|
||||
RESULT_VARIABLE _process_result
|
||||
COMMAND_ERROR_IS_FATAL ANY
|
||||
)
|
||||
message(STATUS "Build ${label} (Release - ${arch}) - done")
|
||||
|
||||
message(STATUS "Install ${label} (${arch})")
|
||||
execute_process(
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" --install build_${arch} --component Development --config Release --prefix "${dependencies_dir}"
|
||||
WORKING_DIRECTORY "${dependencies_dir}/${_obs_destination}"
|
||||
RESULT_VARIABLE _process_result
|
||||
COMMAND_ERROR_IS_FATAL ANY
|
||||
)
|
||||
message(STATUS "Install ${label} (${arch}) - done")
|
||||
endfunction()
|
||||
|
||||
# _check_dependencies: Fetch and extract pre-built OBS build dependencies
|
||||
function(_check_dependencies)
|
||||
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/buildspec.json" buildspec)
|
||||
|
||||
string(JSON dependency_data GET ${buildspec} dependencies)
|
||||
|
||||
foreach(dependency IN LISTS dependencies_list)
|
||||
string(JSON data GET ${dependency_data} ${dependency})
|
||||
string(JSON version GET ${data} version)
|
||||
string(JSON hash GET ${data} hashes ${platform})
|
||||
string(JSON url GET ${data} baseUrl)
|
||||
string(JSON label GET ${data} label)
|
||||
string(JSON revision ERROR_VARIABLE error GET ${data} revision ${platform})
|
||||
|
||||
message(STATUS "Setting up ${label} (${arch})")
|
||||
|
||||
set(file "${${dependency}_filename}")
|
||||
set(destination "${${dependency}_destination}")
|
||||
string(REPLACE "VERSION" "${version}" file "${file}")
|
||||
string(REPLACE "VERSION" "${version}" destination "${destination}")
|
||||
string(REPLACE "ARCH" "${arch}" file "${file}")
|
||||
string(REPLACE "ARCH" "${arch}" destination "${destination}")
|
||||
if(revision)
|
||||
string(REPLACE "_REVISION" "_v${revision}" file "${file}")
|
||||
string(REPLACE "-REVISION" "-v${revision}" file "${file}")
|
||||
else()
|
||||
string(REPLACE "_REVISION" "" file "${file}")
|
||||
string(REPLACE "-REVISION" "" file "${file}")
|
||||
endif()
|
||||
|
||||
if(EXISTS "${dependencies_dir}/.dependency_${dependency}_${arch}.sha256")
|
||||
file(
|
||||
READ
|
||||
"${dependencies_dir}/.dependency_${dependency}_${arch}.sha256"
|
||||
OBS_DEPENDENCY_${dependency}_${arch}_HASH
|
||||
)
|
||||
endif()
|
||||
|
||||
set(skip FALSE)
|
||||
if(dependency STREQUAL prebuilt OR dependency STREQUAL qt6)
|
||||
if(OBS_DEPENDENCY_${dependency}_${arch}_HASH STREQUAL ${hash})
|
||||
_check_deps_version(${version})
|
||||
|
||||
if(found)
|
||||
set(skip TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(skip)
|
||||
message(STATUS "Setting up ${label} (${arch}) - skipped")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
if(dependency STREQUAL obs-studio)
|
||||
set(url ${url}/${file})
|
||||
else()
|
||||
set(url ${url}/${version}/${file})
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${dependencies_dir}/${file}")
|
||||
message(STATUS "Downloading ${url}")
|
||||
file(DOWNLOAD "${url}" "${dependencies_dir}/${file}" STATUS download_status EXPECTED_HASH SHA256=${hash})
|
||||
|
||||
list(GET download_status 0 error_code)
|
||||
list(GET download_status 1 error_message)
|
||||
if(error_code GREATER 0)
|
||||
message(STATUS "Downloading ${url} - Failure")
|
||||
message(FATAL_ERROR "Unable to download ${url}, failed with error: ${error_message}")
|
||||
file(REMOVE "${dependencies_dir}/${file}")
|
||||
else()
|
||||
message(STATUS "Downloading ${url} - done")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT OBS_DEPENDENCY_${dependency}_${arch}_HASH STREQUAL ${hash})
|
||||
file(REMOVE_RECURSE "${dependencies_dir}/${destination}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${dependencies_dir}/${destination}")
|
||||
file(MAKE_DIRECTORY "${dependencies_dir}/${destination}")
|
||||
if(dependency STREQUAL obs-studio)
|
||||
file(ARCHIVE_EXTRACT INPUT "${dependencies_dir}/${file}" DESTINATION "${dependencies_dir}")
|
||||
else()
|
||||
file(ARCHIVE_EXTRACT INPUT "${dependencies_dir}/${file}" DESTINATION "${dependencies_dir}/${destination}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file(WRITE "${dependencies_dir}/.dependency_${dependency}_${arch}.sha256" "${hash}")
|
||||
|
||||
if(dependency STREQUAL prebuilt)
|
||||
list(APPEND CMAKE_PREFIX_PATH "${dependencies_dir}/${destination}")
|
||||
elseif(dependency STREQUAL qt6)
|
||||
list(APPEND CMAKE_PREFIX_PATH "${dependencies_dir}/${destination}")
|
||||
elseif(dependency STREQUAL obs-studio)
|
||||
set(_obs_version ${version})
|
||||
set(_obs_destination "${destination}")
|
||||
list(APPEND CMAKE_PREFIX_PATH "${dependencies_dir}")
|
||||
endif()
|
||||
|
||||
message(STATUS "Setting up ${label} (${arch}) - done")
|
||||
endforeach()
|
||||
|
||||
list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH)
|
||||
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} CACHE PATH "CMake prefix search path" FORCE)
|
||||
|
||||
_setup_obs_studio()
|
||||
endfunction()
|
||||
@@ -0,0 +1,20 @@
|
||||
# CMake operating system bootstrap module
|
||||
|
||||
include_guard(GLOBAL)
|
||||
|
||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(CMAKE_C_EXTENSIONS FALSE)
|
||||
set(CMAKE_CXX_EXTENSIONS FALSE)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/windows")
|
||||
set(OS_WINDOWS TRUE)
|
||||
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set(CMAKE_C_EXTENSIONS FALSE)
|
||||
set(CMAKE_CXX_EXTENSIONS FALSE)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos")
|
||||
set(OS_MACOS TRUE)
|
||||
elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD|OpenBSD")
|
||||
set(CMAKE_CXX_EXTENSIONS FALSE)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux")
|
||||
string(TOUPPER "${CMAKE_HOST_SYSTEM_NAME}" _SYSTEM_NAME_U)
|
||||
set(OS_${_SYSTEM_NAME_U} TRUE)
|
||||
endif()
|
||||
Reference in New Issue
Block a user