Skip to content

Commit

Permalink
Core/ScriptReloadMgr: Fixed scripts hot swapping on OS X (TrinityCore…
Browse files Browse the repository at this point in the history
  • Loading branch information
svranesevic authored and Gacko committed Apr 5, 2017
1 parent 0b0d4c4 commit 886e9e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion cmake/macros/ConfigureScripts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 7 additions & 2 deletions src/server/game/Scripting/ScriptReloadMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ namespace fs = boost::filesystem;
#ifdef _WIN32
#include <windows.h>
#define HOTSWAP_PLATFORM_REQUIRES_CACHING
#elif __APPLE__
#include <dlfcn.h>
#define HOTSWAP_PLATFORM_REQUIRES_CACHING
#else // Posix
#include <dlfcn.h>
// #define HOTSWAP_PLATFORM_REQUIRES_CACHING
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 886e9e8

Please sign in to comment.