summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorTim Jenssen <tim.jenssen@nokia.com>2011-05-10 20:30:06 +0200
committerTim Jenssen <tim.jenssen@nokia.com>2011-05-10 20:30:36 +0200
commit041a6e9345026d7d80434ccdac63dec8cae2af9d (patch)
tree13dac2337185be4709121e20e146b73a387a21e3 /tools
parent7f37da612198a0054f878c2c0399125ee6222226 (diff)
now operation runner can run all operations
Diffstat (limited to 'tools')
-rw-r--r--tools/operationrunner/fakeinstaller.cpp16
-rw-r--r--tools/operationrunner/fakeinstaller.h24
-rw-r--r--tools/operationrunner/operationrunner.cpp60
-rw-r--r--tools/operationrunner/operationrunner.pro6
4 files changed, 104 insertions, 2 deletions
diff --git a/tools/operationrunner/fakeinstaller.cpp b/tools/operationrunner/fakeinstaller.cpp
new file mode 100644
index 000000000..e58aa1258
--- /dev/null
+++ b/tools/operationrunner/fakeinstaller.cpp
@@ -0,0 +1,16 @@
+#include "fakeinstaller.h"
+
+void FakeInstaller::setTargetDir(const QString &targetDir)
+{
+ m_targetDir = targetDir;
+}
+
+QString FakeInstaller::value(const QString &key, const QString &/*defaultValue*/) const
+{
+ if(key == QLatin1String("TargetDir")) {
+ return m_targetDir;
+ } else {
+ qFatal("This is only a fake installer and it can only handle \"TargetDir\" value.");
+ }
+ return QString();
+}
diff --git a/tools/operationrunner/fakeinstaller.h b/tools/operationrunner/fakeinstaller.h
new file mode 100644
index 000000000..e623a1487
--- /dev/null
+++ b/tools/operationrunner/fakeinstaller.h
@@ -0,0 +1,24 @@
+#ifndef FAKEINSTALLER_H
+#define FAKEINSTALLER_H
+
+#include <qinstaller.h>
+
+#include <QObject>
+#include <QMetaType>
+#include <QString>
+
+class FakeInstaller : public QInstaller::Installer
+{
+ Q_OBJECT
+public:
+ FakeInstaller() : QInstaller::Installer() {}
+ void setTargetDir(const QString &targetDir);
+ virtual Q_INVOKABLE QString value(const QString &key, const QString &defaultValue = QString()) const;
+
+private:
+ QString m_targetDir;
+};
+
+Q_DECLARE_METATYPE(FakeInstaller*)
+
+#endif // FAKEINSTALLER_H
diff --git a/tools/operationrunner/operationrunner.cpp b/tools/operationrunner/operationrunner.cpp
index 242aa9866..4a4e81900 100644
--- a/tools/operationrunner/operationrunner.cpp
+++ b/tools/operationrunner/operationrunner.cpp
@@ -30,6 +30,10 @@
** (qt-info@nokia.com).
**
**************************************************************************/
+#include "fakeinstaller.h" //this should be the pseudo one next to this file
+
+#include <qinstaller.h>
+
#include <common/errors.h>
#include <common/utils.h>
#include <common/repositorygen.h>
@@ -43,6 +47,7 @@
#include <QFileInfo>
#include <QString>
#include <QStringList>
+#include <QDir>
#include <iostream>
@@ -51,8 +56,24 @@ static void printUsage()
std::cout << "Usage: " << std::endl;
std::cout << std::endl;
std::cout << "operationrunner \"Execute\" \"{0,1}\" \"C:\\Windows\\System32\\cmd.exe\" \"/A\" \"/Q\" \"/C\" \"magicmaemoscript.bat\" \"showStandardError\"" << std::endl;
+ std::cout << std::endl;
+ std::cout << "Note: there is an optional argument --sdktargetdir which is needed by some operations" << std::endl;
+ std::cout << "operationrunner --sdktargetdir c:\\QtSDK \"RegisterToolChain\" \"GccToolChain\" \"Qt4ProjectManager.ToolChain.GCCE\" \"GCCE 4 for Symbian targets\" \"arm-symbian-device-elf-32bit\" \"c:\\QtSDK\\Symbian\\tools\\gcce4\\bin\\arm-none-symbianelf-g++.exe\""<< std::endl;
}
+class OutputHandler : public QObject
+{
+ Q_OBJECT
+
+public slots:
+ void drawItToCommandLine(const QString &outPut)
+ {
+ std::cout << qPrintable(outPut) << std::endl;
+ }
+};
+
+
+
int main(int argc, char **argv)
{
try {
@@ -67,22 +88,57 @@ int main(int argc, char **argv)
}
argumentList.removeFirst(); // we don't need the application name
+ QString sdkTargetDir;
+ int sdkTargetDirArgumentPosition = argumentList.indexOf(QRegExp("--sdktargetdir", Qt::CaseInsensitive));
+ //+1 means the needed following argument
+ if (sdkTargetDirArgumentPosition != -1 && argumentList.count() > sdkTargetDirArgumentPosition + 1) {
+ sdkTargetDir = argumentList.at(sdkTargetDirArgumentPosition + 1);
+ if (!QDir(sdkTargetDir).exists()) {
+ std::cerr << qPrintable(QString("The following argument of %1 is not an existing directory.").arg(
+ argumentList.at(sdkTargetDirArgumentPosition))) << std::endl;
+ return 1;
+ }
+ argumentList.removeAt(sdkTargetDirArgumentPosition + 1);
+ argumentList.removeAt(sdkTargetDirArgumentPosition);
+ }
+
+
QInstaller::init();
QInstaller::setVerbose( true );
QString operationName = argumentList.takeFirst();
- KDUpdater::UpdateOperation* const operation = KDUpdater::UpdateOperationFactory::instance().create( operationName );
+ KDUpdater::UpdateOperation* const operation = KDUpdater::UpdateOperationFactory::instance().create(operationName);
if (!operation) {
std::cerr << "Can not find the operation: " << qPrintable(operationName) << std::endl;
return 1;
}
+
+ OutputHandler myOutPutHandler;
+ QObject* const operationObject = dynamic_cast<QObject*>(operation);
+ if (operationObject != 0) {
+ const QMetaObject* const mo = operationObject->metaObject();
+ if (mo->indexOfSignal(QMetaObject::normalizedSignature("outputTextChanged(QString)")) > -1) {
+ QObject::connect(operationObject, SIGNAL(outputTextChanged(QString)),
+ &myOutPutHandler, SLOT(drawItToCommandLine(QString)));
+ }
+ }
+
+ FakeInstaller fakeInstaller;
+ fakeInstaller.setTargetDir(sdkTargetDir);
+
+ operation->setValue(QLatin1String("installer"),
+ QVariant::fromValue(static_cast<QInstaller::Installer*>(&fakeInstaller)));
+
operation->setArguments(argumentList);
+
bool readyPerformed = operation->performOperation();
+ std::cout << "========================================" << std::endl;
if (readyPerformed) {
std::cout << "Operation was succesfully performed." << std::endl;
} else {
std::cerr << "There was a problem while performing the operation: " << qPrintable(operation->errorString()) << std::endl;
+ std::cerr << "\tNote: if you see something like installer is null/empty then --sdktargetdir argument was missing." << std::endl;
}
return 0;
} catch ( const QInstaller::Error& e ) {
@@ -90,3 +146,5 @@ int main(int argc, char **argv)
}
return 1;
}
+
+#include "operationrunner.moc"
diff --git a/tools/operationrunner/operationrunner.pro b/tools/operationrunner/operationrunner.pro
index d2f1b05cc..9cf0c9299 100644
--- a/tools/operationrunner/operationrunner.pro
+++ b/tools/operationrunner/operationrunner.pro
@@ -13,6 +13,10 @@ QT += xml
include(../../installerbuilder/libinstaller/libinstaller.pri)
# Input
-SOURCES += operationrunner.cpp
+SOURCES += operationrunner.cpp \
+ fakeinstaller.cpp
+
+HEADERS += \
+ fakeinstaller.h
LIBS = -L../../installerbuilder/lib -linstaller $$LIBS