From 886e9e839b304b7567dd655e4fa3afb2251c96ca Mon Sep 17 00:00:00 2001 From: "S.V" Date: Fri, 31 Mar 2017 23:10:18 +0200 Subject: Core/ScriptReloadMgr: Fixed scripts hot swapping on OS X (#19365) --- cmake/macros/ConfigureScripts.cmake | 4 +++- src/server/game/Scripting/ScriptReloadMgr.cpp | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cmake/macros/ConfigureScripts.cmake b/cmake/macros/ConfigureScripts.cmake index f6371a32f96..1658f47e9e2 100644 --- a/cmake/macros/ConfigureScripts.cmake +++ b/cmake/macros/ConfigureScripts.cmake @@ -85,10 +85,12 @@ function(IsDynamicLinkingRequired variable) set(${variable} ${IS_REQUIRED} PARENT_SCOPE) endfunction() -# Stores the native variable name +# Stores the native variable name function(GetNativeSharedLibraryName module variable) if(WIN32) set(${variable} "${module}.dll" PARENT_SCOPE) + elseif(APPLE) + set(${variable} "lib${module}.dylib" PARENT_SCOPE) else() set(${variable} "lib${module}.so" PARENT_SCOPE) endif() diff --git a/src/server/game/Scripting/ScriptReloadMgr.cpp b/src/server/game/Scripting/ScriptReloadMgr.cpp index b26ca8e0540..246d66698d2 100644 --- a/src/server/game/Scripting/ScriptReloadMgr.cpp +++ b/src/server/game/Scripting/ScriptReloadMgr.cpp @@ -66,6 +66,9 @@ namespace fs = boost::filesystem; #ifdef _WIN32 #include #define HOTSWAP_PLATFORM_REQUIRES_CACHING +#elif __APPLE__ + #include + #define HOTSWAP_PLATFORM_REQUIRES_CACHING #else // Posix #include // #define HOTSWAP_PLATFORM_REQUIRES_CACHING @@ -86,11 +89,13 @@ static char const* GetSharedLibraryPrefix() #endif } -// Returns "dll" on Windows and "so" on posix. +// Returns "dll" on Windows, "dylib" on OS X, and "so" on posix. static char const* GetSharedLibraryExtension() { #ifdef _WIN32 return "dll"; +#elif __APPLE__ + return "dylib"; #else // Posix return "so"; #endif @@ -111,7 +116,7 @@ static fs::path GetDirectoryOfExecutable() if (path.is_absolute()) return path.parent_path(); else - return fs::absolute(path).parent_path(); + return fs::canonical(fs::absolute(path)).parent_path(); } class SharedLibraryUnloader -- cgit v1.2.3