From da0b4493093230f076fb429d2fcda82f3ce1b247 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Tue, 11 Sep 2018 00:59:25 -0700 Subject: [PATCH] Use baked CEF dir on OSX unless deploying Makes it so it's easier to compile/use the browser plugin on mac. --- CMakeLists.txt | 20 ++++++++++++++++++++ browser-config.h.in | 4 ++++ obs-browser-plugin.cpp | 6 +++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08290f047..5aa1c2a3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,13 @@ endif() option(EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED "Enable shared texture support for the browser plugin (Win32)" ON) option(BROWSER_PANEL_SUPPORT_ENABLED "Enables Qt web browser panel support" ON) +if(APPLE) + option(BROWSER_DEPLOY "Marks full deployment of browser plugin" OFF) + if(BROWSER_DEPLOY) + add_definitions(-DBROWSER_DEPLOY) + endif() +endif() + configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/browser-config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/browser-config.h") @@ -191,5 +198,18 @@ if (WIN32) ) endif() +if(APPLE AND NOT BROWSER_DEPLOY) + add_custom_command(TARGET obs-browser POST_BUILD + COMMAND "install_name_tool" -change + "@rpath/Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework" + "${CEF_LIBRARY}/Chromium Embedded Framework" + "obs-browser.so") + add_custom_command(TARGET obs-browser-page POST_BUILD + COMMAND "install_name_tool" -change + "@rpath/Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework" + "${CEF_LIBRARY}/Chromium Embedded Framework" + "obs-browser-page") +endif() + install_obs_plugin_with_data(obs-browser data) install_obs_plugin(obs-browser-page) diff --git a/browser-config.h.in b/browser-config.h.in index ef4e7ed59..c71526519 100644 --- a/browser-config.h.in +++ b/browser-config.h.in @@ -16,6 +16,10 @@ #define FALSE false #endif +#ifdef __APPLE__ +#define CEF_LIBRARY "@CEF_LIBRARY@" +#endif + #ifdef _WIN32 #define EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED \ @EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED@ diff --git a/obs-browser-plugin.cpp b/obs-browser-plugin.cpp index ce0da786c..49d45e11a 100644 --- a/obs-browser-plugin.cpp +++ b/obs-browser-plugin.cpp @@ -30,6 +30,7 @@ #include "browser-scheme.hpp" #include "browser-app.hpp" #include "browser-version.h" +#include "browser-config.h" #include "json11/json11.hpp" #include "cef-headers.hpp" @@ -171,9 +172,8 @@ static void BrowserManagerThread(void) settings.windowless_rendering_enabled = true; settings.no_sandbox = true; -#if defined(__APPLE__) && defined(_DEBUG) - CefString(&settings.framework_dir_path) = - "/Library/Frameworks/Chromium Embedded Framework.framework"; +#if defined(__APPLE__) && !defined(BROWSER_DEPLOY) + CefString(&settings.framework_dir_path) = CEF_LIBRARY; #endif BPtr conf_path = obs_module_config_path("");