on xenial help sign in
Change and extend the way non-installed scopes are started with the scope-tool.
5319a47Michal Hruby
tools/registry-tracker.cpp+18−4
@@ -25,8 +25,10 @@
25#include "registry-tracker.h"
25#include "registry-tracker.h"
26
26
27
27
28−RegistryTracker::RegistryTracker(QString const& scope_dir):
28+RegistryTracker::RegistryTracker(QStringList const& scopes, bool systemScopes, bool serverScopes):
29− m_scopeDir(scope_dir),
29+ m_scopes(scopes),
30+ m_systemScopes(systemScopes),
31+ m_serverScopes(serverScopes),
30 m_registry(nullptr),
32 m_registry(nullptr),
31 m_endpoints_dir(QDir::temp().filePath("scope-dev-endpoints.XXXXXX"))
33 m_endpoints_dir(QDir::temp().filePath("scope-dev-endpoints.XXXXXX"))
32{
34{
@@ -56,7 +58,8 @@ RegistryTracker::~RegistryTracker()
56"Zmq.EndpointDir = %2\n" \
58"Zmq.EndpointDir = %2\n" \
57"Zmq.ConfigFile = %3\n" \
59"Zmq.ConfigFile = %3\n" \
58"Scope.InstallDir = %4\n" \
60"Scope.InstallDir = %4\n" \
59−"Scoperunner.Path = %5\n"
61+"Scoperunner.Path = %5\n" \
62+"%6"
60
63
61#define MW_CONFIG \
64#define MW_CONFIG \
62"[Zmq]\n" \
65"[Zmq]\n" \
@@ -95,7 +98,17 @@ void RegistryTracker::runRegistry()
95 QString scopeRunnerPath = QDir(scopesLibdir).filePath("scoperunner/scoperunner");
98 QString scopeRunnerPath = QDir(scopesLibdir).filePath("scoperunner/scoperunner");
96
99
97 QString runtime_ini = QString(RUNTIME_CONFIG).arg(m_registry_config.fileName()).arg(m_mw_config.fileName());
100 QString runtime_ini = QString(RUNTIME_CONFIG).arg(m_registry_config.fileName()).arg(m_mw_config.fileName());
101+ // FIXME: keep in sync with the SSRegistry config
102+ QString serverRegistryConfig(m_serverScopes ? "SS.Registry.Identity = SSRegistry\nSS.Registry.Endpoint = ipc:///tmp/SSRegistry" : "");
103+ QString scopeInstallDir(scopesLibdir + "/unity-scopes");
104+ if (!m_systemScopes) {
105+ m_scopeInstallDir.reset(new QTemporaryDir(tmp.filePath("scopes.XXXXXX")));
106+ if (!m_scopeInstallDir->isValid()) {
107+ qWarning("Unable to create temporary scopes directory!");
108+ }
109+ scopeInstallDir = m_scopeInstallDir->path();
110+ }
98− QString registry_ini = QString(REGISTRY_CONFIG).arg(m_endpoints_dir.path()).arg(m_endpoints_dir.path()).arg(m_mw_config.fileName()).arg(m_scopeDir).arg(scopeRunnerPath);
111+ QString registry_ini = QString(REGISTRY_CONFIG).arg(m_endpoints_dir.path()).arg(m_endpoints_dir.path()).arg(m_mw_config.fileName()).arg(scopeInstallDir).arg(scopeRunnerPath).arg(serverRegistryConfig);
99 QString mw_ini = QString(MW_CONFIG).arg(m_endpoints_dir.path()).arg(m_endpoints_dir.path());
112 QString mw_ini = QString(MW_CONFIG).arg(m_endpoints_dir.path()).arg(m_endpoints_dir.path());
100
113
101 m_runtime_config.write(runtime_ini.toUtf8());
114 m_runtime_config.write(runtime_ini.toUtf8());
@@ -111,6 +124,7 @@ void RegistryTracker::runRegistry()
111 QString registryBin(QDir(scopesLibdir).filePath("scoperegistry/scoperegistry"));
124 QString registryBin(QDir(scopesLibdir).filePath("scoperegistry/scoperegistry"));
112 QStringList arguments;
125 QStringList arguments;
113 arguments << m_runtime_config.fileName();
126 arguments << m_runtime_config.fileName();
127+ arguments << m_scopes;
114
128
115 m_registry.start(registryBin, arguments);
129 m_registry.start(registryBin, arguments);
116}
130}
tools/registry-tracker.h+7−2
@@ -22,12 +22,14 @@
22#include <QTemporaryFile>
22#include <QTemporaryFile>
23#include <QTemporaryDir>
23#include <QTemporaryDir>
24#include <QDebug>
24#include <QDebug>
25+#include <QStringList>
26+#include <QScopedPointer>
25
27
26
28
27class RegistryTracker
29class RegistryTracker
28{
30{
29public:
31public:
30− RegistryTracker(QString const&);
32+ RegistryTracker(QStringList const&, bool, bool);
31 ~RegistryTracker();
33 ~RegistryTracker();
32
34
33 QProcess* registry() const;
35 QProcess* registry() const;
@@ -35,10 +37,13 @@ public:
35private:
37private:
36 void runRegistry();
38 void runRegistry();
37
39
38− QString m_scopeDir;
40+ QStringList m_scopes;
41+ bool m_systemScopes;
42+ bool m_serverScopes;
39 QProcess m_registry;
43 QProcess m_registry;
40 QTemporaryDir m_endpoints_dir;
44 QTemporaryDir m_endpoints_dir;
41 QTemporaryFile m_runtime_config;
45 QTemporaryFile m_runtime_config;
42 QTemporaryFile m_registry_config;
46 QTemporaryFile m_registry_config;
43 QTemporaryFile m_mw_config;
47 QTemporaryFile m_mw_config;
48+ QScopedPointer<QTemporaryDir> m_scopeInstallDir;
44};
49};
tools/scopetool.cpp+27−8
@@ -24,6 +24,8 @@
24#include <QtQml/QQmlContext>
24#include <QtQml/QQmlContext>
25#include <QScopedPointer>
25#include <QScopedPointer>
26#include <QDebug>
26#include <QDebug>
27+#include <QCommandLineParser>
28+#include <QCommandLineOption>
27#include <libintl.h>
29#include <libintl.h>
28
30
29
31
@@ -46,16 +48,33 @@ int main(int argc, char *argv[])
46 QGuiApplication *application;
48 QGuiApplication *application;
47 application = new QGuiApplication(argc, argv);
49 application = new QGuiApplication(argc, argv);
48
50
49− QStringList arguments = application->arguments();
51+ QCommandLineParser parser;
50− QString scopesDir;
52+ parser.setApplicationDescription("Unity Scope Tool\n\n"
51− if (arguments.contains("--scope-dir")) {
53+ "This tool allows development and testing of scopes. Running it without\n"
52− int idx = arguments.indexOf("--scope-dir");
54+ "any arguments will open a session to all scopes available on the system.\n"
53− scopesDir = arguments[idx+1];
55+ "Otherwise passing a path to a scope config file will open a session with\n"
54− }
56+ "only that scope (assuming that the binary implementing the scope can be\n"
57+ "found in the same directory as the config file).");
58+ parser.addHelpOption();
59+ parser.addPositionalArgument("scopes", "Paths to scope config files to spawn, optionally.", "[scopes...]");
60+
61+ QCommandLineOption includeSystemScopes("include-system-scopes",
62+ "Initialize the registry with scopes installed on this system");
63+ QCommandLineOption includeServerScopes("include-server-scopes",
64+ "Initialize the registry with scopes on the default server");
65+
66+ parser.addOption(includeServerScopes);
67+ parser.addOption(includeSystemScopes);
68+
69+ parser.process(*application);
70+
71+ QStringList extraScopes = parser.positionalArguments();
55
72
56 QScopedPointer<RegistryTracker> tracker;
73 QScopedPointer<RegistryTracker> tracker;
57− if (!scopesDir.isEmpty()) {
74+ if (!extraScopes.isEmpty()) {
75+ bool systemScopes = parser.isSet(includeSystemScopes);
76+ bool serverScopes = parser.isSet(includeServerScopes);
58− tracker.reset(new RegistryTracker(scopesDir));
77+ tracker.reset(new RegistryTracker(extraScopes, systemScopes, serverScopes));
59 }
78 }
60
79
61 resolveIconTheme();
80 resolveIconTheme();