forked from qt-creator/qt-creator
Copy and install file prior to running it.
This commit is contained in:
@@ -28,6 +28,10 @@
|
|||||||
* Run on device
|
* Run on device
|
||||||
* Finish runner when application exits
|
* Finish runner when application exits
|
||||||
* passphrase for signing
|
* passphrase for signing
|
||||||
|
* time stamp of copied sisx is ridiculous
|
||||||
|
* maybe don't copy the sisx all the time
|
||||||
|
* don't hardcode com port
|
||||||
|
* don't hardcode copy destination
|
||||||
|
|
||||||
* Add compile output parser winscw at least
|
* Add compile output parser winscw at least
|
||||||
|
|
||||||
|
@@ -431,15 +431,6 @@ S60DeviceRunControl::S60DeviceRunControl(QSharedPointer<RunConfiguration> runCon
|
|||||||
this, SLOT(signsisProcessFailed()));
|
this, SLOT(signsisProcessFailed()));
|
||||||
connect(m_signsis, SIGNAL(finished(int,QProcess::ExitStatus)),
|
connect(m_signsis, SIGNAL(finished(int,QProcess::ExitStatus)),
|
||||||
this, SLOT(signsisProcessFinished()));
|
this, SLOT(signsisProcessFinished()));
|
||||||
m_install = new QProcess(this);
|
|
||||||
connect(m_install, SIGNAL(readyReadStandardError()),
|
|
||||||
this, SLOT(readStandardError()));
|
|
||||||
connect(m_install, SIGNAL(readyReadStandardOutput()),
|
|
||||||
this, SLOT(readStandardOutput()));
|
|
||||||
connect(m_install, SIGNAL(error(QProcess::ProcessError)),
|
|
||||||
this, SLOT(installProcessFailed()));
|
|
||||||
connect(m_install, SIGNAL(finished(int,QProcess::ExitStatus)),
|
|
||||||
this, SLOT(installProcessFinished()));
|
|
||||||
m_run = new QProcess(this);
|
m_run = new QProcess(this);
|
||||||
connect(m_run, SIGNAL(readyReadStandardError()),
|
connect(m_run, SIGNAL(readyReadStandardError()),
|
||||||
this, SLOT(readStandardError()));
|
this, SLOT(readStandardError()));
|
||||||
@@ -489,7 +480,6 @@ void S60DeviceRunControl::stop()
|
|||||||
{
|
{
|
||||||
m_makesis->kill();
|
m_makesis->kill();
|
||||||
m_signsis->kill();
|
m_signsis->kill();
|
||||||
m_install->kill();
|
|
||||||
m_run->kill();
|
m_run->kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,29 +542,12 @@ void S60DeviceRunControl::signsisProcessFinished()
|
|||||||
emit finished();
|
emit finished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString applicationInstaller = "cmd.exe";
|
|
||||||
QStringList arguments;
|
|
||||||
arguments << "/C" << QDir::toNativeSeparators(m_baseFileName + ".sisx");
|
|
||||||
m_install->setWorkingDirectory(m_workingDirectory);
|
|
||||||
emit addToOutputWindow(this, tr("%1 %2").arg(QDir::toNativeSeparators(applicationInstaller), arguments.join(tr(" "))));
|
|
||||||
m_install->start(applicationInstaller, arguments, QIODevice::ReadOnly);
|
|
||||||
}
|
|
||||||
|
|
||||||
void S60DeviceRunControl::installProcessFailed()
|
|
||||||
{
|
|
||||||
processFailed("ApplicationInstaller", m_install->error());
|
|
||||||
}
|
|
||||||
|
|
||||||
void S60DeviceRunControl::installProcessFinished()
|
|
||||||
{
|
|
||||||
if (m_install->exitCode() != 0) {
|
|
||||||
error(this, tr("An error occurred while installing the package."));
|
|
||||||
emit finished();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QString trklauncher = QApplication::applicationDirPath() + "/../tests/manual/trk/debug/trklauncher.exe";
|
QString trklauncher = QApplication::applicationDirPath() + "/../tests/manual/trk/debug/trklauncher.exe";
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments << "COM5" << QString("C:\\sys\\bin\\%1.exe").arg(m_targetName); //TODO com selection and file path
|
//TODO com selection, sisx destination and file path user definable
|
||||||
|
arguments << "COM5" << "-I" << (m_baseFileName + ".sisx")
|
||||||
|
<< QString("C:\\Data\\%1.sisx").arg(QFileInfo(m_baseFileName).fileName())
|
||||||
|
<< QString("C:\\sys\\bin\\%1.exe").arg(m_targetName);
|
||||||
emit addToOutputWindow(this, tr("%1 %2").arg(QDir::toNativeSeparators(trklauncher), arguments.join(tr(" "))));
|
emit addToOutputWindow(this, tr("%1 %2").arg(QDir::toNativeSeparators(trklauncher), arguments.join(tr(" "))));
|
||||||
m_run->start(trklauncher, arguments, QIODevice::ReadOnly);
|
m_run->start(trklauncher, arguments, QIODevice::ReadOnly);
|
||||||
}
|
}
|
||||||
|
@@ -147,8 +147,6 @@ private slots:
|
|||||||
void makesisProcessFinished();
|
void makesisProcessFinished();
|
||||||
void signsisProcessFailed();
|
void signsisProcessFailed();
|
||||||
void signsisProcessFinished();
|
void signsisProcessFinished();
|
||||||
void installProcessFailed();
|
|
||||||
void installProcessFinished();
|
|
||||||
void runProcessFailed();
|
void runProcessFailed();
|
||||||
void runProcessFinished();
|
void runProcessFinished();
|
||||||
|
|
||||||
@@ -165,7 +163,6 @@ private:
|
|||||||
QString m_customKeyPath;
|
QString m_customKeyPath;
|
||||||
QProcess *m_makesis;
|
QProcess *m_makesis;
|
||||||
QProcess *m_signsis;
|
QProcess *m_signsis;
|
||||||
QProcess *m_install;
|
|
||||||
QProcess *m_run;
|
QProcess *m_run;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
#include <QtCore/QQueue>
|
#include <QtCore/QQueue>
|
||||||
#include <QtCore/QTimer>
|
#include <QtCore/QTimer>
|
||||||
|
#include <QtCore/QDateTime>
|
||||||
|
|
||||||
#include <QtNetwork/QTcpServer>
|
#include <QtNetwork/QTcpServer>
|
||||||
#include <QtNetwork/QTcpSocket>
|
#include <QtNetwork/QTcpSocket>
|
||||||
@@ -88,6 +89,8 @@ public:
|
|||||||
~Adapter();
|
~Adapter();
|
||||||
void setTrkServerName(const QString &name) { m_trkServerName = name; }
|
void setTrkServerName(const QString &name) { m_trkServerName = name; }
|
||||||
void setFileName(const QString &name) { m_fileName = name; }
|
void setFileName(const QString &name) { m_fileName = name; }
|
||||||
|
void setCopyFileName(const QString &srcName, const QString &dstName) { m_copySrcFileName = srcName; m_copyDstFileName = dstName; }
|
||||||
|
void setInstallFileName(const QString &name) { m_installFileName = name; }
|
||||||
bool startServer();
|
bool startServer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -128,6 +131,8 @@ private:
|
|||||||
void timerEvent(QTimerEvent *ev);
|
void timerEvent(QTimerEvent *ev);
|
||||||
byte nextTrkWriteToken();
|
byte nextTrkWriteToken();
|
||||||
|
|
||||||
|
void handleFileCreation(const TrkResult &result);
|
||||||
|
void handleFileCreated(const TrkResult &result);
|
||||||
void handleCpuType(const TrkResult &result);
|
void handleCpuType(const TrkResult &result);
|
||||||
void handleCreateProcess(const TrkResult &result);
|
void handleCreateProcess(const TrkResult &result);
|
||||||
void handleWaitForFinished(const TrkResult &result);
|
void handleWaitForFinished(const TrkResult &result);
|
||||||
@@ -136,6 +141,10 @@ private:
|
|||||||
|
|
||||||
void handleAndReportCreateProcess(const TrkResult &result);
|
void handleAndReportCreateProcess(const TrkResult &result);
|
||||||
void handleResult(const TrkResult &data);
|
void handleResult(const TrkResult &data);
|
||||||
|
|
||||||
|
void copyFileToRemote();
|
||||||
|
void installRemotePackageSilently(const QString &filename);
|
||||||
|
void installAndRun();
|
||||||
void startInferiorIfNeeded();
|
void startInferiorIfNeeded();
|
||||||
|
|
||||||
#if USE_NATIVE
|
#if USE_NATIVE
|
||||||
@@ -158,6 +167,9 @@ private:
|
|||||||
Session m_session; // global-ish data (process id, target information)
|
Session m_session; // global-ish data (process id, target information)
|
||||||
|
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
|
QString m_copySrcFileName;
|
||||||
|
QString m_copyDstFileName;
|
||||||
|
QString m_installFileName;
|
||||||
};
|
};
|
||||||
|
|
||||||
Adapter::Adapter()
|
Adapter::Adapter()
|
||||||
@@ -198,11 +210,22 @@ bool Adapter::startServer()
|
|||||||
sendTrkMessage(TrkSupported, CB(handleSupportMask));
|
sendTrkMessage(TrkSupported, CB(handleSupportMask));
|
||||||
sendTrkMessage(TrkCpuType, CB(handleCpuType));
|
sendTrkMessage(TrkCpuType, CB(handleCpuType));
|
||||||
sendTrkMessage(TrkVersions); // Versions
|
sendTrkMessage(TrkVersions); // Versions
|
||||||
// sendTrkMessage(0x09); // Unrecognized command
|
if (!m_copySrcFileName.isEmpty() && !m_copyDstFileName.isEmpty())
|
||||||
startInferiorIfNeeded();
|
copyFileToRemote();
|
||||||
|
else
|
||||||
|
installAndRun();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Adapter::installAndRun()
|
||||||
|
{
|
||||||
|
if (!m_installFileName.isEmpty()) {
|
||||||
|
installRemotePackageSilently(m_installFileName);
|
||||||
|
startInferiorIfNeeded();
|
||||||
|
} else {
|
||||||
|
startInferiorIfNeeded();
|
||||||
|
}
|
||||||
|
}
|
||||||
void Adapter::logMessage(const QString &msg)
|
void Adapter::logMessage(const QString &msg)
|
||||||
{
|
{
|
||||||
qDebug() << "ADAPTER: " << qPrintable(msg);
|
qDebug() << "ADAPTER: " << qPrintable(msg);
|
||||||
@@ -508,6 +531,38 @@ void Adapter::handleResult(const TrkResult &result)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Adapter::handleFileCreation(const TrkResult &result)
|
||||||
|
{
|
||||||
|
// we don't do any error handling yet, which is bad
|
||||||
|
const char *data = result.data.data();
|
||||||
|
uint copyFileHandle = extractInt(data + 2);
|
||||||
|
qDebug() << copyFileHandle;
|
||||||
|
QFile file(m_copySrcFileName);
|
||||||
|
file.open(QIODevice::ReadOnly);
|
||||||
|
QByteArray src = file.readAll();
|
||||||
|
file.close();
|
||||||
|
const int BLOCKSIZE = 1024;
|
||||||
|
int size = src.length();
|
||||||
|
int pos = 0;
|
||||||
|
while (pos < size) {
|
||||||
|
QByteArray ba;
|
||||||
|
appendInt(&ba, copyFileHandle, TargetByteOrder);
|
||||||
|
appendString(&ba, src.mid(pos, BLOCKSIZE), TargetByteOrder, false);
|
||||||
|
sendTrkMessage(TrkWriteFile, 0, ba);
|
||||||
|
pos += BLOCKSIZE;
|
||||||
|
}
|
||||||
|
QByteArray ba;
|
||||||
|
appendInt(&ba, copyFileHandle, TargetByteOrder);
|
||||||
|
appendInt(&ba, QDateTime::currentDateTime().toTime_t(), TargetByteOrder);
|
||||||
|
sendTrkMessage(TrkCloseFile, CB(handleFileCreated), ba);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Adapter::handleFileCreated(const TrkResult &result)
|
||||||
|
{
|
||||||
|
Q_UNUSED(result)
|
||||||
|
installAndRun();
|
||||||
|
}
|
||||||
|
|
||||||
void Adapter::handleCpuType(const TrkResult &result)
|
void Adapter::handleCpuType(const TrkResult &result)
|
||||||
{
|
{
|
||||||
logMessage("HANDLE CPU TYPE: " + result.toString());
|
logMessage("HANDLE CPU TYPE: " + result.toString());
|
||||||
@@ -618,6 +673,22 @@ void Adapter::cleanUp()
|
|||||||
// Error: 0x00
|
// Error: 0x00
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Adapter::copyFileToRemote()
|
||||||
|
{
|
||||||
|
QByteArray ba;
|
||||||
|
appendByte(&ba, 0x10);
|
||||||
|
appendString(&ba, m_copyDstFileName.toLocal8Bit(), TargetByteOrder, false);
|
||||||
|
sendTrkMessage(TrkOpenFile, CB(handleFileCreation), ba);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Adapter::installRemotePackageSilently(const QString &fileName)
|
||||||
|
{
|
||||||
|
QByteArray ba;
|
||||||
|
appendByte(&ba, 'C');
|
||||||
|
appendString(&ba, fileName.toLocal8Bit(), TargetByteOrder, false);
|
||||||
|
sendTrkMessage(TrkInstallFile, 0, ba);
|
||||||
|
}
|
||||||
|
|
||||||
void Adapter::startInferiorIfNeeded()
|
void Adapter::startInferiorIfNeeded()
|
||||||
{
|
{
|
||||||
if (m_session.pid != 0) {
|
if (m_session.pid != 0) {
|
||||||
@@ -635,9 +706,13 @@ void Adapter::startInferiorIfNeeded()
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc < 3) {
|
if ((argc != 3 && argc != 5 && argc != 6)
|
||||||
qDebug() << "Usage: " << argv[0] << "<trkservername> <remotefilename>";
|
|| (argc == 5 && QString(argv[2]) != "-i")
|
||||||
|
|| (argc == 6 && QString(argv[2]) != "-I")) {
|
||||||
|
qDebug() << "Usage: " << argv[0] << "<trk_port_name> [-i remote_sis_file | -I local_sis_file remote_sis_file] <remote_executable_name>";
|
||||||
qDebug() << "for example" << argv[0] << "COM5 C:\\sys\\bin\\test.exe";
|
qDebug() << "for example" << argv[0] << "COM5 C:\\sys\\bin\\test.exe";
|
||||||
|
qDebug() << " " << argv[0] << "COM5 -i C:\\Data\\test_gcce_udeb.sisx C:\\sys\\bin\\test.exe";
|
||||||
|
qDebug() << " " << argv[0] << "COM5 -I C:\\Projects\\test\\test_gcce_udeb.sisx C:\\Data\\test_gcce_udeb.sisx C:\\sys\\bin\\test.exe";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -649,7 +724,16 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Adapter adapter;
|
Adapter adapter;
|
||||||
adapter.setTrkServerName(argv[1]);
|
adapter.setTrkServerName(argv[1]);
|
||||||
adapter.setFileName(argv[2]);
|
if (argc == 3) {
|
||||||
|
adapter.setFileName(argv[2]);
|
||||||
|
} else if (argc == 5) {
|
||||||
|
adapter.setInstallFileName(argv[3]);
|
||||||
|
adapter.setFileName(argv[4]);
|
||||||
|
} else {
|
||||||
|
adapter.setCopyFileName(argv[3], argv[4]);
|
||||||
|
adapter.setInstallFileName(argv[4]);
|
||||||
|
adapter.setFileName(argv[5]);
|
||||||
|
}
|
||||||
if (adapter.startServer())
|
if (adapter.startServer())
|
||||||
return app.exec();
|
return app.exec();
|
||||||
return 4;
|
return 4;
|
||||||
|
@@ -261,13 +261,15 @@ void appendInt(QByteArray *ba, uint i, Endianness endian)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void appendString(QByteArray *ba, const QByteArray &str, Endianness endian)
|
void appendString(QByteArray *ba, const QByteArray &str, Endianness endian, bool appendNullTerminator)
|
||||||
{
|
{
|
||||||
const int n = str.size();
|
const int n = str.size();
|
||||||
appendShort(ba, n+1, endian); // count the terminating \0
|
const int fullSize = n + (appendNullTerminator ? 1 : 0);
|
||||||
|
appendShort(ba, fullSize, endian); // count the terminating \0
|
||||||
for (int i = 0; i != n; ++i)
|
for (int i = 0; i != n; ++i)
|
||||||
ba->append(str.at(i));
|
ba->append(str.at(i));
|
||||||
ba->append('\0');
|
if (appendNullTerminator)
|
||||||
|
ba->append('\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray errorMessage(byte code)
|
QByteArray errorMessage(byte code)
|
||||||
|
@@ -40,14 +40,22 @@ typedef unsigned char byte;
|
|||||||
namespace trk {
|
namespace trk {
|
||||||
|
|
||||||
enum Command {
|
enum Command {
|
||||||
|
TrkPing = 0x00,
|
||||||
TrkConnect = 0x01,
|
TrkConnect = 0x01,
|
||||||
TrkVersions = 0x04,
|
TrkVersions = 0x04,
|
||||||
TrkSupported = 0x05,
|
TrkSupported = 0x05,
|
||||||
TrkCpuType = 0x06,
|
TrkCpuType = 0x06,
|
||||||
|
TrkHostVersions = 0x09,
|
||||||
TrkContinue = 0x18,
|
TrkContinue = 0x18,
|
||||||
TrkCreateItem = 0x40,
|
TrkCreateItem = 0x40,
|
||||||
TrkDeleteItem = 0x41,
|
TrkDeleteItem = 0x41,
|
||||||
|
|
||||||
|
TrkWriteFile = 0x48,
|
||||||
|
TrkOpenFile = 0x4a,
|
||||||
|
TrkCloseFile = 0x4b,
|
||||||
|
TrkInstallFile = 0x4d,
|
||||||
|
TrkInstallFile2 = 0x4e,
|
||||||
|
|
||||||
TrkNotifyAck = 0x80,
|
TrkNotifyAck = 0x80,
|
||||||
TrkNotifyNak = 0xff,
|
TrkNotifyNak = 0xff,
|
||||||
TrkNotifyStopped = 0x90,
|
TrkNotifyStopped = 0x90,
|
||||||
@@ -83,7 +91,7 @@ enum Endianness
|
|||||||
void appendByte(QByteArray *ba, byte b);
|
void appendByte(QByteArray *ba, byte b);
|
||||||
void appendShort(QByteArray *ba, ushort s, Endianness = TargetByteOrder);
|
void appendShort(QByteArray *ba, ushort s, Endianness = TargetByteOrder);
|
||||||
void appendInt(QByteArray *ba, uint i, Endianness = TargetByteOrder);
|
void appendInt(QByteArray *ba, uint i, Endianness = TargetByteOrder);
|
||||||
void appendString(QByteArray *ba, const QByteArray &str, Endianness = TargetByteOrder);
|
void appendString(QByteArray *ba, const QByteArray &str, Endianness = TargetByteOrder, bool appendNullTerminator = true);
|
||||||
|
|
||||||
enum CodeMode
|
enum CodeMode
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user