build: Provide AppImage package for Linux (issue #279) (#945)

* Create AppImage package using linuxdeployqt in Travis CI
* Renamed appPath() to sharedDataPath()
* Fixed include error in tutorial
This commit is contained in:
Eberhard Gräther
2020-03-29 17:10:30 +02:00
committed by GitHub
parent 76562bb8ee
commit bf6a017720
20 changed files with 184 additions and 45 deletions
+2 -1
View File
@@ -97,7 +97,8 @@ int main(int argc, char *argv[])
#pragma warning(push)
#pragma warning(disable : 4996)
if (utility::getOsType() == OS_LINUX && std::getenv("SOURCETRAIL_VIA_SCRIPT") == nullptr)
if (utility::getOsType() == OS_LINUX && std::getenv("SOURCETRAIL_VIA_SCRIPT") == nullptr &&
!FilePath(QCoreApplication::applicationDirPath().toStdWString() + L"/../share").exists())
{
std::cout << "ERROR: Please run Sourcetrail via the Sourcetrail.sh script!" << std::endl;
}
+2 -2
View File
@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
logFilePath = argv[5];
}
AppPath::setAppPath(FilePath(appPath));
AppPath::setSharedDataPath(FilePath(appPath));
UserPaths::setUserDataPath(FilePath(userDataPath));
if (!logFilePath.empty())
@@ -88,7 +88,7 @@ int main(int argc, char *argv[])
appSettings->load(FilePath(UserPaths::getAppSettingsPath()));
LogManager::getInstance()->setLoggingEnabled(appSettings->getLoggingEnabled());
LOG_INFO(L"appPath: " + AppPath::getAppPath().wstr());
LOG_INFO(L"sharedDataPath: " + AppPath::getSharedDataPath().wstr());
LOG_INFO(L"userDataPath: " + UserPaths::getUserDataPath().wstr());
+31 -5
View File
@@ -1,17 +1,43 @@
#include "AppPath.h"
FilePath AppPath::m_appPath(L"");
FilePath AppPath::m_sharedDataPath(L"");
FilePath AppPath::m_cxxIndexerPath(L"");
FilePath AppPath::getAppPath()
FilePath AppPath::getSharedDataPath()
{
return m_appPath;
return m_sharedDataPath;
}
bool AppPath::setAppPath(const FilePath& path)
bool AppPath::setSharedDataPath(const FilePath& path)
{
if (!path.empty())
{
m_appPath = path;
m_sharedDataPath = path;
return true;
}
return false;
}
FilePath AppPath::getCxxIndexerPath()
{
#if _WIN32
const std::wstring cxxIndexerName(L"sourcetrail_indexer.exe");
#else
const std::wstring cxxIndexerName(L"sourcetrail_indexer");
#endif
if (!m_cxxIndexerPath.empty())
{
return m_cxxIndexerPath.getConcatenated(cxxIndexerName);
}
return m_sharedDataPath.getConcatenated(cxxIndexerName);
}
bool AppPath::setCxxIndexerPath(const FilePath& path)
{
if (!path.empty())
{
m_cxxIndexerPath = path;
return true;
}
return false;
+7 -3
View File
@@ -6,11 +6,15 @@
class AppPath
{
public:
static FilePath getAppPath();
static bool setAppPath(const FilePath& path);
static FilePath getSharedDataPath();
static bool setSharedDataPath(const FilePath& path);
static FilePath getCxxIndexerPath();
static bool setCxxIndexerPath(const FilePath& path);
private:
static FilePath m_appPath;
static FilePath m_sharedDataPath;
static FilePath m_cxxIndexerPath;
};
#endif // APP_PATH_H
+9 -9
View File
@@ -4,45 +4,45 @@
FilePath ResourcePaths::getColorSchemesPath()
{
return AppPath::getAppPath().concatenate(L"data/color_schemes/");
return AppPath::getSharedDataPath().concatenate(L"data/color_schemes/");
}
FilePath ResourcePaths::getSyntaxHighlightingRulesPath()
{
return AppPath::getAppPath().concatenate(L"data/syntax_highlighting_rules/");
return AppPath::getSharedDataPath().concatenate(L"data/syntax_highlighting_rules/");
}
FilePath ResourcePaths::getFallbackPath()
{
return AppPath::getAppPath().concatenate(L"data/fallback/");
return AppPath::getSharedDataPath().concatenate(L"data/fallback/");
}
FilePath ResourcePaths::getFontsPath()
{
return AppPath::getAppPath().concatenate(L"data/fonts/");
return AppPath::getSharedDataPath().concatenate(L"data/fonts/");
}
FilePath ResourcePaths::getGuiPath()
{
return AppPath::getAppPath().concatenate(L"data/gui/");
return AppPath::getSharedDataPath().concatenate(L"data/gui/");
}
FilePath ResourcePaths::getLicensePath()
{
return AppPath::getAppPath().concatenate(L"data/license/");
return AppPath::getSharedDataPath().concatenate(L"data/license/");
}
FilePath ResourcePaths::getJavaPath()
{
return AppPath::getAppPath().concatenate(L"data/java/");
return AppPath::getSharedDataPath().concatenate(L"data/java/");
}
FilePath ResourcePaths::getPythonPath()
{
return AppPath::getAppPath().concatenate(L"data/python/");
return AppPath::getSharedDataPath().concatenate(L"data/python/");
}
FilePath ResourcePaths::getCxxCompilerHeaderPath()
{
return AppPath::getAppPath().concatenate(L"data/cxx/include/").getCanonical();
return AppPath::getSharedDataPath().concatenate(L"data/cxx/include/").getCanonical();
}
+2 -9
View File
@@ -13,13 +13,6 @@
#include "UserPaths.h"
#include "utilityApp.h"
#if _WIN32
const std::wstring TaskBuildIndex::s_processName(L"sourcetrail_indexer.exe");
#else
const std::wstring TaskBuildIndex::s_processName(L"sourcetrail_indexer");
#endif
TaskBuildIndex::TaskBuildIndex(
size_t processCount,
std::shared_ptr<StorageProvider> storageProvider,
@@ -185,7 +178,7 @@ void TaskBuildIndex::handleMessage(MessageIndexingInterrupted* message)
void TaskBuildIndex::runIndexerProcess(int processId, const std::wstring& logFilePath)
{
const FilePath indexerProcessPath = AppPath::getAppPath().concatenate(s_processName);
const FilePath indexerProcessPath = AppPath::getCxxIndexerPath();
if (!indexerProcessPath.exists())
{
m_interrupted = true;
@@ -199,7 +192,7 @@ void TaskBuildIndex::runIndexerProcess(int processId, const std::wstring& logFil
std::vector<std::wstring> commandArguments;
commandArguments.push_back(std::to_wstring(processId));
commandArguments.push_back(utility::decodeFromUtf8(m_appUUID));
commandArguments.push_back(L"\"" + AppPath::getAppPath().getAbsolute().wstr() + L"\"");
commandArguments.push_back(L"\"" + AppPath::getSharedDataPath().getAbsolute().wstr() + L"\"");
commandArguments.push_back(L"\"" + UserPaths::getUserDataPath().getAbsolute().wstr() + L"\"");
if (!logFilePath.empty())
+10 -3
View File
@@ -44,8 +44,15 @@ void setupPlatform(int argc, char* argv[])
void setupApp(int argc, char* argv[])
{
AppPath::setAppPath(
FilePath(QCoreApplication::applicationDirPath().toStdWString() + L"/").getAbsolute());
FilePath appPath = FilePath(QCoreApplication::applicationDirPath().toStdWString() + L"/").getAbsolute();
AppPath::setSharedDataPath(appPath);
AppPath::setCxxIndexerPath(appPath);
// Check if bundled as Linux AppImage
if (appPath.getConcatenated(L"/../share/data").exists())
{
AppPath::setSharedDataPath(appPath.getConcatenated(L"/../share").getAbsolute());
}
std::string userdir(std::getenv("HOME"));
userdir.append("/.config/sourcetrail/");
@@ -60,7 +67,7 @@ void setupApp(int argc, char* argv[])
utility::copyNewFilesFromDirectory(
QString::fromStdWString(ResourcePaths::getFallbackPath().wstr()), userDataPath);
utility::copyNewFilesFromDirectory(
QString::fromStdWString(AppPath::getAppPath().concatenate(L"user/").wstr()), userDataPath);
QString::fromStdWString(AppPath::getSharedDataPath().concatenate(L"user/").wstr()), userDataPath);
}
#endif // INCLUDES_DEFAULT_H
+1 -1
View File
@@ -77,7 +77,7 @@ void setupPlatform(int argc, char* argv[])
void setupApp(int argc, char* argv[])
{
const FilePath path(QDir::currentPath().toStdWString() + L"/");
AppPath::setAppPath(path.getAbsolute());
AppPath::setSharedDataPath(path.getAbsolute());
}
#endif // INCLUDES_MAC_H
@@ -34,11 +34,11 @@ void setupApp(int argc, char* argv[])
{
appPath = appPath.substr(0, pos + 1);
}
AppPath::setAppPath(FilePath(appPath));
AppPath::setSharedDataPath(FilePath(appPath));
}
{
FilePath userDataPath = AppPath::getAppPath().concatenate(L"user/");
FilePath userDataPath = AppPath::getSharedDataPath().concatenate(L"user/");
if (!userDataPath.exists())
{
#pragma warning(push)
@@ -65,7 +65,7 @@ void setupApp(int argc, char* argv[])
}
else
{
userDataPath = AppPath::getAppPath().concatenate(L"user_fallback/");
userDataPath = AppPath::getSharedDataPath().concatenate(L"user_fallback/");
LOG_ERROR(
L"The \"%LOCALAPPDATA%\" path could not be found. Falling back to \"" +
userDataPath.wstr() + L"\" to store settings data.");
+3 -3
View File
@@ -505,8 +505,8 @@ TEST_CASE("sourcegroup java gradle generates expected output")
std::shared_ptr<ApplicationSettings> applicationSettings = ApplicationSettings::getInstance();
const FilePath storedAppPath = AppPath::getAppPath();
AppPath::setAppPath(storedAppPath.getConcatenated(L"../app").makeAbsolute());
const FilePath storedAppPath = AppPath::getSharedDataPath();
AppPath::setSharedDataPath(storedAppPath.getConcatenated(L"../app").makeAbsolute());
std::vector<FilePath> storedJreSystemLibraryPaths =
applicationSettings->getJreSystemLibraryPaths();
@@ -516,7 +516,7 @@ TEST_CASE("sourcegroup java gradle generates expected output")
projectName, std::make_shared<SourceGroupJavaGradle>(sourceGroupSettings));
applicationSettings->setJreSystemLibraryPaths(storedJreSystemLibraryPaths);
AppPath::setAppPath(storedAppPath);
AppPath::setSharedDataPath(storedAppPath);
# endif
}