Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 43 additions & 5 deletions cmake/common/helpers_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function(message_configuration)
endforeach()
endif()

if(ENABLE_PLUGINS)
if(ENABLE_CORE_MODULES)
get_property(OBS_MODULES_ENABLED GLOBAL PROPERTY OBS_MODULES_ENABLED)
list(SORT OBS_MODULES_ENABLED COMPARE NATURAL CASE SENSITIVE ORDER ASCENDING)

Expand Down Expand Up @@ -82,6 +82,11 @@ function(target_disable_feature target feature_description)
endif()
endfunction()

# target_enable: Adds target to list of enabled modules
function(target_enable target)
set_property(GLOBAL APPEND PROPERTY OBS_MODULES_ENABLED ${target})
endfunction()

# target_disable: Adds target to list of disabled modules
function(target_disable target)
set_property(GLOBAL APPEND PROPERTY OBS_MODULES_DISABLED ${target})
Expand Down Expand Up @@ -451,13 +456,17 @@ function(check_uuid uuid_string return_value)
return(PROPAGATE ${return_value})
endfunction()

# add_obs_plugin: Add plugin subdirectory if host platform is in specified list of supported platforms and architectures
function(add_obs_plugin target)
# add_core_module: Add module subdirectory if host platform is in specified list of supported platforms and architectures
function(add_core_module target)
set(options WITH_MESSAGE)
set(oneValueArgs "")
set(multiValueArgs PLATFORMS ARCHITECTURES)
cmake_parse_arguments(PARSE_ARGV 0 _AOP "${options}" "${oneValueArgs}" "${multiValueArgs}")

if(NOT TARGET libobs)
message(FATAL_ERROR "Cannot add libobs core module without existing 'libobs' target")
endif()

set(found_platform FALSE)
list(LENGTH _AOP_PLATFORMS _AOP_NUM_PLATFORMS)

Expand Down Expand Up @@ -499,8 +508,37 @@ function(add_obs_plugin target)

if(found_platform AND found_architecture)
add_subdirectory(${target})
elseif(_AOP_WITH_MESSAGE)
add_custom_target(${target} COMMENT "Dummy target for unavailable module ${target}")
endif()

if(TARGET ${target})
target_enable(${target})
else()
if(_AOP_WITH_MESSAGE)
add_custom_target(${target} COMMENT "Dummy target for unavailable module ${target}")
endif()
target_disable(${target})
endif()
endfunction()

function(set_obs_core_modules)
if(NOT TARGET libobs OR NOT TARGET libobs-core-modules)
message(FATAL_ERROR "Unable to set up OBS Core Modules without 'libobs' target")
endif()

# get_target_property(core_modules_list libobs CORE_MODULE_TARGETS)
get_property(OBS_MODULES_ENABLED GLOBAL PROPERTY OBS_MODULES_ENABLED)
get_target_property(libobs_source_directory libobs SOURCE_DIR)
get_target_property(libobs_binary_directory libobs BINARY_DIR)

list(LENGTH OBS_MODULES_ENABLED core_modules_count)
string(REPLACE ";" "\",\n\t\"" core_modules_array_content "${OBS_MODULES_ENABLED}")

set(OBS_CORE_MODULE_COUNT "${core_modules_count}")
set(OBS_CORE_MODULE_LIST "\t\"${core_modules_array_content}\"")

