From 0642571ecbc9fe7c2dc3f7be1e0906eae8ecfd60 Mon Sep 17 00:00:00 2001 From: JoLan Date: Thu, 23 Oct 2008 08:27:56 +0200 Subject: [PATCH] fixed script library loading for low_endian and MacOS --- src/framework/Platform/Define.h | 8 ++++++-- src/game/ScriptCalls.cpp | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/framework/Platform/Define.h b/src/framework/Platform/Define.h index 3f8cc15..d1d15fe 100644 --- a/src/framework/Platform/Define.h +++ b/src/framework/Platform/Define.h @@ -52,12 +52,16 @@ # define MANGOS_LOAD_LIBRARY(a) dlopen(a,RTLD_NOW) # define MANGOS_CLOSE_LIBRARY dlclose # define MANGOS_GET_PROC_ADDR dlsym -# if defined(__APPLE_CC__) && defined(BIG_ENDIAN) +# ifndef BIG_ENDIAN # define MANGOS_IMPORT __attribute__ ((longcall)) # else # define MANGOS_IMPORT __attribute__ ((cdecl)) # endif //__APPLE_CC__ && BIG_ENDIAN -# define MANGOS_SCRIPT_EXT ".so" +# ifdef __APPLE_CC__ +# define MANGOS_SCRIPT_EXT ".dylib" +# else +# define MANGOS_SCRIPT_EXT ".so" +# endif //__APPLE_CC # define MANGOS_SCRIPT_NAME "libmangosscript" #endif //PLATFORM diff --git a/src/game/ScriptCalls.cpp b/src/game/ScriptCalls.cpp index 00435fa..90892cc 100644 --- a/src/game/ScriptCalls.cpp +++ b/src/game/ScriptCalls.cpp @@ -45,8 +45,13 @@ bool LoadScriptingModule(char const* libName) std::string name = strlen(libName) ? libName : MANGOS_SCRIPT_NAME; name += MANGOS_SCRIPT_EXT; - testScript->hScriptsLib=MANGOS_LOAD_LIBRARY(name.c_str()); - + #if defined(__APPLE_CC__) + name = "@executable_path/../lib/"+name; + testScript->hScriptsLib=dlopen(name.c_str(), RTLD_GLOBAL | RTLD_NOW); + #else + testScript->hScriptsLib=MANGOS_LOAD_LIBRARY(name.c_str()); + #endif + if(!testScript->hScriptsLib ) { printf("Error loading Scripts Library %s !\n",name.c_str()); -- 1.6.0.2 From d69740da580bc7f7b0e863e8d98b12b6f8d45842 Mon Sep 17 00:00:00 2001 From: JoLan Date: Fri, 24 Oct 2008 09:34:40 +0200 Subject: [PATCH] MacOS : Load system-wide script library if not found in ../lib --- src/game/ScriptCalls.cpp | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/game/ScriptCalls.cpp b/src/game/ScriptCalls.cpp index 90892cc..742b4cd 100644 --- a/src/game/ScriptCalls.cpp +++ b/src/game/ScriptCalls.cpp @@ -45,13 +45,15 @@ bool LoadScriptingModule(char const* libName) std::string name = strlen(libName) ? libName : MANGOS_SCRIPT_NAME; name += MANGOS_SCRIPT_EXT; - #if defined(__APPLE_CC__) - name = "@executable_path/../lib/"+name; - testScript->hScriptsLib=dlopen(name.c_str(), RTLD_GLOBAL | RTLD_NOW); + #if defined(__APPLE_CC__) + std::string relative_name = "@executable_path/../lib/"+name; // dlopen dosent search mangos's lib + testScript->hScriptsLib=dlopen(relative_name.c_str(), RTLD_GLOBAL | RTLD_NOW); + if(!testScript->hScriptsLib ) + testScript->hScriptsLib=dlopen(name.c_str(), RTLD_GLOBAL | RTLD_NOW); #else testScript->hScriptsLib=MANGOS_LOAD_LIBRARY(name.c_str()); #endif - + if(!testScript->hScriptsLib ) { printf("Error loading Scripts Library %s !\n",name.c_str()); -- 1.6.0.2