obs-scripting: Update CMakeLists.txt for scripting modules
This commit is contained in:
parent
dba1041034
commit
dbdf5c7f7a
337
deps/obs-scripting/CMakeLists.txt
vendored
337
deps/obs-scripting/CMakeLists.txt
vendored
@ -1,216 +1,181 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.12)
|
option(ENABLE_SCRIPTING_LUA "Enable Lua scripting support" ON)
|
||||||
|
option(ENABLE_SCRIPTING_PYTHON "Enable Python scripting support" ON)
|
||||||
|
|
||||||
if(NOT ENABLE_SCRIPTING)
|
if(NOT ENABLE_SCRIPTING)
|
||||||
message(STATUS "Scripting plugin disabled")
|
message(STATUS "OBS: DISABLED obs-scripting")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(obs-scripting)
|
project(obs-scripting)
|
||||||
|
|
||||||
if(POLICY CMP0068)
|
if(ENABLE_SCRIPTING_LUA)
|
||||||
# RPATH settings on macOS do not affect install_name.
|
add_subdirectory(obslua)
|
||||||
cmake_policy(SET CMP0068 NEW)
|
find_package(Luajit)
|
||||||
endif()
|
|
||||||
|
|
||||||
if(MSVC)
|
if(NOT TARGET Luajit::Luajit)
|
||||||
set(obs-scripting_PLATFORM_DEPS
|
message(FATAL_ERROR "OBS: - Luajit not found")
|
||||||
w32-pthreads)
|
return()
|
||||||
endif()
|
else()
|
||||||
|
message(STATUS "OBS: - Luajit found")
|
||||||
if(APPLE)
|
endif()
|
||||||
set(obs-scripting_PLATFORM_DEPS
|
|
||||||
objc)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(DISABLE_LUA "Disable Lua scripting support" OFF)
|
|
||||||
option(DISABLE_PYTHON "Disable Python scripting support" OFF)
|
|
||||||
|
|
||||||
set(COMPILE_PYTHON FALSE CACHE BOOL "" FORCE)
|
|
||||||
set(COMPILE_LUA FALSE CACHE BOOL "" FORCE)
|
|
||||||
|
|
||||||
if(NOT DISABLE_LUA)
|
|
||||||
find_package(Luajit QUIET)
|
|
||||||
|
|
||||||
if(NOT DISABLE_LUA AND NOT LUAJIT_FOUND)
|
|
||||||
message(STATUS "Luajit support not found.")
|
|
||||||
set(LUAJIT_FOUND FALSE)
|
|
||||||
else()
|
|
||||||
message(STATUS "Scripting: Luajit supported")
|
|
||||||
set(COMPILE_LUA TRUE CACHE BOOL "" FORCE)
|
|
||||||
endif()
|
|
||||||
else()
|
else()
|
||||||
message(STATUS "Scripting: Luajit support disabled")
|
message(STATUS "OBS: DISABLED Luajit support")
|
||||||
set(LUAJIT_FOUND FALSE)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT DISABLE_PYTHON)
|
if(ENABLE_SCRIPTING_PYTHON)
|
||||||
find_package(PythonDeps QUIET)
|
add_subdirectory(obspython)
|
||||||
|
if(OS_WINDOWS)
|
||||||
|
find_package(PythonWindows)
|
||||||
|
else()
|
||||||
|
find_package(Python COMPONENTS Interpreter Development)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT DISABLE_PYTHON AND NOT PYTHONLIBS_FOUND)
|
if(NOT TARGET Python::Python)
|
||||||
message(STATUS "Python support not found.")
|
message(FATAL_ERROR "OBS: - Python not found")
|
||||||
set(PYTHON_FOUND FALSE)
|
return()
|
||||||
set(PYTHONLIBS_FOUND FALSE)
|
else()
|
||||||
else()
|
message(STATUS "OBS: - Python ${Python_VERSION} found")
|
||||||
message(STATUS "Scripting: Python 3 supported")
|
endif()
|
||||||
set(PYTHON_FOUND TRUE)
|
|
||||||
set(COMPILE_PYTHON TRUE CACHE BOOL "" FORCE)
|
|
||||||
|
|
||||||
get_filename_component(PYTHON_LIB "${PYTHON_LIBRARIES}" NAME)
|
|
||||||
string(REGEX REPLACE "\\.[^.]*$" "" PYTHON_LIB ${PYTHON_LIB})
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
string(REGEX REPLACE "_d" "" PYTHON_LIB "${PYTHON_LIB}")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
else()
|
else()
|
||||||
message(STATUS "Scripting: Python 3 support disabled")
|
message(STATUS "OBS: DISABLED Python support")
|
||||||
set(PYTHON_FOUND FALSE)
|
|
||||||
set(PYTHONLIBS_FOUND FALSE)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(SwigDeps QUIET 2)
|
if(NOT TARGET Luajit::Luajit AND NOT TARGET Python::Python)
|
||||||
|
message(
|
||||||
if(NOT SWIG_FOUND)
|
WARNING
|
||||||
message(STATUS "Scripting: SWIG not found; scripting disabled")
|
"OBS: DISABLED obs-scripting - no supported scripting libraries found")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT PYTHONLIBS_FOUND AND NOT LUAJIT_FOUND)
|
if(OS_MACOS)
|
||||||
message(STATUS "Scripting: Neither Python 3 nor Luajit was found; scripting plugin disabled")
|
find_package(SWIG 4 REQUIRED)
|
||||||
return()
|
elseif(OS_POSIX)
|
||||||
|
find_package(SWIG 3 REQUIRED)
|
||||||
|
elseif(OS_WINDOWS)
|
||||||
|
find_package(SwigWindows 3 REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(SCRIPTING_ENABLED ON CACHE BOOL "Internal global cmake variable" FORCE)
|
add_library(obs-scripting SHARED)
|
||||||
|
add_library(OBS::scripting ALIAS obs-scripting)
|
||||||
|
|
||||||
if(UI_ENABLED)
|
target_sources(
|
||||||
set(EXTRA_LIBS obs-frontend-api)
|
obs-scripting
|
||||||
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/UI/obs-frontend-api")
|
PUBLIC obs-scripting.h
|
||||||
|
PRIVATE obs-scripting.c cstrcache.cpp cstrcache.h obs-scripting-logging.c
|
||||||
|
obs-scripting-callback.h)
|
||||||
|
|
||||||
|
target_link_libraries(obs-scripting PRIVATE OBS::libobs)
|
||||||
|
|
||||||
|
target_compile_features(obs-scripting PRIVATE cxx_auto_type)
|
||||||
|
|
||||||
|
target_include_directories(obs-scripting PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_BINARY_DIR}/config)
|
||||||
|
|
||||||
|
if(OS_WINDOWS)
|
||||||
|
set(MODULE_DESCRIPTION "OBS Studio scripting module")
|
||||||
|
configure_file(${CMAKE_SOURCE_DIR}/cmake/bundle/windows/obs-module.rc.in
|
||||||
|
obs-scripting.rc)
|
||||||
|
|
||||||
|
target_sources(obs-scripting PRIVATE obs-scripting.rc)
|
||||||
|
|
||||||
|
target_link_libraries(obs-scripting PRIVATE OBS::w32-pthreads)
|
||||||
|
|
||||||
|
elseif(OS_MACOS)
|
||||||
|
target_link_libraries(obs-scripting PRIVATE objc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
configure_file(
|
set_target_properties(
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/obs-scripting-config.h.in"
|
obs-scripting
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/obs-scripting-config.h")
|
PROPERTIES FOLDER "scripting"
|
||||||
|
VERSION "${OBS_VERSION_MAJOR}"
|
||||||
include(${SWIG_USE_FILE})
|
SOVERSION "1")
|
||||||
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/libobs)
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
|
|
||||||
if(PYTHONLIBS_FOUND)
|
|
||||||
include_directories(${PYTHON_INCLUDE_DIR})
|
|
||||||
|
|
||||||
set(obs-scripting-python_SOURCES
|
|
||||||
obs-scripting-python.c
|
|
||||||
)
|
|
||||||
set(obs-scripting-python_HEADERS
|
|
||||||
obs-scripting-python.h
|
|
||||||
obs-scripting-python-import.h
|
|
||||||
)
|
|
||||||
|
|
||||||
if(UI_ENABLED)
|
|
||||||
set(obs-scripting-python_SOURCES
|
|
||||||
${obs-scripting-python_SOURCES}
|
|
||||||
obs-scripting-python-frontend.c
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
if(WIN32 OR APPLE)
|
|
||||||
set(obs-scripting-python_SOURCES
|
|
||||||
${obs-scripting-python_SOURCES}
|
|
||||||
obs-scripting-python-import.c
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
set(EXTRA_LIBS ${EXTRA_LIBS} ${PYTHON_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(LUAJIT_FOUND)
|
|
||||||
include_directories(${LUAJIT_INCLUDE_DIR})
|
|
||||||
|
|
||||||
set(obs-scripting-lua_SOURCES
|
|
||||||
obs-scripting-lua.c
|
|
||||||
obs-scripting-lua-source.c
|
|
||||||
)
|
|
||||||
set(obs-scripting-lua_HEADERS
|
|
||||||
obs-scripting-lua.h
|
|
||||||
)
|
|
||||||
if(UI_ENABLED)
|
|
||||||
set(obs-scripting-lua_SOURCES
|
|
||||||
${obs-scripting-lua_SOURCES}
|
|
||||||
obs-scripting-lua-frontend.c
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(obs-scripting_SOURCES
|
|
||||||
obs-scripting.c
|
|
||||||
obs-scripting-logging.c
|
|
||||||
cstrcache.cpp
|
|
||||||
)
|
|
||||||
set(obs-scripting_HEADERS
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/obs-scripting-config.h
|
|
||||||
obs-scripting.h
|
|
||||||
obs-scripting-callback.h
|
|
||||||
cstrcache.h
|
|
||||||
)
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
set(MODULE_DESCRIPTION "OBS Studio scripting module")
|
|
||||||
configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in obs-scripting.rc)
|
|
||||||
list(APPEND obs-scripting_SOURCES
|
|
||||||
obs-scripting.rc)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/swig)
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/swig)
|
||||||
|
|
||||||
if(PYTHONLIBS_FOUND)
|
if(TARGET Luajit::Luajit)
|
||||||
set(SWIG_PY_RUNTIME swig/swigpyrun.h)
|
add_custom_command(
|
||||||
add_custom_command(OUTPUT ${SWIG_PY_RUNTIME}
|
OUTPUT swig/swigluarun.h
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
PRE_BUILD
|
PRE_BUILD
|
||||||
COMMAND ${SWIG_EXECUTABLE} -python -external-runtime ${SWIG_PY_RUNTIME}
|
COMMAND ${SWIG_EXECUTABLE} -lua -external-runtime swig/swigluarun.h
|
||||||
COMMENT "Scripting plugin: Building Python SWIG interface header"
|
COMMENT "obs-scripting - generating Luajit SWIG interface headers")
|
||||||
)
|
|
||||||
set_source_files_properties(${SWIG_PY_RUNTIME} PROPERTIES GENERATED TRUE)
|
set_source_files_properties(swig/swigluarun.h PROPERTIES GENERATED ON)
|
||||||
|
|
||||||
|
target_link_libraries(obs-scripting PRIVATE Luajit::Luajit)
|
||||||
|
|
||||||
|
target_sources(
|
||||||
|
obs-scripting
|
||||||
|
PRIVATE obs-scripting-lua.c obs-scripting-lua.h obs-scripting-lua-source.c
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/swig/swigluarun.h)
|
||||||
|
|
||||||
|
target_include_directories(obs-scripting PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
if(ENABLE_UI)
|
||||||
|
target_link_libraries(obs-scripting PRIVATE OBS::frontend-api)
|
||||||
|
|
||||||
|
target_sources(obs-scripting PRIVATE obs-scripting-lua-frontend.c)
|
||||||
|
|
||||||
|
target_compile_definitions(obs-scripting PRIVATE UI_ENABLED=ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LUAJIT_FOUND)
|
if(TARGET Python::Python)
|
||||||
set(SWIG_LUA_RUNTIME swig/swigluarun.h)
|
add_custom_command(
|
||||||
add_custom_command(OUTPUT ${SWIG_LUA_RUNTIME}
|
OUTPUT swig/swigpyrun.h
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
PRE_BUILD
|
PRE_BUILD
|
||||||
COMMAND ${SWIG_EXECUTABLE} -lua -external-runtime ${SWIG_LUA_RUNTIME}
|
COMMAND ${SWIG_EXECUTABLE} -python -external-runtime swig/swigpyrun.h
|
||||||
COMMENT "Scripting: Building Lua SWIG interface header"
|
COMMENT "obs-scripting - generating Python 3 SWIG interface headers")
|
||||||
)
|
|
||||||
set_source_files_properties(${SWIG_LUA_RUNTIME} PROPERTIES GENERATED TRUE)
|
set_source_files_properties(swig/swigpyrun.h PROPERTIES GENERATED ON)
|
||||||
|
|
||||||
|
target_sources(
|
||||||
|
obs-scripting
|
||||||
|
PRIVATE obs-scripting-python.c obs-scripting-python.h
|
||||||
|
obs-scripting-python-import.h
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/swig/swigpyrun.h)
|
||||||
|
|
||||||
|
target_include_directories(obs-scripting PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
get_filename_component(_PYTHON_PATH "${Python_LIBRARIES}" PATH)
|
||||||
|
get_filename_component(_PYTHON_FILE "${Python_LIBRARIES}" NAME)
|
||||||
|
|
||||||
|
string(REGEX REPLACE "\\.[^.]*$" "" _PYTHON_FILE ${_PYTHON_FILE})
|
||||||
|
|
||||||
|
if(OS_WINDOWS)
|
||||||
|
string(REGEX REPLACE "_d" "" _PYTHON_FILE ${_PYTHON_FILE})
|
||||||
|
endif()
|
||||||
|
set(OBS_SCRIPT_PYTHON_PATH "${_PYTHON_FILE}")
|
||||||
|
|
||||||
|
unset(_PYTHON_FILE)
|
||||||
|
unset(_PYTHON_PATH)
|
||||||
|
|
||||||
|
if(OS_WINDOWS OR OS_MACOS)
|
||||||
|
target_include_directories(obs-scripting PRIVATE ${Python_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
target_sources(obs-scripting PRIVATE obs-scripting-python-import.c)
|
||||||
|
if(OS_MACOS)
|
||||||
|
target_link_options(obs-scripting PRIVATE -undefined dynamic_lookup)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
target_link_libraries(obs-scripting PRIVATE Python::Python)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_UI)
|
||||||
|
target_link_libraries(obs-scripting PRIVATE OBS::frontend-api)
|
||||||
|
|
||||||
|
target_sources(obs-scripting PRIVATE obs-scripting-python-frontend.c)
|
||||||
|
|
||||||
|
target_compile_definitions(obs-scripting PRIVATE UI_ENABLED=ON)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(obs-scripting SHARED
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/obs-scripting-config.h.in
|
||||||
${obs-scripting_SOURCES}
|
${CMAKE_BINARY_DIR}/config/obs-scripting-config.h)
|
||||||
${obs-scripting_HEADERS}
|
|
||||||
${obs-scripting-python_SOURCES}
|
|
||||||
${obs-scripting-python_HEADERS}
|
|
||||||
${obs-scripting-lua_SOURCES}
|
|
||||||
${obs-scripting-lua_HEADERS}
|
|
||||||
${SWIG_PY_RUNTIME}
|
|
||||||
${SWIG_LUA_RUNTIME}
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(obs-scripting
|
target_sources(obs-scripting
|
||||||
libobs
|
PUBLIC ${CMAKE_BINARY_DIR}/config/obs-scripting-config.h)
|
||||||
${LUAJIT_LIBRARIES}
|
|
||||||
${EXTRA_LIBS}
|
|
||||||
${obs-scripting_PLATFORM_DEPS}
|
|
||||||
)
|
|
||||||
|
|
||||||
set_target_properties(obs-scripting PROPERTIES FOLDER "scripting")
|
setup_binary_target(obs-scripting)
|
||||||
|
|
||||||
if(PYTHONLIBS_FOUND)
|
|
||||||
add_subdirectory(obspython)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(LUAJIT_FOUND)
|
|
||||||
add_subdirectory(obslua)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install_obs_core(obs-scripting)
|
|
||||||
|
10
deps/obs-scripting/obs-scripting-config.h.in
vendored
10
deps/obs-scripting/obs-scripting-config.h.in
vendored
@ -16,8 +16,10 @@
|
|||||||
#define OFF 0
|
#define OFF 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#cmakedefine LUAJIT_FOUND
|
||||||
|
#cmakedefine Python_FOUND
|
||||||
|
|
||||||
#define SCRIPT_DIR "@OBS_SCRIPT_PLUGIN_PATH@"
|
#define SCRIPT_DIR "@OBS_SCRIPT_PLUGIN_PATH@"
|
||||||
#define PYTHON_LIB "@PYTHON_LIB@"
|
#define PYTHON_LIB "@OBS_SCRIPT_PYTHON_PATH@"
|
||||||
#define COMPILE_LUA @LUAJIT_FOUND@
|
|
||||||
#define COMPILE_PYTHON @PYTHON_FOUND@
|
#define UI_ENABLED @ENABLE_UI@
|
||||||
#define UI_ENABLED @UI_ENABLED@
|
|
||||||
|
56
deps/obs-scripting/obs-scripting-lua.c
vendored
56
deps/obs-scripting/obs-scripting-lua.c
vendored
@ -32,19 +32,21 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#define SO_EXT "dylib"
|
#define SO_EXT "so"
|
||||||
#elif _WIN32
|
#elif _WIN32
|
||||||
|
#include <windows.h>
|
||||||
#define SO_EXT "dll"
|
#define SO_EXT "dll"
|
||||||
#else
|
#else
|
||||||
#define SO_EXT "so"
|
#define SO_EXT "so"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char *startup_script_template = "\
|
static const char *startup_script_template =
|
||||||
|
"\
|
||||||
for val in pairs(package.preload) do\n\
|
for val in pairs(package.preload) do\n\
|
||||||
package.preload[val] = nil\n\
|
package.preload[val] = nil\n\
|
||||||
end\n\
|
end\n\
|
||||||
package.cpath = package.cpath .. \";\" .. \"%s/Contents/MacOS/?.so\" .. \";\" .. \"%s\" .. \"/?." SO_EXT
|
package.cpath = package.cpath .. \";\" .. \"%s/?." SO_EXT
|
||||||
"\"\n\
|
"\" .. \";\" .. \"%s\" .. \"/?." SO_EXT "\"\n\
|
||||||
require \"obslua\"\n";
|
require \"obslua\"\n";
|
||||||
|
|
||||||
static const char *get_script_path_func = "\
|
static const char *get_script_path_func = "\
|
||||||
@ -1312,7 +1314,6 @@ void obs_lua_script_save(obs_script_t *s)
|
|||||||
|
|
||||||
void obs_lua_load(void)
|
void obs_lua_load(void)
|
||||||
{
|
{
|
||||||
struct dstr dep_paths = {0};
|
|
||||||
struct dstr tmp = {0};
|
struct dstr tmp = {0};
|
||||||
|
|
||||||
pthread_mutex_init(&tick_mutex, NULL);
|
pthread_mutex_init(&tick_mutex, NULL);
|
||||||
@ -1322,34 +1323,29 @@ void obs_lua_load(void)
|
|||||||
/* ---------------------------------------------- */
|
/* ---------------------------------------------- */
|
||||||
/* Initialize Lua startup script */
|
/* Initialize Lua startup script */
|
||||||
|
|
||||||
char *bundlePath = "./";
|
#if _WIN32
|
||||||
|
#define PATH_MAX MAX_PATH
|
||||||
#ifdef __APPLE__
|
|
||||||
Class nsRunningApplication = objc_lookUpClass("NSRunningApplication");
|
|
||||||
SEL currentAppSel = sel_getUid("currentApplication");
|
|
||||||
|
|
||||||
typedef id (*running_app_func)(Class, SEL);
|
|
||||||
running_app_func operatingSystemName = (running_app_func)objc_msgSend;
|
|
||||||
id app = operatingSystemName(nsRunningApplication, currentAppSel);
|
|
||||||
|
|
||||||
typedef id (*bundle_url_func)(id, SEL);
|
|
||||||
bundle_url_func bundleURL = (bundle_url_func)objc_msgSend;
|
|
||||||
id url = bundleURL(app, sel_getUid("bundleURL"));
|
|
||||||
|
|
||||||
typedef id (*url_path_func)(id, SEL);
|
|
||||||
url_path_func urlPath = (url_path_func)objc_msgSend;
|
|
||||||
|
|
||||||
id path = urlPath(url, sel_getUid("path"));
|
|
||||||
|
|
||||||
typedef id (*string_func)(id, SEL);
|
|
||||||
string_func utf8String = (string_func)objc_msgSend;
|
|
||||||
bundlePath = (char *)utf8String(path, sel_registerName("UTF8String"));
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dstr_printf(&tmp, startup_script_template, bundlePath, SCRIPT_DIR);
|
char import_path[PATH_MAX];
|
||||||
startup_script = tmp.array;
|
|
||||||
|
|
||||||
dstr_free(&dep_paths);
|
#ifdef __APPLE__
|
||||||
|
struct dstr bundle_path;
|
||||||
|
|
||||||
|
dstr_init_move_array(&bundle_path, os_get_executable_path_ptr(""));
|
||||||
|
dstr_cat(&bundle_path, "../PlugIns");
|
||||||
|
char *absolute_plugin_path = os_get_abs_path_ptr(bundle_path.array);
|
||||||
|
|
||||||
|
if(absolute_plugin_path != NULL) {
|
||||||
|
strcpy(import_path, absolute_plugin_path);
|
||||||
|
bfree(absolute_plugin_path);
|
||||||
|
}
|
||||||
|
dstr_free(&bundle_path);
|
||||||
|
#else
|
||||||
|
strcpy(import_path, "./");
|
||||||
|
#endif
|
||||||
|
dstr_printf(&tmp, startup_script_template, import_path, SCRIPT_DIR);
|
||||||
|
startup_script = tmp.array;
|
||||||
|
|
||||||
obs_add_tick_callback(lua_tick, NULL);
|
obs_add_tick_callback(lua_tick, NULL);
|
||||||
}
|
}
|
||||||
|
21
deps/obs-scripting/obs-scripting-python.c
vendored
21
deps/obs-scripting/obs-scripting-python.c
vendored
@ -1671,17 +1671,24 @@ bool obs_scripting_load_python(const char *python_path)
|
|||||||
/* ---------------------------------------------- */
|
/* ---------------------------------------------- */
|
||||||
/* Load main interface module */
|
/* Load main interface module */
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
struct dstr bundle_path;
|
||||||
|
|
||||||
|
dstr_init_move_array(&bundle_path, os_get_executable_path_ptr(""));
|
||||||
|
dstr_cat(&bundle_path, "../PlugIns");
|
||||||
|
char *absolute_plugin_path = os_get_abs_path_ptr(bundle_path.array);
|
||||||
|
|
||||||
|
if(absolute_plugin_path != NULL) {
|
||||||
|
add_to_python_path(absolute_plugin_path);
|
||||||
|
bfree(absolute_plugin_path);
|
||||||
|
}
|
||||||
|
dstr_free(&bundle_path);
|
||||||
|
#endif
|
||||||
|
|
||||||
char *absolute_script_path = os_get_abs_path_ptr(SCRIPT_DIR);
|
char *absolute_script_path = os_get_abs_path_ptr(SCRIPT_DIR);
|
||||||
add_to_python_path(absolute_script_path);
|
add_to_python_path(absolute_script_path);
|
||||||
bfree(absolute_script_path);
|
bfree(absolute_script_path);
|
||||||
|
|
||||||
#if __APPLE__
|
|
||||||
char *exec_path = os_get_executable_path_ptr("");
|
|
||||||
if (exec_path)
|
|
||||||
add_to_python_path(exec_path);
|
|
||||||
bfree(exec_path);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
py_obspython = PyImport_ImportModule("obspython");
|
py_obspython = PyImport_ImportModule("obspython");
|
||||||
bool success = !py_error();
|
bool success = !py_error();
|
||||||
if (!success) {
|
if (!success) {
|
||||||
|
46
deps/obs-scripting/obs-scripting.c
vendored
46
deps/obs-scripting/obs-scripting.c
vendored
@ -25,7 +25,7 @@
|
|||||||
#include "obs-scripting-callback.h"
|
#include "obs-scripting-callback.h"
|
||||||
#include "obs-scripting-config.h"
|
#include "obs-scripting-config.h"
|
||||||
|
|
||||||
#if COMPILE_LUA
|
#if defined(LUAJIT_FOUND)
|
||||||
extern obs_script_t *obs_lua_script_create(const char *path,
|
extern obs_script_t *obs_lua_script_create(const char *path,
|
||||||
obs_data_t *settings);
|
obs_data_t *settings);
|
||||||
extern bool obs_lua_script_load(obs_script_t *s);
|
extern bool obs_lua_script_load(obs_script_t *s);
|
||||||
@ -39,7 +39,7 @@ extern void obs_lua_script_update(obs_script_t *script, obs_data_t *settings);
|
|||||||
extern void obs_lua_script_save(obs_script_t *script);
|
extern void obs_lua_script_save(obs_script_t *script);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if COMPILE_PYTHON
|
#if defined(Python_FOUND)
|
||||||
extern obs_script_t *obs_python_script_create(const char *path,
|
extern obs_script_t *obs_python_script_create(const char *path,
|
||||||
obs_data_t *settings);
|
obs_data_t *settings);
|
||||||
extern bool obs_python_script_load(obs_script_t *s);
|
extern bool obs_python_script_load(obs_script_t *s);
|
||||||
@ -61,10 +61,10 @@ static struct dstr file_filter = {0};
|
|||||||
static bool scripting_loaded = false;
|
static bool scripting_loaded = false;
|
||||||
|
|
||||||
static const char *supported_formats[] = {
|
static const char *supported_formats[] = {
|
||||||
#if COMPILE_LUA
|
#if defined(LUAJIT_FOUND)
|
||||||
"lua",
|
"lua",
|
||||||
#endif
|
#endif
|
||||||
#if COMPILE_PYTHON
|
#if defined(Python_FOUND)
|
||||||
"py",
|
"py",
|
||||||
#endif
|
#endif
|
||||||
NULL};
|
NULL};
|
||||||
@ -144,13 +144,15 @@ bool obs_scripting_load(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if COMPILE_LUA
|
#if defined(LUAJIT_FOUND)
|
||||||
obs_lua_load();
|
obs_lua_load();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if COMPILE_PYTHON
|
#if defined(Python_FOUND)
|
||||||
obs_python_load();
|
obs_python_load();
|
||||||
#ifndef _WIN32 /* don't risk python startup load issues on windows */
|
#if !defined(_WIN32) && \
|
||||||
|
!defined( \
|
||||||
|
__APPLE__) /* Win32 and macOS need user-provided Python library paths */
|
||||||
obs_scripting_load_python(NULL);
|
obs_scripting_load_python(NULL);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@ -166,11 +168,11 @@ void obs_scripting_unload(void)
|
|||||||
|
|
||||||
/* ---------------------- */
|
/* ---------------------- */
|
||||||
|
|
||||||
#if COMPILE_LUA
|
#if defined(LUAJIT_FOUND)
|
||||||
obs_lua_unload();
|
obs_lua_unload();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if COMPILE_PYTHON
|
#if defined(Python_FOUND)
|
||||||
obs_python_unload();
|
obs_python_unload();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -249,12 +251,12 @@ obs_script_t *obs_script_create(const char *path, obs_data_t *settings)
|
|||||||
if (!ext)
|
if (!ext)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#if COMPILE_LUA
|
#if defined(LUAJIT_FOUND)
|
||||||
if (strcmp(ext, ".lua") == 0) {
|
if (strcmp(ext, ".lua") == 0) {
|
||||||
script = obs_lua_script_create(path, settings);
|
script = obs_lua_script_create(path, settings);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
#if COMPILE_PYTHON
|
#if defined(Python_FOUND)
|
||||||
if (strcmp(ext, ".py") == 0) {
|
if (strcmp(ext, ".py") == 0) {
|
||||||
script = obs_python_script_create(path, settings);
|
script = obs_python_script_create(path, settings);
|
||||||
} else
|
} else
|
||||||
@ -306,13 +308,13 @@ obs_properties_t *obs_script_get_properties(obs_script_t *script)
|
|||||||
|
|
||||||
if (!ptr_valid(script))
|
if (!ptr_valid(script))
|
||||||
return NULL;
|
return NULL;
|
||||||
#if COMPILE_LUA
|
#if defined(LUAJIT_FOUND)
|
||||||
if (script->type == OBS_SCRIPT_LANG_LUA) {
|
if (script->type == OBS_SCRIPT_LANG_LUA) {
|
||||||
props = obs_lua_script_get_properties(script);
|
props = obs_lua_script_get_properties(script);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if COMPILE_PYTHON
|
#if defined(Python_FOUND)
|
||||||
if (script->type == OBS_SCRIPT_LANG_PYTHON) {
|
if (script->type == OBS_SCRIPT_LANG_PYTHON) {
|
||||||
props = obs_python_script_get_properties(script);
|
props = obs_python_script_get_properties(script);
|
||||||
goto out;
|
goto out;
|
||||||
@ -332,13 +334,13 @@ obs_data_t *obs_script_save(obs_script_t *script)
|
|||||||
if (!ptr_valid(script))
|
if (!ptr_valid(script))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#if COMPILE_LUA
|
#if defined(LUAJIT_FOUND)
|
||||||
if (script->type == OBS_SCRIPT_LANG_LUA) {
|
if (script->type == OBS_SCRIPT_LANG_LUA) {
|
||||||
obs_lua_script_save(script);
|
obs_lua_script_save(script);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if COMPILE_PYTHON
|
#if defined(Python_FOUND)
|
||||||
if (script->type == OBS_SCRIPT_LANG_PYTHON) {
|
if (script->type == OBS_SCRIPT_LANG_PYTHON) {
|
||||||
obs_python_script_save(script);
|
obs_python_script_save(script);
|
||||||
goto out;
|
goto out;
|
||||||
@ -373,12 +375,12 @@ void obs_script_update(obs_script_t *script, obs_data_t *settings)
|
|||||||
{
|
{
|
||||||
if (!ptr_valid(script))
|
if (!ptr_valid(script))
|
||||||
return;
|
return;
|
||||||
#if COMPILE_LUA
|
#if defined(LUAJIT_FOUND)
|
||||||
if (script->type == OBS_SCRIPT_LANG_LUA) {
|
if (script->type == OBS_SCRIPT_LANG_LUA) {
|
||||||
obs_lua_script_update(script, settings);
|
obs_lua_script_update(script, settings);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if COMPILE_PYTHON
|
#if defined(Python_FOUND)
|
||||||
if (script->type == OBS_SCRIPT_LANG_PYTHON) {
|
if (script->type == OBS_SCRIPT_LANG_PYTHON) {
|
||||||
obs_python_script_update(script, settings);
|
obs_python_script_update(script, settings);
|
||||||
}
|
}
|
||||||
@ -392,7 +394,7 @@ bool obs_script_reload(obs_script_t *script)
|
|||||||
if (!ptr_valid(script))
|
if (!ptr_valid(script))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#if COMPILE_LUA
|
#if defined(LUAJIT_FOUND)
|
||||||
if (script->type == OBS_SCRIPT_LANG_LUA) {
|
if (script->type == OBS_SCRIPT_LANG_LUA) {
|
||||||
obs_lua_script_unload(script);
|
obs_lua_script_unload(script);
|
||||||
clear_call_queue();
|
clear_call_queue();
|
||||||
@ -400,7 +402,7 @@ bool obs_script_reload(obs_script_t *script)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if COMPILE_PYTHON
|
#if defined(Python_FOUND)
|
||||||
if (script->type == OBS_SCRIPT_LANG_PYTHON) {
|
if (script->type == OBS_SCRIPT_LANG_PYTHON) {
|
||||||
obs_python_script_unload(script);
|
obs_python_script_unload(script);
|
||||||
clear_call_queue();
|
clear_call_queue();
|
||||||
@ -423,14 +425,14 @@ void obs_script_destroy(obs_script_t *script)
|
|||||||
if (!script)
|
if (!script)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if COMPILE_LUA
|
#if defined(LUAJIT_FOUND)
|
||||||
if (script->type == OBS_SCRIPT_LANG_LUA) {
|
if (script->type == OBS_SCRIPT_LANG_LUA) {
|
||||||
obs_lua_script_unload(script);
|
obs_lua_script_unload(script);
|
||||||
obs_lua_script_destroy(script);
|
obs_lua_script_destroy(script);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if COMPILE_PYTHON
|
#if defined(Python_FOUND)
|
||||||
if (script->type == OBS_SCRIPT_LANG_PYTHON) {
|
if (script->type == OBS_SCRIPT_LANG_PYTHON) {
|
||||||
obs_python_script_unload(script);
|
obs_python_script_unload(script);
|
||||||
obs_python_script_destroy(script);
|
obs_python_script_destroy(script);
|
||||||
@ -439,7 +441,7 @@ void obs_script_destroy(obs_script_t *script)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !COMPILE_PYTHON
|
#if !defined(Python_FOUND)
|
||||||
bool obs_scripting_load_python(const char *python_path)
|
bool obs_scripting_load_python(const char *python_path)
|
||||||
{
|
{
|
||||||
UNUSED_PARAMETER(python_path);
|
UNUSED_PARAMETER(python_path);
|
||||||
|
103
deps/obs-scripting/obslua/CMakeLists.txt
vendored
103
deps/obs-scripting/obslua/CMakeLists.txt
vendored
@ -1,62 +1,61 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.12)
|
if(POLICY CMP0086)
|
||||||
project(obslua)
|
cmake_policy(SET CMP0086 NEW)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(POLICY CMP0078)
|
if(POLICY CMP0078)
|
||||||
# UseSWIG generates standard target names.
|
cmake_policy(SET CMP0078 NEW)
|
||||||
cmake_policy(SET CMP0078 OLD)
|
|
||||||
endif()
|
|
||||||
if(POLICY CMP0086)
|
|
||||||
# UseSWIG honors SWIG_MODULE_NAME via -module flag.
|
|
||||||
cmake_policy(SET CMP0086 OLD)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(SWIG 2 REQUIRED)
|
project(obslua)
|
||||||
include(${SWIG_USE_FILE})
|
|
||||||
|
|
||||||
add_definitions(-DSWIG_TYPE_TABLE=obslua -DSWIG_LUA_INTERPRETER_NO_DEBUG)
|
find_package(Luajit REQUIRED)
|
||||||
|
|
||||||
if(MSVC)
|
if(OS_MACOS)
|
||||||
add_compile_options("/wd4054")
|
find_package(SWIG 4 REQUIRED)
|
||||||
add_compile_options("/wd4197")
|
elseif(OS_POSIX)
|
||||||
add_compile_options("/wd4244")
|
find_package(SWIG 3 REQUIRED)
|
||||||
add_compile_options("/wd4267")
|
elseif(OS_WINDOWS)
|
||||||
|
find_package(SwigWindows 3 REQUIRED)
|
||||||
|
endif()
|
||||||
|
include(UseSWIG)
|
||||||
|
|
||||||
|
set_source_files_properties(obslua.i PROPERTIES USE_TARGET_INCLUDE_DIRECTORIES
|
||||||
|
TRUE)
|
||||||
|
|
||||||
|
swig_add_library(
|
||||||
|
obslua
|
||||||
|
LANGUAGE lua
|
||||||
|
TYPE MODULE
|
||||||
|
SOURCES obslua.i ../cstrcache.cpp ../cstrcache.h)
|
||||||
|
|
||||||
|
target_link_libraries(obslua PRIVATE OBS::scripting OBS::libobs Luajit::Luajit)
|
||||||
|
|
||||||
|
set_target_properties(
|
||||||
|
obslua PROPERTIES SWIG_COMPILE_DEFINITIONS
|
||||||
|
"SWIG_TYPE_TABLE=obslua;SWIG_LUA_INTERPRETER_NO_DEBUG")
|
||||||
|
|
||||||
|
set_target_properties(
|
||||||
|
obslua
|
||||||
|
PROPERTIES FOLDER "scripting"
|
||||||
|
VERSION "${OBS_VERSION_MAJOR}"
|
||||||
|
SOVERSION "${OBS_VERSION_CANONICAL}")
|
||||||
|
|
||||||
|
target_compile_definitions(obslua PRIVATE SWIG_TYPE_TABLE=obslua
|
||||||
|
SWIG_LUA_INTERPRETER_NO_DEBUG)
|
||||||
|
|
||||||
|
if(ENABLE_UI)
|
||||||
|
target_link_libraries(obslua PRIVATE OBS::frontend-api)
|
||||||
|
|
||||||
|
target_compile_definitions(obslua PRIVATE ENABLE_UI)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/libobs")
|
if(OS_WINDOWS)
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
if(MSVC)
|
||||||
|
target_compile_options(obslua PRIVATE /wd4054 /wd4197 /wd4244 /wd4267)
|
||||||
if(CMAKE_VERSION VERSION_GREATER 3.7.2)
|
endif()
|
||||||
SWIG_ADD_LIBRARY(obslua
|
elseif(OS_MACOS)
|
||||||
LANGUAGE lua
|
set_target_properties(obslua PROPERTIES MACHO_CURRENT_VERSION 0
|
||||||
TYPE MODULE
|
MACHO_COMPATIBILITY_VERSION 0)
|
||||||
SOURCES obslua.i ../cstrcache.cpp ../cstrcache.h)
|
|
||||||
else()
|
|
||||||
SWIG_ADD_MODULE(obslua lua obslua.i ../cstrcache.cpp ../cstrcache.h)
|
|
||||||
endif()
|
endif()
|
||||||
SWIG_LINK_LIBRARIES(obslua obs-scripting libobs ${LUA_LIBRARIES} ${EXTRA_LIBS})
|
|
||||||
|
|
||||||
set_target_properties(obslua PROPERTIES FOLDER "scripting")
|
setup_script_plugin_target(obslua)
|
||||||
|
|
||||||
function(install_plugin_bin_swig target additional_target)
|
|
||||||
if(APPLE)
|
|
||||||
set(_bit_suffix "")
|
|
||||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
||||||
set(_bit_suffix "64bit/")
|
|
||||||
else()
|
|
||||||
set(_bit_suffix "32bit/")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set_target_properties(${additional_target} PROPERTIES
|
|
||||||
PREFIX "")
|
|
||||||
|
|
||||||
install(TARGETS "${additional_target}"
|
|
||||||
LIBRARY DESTINATION "${OBS_SCRIPT_PLUGIN_DESTINATION}")
|
|
||||||
|
|
||||||
add_custom_command(TARGET ${additional_target} POST_BUILD
|
|
||||||
COMMAND "${CMAKE_COMMAND}" -E copy
|
|
||||||
"$<TARGET_FILE:${additional_target}>"
|
|
||||||
"${OBS_OUTPUT_DIR}/$<CONFIGURATION>/data/obs-scripting/${_bit_suffix}$<TARGET_FILE_NAME:${additional_target}>"
|
|
||||||
VERBATIM)
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
install_plugin_bin_swig(obs-scripting obslua)
|
|
||||||
|
4
deps/obs-scripting/obslua/obslua.i
vendored
4
deps/obs-scripting/obslua/obslua.i
vendored
@ -26,7 +26,7 @@
|
|||||||
#include "obs-scripting-config.h"
|
#include "obs-scripting-config.h"
|
||||||
#include <util/platform.h>
|
#include <util/platform.h>
|
||||||
|
|
||||||
#if UI_ENABLED
|
#if defined(ENABLE_UI)
|
||||||
#include "obs-frontend-api.h"
|
#include "obs-frontend-api.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -104,6 +104,6 @@ static inline void wrap_blog(int log_level, const char *message)
|
|||||||
%include "util/base.h"
|
%include "util/base.h"
|
||||||
%include "util/platform.h"
|
%include "util/platform.h"
|
||||||
|
|
||||||
#if UI_ENABLED
|
#if defined(ENABLE_UI)
|
||||||
%include "obs-frontend-api.h"
|
%include "obs-frontend-api.h"
|
||||||
#endif
|
#endif
|
||||||
|
185
deps/obs-scripting/obspython/CMakeLists.txt
vendored
185
deps/obs-scripting/obspython/CMakeLists.txt
vendored
@ -1,92 +1,113 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.12)
|
if(POLICY CMP0078)
|
||||||
|
cmake_policy(SET CMP0078 NEW)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(POLICY CMP0086)
|
||||||
|
cmake_policy(SET CMP0086 NEW)
|
||||||
|
endif()
|
||||||
|
|
||||||
project(obspython)
|
project(obspython)
|
||||||
|
|
||||||
if(POLICY CMP0078)
|
if(OS_MACOS)
|
||||||
# UseSWIG generates standard target names.
|
find_package(Python REQUIRED COMPONENTS Interpreter Development)
|
||||||
cmake_policy(SET CMP0078 OLD)
|
find_package(SWIG 4 REQUIRED)
|
||||||
|
elseif(OS_POSIX)
|
||||||
|
find_package(Python REQUIRED COMPONENTS Interpreter Development)
|
||||||
|
find_package(SWIG 3 REQUIRED)
|
||||||
|
elseif(OS_WINDOWS)
|
||||||
|
find_package(PythonWindows REQUIRED)
|
||||||
|
find_package(SwigWindows 3 REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
if(POLICY CMP0086)
|
include(UseSWIG)
|
||||||
# UseSWIG honors SWIG_MODULE_NAME via -module flag.
|
|
||||||
cmake_policy(SET CMP0086 OLD)
|
set_source_files_properties(
|
||||||
|
obspython.i PROPERTIES USE_TARGET_INCLUDE_DIRECTORIES TRUE SWIG_FLAGS
|
||||||
|
"-builtin;-py3")
|
||||||
|
|
||||||
|
swig_add_library(
|
||||||
|
obspython
|
||||||
|
LANGUAGE python
|
||||||
|
TYPE MODULE
|
||||||
|
SOURCES obspython.i ../cstrcache.cpp ../cstrcache.h)
|
||||||
|
|
||||||
|
target_link_libraries(obspython PRIVATE OBS::scripting OBS::libobs)
|
||||||
|
|
||||||
|
set_target_properties(
|
||||||
|
obspython
|
||||||
|
PROPERTIES
|
||||||
|
SWIG_COMPILE_DEFINITIONS
|
||||||
|
"SWIG_TYPE_TABLE=obspython;Py_ENABLE_SHARED=1;SWIG_PYTHON_INTERPRETER_NO_DEBUG"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_features(obspython PRIVATE cxx_auto_type c_std_11)
|
||||||
|
|
||||||
|
target_compile_definitions(
|
||||||
|
obspython PRIVATE SWIG_TYPE_TABLE=obspython Py_ENABLE_SHARED=1
|
||||||
|
SWIG_PYTHON_INTERPRETER_NO_DEBUG)
|
||||||
|
|
||||||
|
if(ENABLE_UI)
|
||||||
|
target_link_libraries(obspython PRIVATE OBS::frontend-api)
|
||||||
|
|
||||||
|
target_compile_definitions(obspython PRIVATE ENABLE_UI)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(SWIG 2 REQUIRED)
|
if(OS_WINDOWS)
|
||||||
include(${SWIG_USE_FILE})
|
set_target_properties(
|
||||||
|
obspython
|
||||||
|
PROPERTIES
|
||||||
|
SWIG_COMPILE_DEFINITIONS
|
||||||
|
"SWIG_TYPE_TABLE=obspython;Py_ENABLE_SHARED=1;SWIG_PYTHON_INTERPRETER_NO_DEBUG;MS_NO_COREDLL"
|
||||||
|
)
|
||||||
|
|
||||||
add_definitions(-DSWIG_TYPE_TABLE=obspython -DMS_NO_COREDLL -DPy_ENABLE_SHARED=1 -DSWIG_PYTHON_INTERPRETER_NO_DEBUG)
|
target_link_libraries(obspython PRIVATE Python::Python)
|
||||||
|
|
||||||
|
target_compile_options(obspython PRIVATE /wd4100)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
add_custom_command(
|
||||||
|
TARGET obspython
|
||||||
|
POST_BUILD
|
||||||
|
COMMAND
|
||||||
|
"${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_BINARY_DIR}/obspython.py"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/obspython.py"
|
||||||
|
VERBATIM)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
elseif(OS_MACOS)
|
||||||
|
get_target_property(_PYTHON_INCLUDE_DIRECTORY Python::Python
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
|
|
||||||
|
target_include_directories(obspython PRIVATE ${_PYTHON_INCLUDE_DIRECTORY})
|
||||||
|
|
||||||
|
target_link_options(obspython PRIVATE -undefined dynamic_lookup)
|
||||||
|
|
||||||
|
target_compile_options(obspython PRIVATE -Wno-unused-parameter)
|
||||||
|
|
||||||
|
if(XCODE)
|
||||||
|
add_custom_command(
|
||||||
|
TARGET obspython
|
||||||
|
POST_BUILD
|
||||||
|
COMMAND
|
||||||
|
"${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_BINARY_DIR}/obspython.py"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/obspython.py"
|
||||||
|
VERBATIM)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set_target_properties(obspython PROPERTIES MACHO_CURRENT_VERSION 0
|
||||||
|
MACHO_COMPATIBILITY_VERSION 0)
|
||||||
|
elseif(OS_POSIX)
|
||||||
|
target_link_libraries(obspython PRIVATE Python::Python)
|
||||||
|
|
||||||
|
target_compile_options(obspython PRIVATE -Wno-unused-parameter)
|
||||||
|
|
||||||
|
set_target_properties(obspython PROPERTIES PREFIX "")
|
||||||
|
|
||||||
if(MSVC)
|
|
||||||
add_compile_options("/wd4054")
|
|
||||||
add_compile_options("/wd4100")
|
|
||||||
add_compile_options("/wd4115")
|
|
||||||
add_compile_options("/wd4197")
|
|
||||||
add_compile_options("/wd4701")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(${PYTHON_INCLUDE_DIR})
|
set_target_properties(
|
||||||
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/libobs")
|
obspython
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
PROPERTIES FOLDER "scripting"
|
||||||
|
VERSION "${OBS_VERSION_MAJOR}"
|
||||||
|
SOVERSION "${OBS_VERSION_CANONICAL}")
|
||||||
|
|
||||||
#add_definitions( -DSWIG_TYPE_TABLE=libobs )
|
setup_script_plugin_target(obspython)
|
||||||
SET_SOURCE_FILES_PROPERTIES(obspython.i PROPERTIES SWIG_FLAGS "-modern")
|
|
||||||
SET_SOURCE_FILES_PROPERTIES(obspython.i PROPERTIES SWIG_FLAGS "-builtin")
|
|
||||||
SET_SOURCE_FILES_PROPERTIES(obspython.i PROPERTIES SWIG_FLAGS "-modernargs")
|
|
||||||
SET_SOURCE_FILES_PROPERTIES(obspython.i PROPERTIES SWIG_FLAGS "-includeall")
|
|
||||||
SET_SOURCE_FILES_PROPERTIES(obspython.i PROPERTIES SWIG_FLAGS "-importall")
|
|
||||||
SET_SOURCE_FILES_PROPERTIES(obspython.i PROPERTIES SWIG_FLAGS "-py3")
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
string(REGEX REPLACE "_d" "" PYTHON_LIBRARIES "${PYTHON_LIBRARIES}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_GREATER 3.7.2)
|
|
||||||
SWIG_ADD_LIBRARY(obspython
|
|
||||||
LANGUAGE python
|
|
||||||
TYPE MODULE
|
|
||||||
SOURCES obspython.i ../cstrcache.cpp ../cstrcache.h)
|
|
||||||
else()
|
|
||||||
SWIG_ADD_MODULE(obspython python obspython.i ../cstrcache.cpp ../cstrcache.h)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
IF(APPLE)
|
|
||||||
SWIG_LINK_LIBRARIES(obspython obs-scripting libobs)
|
|
||||||
ELSE()
|
|
||||||
SWIG_LINK_LIBRARIES(obspython obs-scripting libobs ${PYTHON_LIBRARIES})
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
set_target_properties(_obspython PROPERTIES FOLDER "scripting")
|
|
||||||
|
|
||||||
function(install_plugin_bin_swig target additional_target)
|
|
||||||
if(APPLE)
|
|
||||||
set(_bit_suffix "")
|
|
||||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
||||||
set(_bit_suffix "64bit/")
|
|
||||||
else()
|
|
||||||
set(_bit_suffix "32bit/")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set_target_properties(${additional_target} PROPERTIES
|
|
||||||
PREFIX "")
|
|
||||||
|
|
||||||
if (APPLE)
|
|
||||||
SET_TARGET_PROPERTIES(${additional_target} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/obspython.py"
|
|
||||||
DESTINATION "${OBS_SCRIPT_PLUGIN_DESTINATION}")
|
|
||||||
install(TARGETS "${additional_target}"
|
|
||||||
LIBRARY DESTINATION "${OBS_SCRIPT_PLUGIN_DESTINATION}")
|
|
||||||
|
|
||||||
add_custom_command(TARGET ${additional_target} POST_BUILD
|
|
||||||
COMMAND "${CMAKE_COMMAND}" -E copy
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/obspython.py"
|
|
||||||
"${OBS_OUTPUT_DIR}/$<CONFIGURATION>/data/obs-scripting/${_bit_suffix}/obspython.py"
|
|
||||||
VERBATIM)
|
|
||||||
add_custom_command(TARGET ${additional_target} POST_BUILD
|
|
||||||
COMMAND "${CMAKE_COMMAND}" -E copy
|
|
||||||
"$<TARGET_FILE:${additional_target}>"
|
|
||||||
"${OBS_OUTPUT_DIR}/$<CONFIGURATION>/data/obs-scripting/${_bit_suffix}$<TARGET_FILE_NAME:${additional_target}>"
|
|
||||||
VERBATIM)
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
install_plugin_bin_swig(obs-scripting _obspython)
|
|
||||||
|
4
deps/obs-scripting/obspython/obspython.i
vendored
4
deps/obs-scripting/obspython/obspython.i
vendored
@ -26,7 +26,7 @@
|
|||||||
#include "obs-scripting-config.h"
|
#include "obs-scripting-config.h"
|
||||||
#include <util/platform.h>
|
#include <util/platform.h>
|
||||||
|
|
||||||
#if UI_ENABLED
|
#if defined(ENABLE_UI)
|
||||||
#include "obs-frontend-api.h"
|
#include "obs-frontend-api.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ static inline void wrap_blog(int log_level, const char *message)
|
|||||||
%include "util/base.h"
|
%include "util/base.h"
|
||||||
%include "util/platform.h"
|
%include "util/platform.h"
|
||||||
|
|
||||||
#if UI_ENABLED
|
#if defined(ENABLE_UI)
|
||||||
%include "obs-frontend-api.h"
|
%include "obs-frontend-api.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user