deps/obs-scripting: Fix installed files/locations on linux

Uses the 'install' command in cmake to install scripting modules/files
(such as _obspython.so, obslua.so, and obspython.py), and changes the
install location of those files on all operating systems.  If using a
non-unix structure install, those files will be installed in
data/obs-scripting/[32bit/64bit], otherwise with unix structure installs
those files will be installed to [/usr/local/lib]/obs-scripting.
This commit is contained in:
jp9000
2018-01-16 03:55:38 -08:00
parent 17d2a17f9e
commit db2d4c97e8
6 changed files with 34 additions and 7 deletions

View File

@@ -16,6 +16,7 @@
#define OFF 0
#endif
#define SCRIPT_DIR "@OBS_SCRIPT_PLUGIN_PATH@"
#define PYTHON_LIB "@PYTHON_LIB@"
#define COMPILE_LUA @LUAJIT_FOUND@
#define COMPILE_PYTHON @PYTHON_FOUND@

View File

@@ -31,12 +31,20 @@
# define ARCH_DIR "32bit"
#endif
#ifdef __APPLE__
# define SO_EXT "dylib"
#elif _WIN32
# define SO_EXT "dll"
#else
# define SO_EXT "so"
#endif
static const char *startup_script_template = "\
for val in pairs(package.preload) do\n\
package.preload[val] = nil\n\
end\n\
require \"obslua\"\n\
package.path = package.path .. \"%s\"\n";
package.cpath = package.cpath .. \";\" .. \"%s\" .. \"/?." SO_EXT "\"\n\
require \"obslua\"\n";
static const char *get_script_path_func = "\
function script_path()\n\
@@ -1267,8 +1275,7 @@ void obs_lua_load(void)
/* ---------------------------------------------- */
/* Initialize Lua startup script */
dstr_printf(&tmp, startup_script_template,
dep_paths.array);
dstr_printf(&tmp, startup_script_template, SCRIPT_DIR);
startup_script = tmp.array;
dstr_free(&dep_paths);

View File

@@ -1649,6 +1649,8 @@ bool obs_scripting_load_python(const char *python_path)
/* ---------------------------------------------- */
/* Load main interface module */
add_to_python_path(SCRIPT_DIR);
py_obspython = PyImport_ImportModule("obspython");
bool success = !py_error();
if (!success) {

View File

@@ -31,10 +31,13 @@ function(install_plugin_bin_swig target additional_target)
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>/bin/${_bit_suffix}$<TARGET_FILE_NAME:${additional_target}>"
"${OBS_OUTPUT_DIR}/$<CONFIGURATION>/data/obs-scripting/${_bit_suffix}$<TARGET_FILE_NAME:${additional_target}>"
VERBATIM)
endfunction()

View File

@@ -45,15 +45,20 @@ function(install_plugin_bin_swig target additional_target)
set_target_properties(${additional_target} PROPERTIES
PREFIX "")
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>/bin/${_bit_suffix}/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>/bin/${_bit_suffix}$<TARGET_FILE_NAME:${additional_target}>"
"${OBS_OUTPUT_DIR}/$<CONFIGURATION>/data/obs-scripting/${_bit_suffix}$<TARGET_FILE_NAME:${additional_target}>"
VERBATIM)
endfunction()