on xenial help sign in
Refactor paths to support UNITY_ env vars pointing to build/source dirs
4e5bb7aMichał Sawicz
include/paths.h.in+16−10
@@ -33,11 +33,21 @@ inline bool isRunningInstalled() {
33 return installed;
33 return installed;
34}
34}
35
35
36+inline QString buildDirectory() {
37+ if (!qEnvironmentVariableIsEmpty("UNITY_BINARY_DIR")) return qgetenv("UNITY_BINARY_DIR");
38+ return QString("@CMAKE_BINARY_DIR@");
39+}
40+
41+inline QString sourceDirectory() {
42+ if (!qEnvironmentVariableIsEmpty("UNITY_SOURCE_DIR")) return qgetenv("UNITY_SOURCE_DIR");
43+ return QString("@CMAKE_SOURCE_DIR@");
44+}
45+
36inline QString translationDirectory() {
46inline QString translationDirectory() {
37 if (isRunningInstalled()) {
47 if (isRunningInstalled()) {
38 return QString("@CMAKE_INSTALL_PREFIX@/share/locale");
48 return QString("@CMAKE_INSTALL_PREFIX@/share/locale");
39 } else {
49 } else {
40− return QString("@CMAKE_BINARY_DIR@/po/locale");
50+ return QString(buildDirectory() + "/po/locale");
41 }
51 }
42}
52}
43
53
@@ -45,14 +55,14 @@ inline QString qmlDirectory() {
45 if (isRunningInstalled()) {
55 if (isRunningInstalled()) {
46 return QString("@CMAKE_INSTALL_PREFIX@/@SHELL_APP_DIR@/");
56 return QString("@CMAKE_INSTALL_PREFIX@/@SHELL_APP_DIR@/");
47 } else {
57 } else {
48− return QString("@CMAKE_SOURCE_DIR@/qml/");
58+ return QString(sourceDirectory() + "/qml");
49 }
59 }
50}
60}
51
61
52inline QStringList overrideImportPaths() {
62inline QStringList overrideImportPaths() {
53 QStringList paths;
63 QStringList paths;
54 if (!isRunningInstalled()) {
64 if (!isRunningInstalled()) {
55− paths << QString("@CMAKE_BINARY_DIR@/plugins");
65+ paths << QString(buildDirectory() + "/plugins");
56 }
66 }
57 return paths;
67 return paths;
58}
68}
@@ -62,7 +72,7 @@ inline QStringList nonMirImportPaths() {
62 if (isRunningInstalled()) {
72 if (isRunningInstalled()) {
63 paths << QString("@CMAKE_INSTALL_PREFIX@/@SHELL_INSTALL_QML@/nonmirplugins");
73 paths << QString("@CMAKE_INSTALL_PREFIX@/@SHELL_INSTALL_QML@/nonmirplugins");
64 } else {
74 } else {
65− paths << QString("@CMAKE_BINARY_DIR@/nonmirplugins");
75+ paths << QString(buildDirectory() + "/nonmirplugins");
66 }
76 }
67 return paths;
77 return paths;
68}
78}
@@ -77,7 +87,7 @@ inline QStringList fallbackImportPaths() {
77 } else {
87 } else {
78 paths << QString("@USS_PRIVATE_PLUGINDIR@");
88 paths << QString("@USS_PRIVATE_PLUGINDIR@");
79 paths << QString("@SHELL_PLUGINDIR@");
89 paths << QString("@SHELL_PLUGINDIR@");
80− paths << QString("@CMAKE_BINARY_DIR@/tests/mocks");
90+ paths << QString(buildDirectory() + "/tests/mocks");
81 }
91 }
82 return paths;
92 return paths;
83}
93}
@@ -86,7 +96,7 @@ inline QString mockPluginsDir() {
86 if (isRunningInstalled()) {
96 if (isRunningInstalled()) {
87 return QString("@CMAKE_INSTALL_PREFIX@/@SHELL_INSTALL_QML@/mocks");
97 return QString("@CMAKE_INSTALL_PREFIX@/@SHELL_INSTALL_QML@/mocks");
88 } else {
98 } else {
89− return QString("@CMAKE_BINARY_DIR@/tests/mocks");
99+ return QString(buildDirectory() + "/tests/mocks");
90 }
100 }
91}
101}
92
102
@@ -99,10 +109,6 @@ inline QStringList shellDataDirs() {
99 return dirs;
109 return dirs;
100}
110}
101
111
102−inline QString sourceDirectory() {
103− return QString("@CMAKE_SOURCE_DIR@/");
104−}
105−
106inline void prependImportPaths(QQmlEngine *engine, const QStringList &paths)
112inline void prependImportPaths(QQmlEngine *engine, const QStringList &paths)
107{
113{
108 QStringList importPathList = engine->importPathList();
114 QStringList importPathList = engine->importPathList();
src/Dash/main.cpp+1−1
@@ -101,7 +101,7 @@ int main(int argc, const char *argv[])
101 mouseTouchAdaptor = MouseTouchAdaptor::instance();
101 mouseTouchAdaptor = MouseTouchAdaptor::instance();
102 }
102 }
103
103
104− QUrl source(::qmlDirectory()+"Dash/DashApplication.qml");
104+ QUrl source(::qmlDirectory() + "/Dash/DashApplication.qml");
105 prependImportPaths(view->engine(), ::overrideImportPaths());
105 prependImportPaths(view->engine(), ::overrideImportPaths());
106 appendImportPaths(view->engine(), ::fallbackImportPaths());
106 appendImportPaths(view->engine(), ::fallbackImportPaths());
107
107
src/Panel/Indicators/client/indicatorsclient.cpp+1−1
@@ -36,7 +36,7 @@ IndicatorsClient::IndicatorsClient(int &argc, char **argv)
36 QStringList args = m_application->arguments();
36 QStringList args = m_application->arguments();
37
37
38 m_view = new QQuickView;
38 m_view = new QQuickView;
39− m_view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()+"Panel/Indicators/client/"));
39+ m_view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory() + "/Panel/Indicators/client/"));
40 prependImportPaths(m_view->engine(), ::overrideImportPaths());
40 prependImportPaths(m_view->engine(), ::overrideImportPaths());
41 appendImportPaths(m_view->engine(), ::fallbackImportPaths());
41 appendImportPaths(m_view->engine(), ::fallbackImportPaths());
42
42
src/main.cpp+1−1
@@ -105,7 +105,7 @@ int main(int argc, const char *argv[])
105 mouseTouchAdaptor = MouseTouchAdaptor::instance();
105 mouseTouchAdaptor = MouseTouchAdaptor::instance();
106 }
106 }
107
107
108− QUrl source(::qmlDirectory()+"OrientedShell.qml");
108+ QUrl source(::qmlDirectory() + "/OrientedShell.qml");
109 prependImportPaths(view->engine(), ::overrideImportPaths());
109 prependImportPaths(view->engine(), ::overrideImportPaths());
110 if (!isMirServer) {
110 if (!isMirServer) {
111 prependImportPaths(view->engine(), ::nonMirImportPaths());
111 prependImportPaths(view->engine(), ::nonMirImportPaths());
tests/mocks/AccountsService/AccountsService.cpp+1−1
@@ -24,7 +24,7 @@ AccountsService::AccountsService(QObject* parent)
24 : QObject(parent),
24 : QObject(parent),
25 m_enableLauncherWhileLocked(true),
25 m_enableLauncherWhileLocked(true),
26 m_enableIndicatorsWhileLocked(true),
26 m_enableIndicatorsWhileLocked(true),
27− m_backgroundFile(qmlDirectory() + "graphics/phone_background.jpg"),
27+ m_backgroundFile(qmlDirectory() + "/graphics/phone_background.jpg"),
28 m_statsWelcomeScreen(true),
28 m_statsWelcomeScreen(true),
29 m_failedLogins(0),
29 m_failedLogins(0),
30 m_demoEdges(false),
30 m_demoEdges(false),
tests/mocks/Unity/Launcher/MockLauncherItem.cpp+1−1
@@ -29,7 +29,7 @@ MockLauncherItem::MockLauncherItem(const QString &appId, const QString& desktopF
29 m_appId(appId),
29 m_appId(appId),
30 m_desktopFile(desktopFile),
30 m_desktopFile(desktopFile),
31 m_name(name),
31 m_name(name),
32− m_icon(qmlDirectory() + "graphics/applicationIcons/" + icon + ".png"),
32+ m_icon(qmlDirectory() + "/graphics/applicationIcons/" + icon + ".png"),
33 m_pinned(false),
33 m_pinned(false),
34 m_running(false),
34 m_running(false),
35 m_recent(false),
35 m_recent(false),
tests/mocks/Unity/fake_resultsmodel.cpp+1−1
@@ -78,7 +78,7 @@ ResultsModel::data(const QModelIndex& index, int role) const
78 case RoleTitle:
78 case RoleTitle:
79 return QString("Title.%1.%2").arg(m_categoryId).arg(index.row());
79 return QString("Title.%1.%2").arg(m_categoryId).arg(index.row());
80 case RoleArt:
80 case RoleArt:
81− return qmlDirectory() + "graphics/applicationIcons/dash.png";
81+ return qmlDirectory() + "/graphics/applicationIcons/dash.png";
82 case RoleSubtitle:
82 case RoleSubtitle:
83 return QString("Subtitle.%1.%2").arg(m_categoryId).arg(index.row());
83 return QString("Subtitle.%1.%2").arg(m_categoryId).arg(index.row());
84 case RoleMascot:
84 case RoleMascot:
tests/mocks/Unity/fake_scope.cpp+2−2
@@ -253,11 +253,11 @@ QVariantMap Scope::customizations() const
253 m["foreground-color"] = "blue";
253 m["foreground-color"] = "blue";
254 m["page-header"] = h;
254 m["page-header"] = h;
255 } else if (m_id == "MockScope4") {
255 } else if (m_id == "MockScope4") {
256− h["navigation-background"] = QUrl(sourceDirectory() + "tests/qmltests/Dash/artwork/background.png");
256+ h["navigation-background"] = QUrl(sourceDirectory() + "/tests/qmltests/Dash/artwork/background.png");
257 m["page-header"] = h;
257 m["page-header"] = h;
258 } else if (m_id == "MockScope5") {
258 } else if (m_id == "MockScope5") {
259 h["background"] = "gradient:///lightgrey/grey";
259 h["background"] = "gradient:///lightgrey/grey";
260− h["logo"] = QUrl(sourceDirectory() + "tests/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svg");
260+ h["logo"] = QUrl(sourceDirectory() + "/tests/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svg");
261 h["divider-color"] = "red";
261 h["divider-color"] = "red";
262 h["navigation-background"] = "color:///black";
262 h["navigation-background"] = "color:///black";
263 m["page-header"] = h;
263 m["page-header"] = h;
tests/mocks/Unity/fake_scopesoverview.cpp+1−1
@@ -308,7 +308,7 @@ QVariant ScopesOverviewResultsModel::data(const QModelIndex& index, int role) co
308 case RoleSubtitle:
308 case RoleSubtitle:
309 return scope && scope->name() == "Videos this is long ab cd ef gh ij kl" ? "tube, movies, cinema, pictures, art, moving images, magic in a box" : QString();
309 return scope && scope->name() == "Videos this is long ab cd ef gh ij kl" ? "tube, movies, cinema, pictures, art, moving images, magic in a box" : QString();
310 case RoleArt:
310 case RoleArt:
311− return qmlDirectory() + "graphics/applicationIcons/dash.png";
311+ return qmlDirectory() + "/graphics/applicationIcons/dash.png";
312 case RoleMascot:
312 case RoleMascot:
313 case RoleEmblem:
313 case RoleEmblem:
314 case RoleSummary:
314 case RoleSummary:
tools/scopetool.cpp+1−1
@@ -89,7 +89,7 @@ int main(int argc, char *argv[])
89 view->setTitle(QGuiApplication::applicationName());
89 view->setTitle(QGuiApplication::applicationName());
90 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
90 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
91
91
92− QUrl source(::qmlDirectory() + "ScopeTool.qml");
92+ QUrl source(::qmlDirectory() + "/ScopeTool.qml");
93 prependImportPaths(view->engine(), ::overrideImportPaths());
93 prependImportPaths(view->engine(), ::overrideImportPaths());
94 prependImportPaths(view->engine(), ::nonMirImportPaths());
94 prependImportPaths(view->engine(), ::nonMirImportPaths());
95 appendImportPaths(view->engine(), ::fallbackImportPaths());
95 appendImportPaths(view->engine(), ::fallbackImportPaths());