configure_file(
"${libobs_source_directory}/obs-core-modules.c.in"
"${libobs_binary_directory}/obs-core-modules.c"
@ONLY
)
endfunction()
4 changes: 2 additions & 2 deletions cmake/linux/defaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ set(OBS_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/rundir")
set(OBS_EXECUTABLE_DESTINATION "${CMAKE_INSTALL_BINDIR}")
set(OBS_INCLUDE_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/obs")
set(OBS_LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}")
set(OBS_PLUGIN_DESTINATION "${CMAKE_INSTALL_LIBDIR}/obs-plugins")
set(OBS_PLUGIN_DESTINATION "${CMAKE_INSTALL_LIBDIR}/obs-modules")
set(OBS_SCRIPT_PLUGIN_DESTINATION "${CMAKE_INSTALL_LIBDIR}/obs-scripting")
set(OBS_DATA_DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/obs")
set(OBS_CMAKE_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake")

# Set additional paths used by OBS for self-discovery
set(OBS_PLUGIN_PATH "${CMAKE_INSTALL_LIBDIR}/obs-plugins")
set(OBS_PLUGIN_PATH "${CMAKE_INSTALL_LIBDIR}/obs-modules/core")
set(OBS_SCRIPT_PLUGIN_PATH "${CMAKE_INSTALL_LIBDIR}/obs-scripting")
set(OBS_DATA_PATH "${OBS_DATA_DESTINATION}")
set(OBS_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
Expand Down
35 changes: 19 additions & 16 deletions cmake/linux/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ function(set_target_properties_obs target)
set(OBS_SOVERSION 30)

if(target_type STREQUAL EXECUTABLE)
if(target STREQUAL browser-helper)
set(OBS_EXECUTABLE_DESTINATION "${OBS_PLUGIN_DESTINATION}/core")
endif()

install(TARGETS ${target} RUNTIME DESTINATION "${OBS_EXECUTABLE_DESTINATION}" COMPONENT Runtime)

add_custom_command(
Expand Down Expand Up @@ -124,7 +128,7 @@ function(set_target_properties_obs target)
set(plugin_destination "${OBS_SCRIPT_PLUGIN_DESTINATION}")
set_property(TARGET ${target} PROPERTY INSTALL_RPATH "$ORIGIN/;$ORIGIN/..")
else()
set(plugin_destination "${OBS_PLUGIN_DESTINATION}")
set(plugin_destination "${OBS_PLUGIN_DESTINATION}/core")
endif()

install(
Expand Down Expand Up @@ -170,20 +174,21 @@ function(set_target_properties_obs target)
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/core"
COMMAND
"${CMAKE_COMMAND}" -E copy_if_different "${imported_location}" "${cef_location}/chrome-sandbox"
"${cef_location}/libEGL.so" "${cef_location}/libGLESv2.so" "${cef_location}/libvk_swiftshader.so"
"${cef_location}/libvulkan.so.1" "${cef_location}/v8_context_snapshot.bin"
"${cef_location}/vk_swiftshader_icd.json" "${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/"
"${cef_location}/vk_swiftshader_icd.json" "${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/core"
COMMAND
"${CMAKE_COMMAND}" -E copy_if_different "${cef_root_location}/Resources/chrome_100_percent.pak"
"${cef_root_location}/Resources/chrome_200_percent.pak" "${cef_root_location}/Resources/icudtl.dat"
"${cef_root_location}/Resources/resources.pak" "${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/"
"${cef_root_location}/Resources/resources.pak"
"${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/core"
COMMAND
"${CMAKE_COMMAND}" -E copy_directory "${cef_root_location}/Resources/locales"
"${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/locales"
COMMENT "Add Chromium Embedded Framework to library directory"
"${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/core/locales"
COMMENT "Add Chromium Embedded Framwork to library directory"
)

install(
Expand All @@ -200,21 +205,19 @@ function(set_target_properties_obs target)
"${cef_root_location}/Resources/chrome_200_percent.pak"
"${cef_root_location}/Resources/icudtl.dat"
"${cef_root_location}/Resources/resources.pak"
DESTINATION "${OBS_PLUGIN_DESTINATION}"
DESTINATION "${OBS_PLUGIN_DESTINATION}/core"
COMPONENT Runtime
)

install(
DIRECTORY "${cef_root_location}/Resources/locales"
DESTINATION "${OBS_PLUGIN_DESTINATION}"
DESTINATION "${OBS_PLUGIN_DESTINATION}/core"
USE_SOURCE_PERMISSIONS
COMPONENT Runtime
)
endif()
endif()
endif()

set_property(GLOBAL APPEND PROPERTY OBS_MODULES_ENABLED ${target})
endif()

target_install_resources(${target})
Expand All @@ -236,9 +239,9 @@ function(target_install_resources target)
source_group("Resources/${relative_path}" FILES "${data_file}")
endforeach()

get_property(obs_module_list GLOBAL PROPERTY OBS_MODULES_ENABLED)
if(target IN_LIST obs_module_list)
set(target_destination "${OBS_DATA_DESTINATION}/obs-plugins/${target}")
get_target_property(target_type ${target} TYPE)
if(target_type STREQUAL MODULE_LIBRARY)
set(target_destination "${OBS_DATA_DESTINATION}/obs-modules/core/${target}")
elseif(target STREQUAL obs)
set(target_destination "${OBS_DATA_DESTINATION}/obs-studio")
else()
Expand Down Expand Up @@ -267,11 +270,11 @@ endfunction()

# Helper function to add a specific resource to a bundle
function(target_add_resource target resource)
get_property(obs_module_list GLOBAL PROPERTY OBS_MODULES_ENABLED)
get_target_property(target_type ${target} TYPE)
if(ARGN)
set(target_destination "${ARGN}")
elseif(${target} IN_LIST obs_module_list)
set(target_destination "${OBS_DATA_DESTINATION}/obs-plugins/${target}")
elseif(target_type STREQUAL MODULE_LIBRARY)
set(target_destination "${OBS_DATA_DESTINATION}/obs-modules/core/${target}")
elseif(target STREQUAL obs)
set(target_destination "${OBS_DATA_DESTINATION}/obs-studio")
else()
Expand Down
1 change: 0 additions & 1 deletion cmake/macos/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ function(set_target_properties_obs target)
endif()
endif()

set_property(GLOBAL APPEND PROPERTY OBS_MODULES_ENABLED ${target})
set_property(GLOBAL APPEND PROPERTY _OBS_DEPENDENCIES ${target})
endif()

Expand Down
4 changes: 2 additions & 2 deletions cmake/windows/defaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include_guard(GLOBAL)
set(OBS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(OBS_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/rundir")

set(OBS_PLUGIN_DESTINATION obs-plugins/64bit)
set(OBS_PLUGIN_DESTINATION core)
set(OBS_DATA_DESTINATION data)
set(OBS_CMAKE_DESTINATION cmake)
set(OBS_SCRIPT_PLUGIN_DESTINATION "${OBS_DATA_DESTINATION}/obs-scripting/64bit")
Expand All @@ -14,7 +14,7 @@ set(OBS_EXECUTABLE_DESTINATION bin/64bit)
set(OBS_LIBRARY_DESTINATION lib)
set(OBS_INCLUDE_DESTINATION include)
# Set relative paths used by OBS for self-discovery
set(OBS_PLUGIN_PATH "../../${CMAKE_INSTALL_LIBDIR}/obs-plugins/64bit")
set(OBS_PLUGIN_PATH "../../${CMAKE_INSTALL_LIBDIR}/core")
set(OBS_SCRIPT_PLUGIN_PATH "../../${OBS_DATA_DESTINATION}/obs-scripting/64bit")
set(OBS_DATA_PATH "../../${OBS_DATA_DESTINATION}")

Expand Down
26 changes: 12 additions & 14 deletions cmake/windows/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ function(set_target_properties_obs target)

if(target_type STREQUAL EXECUTABLE)
if(target STREQUAL obs-browser-helper)
set(OBS_EXECUTABLE_DESTINATION "${OBS_PLUGIN_DESTINATION}")
set(OBS_EXECUTABLE_DESTINATION "${OBS_PLUGIN_DESTINATION}/obs-browser")
elseif(target STREQUAL inject-helper OR target STREQUAL get-graphics-offsets)
set(OBS_EXECUTABLE_DESTINATION "${OBS_DATA_DESTINATION}/obs-plugins/win-capture")
set(OBS_EXECUTABLE_DESTINATION "${OBS_PLUGIN_DESTINATION}/win-capture/data")

_target_install_obs(${target} DESTINATION ${OBS_EXECUTABLE_DESTINATION} x86)

Expand Down Expand Up @@ -66,7 +66,7 @@ function(set_target_properties_obs target)
elseif(target STREQUAL "obspython" OR target STREQUAL "obslua")
set(target_destination "${OBS_SCRIPT_PLUGIN_DESTINATION}")
elseif(target STREQUAL graphics-hook)
set(target_destination "${OBS_DATA_DESTINATION}/obs-plugins/win-capture")
set(target_destination "${OBS_PLUGIN_DESTINATION}/win-capture/data")
target_add_resource(graphics-hook "${CMAKE_CURRENT_SOURCE_DIR}/obs-vulkan64.json" "${target_destination}")
target_add_resource(graphics-hook "${CMAKE_CURRENT_SOURCE_DIR}/obs-vulkan32.json" "${target_destination}")

Expand All @@ -76,15 +76,15 @@ function(set_target_properties_obs target)
_target_install_obs(${target} DESTINATION ${target_destination} x64)
endif()
elseif(target STREQUAL obs-virtualcam-module)
set(target_destination "${OBS_DATA_DESTINATION}/obs-plugins/win-dshow")
set(target_destination "${OBS_PLUGIN_DESTINATION}/win-dshow/data")

_target_install_obs(${target} DESTINATION ${target_destination} x86)

if(CMAKE_VS_PLATFORM_NAME STREQUAL ARM64)
_target_install_obs(${target} DESTINATION ${target_destination} x64)
endif()
else()
set(target_destination "${OBS_PLUGIN_DESTINATION}")
set(target_destination "${OBS_PLUGIN_DESTINATION}/${target}")
endif()

_target_install_obs(${target} DESTINATION ${target_destination})
Expand Down Expand Up @@ -157,8 +157,6 @@ function(set_target_properties_obs target)
endif()
endif()
endif()

set_property(GLOBAL APPEND PROPERTY OBS_MODULES_ENABLED ${target})
endif()

target_link_options(${target} PRIVATE "/PDBALTPATH:$<TARGET_PDB_FILE_NAME:${target}>")
Expand Down Expand Up @@ -314,9 +312,9 @@ function(target_install_resources target)
source_group("Resources/${relative_path}" FILES "${data_file}")
endforeach()

get_property(obs_module_list GLOBAL PROPERTY OBS_MODULES_ENABLED)
if(target IN_LIST obs_module_list)
set(target_destination "${OBS_DATA_DESTINATION}/obs-plugins/${target}")
get_target_property(target_type ${target} TYPE)
if(target_type STREQUAL MODULE_LIBRARY)
set(target_destination "${OBS_PLUGIN_DESTINATION}/${target}/data")
elseif(target STREQUAL obs-studio)
set(target_destination "${OBS_DATA_DESTINATION}/obs-studio")
else()
Expand Down Expand Up @@ -346,11 +344,11 @@ endfunction()

# Helper function to add a specific resource to a bundle
function(target_add_resource target resource)
get_property(obs_module_list GLOBAL PROPERTY OBS_MODULES_ENABLED)
get_target_property(target_type ${target} TYPE)
if(ARGN)
set(target_destination "${ARGN}")
elseif(${target} IN_LIST obs_module_list)
set(target_destination "${OBS_DATA_DESTINATION}/obs-plugins/${target}")
elseif(target_type STREQUAL MODULE_LIBRARY)
set(target_destination "${OBS_PLUGIN_DESTINATION}/${target}/data")
elseif(target STREQUAL obs-studio)
set(target_destination "${OBS_DATA_DESTINATION}/obs-studio")
else()
Expand Down Expand Up @@ -397,7 +395,7 @@ function(_bundle_dependencies target)
set(plugins_list)

foreach(library IN LISTS found_dependencies)
# CEF needs to be placed in obs-plugins directory on Windows, which is handled already
# CEF needs to be placed in core directory on Windows, which is handled already
if(${library} STREQUAL CEF::Library)
continue()
endif()
Expand Down
4 changes: 0 additions & 4 deletions frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ foreach(graphics_library IN ITEMS opengl metal d3d11)
endif()
endforeach()

get_property(obs_module_list GLOBAL PROPERTY OBS_MODULES_ENABLED)
list(JOIN obs_module_list "|" SAFE_MODULES)
target_compile_definitions(obs-studio PRIVATE "SAFE_MODULES=\"${SAFE_MODULES}\"")

get_target_property(target_sources obs-studio SOURCES)
set(target_cpp_sources ${target_sources})
set(target_hpp_sources ${target_sources})
Expand Down
58 changes: 49 additions & 9 deletions frontend/OBSApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,35 @@ typedef struct UncleanLaunchAction {
bool sendCrashReport = false;
} UncleanLaunchAction;

enum class PluginFailureAction { Continue, OpenPluginManager };

PluginFailureAction handlePluginFailure()
{
QMessageBox pluginWarning;

pluginWarning.setIcon(QMessageBox::Warning);

pluginWarning.setWindowTitle(QTStr("PluginFailure.Dialog.Title"));
pluginWarning.setText(QTStr("PluginFailure.Labels.Text"));

QPushButton *continueButton =
pluginWarning.addButton(QTStr("PluginFailure.Dialog.Continue"), QMessageBox::RejectRole);
QPushButton *handleButton =
pluginWarning.addButton(QTStr("PluginFailure.Dialog.Open"), QMessageBox::AcceptRole);

pluginWarning.setDefaultButton(continueButton);

pluginWarning.exec();

bool openPluginManager = pluginWarning.clickedButton() == handleButton;

if (openPluginManager) {
return PluginFailureAction::OpenPluginManager;
} else {
return PluginFailureAction::Continue;
}
}

UncleanLaunchAction handleUncleanShutdown(bool enableCrashUpload)
{
UncleanLaunchAction launchAction;
Expand Down Expand Up @@ -2037,16 +2066,27 @@ void OBSApp::addLogLine(int logLevel, const QString &message)
emit logLineAdded(logLevel, message);
}

void OBSApp::loadAppModules(struct obs_module_failure_info &mfi)
void OBSApp::loadAppModules()
{
using PluginMode = OBS::PluginManager::Mode;
PluginMode mode = (disable_3p_plugins || safe_mode) ? PluginMode::CoreOnly : PluginMode::Full;
pluginManager_->setPluginMode(mode);

pluginManager_->loadAllPlugins(portable_mode);
}

void OBSApp::handlePluginLoadState()
{
pluginManager_->preLoad();
blog(LOG_INFO, "---------------------------------");
obs_load_all_modules2(&mfi);
blog(LOG_INFO, "---------------------------------");
obs_log_loaded_modules();
blog(LOG_INFO, "---------------------------------");
obs_post_load_modules();
pluginManager_->postLoad();
using PluginState = OBS::PluginManager::State;
PluginState loadState = pluginManager_->loadState();

if (loadState != PluginState::Success) {
PluginFailureAction action = handlePluginFailure();

if (action == PluginFailureAction::OpenPluginManager) {
pluginManagerOpenDialog();
}
}
}

void OBSApp::pluginManagerOpenDialog()
Expand Down
Loading
Loading