obs-scripting: Update CMakeLists.txt for scripting modules

This commit is contained in:
PatTheMav
2022-03-16 23:11:08 +01:00
parent dba1041034
commit dbdf5c7f7a
9 changed files with 379 additions and 387 deletions
+26 -30
View File
@@ -32,19 +32,21 @@
#endif
#ifdef __APPLE__
#define SO_EXT "dylib"
#define SO_EXT "so"
#elif _WIN32
#include <windows.h>
#define SO_EXT "dll"
#else
#define SO_EXT "so"
#endif
static const char *startup_script_template = "\
static const char *startup_script_template =
"\
for val in pairs(package.preload) do\n\
package.preload[val] = nil\n\
end\n\
package.cpath = package.cpath .. \";\" .. \"%s/Contents/MacOS/?.so\" .. \";\" .. \"%s\" .. \"/?." SO_EXT
"\"\n\
package.cpath = package.cpath .. \";\" .. \"%s/?." SO_EXT
"\" .. \";\" .. \"%s\" .. \"/?." SO_EXT "\"\n\
require \"obslua\"\n";
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)
{
struct dstr dep_paths = {0};
struct dstr tmp = {0};
pthread_mutex_init(&tick_mutex, NULL);
@@ -1322,34 +1323,29 @@ void obs_lua_load(void)
/* ---------------------------------------------- */
/* Initialize Lua startup script */
char *bundlePath = "./";
#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"));
#if _WIN32
#define PATH_MAX MAX_PATH
#endif
dstr_printf(&tmp, startup_script_template, bundlePath, SCRIPT_DIR);
startup_script = tmp.array;
char import_path[PATH_MAX];
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);
}