build: Added portable Windows build

* implemented detecting if Sourcetrail runs as installed version by checking if user folder exists next to exe
* removed "deploy"-flag mechanism for windows builds
* moved code to set the app path for windows builds to includesWindows.h
* implemented functions in setup bash script to copy dlls
* bash functions for installer and portable packaging
This commit is contained in:
mlangkabel
2018-01-16 13:55:33 +01:00
parent 0a53d2828d
commit 8b3b3c3f00
7 changed files with 232 additions and 298 deletions
-44
View File
@@ -6,53 +6,9 @@ std::string AppPath::m_appPath = "";
std::string AppPath::getAppPath()
{
if (m_appPath.length() <= 0)
{
setupAppPath();
}
return m_appPath;
}
void AppPath::setupAppPath()
{
#ifdef _WIN32
HMODULE hModule = GetModuleHandleW(NULL);
WCHAR path[MAX_PATH];
GetModuleFileNameW(hModule, path, MAX_PATH);
std::wstring wPath(path);
m_appPath = std::string(wPath.begin(), wPath.end());
size_t pos = m_appPath.find_last_of("/");
if (pos == std::string::npos)
{
pos = m_appPath.find_last_of("\\");
}
if (pos != std::string::npos)
{
m_appPath = m_appPath.substr(0, pos + 1);
}
#elif _WIN64
HMODULE hModule = GetModuleHandleW(NULL);
WCHAR path[MAX_PATH];
GetModuleFileNameW(hModule, path, MAX_PATH);
std::wstring wPath(path);
m_appPath = std::string(wPath.begin(), wPath.end());
size_t pos = m_appPath.find_last_of("/");
if (pos == std::string::npos)
{
pos = m_appPath.find_last_of("\\");
}
if (pos != std::string::npos)
{
m_appPath = m_appPath.substr(0, pos + 1);
}
#endif // WINDOWS
}
bool AppPath::setAppPath(std::string path)
{
if(!path.empty())
+1 -7
View File
@@ -7,11 +7,7 @@
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <Windows.h>
#elif _WIN64
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <Windows.h>
#endif // WINDOWS
#endif // _WIN32
class AppPath
{
@@ -20,8 +16,6 @@ public:
static bool setAppPath(std::string path);
private:
static void setupAppPath();
static std::string m_appPath;
};
-1
View File
@@ -1,7 +1,6 @@
add_files(
LIB_GUI_FILES
platform_includes/deploy.h
platform_includes/includesLinux.h
platform_includes/includesMac.h
platform_includes/includesWindows.h
-1
View File
@@ -1 +0,0 @@
// #define DEPLOY
+34 -15
View File
@@ -8,35 +8,54 @@
#include "vld.h"
#include "utility/file/FileSystem.h"
#include "utility/AppPath.h"
#include "utility/ResourcePaths.h"
#include "utility/UserPaths.h"
#include "utility/utility.h"
#include "platform_includes/deploy.h"
void setupPlatform(int argc, char *argv[])
{
}
void setupApp(int argc, char *argv[])
{
#ifdef DEPLOY
std::string path = std::getenv("APPDATA");
path += "/../local/Coati Software/";
if (utility::getApplicationArchitectureType() == APPLICATION_ARCHITECTURE_X86_64)
{
path += "Sourcetrail 64-bit/";
HMODULE hModule = GetModuleHandleW(NULL);
WCHAR path[MAX_PATH];
GetModuleFileNameW(hModule, path, MAX_PATH);
const std::wstring wPath(path);
std::string appPath = std::string(wPath.begin(), wPath.end());
size_t pos = appPath.find_last_of("/");
if (pos == std::string::npos)
{
pos = appPath.find_last_of("\\");
}
if (pos != std::string::npos)
{
appPath = appPath.substr(0, pos + 1);
}
AppPath::setAppPath(FilePath(appPath).str());
}
else
{
path += "Sourcetrail/";
FilePath userDataPath(AppPath::getAppPath() + "user/");
if (!userDataPath.exists())
{
userDataPath = FilePath(std::string(std::getenv("APPDATA")) + "/../local/Coati Software/");
if (utility::getApplicationArchitectureType() == APPLICATION_ARCHITECTURE_X86_64)
{
userDataPath.concatenate(FilePath("Sourcetrail 64-bit/"));
}
else
{
userDataPath.concatenate(FilePath("Sourcetrail/"));
}
userDataPath.makeCanonical();
}
UserPaths::setUserDataPath(userDataPath);
}
UserPaths::setUserDataPath(FilePath(path));
#else
std::string path = QDir::currentPath().toStdString();
path += "/user/";
UserPaths::setUserDataPath(FilePath(path));
#endif
// This "copyFile" method does nothing if the copy destination already exist
FileSystem::copyFile(ResourcePaths::getFallbackPath().concatenate(FilePath("ApplicationSettings.xml")), UserPaths::getAppSettingsPath());