on xenial help sign in
Change and extend the way non-installed scopes are started with the scope-tool
commitc80783fc7407f75a4b8333292e42195871bf282a authorMichal Hruby <michal.mhr@gmail.com> dateFri 14 Mar 2014, 17:18 (13 years ago) parent5ff2370
3 files changed+52−14
tools/registry-tracker.cpp+18−4 tools/registry-tracker.h+7−2 tools/scopetool.cpp+27−8
tools/registry-tracker.cpp+18−4
@@ -25,8 +25,10 @@
2525#include "registry-tracker.h"
2626
2727
28−RegistryTracker::RegistryTracker(QString const& scope_dir):
29− m_scopeDir(scope_dir),
28+RegistryTracker::RegistryTracker(QStringList const& scopes, bool systemScopes, bool serverScopes):
29+ m_scopes(scopes),
30+ m_systemScopes(systemScopes),
31+ m_serverScopes(serverScopes),
3032 m_registry(nullptr),
3133 m_endpoints_dir(QDir::temp().filePath("scope-dev-endpoints.XXXXXX"))
3234{
@@ -56,7 +58,8 @@ RegistryTracker::~RegistryTracker()
5658"Zmq.EndpointDir = %2\n" \
5759"Zmq.ConfigFile = %3\n" \
5860"Scope.InstallDir = %4\n" \
59−"Scoperunner.Path = %5\n"
61+"Scoperunner.Path = %5\n" \
62+"%6"
6063
6164#define MW_CONFIG \
6265"[Zmq]\n" \
@@ -95,7 +98,17 @@ void RegistryTracker::runRegistry()
9598 QString scopeRunnerPath = QDir(scopesLibdir).filePath("scoperunner/scoperunner");
9699
97100 QString runtime_ini = QString(RUNTIME_CONFIG).arg(m_registry_config.fileName()).arg(m_mw_config.fileName());
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);
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+ }
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);
99112 QString mw_ini = QString(MW_CONFIG).arg(m_endpoints_dir.path()).arg(m_endpoints_dir.path());
100113
101114 m_runtime_config.write(runtime_ini.toUtf8());
@@ -111,6 +124,7 @@ void RegistryTracker::runRegistry()
111124 QString registryBin(QDir(scopesLibdir).filePath("scoperegistry/scoperegistry"));
112125 QStringList arguments;
113126 arguments << m_runtime_config.fileName();
127+ arguments << m_scopes;
114128
115129 m_registry.start(registryBin, arguments);
116130}
tools/registry-tracker.h+7−2
@@ -22,12 +22,14 @@
2222#include <QTemporaryFile>
2323#include <QTemporaryDir>
2424#include <QDebug>
25+#include <QStringList>
26+#include <QScopedPointer>
2527
2628
2729class RegistryTracker
2830{
2931public:
30− RegistryTracker(QString const&);
32+ RegistryTracker(QStringList const&, bool, bool);
3133 ~RegistryTracker();
3234
3335 QProcess* registry() const;
@@ -35,10 +37,13 @@ public:
3537private:
3638 void runRegistry();
3739
38− QString m_scopeDir;
40+ QStringList m_scopes;
41+ bool m_systemScopes;
42+ bool m_serverScopes;
3943 QProcess m_registry;
4044 QTemporaryDir m_endpoints_dir;
4145 QTemporaryFile m_runtime_config;
4246 QTemporaryFile m_registry_config;
4347 QTemporaryFile m_mw_config;
48+ QScopedPointer<QTemporaryDir> m_scopeInstallDir;
4449};
tools/scopetool.cpp+27−8
@@ -24,6 +24,8 @@
2424#include <QtQml/QQmlContext>
2525#include <QScopedPointer>
2626#include <QDebug>
27+#include <QCommandLineParser>
28+#include <QCommandLineOption>
2729#include <libintl.h>
2830
2931
@@ -46,16 +48,33 @@ int main(int argc, char *argv[])
4648 QGuiApplication *application;
4749 application = new QGuiApplication(argc, argv);
4850
49− QStringList arguments = application->arguments();
50− QString scopesDir;
51− if (arguments.contains("--scope-dir")) {
52− int idx = arguments.indexOf("--scope-dir");
53− scopesDir = arguments[idx+1];
54− }
51+ QCommandLineParser parser;
52+ parser.setApplicationDescription("Unity Scope Tool\n\n"
53+ "This tool allows development and testing of scopes. Running it without\n"
54+ "any arguments will open a session to all scopes available on the system.\n"
55+ "Otherwise passing a path to a scope config file will open a session with\n"
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();
5572
5673 QScopedPointer<RegistryTracker> tracker;
57− if (!scopesDir.isEmpty()) {
58− tracker.reset(new RegistryTracker(scopesDir));
74+ if (!extraScopes.isEmpty()) {
75+ bool systemScopes = parser.isSet(includeSystemScopes);
76+ bool serverScopes = parser.isSet(includeServerScopes);
77+ tracker.reset(new RegistryTracker(extraScopes, systemScopes, serverScopes));
5978 }
6079
6180 resolveIconTheme();