Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: e90b39bebb
Fetching contributors…

Cannot retrieve contributors at this time

67 lines (53 sloc) 1.995 kb
#include "KissCompileProvider.h"
#include <tinyarchive.hpp>
#include <kiss-compiler/QTinyArchive.h>
#include <kiss-compiler/Temporary.h>
#include <kiss-compiler/ArchiveWriter.h>
#include <kiss-compiler/CompilerManager.h>
#include "RootController.h"
#include "CompilingWidget.h"
#include "Device.h"
#include <QSettings>
#include <QDebug>
#define KISS_COMPILE_GROUP "kiss_compile"
#define EXECUTABLES_KEY "executables"
KissCompileProvider::KissCompileProvider(Device *device, QObject *parent)
: CompileProvider(parent),
m_device(device)
{
QSettings settings;
settings.beginGroup(KISS_COMPILE_GROUP);
QMap<QString, QVariant> map = settings.value(EXECUTABLES_KEY).toMap();
foreach(const QString& key, map.keys()) m_executables[key] = map[key].toStringList();
settings.endGroup();
}
CompilationPtr KissCompileProvider::compile(const QString& name, TinyArchive *archive)
{
if(!archive) return CompilationPtr();
ArchiveWriter writer(archive, Temporary::subdir(name));
QMap<QString, QString> settings;
QByteArray rawSettings = QTinyNode::data(archive->lookup("settings:"));
QDataStream stream(rawSettings);
stream >> settings;
CompilationPtr compilation(new Compilation(CompilerManager::ref().compilers(), name, writer.files(), settings, m_device->name()));
bool success = compilation->start();
qDebug() << "Results:" << compilation->compileResults();
qDebug() << (success ? "Compile Succeeded" : "Compile Failed");
if(success) m_executables[name] = compilation->compileResults();
else m_executables.remove(name);
sync();
return compilation;
}
QString KissCompileProvider::executableFor(const QString& name) const
{
return m_executables.value(name, QStringList() << "")[0];
}
void KissCompileProvider::sync()
{
QSettings settings;
settings.beginGroup(KISS_COMPILE_GROUP);
QMap<QString, QVariant> map;
foreach(const QString& key, m_executables.keys()) map[key] = QVariant(m_executables[key]);
settings.setValue(EXECUTABLES_KEY, map);
settings.endGroup();
}
Jump to Line
Something went wrong with that request. Please try again.