Commit 36b443df authored by Eike Ziller's avatar Eike Ziller

Add defines for relative data paths

Derive the relative paths used in code from the paths used by the build
system.

Change-Id: I208ee55d3c1ee76921734f5c1c6c40d3fcb9724c
Reviewed-by: Christian Kandeler's avatarChristian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent b3a9031b
import qbs
import qbs.Environment
import qbs.FileInfo
import "qtc.js" as HelperFunctions
Module {
......@@ -62,6 +63,13 @@ Module {
property stringList generalDefines: [
"QT_CREATOR",
'IDE_LIBRARY_BASENAME="' + libDirName + '"',
'RELATIVE_PLUGIN_PATH="' + FileInfo.relativePath('/' + ide_bin_path,
'/' + ide_plugin_path) + '"',
'RELATIVE_LIBEXEC_PATH="' + FileInfo.relativePath('/' + ide_bin_path,
'/' + ide_libexec_path) + '"',
'RELATIVE_DATA_PATH="' + FileInfo.relativePath('/' + ide_bin_path,
'/' + ide_data_path) + '"',
'RELATIVE_DOC_PATH="' + FileInfo.relativePath('/' + ide_bin_path, '/' + ide_doc_path) + '"',
"QT_NO_CAST_TO_ASCII",
"QT_RESTRICTED_CAST_FROM_ASCII",
"QT_DISABLE_DEPRECATED_BEFORE=0x050600",
......
......@@ -147,6 +147,15 @@ osx {
INSTALL_APP_PATH = $$QTC_PREFIX/bin
}
RELATIVE_PLUGIN_PATH = $$relative_path($$IDE_PLUGIN_PATH, $$IDE_BIN_PATH)
RELATIVE_LIBEXEC_PATH = $$relative_path($$IDE_LIBEXEC_PATH, $$IDE_BIN_PATH)
RELATIVE_DATA_PATH = $$relative_path($$IDE_DATA_PATH, $$IDE_BIN_PATH)
RELATIVE_DOC_PATH = $$relative_path($$IDE_DOC_PATH, $$IDE_BIN_PATH)
DEFINES += $$shell_quote(RELATIVE_PLUGIN_PATH=\"$$RELATIVE_PLUGIN_PATH\")
DEFINES += $$shell_quote(RELATIVE_LIBEXEC_PATH=\"$$RELATIVE_LIBEXEC_PATH\")
DEFINES += $$shell_quote(RELATIVE_DATA_PATH=\"$$RELATIVE_DATA_PATH\")
DEFINES += $$shell_quote(RELATIVE_DOC_PATH=\"$$RELATIVE_DOC_PATH\")
INCLUDEPATH += \
$$IDE_BUILD_TREE/src \ # for <app/app_version.h> in case of actual build directory
$$IDE_SOURCE_TREE/src \ # for <app/app_version.h> in case of binary package with dev package
......
......@@ -198,30 +198,14 @@ static bool copyRecursively(const QString &srcFilePath,
static inline QStringList getPluginPaths()
{
QStringList rc;
// Figure out root: Up one from 'bin'
QDir rootDir = QApplication::applicationDirPath();
rootDir.cdUp();
const QString rootDirPath = rootDir.canonicalPath();
QString pluginPath;
if (Utils::HostOsInfo::isMacHost()) {
// 1) "PlugIns" (OS X)
pluginPath = rootDirPath + QLatin1String("/PlugIns");
rc.push_back(pluginPath);
} else {
// 2) "plugins" (Win/Linux)
pluginPath = rootDirPath;
pluginPath += QLatin1Char('/');
pluginPath += QLatin1String(IDE_LIBRARY_BASENAME);
pluginPath += QLatin1String("/qtcreator/plugins");
rc.push_back(pluginPath);
}
// 3) <localappdata>/plugins/<ideversion>
QStringList rc(QDir::cleanPath(QApplication::applicationDirPath()
+ '/' + RELATIVE_PLUGIN_PATH));
// Local plugin path: <localappdata>/plugins/<ideversion>
// where <localappdata> is e.g.
// "%LOCALAPPDATA%\QtProject\qtcreator" on Windows Vista and later
// "$XDG_DATA_HOME/data/QtProject/qtcreator" or "~/.local/share/data/QtProject/qtcreator" on Linux
// "~/Library/Application Support/QtProject/Qt Creator" on Mac
pluginPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
QString pluginPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
if (Utils::HostOsInfo::isAnyUnixHost() && !Utils::HostOsInfo::isMacHost())
pluginPath += QLatin1String("/data");
pluginPath += QLatin1Char('/')
......@@ -284,13 +268,9 @@ static inline QSettings *userSettings()
return createUserSettings();
}
static const char *SHARE_PATH =
Utils::HostOsInfo::isMacHost() ? "/../Resources" : "/../share/qtcreator";
void loadFonts()
{
const QDir dir(QCoreApplication::applicationDirPath() + QLatin1String(SHARE_PATH)
+ QLatin1String("/fonts/"));
const QDir dir(QCoreApplication::applicationDirPath() + '/' + RELATIVE_DATA_PATH + "/fonts/");
foreach (const QFileInfo &fileInfo, dir.entryInfoList(QStringList("*.ttf"), QDir::Files))
QFontDatabase::addApplicationFont(fileInfo.absoluteFilePath());
......@@ -329,7 +309,8 @@ int main(int argc, char **argv)
QThreadPool::globalInstance()->setMaxThreadCount(qMax(4, 2 * threadCount));
// Display a backtrace once a serious signal is delivered (Linux only).
const QString libexecPath = QCoreApplication::applicationDirPath() + "/../libexec/qtcreator";
const QString libexecPath = QCoreApplication::applicationDirPath()
+ '/' + RELATIVE_LIBEXEC_PATH;
CrashHandlerSetup setupCrashHandler(appNameC, CrashHandlerSetup::EnableRestart, libexecPath);
#ifdef ENABLE_QT_BREAKPAD
......@@ -378,7 +359,7 @@ int main(int argc, char **argv)
// Must be done before any QSettings class is created
QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope,
QCoreApplication::applicationDirPath() + QLatin1String(SHARE_PATH));
QCoreApplication::applicationDirPath() + '/' + RELATIVE_DATA_PATH);
QSettings::setDefaultFormat(QSettings::IniFormat);
// plugin manager takes control of this settings object
QSettings *settings = userSettings();
......@@ -399,7 +380,7 @@ int main(int argc, char **argv)
if (!overrideLanguage.isEmpty())
uiLanguages.prepend(overrideLanguage);
const QString &creatorTrPath = QCoreApplication::applicationDirPath()
+ QLatin1String(SHARE_PATH) + QLatin1String("/translations");
+ '/' + RELATIVE_DATA_PATH + "/translations";
foreach (QString locale, uiLanguages) {
locale = QLocale(locale).name();
if (translator.load(QLatin1String("qtcreator_") + locale, creatorTrPath)) {
......
......@@ -402,9 +402,7 @@ QString ICore::userInterfaceLanguage()
QString ICore::resourcePath()
{
const QString sharePath = QLatin1String(Utils::HostOsInfo::isMacHost()
? "/../Resources" : "/../share/qtcreator");
return QDir::cleanPath(QCoreApplication::applicationDirPath() + sharePath);
return QDir::cleanPath(QCoreApplication::applicationDirPath() + '/' + RELATIVE_DATA_PATH);
}
QString ICore::userResourcePath()
......@@ -424,9 +422,7 @@ QString ICore::userResourcePath()
QString ICore::documentationPath()
{
const QString docPath = QLatin1String(Utils::HostOsInfo::isMacHost()
? "/../Resources/doc" : "/../share/doc/qtcreator");
return QDir::cleanPath(QCoreApplication::applicationDirPath() + docPath);
return QDir::cleanPath(QCoreApplication::applicationDirPath() + '/' + RELATIVE_DOC_PATH);
}
/*!
......@@ -435,21 +431,7 @@ QString ICore::documentationPath()
*/
QString ICore::libexecPath()
{
QString path;
switch (Utils::HostOsInfo::hostOs()) {
case Utils::OsTypeWindows:
path = QCoreApplication::applicationDirPath();
break;
case Utils::OsTypeMac:
path = QCoreApplication::applicationDirPath() + QLatin1String("/../Resources");
break;
case Utils::OsTypeLinux:
case Utils::OsTypeOtherUnix:
case Utils::OsTypeOther:
path = QCoreApplication::applicationDirPath() + QLatin1String("/../libexec/qtcreator");
break;
}
return QDir::cleanPath(path);
return QDir::cleanPath(QApplication::applicationDirPath() + '/' + RELATIVE_LIBEXEC_PATH);
}
static QString compilerString()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment