mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
Implement relocatable builds on Linux
- Change the path of the Sys folder to the executable's location - Add LINUX_LOCAL_DEV flag to use relocatable version on Linux - Add CMake definition for relocatable build
This commit is contained in:
parent
973118511a
commit
f2ae1a2545
@ -312,6 +312,12 @@ if(WIN32)
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
endif(WIN32)
|
||||
|
||||
# Add an option to build relocatable binaries on Linux
|
||||
# The Sys folder will need to be copied to the Binaries folder.
|
||||
if(UNIX)
|
||||
add_definitions(-DLINUX_LOCAL_DEV=0)
|
||||
endif(UNIX)
|
||||
|
||||
# Dolphin requires threads.
|
||||
# The Apple build may not need an explicit flag because one of the
|
||||
# frameworks may already provide it.
|
||||
|
@ -32,7 +32,7 @@
|
||||
#endif
|
||||
|
||||
// Shared data dirs (Sys and shared User for Linux)
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) || defined(LINUX_LOCAL_DEV)
|
||||
#define SYSDATA_DIR "Sys"
|
||||
#elif defined __APPLE__
|
||||
#define SYSDATA_DIR "Contents/Resources/Sys"
|
||||
|
@ -728,12 +728,12 @@ std::string GetBundleDirectory()
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
std::string& GetExeDirectory()
|
||||
{
|
||||
static std::string DolphinPath;
|
||||
if (DolphinPath.empty())
|
||||
{
|
||||
#ifdef _WIN32
|
||||
TCHAR Dolphin_exe_Path[2048];
|
||||
TCHAR Dolphin_exe_Clean_Path[MAX_PATH];
|
||||
GetModuleFileName(nullptr, Dolphin_exe_Path, 2048);
|
||||
@ -742,10 +742,20 @@ std::string& GetExeDirectory()
|
||||
else
|
||||
DolphinPath = TStrToUTF8(Dolphin_exe_Path);
|
||||
DolphinPath = DolphinPath.substr(0, DolphinPath.find_last_of('\\'));
|
||||
#else
|
||||
char Dolphin_exe_Path[PATH_MAX];
|
||||
ssize_t len = ::readlink("/proc/self/exe", Dolphin_exe_Path, sizeof(Dolphin_exe_Path));
|
||||
if (len == -1 || len == sizeof(Dolphin_exe_Path))
|
||||
{
|
||||
len = 0;
|
||||
}
|
||||
Dolphin_exe_Path[len] = '\0';
|
||||
DolphinPath = Dolphin_exe_Path;
|
||||
DolphinPath = DolphinPath.substr(0, DolphinPath.rfind('/'));
|
||||
#endif
|
||||
}
|
||||
return DolphinPath;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string GetSysDirectory()
|
||||
{
|
||||
@ -753,7 +763,7 @@ std::string GetSysDirectory()
|
||||
|
||||
#if defined (__APPLE__)
|
||||
sysDir = GetBundleDirectory() + DIR_SEP + SYSDATA_DIR;
|
||||
#elif defined (_WIN32)
|
||||
#elif defined (_WIN32) || defined (LINUX_LOCAL_DEV)
|
||||
sysDir = GetExeDirectory() + DIR_SEP + SYSDATA_DIR;
|
||||
#else
|
||||
sysDir = SYSDATA_DIR;
|
||||
|
@ -145,9 +145,7 @@ std::string GetSysDirectory();
|
||||
std::string GetBundleDirectory();
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
std::string &GetExeDirectory();
|
||||
#endif
|
||||
|
||||
bool WriteStringToFile(const std::string& str, const std::string& filename);
|
||||
bool ReadFileToString(const std::string& filename, std::string& str);
|
||||
|
Loading…
Reference in New Issue
Block a user