Commit 95b60c89 authored by Julien Wintz's avatar Julien Wintz

Formatting code following our latest conventions.

parent 545dc980
......@@ -78,15 +78,21 @@ int main(int argc, char **argv)
if (parser->isSet(slaveOption)) {
dtkComposerEvaluatorSlave *slave = new dtkComposerEvaluatorSlave;
if (!parser->isSet(serverOption)) {
qCritical() << "Error: no server set when running as slave! Use --server <url> " ;
return 1;
}
slave->setServer(parser->value(serverOption));
slave->setFactory(factory);
application->spawn();
do { application->exec(slave); } while (slave->status() == 0);
do {
application->exec(slave);
} while (slave->status() == 0);
application->unspawn();
} else {
......@@ -103,15 +109,17 @@ int main(int argc, char **argv)
if (parser->isSet(pgOption)) {
evaluator->setProfiling(true);
}
if (!reader->read(args.first())) {
dtkError() << "read failure for " << args.first();
return 1;
}
if (no_gui) {
evaluator->run_static();
return 0;
} else {
QObject::connect(evaluator,SIGNAL(evaluationStopped()),qApp, SLOT(quit()));
QObject::connect(evaluator, SIGNAL(evaluationStopped()), qApp, SLOT(quit()));
QtConcurrent::run(evaluator, &dtkComposerEvaluator::run_static, false);
return qApp->exec();
}
......
......@@ -18,11 +18,11 @@
dtkConceptDefinitionPage::dtkConceptDefinitionPage(QWidget *parent) : QWizardPage(parent), ui(new Ui::dtkConceptDefinitionPage)
{
this->ui->setupUi(this);
this->registerField("def.runnable",ui->m_runnable);
this->registerField("def.qObject",ui->m_qObject);
this->registerField("def.custom",ui->m_custom);
this->registerField("def.customName",ui->m_customName);
this->registerField("def.pluginSystem",ui->m_pluginSystem);
this->registerField("def.runnable", ui->m_runnable);
this->registerField("def.qObject", ui->m_qObject);
this->registerField("def.custom", ui->m_custom);
this->registerField("def.customName", ui->m_customName);
this->registerField("def.pluginSystem", ui->m_pluginSystem);
}
dtkConceptDefinitionPage::~dtkConceptDefinitionPage(void)
......
......@@ -31,96 +31,96 @@ dtkConceptGenerator::dtkConceptGenerator(void) : QWizard()
void dtkConceptGenerator::accept(void)
{
QString name=field("new.name" ).toString();
QString prefix=field("new.prefix" ).toString();
QString layer=field("new.layer" ).toString();
QString namespaceText=field("new.namespace" ).toString();
QString customName=field("def.customName" ).toString();
QString name = field("new.name" ).toString();
QString prefix = field("new.prefix" ).toString();
QString layer = field("new.layer" ).toString();
QString namespaceText = field("new.namespace" ).toString();
QString customName = field("def.customName" ).toString();
QString pluginPrefix=field("plugin.prefix" ).toString();
QString pluginSuffix=field("plugin.suffix" ).toString();
QString pluginPrefix = field("plugin.prefix" ).toString();
QString pluginSuffix = field("plugin.suffix" ).toString();
QString outputFilesPath=field("intro.path" ).toString();
QString outputFilesPath = field("intro.path" ).toString();
QMap<QString,QString> values;
QMap<QString, QString> values;
// define variables required for abstraction
values.insert("${ABSTRACTION}", prefix+"Abstract"+name);
values.insert("${LAYER_NAME}", prefix+layer);
values.insert("${_LAYER_NAME}", (prefix+layer).toUpper());
values.insert("${ABSTRACTION}", prefix + "Abstract" + name);
values.insert("${LAYER_NAME}", prefix + layer);
values.insert("${_LAYER_NAME}", (prefix + layer).toUpper());
bool inheritsCustom, inheritsQObject, inheritsQRunnable, pluginSystem, inherits=false;
bool inheritsCustom, inheritsQObject, inheritsQRunnable, pluginSystem, inherits = false;
inheritsQRunnable=field("def.runnable" ).toBool();
inheritsQObject =field("def.qObject" ).toBool();
inheritsCustom =field("def.custom" ).toBool();
pluginSystem =field("def.pluginSystem").toBool();
inheritsQRunnable = field("def.runnable" ).toBool();
inheritsQObject = field("def.qObject" ).toBool();
inheritsCustom = field("def.custom" ).toBool();
pluginSystem = field("def.pluginSystem").toBool();
if(inheritsQObject) {
values.insert("${QOBJECT}","QObject");
values.insert("${QOBJECT_INCLUDE}","#include <QObject>");
values.insert("${QOBJECT_CTR}","QObject(parent)");
values.insert("${QOBJECT_CTR_PARAM}","QObject* parent=0");
values.insert("${Q_OBJECT_MACRO}","Q_OBJECT");
inherits=true;
if (inheritsQObject) {
values.insert("${QOBJECT}", "QObject");
values.insert("${QOBJECT_INCLUDE}", "#include <QObject>");
values.insert("${QOBJECT_CTR}", "QObject(parent)");
values.insert("${QOBJECT_CTR_PARAM}", "QObject* parent=0");
values.insert("${Q_OBJECT_MACRO}", "Q_OBJECT");
inherits = true;
} else {
values.insert("${QOBJECT}","");
values.insert("${QOBJECT_INCLUDE}","");
values.insert("${QOBJECT_CTR}","");
values.insert("${QOBJECT_CTR_PARAM}","");
values.insert("${Q_OBJECT_MACRO}","");
values.insert("${QOBJECT}", "");
values.insert("${QOBJECT_INCLUDE}", "");
values.insert("${QOBJECT_CTR}", "");
values.insert("${QOBJECT_CTR_PARAM}", "");
values.insert("${Q_OBJECT_MACRO}", "");
}
if(inheritsQRunnable) {
if (inheritsQRunnable) {
QString separator = inherits ? "," : "";
values.insert("${QRUNNABLE}",separator+"public QRunnable");
values.insert("${QRUNNABLE_CTR}",separator+"QRunnable()");
values.insert("${QRUNNABLE_INCLUDE}","#include <QRunnable>");
values.insert("${QRUNNABLE}", separator + "public QRunnable");
values.insert("${QRUNNABLE_CTR}", separator + "QRunnable()");
values.insert("${QRUNNABLE_INCLUDE}", "#include <QRunnable>");
inherits=true;
inherits = true;
} else {
values.insert("${QRUNNABLE}","");
values.insert("${QRUNNABLE_CTR}","");
values.insert("${QRUNNABLE_INCLUDE}","");
values.insert("${QRUNNABLE}", "");
values.insert("${QRUNNABLE_CTR}", "");
values.insert("${QRUNNABLE_INCLUDE}", "");
}
if(inheritsCustom) {
if (inheritsCustom) {
QString separator=inherits?",": "";
QString separator = inherits ? "," : "";
values.insert("${CUSTOM_ANCESTOR}",separator+customName);
values.insert("${CUSTOM_ANCESTOR_CTR}",separator+customName);
values.insert("${CUSTOM_ANCESTOR_INCLUDE}","#include \""+customName+"\"");
inherits=true;
values.insert("${CUSTOM_ANCESTOR}", separator + customName);
values.insert("${CUSTOM_ANCESTOR_CTR}", separator + customName);
values.insert("${CUSTOM_ANCESTOR_INCLUDE}", "#include \"" + customName + "\"");
inherits = true;
} else {
values.insert("${CUSTOM_ANCESTOR}","");
values.insert("${CUSTOM_ANCESTOR_CTR}","");
values.insert("${CUSTOM_ANCESTOR_INCLUDE}","");
values.insert("${CUSTOM_ANCESTOR}", "");
values.insert("${CUSTOM_ANCESTOR_CTR}", "");
values.insert("${CUSTOM_ANCESTOR_INCLUDE}", "");
}
if(pluginSystem) {
if (pluginSystem) {
QString macroParams="("+values["${ABSTRACTION}"]+", "+values["${_LAYER_NAME}"]+"_EXPORT)";
QString macroParams = "(" + values["${ABSTRACTION}"] + ", " + values["${_LAYER_NAME}"] + "_EXPORT)";
values.insert("${PLUGIN_SYSTEM}",
"DTK_DECLARE_PLUGIN "+macroParams + "\n" +
"DTK_DECLARE_PLUGIN_FACTORY"+macroParams + "\n" +
"DTK_DECLARE_PLUGIN_MANAGER"+macroParams);
"DTK_DECLARE_PLUGIN " + macroParams + "\n" +
"DTK_DECLARE_PLUGIN_FACTORY" + macroParams + "\n" +
"DTK_DECLARE_PLUGIN_MANAGER" + macroParams);
}
//values for plugins
values.insert("${PLUGIN_CLASS_NAME}",pluginPrefix+name+pluginSuffix);
values.insert("${NAMESPACE}",namespaceText);
values.insert("${PLUGIN_CLASS_NAME}", pluginPrefix + name + pluginSuffix);
values.insert("${NAMESPACE}", namespaceText);
//values for node
values.insert("${NODE_CLASS_NAME}",prefix+name+"Node");
values.insert("${NODE_CLASS_NAME}", prefix + name + "Node");
generate("abstraction",values,outputFilesPath);
generate("plugin",values,outputFilesPath);
generate("node",values,outputFilesPath);
generate("abstraction", values, outputFilesPath);
generate("plugin", values, outputFilesPath);
generate("node", values, outputFilesPath);
QWizard::accept();
}
......
......@@ -19,12 +19,12 @@ dtkIntroPage::dtkIntroPage(QWidget *parent) : QWizardPage(parent), ui(new Ui::dt
{
this->ui->setupUi(this);
this->registerField("intro.path", ui->m_path);
this->connect(ui->m_browse,SIGNAL(clicked(bool)),this,SLOT(browse()));
this->connect(ui->m_browse, SIGNAL(clicked(bool)), this, SLOT(browse()));
}
void dtkIntroPage::browse(void)
{
this->ui->m_path->setText(QFileDialog::getExistingDirectory(this,"Save"));
this->ui->m_path->setText(QFileDialog::getExistingDirectory(this, "Save"));
}
dtkIntroPage::~dtkIntroPage(void)
......
......@@ -18,10 +18,10 @@
dtkNewConceptPage::dtkNewConceptPage(QWidget *parent) : QWizardPage(parent), ui(new Ui::dtkNewConceptPage)
{
ui->setupUi(this);
registerField("new.layer",ui->m_layer);
registerField("new.namespace",ui->m_namespace);
registerField("new.prefix",ui->m_prefix);
registerField("new.name",ui->m_name);
registerField("new.layer", ui->m_layer);
registerField("new.namespace", ui->m_namespace);
registerField("new.prefix", ui->m_prefix);
registerField("new.name", ui->m_name);
}
......
......@@ -18,11 +18,11 @@
dtkPluginGeneratorPage::dtkPluginGeneratorPage(QWidget *parent) : QWizardPage(parent), ui(new Ui::dtkPluginGeneratorPage)
{
ui->setupUi(this);
registerField("plugin.prefix",ui->m_prefix);
registerField("plugin.suffix",ui->m_suffix);
registerField("plugin.name",ui->m_name);
connect(ui->m_prefix,SIGNAL(textChanged(QString)),this,SLOT(refresh()));
connect(ui->m_suffix,SIGNAL(textChanged(QString)),this,SLOT(refresh()));
registerField("plugin.prefix", ui->m_prefix);
registerField("plugin.suffix", ui->m_suffix);
registerField("plugin.name", ui->m_name);
connect(ui->m_prefix, SIGNAL(textChanged(QString)), this, SLOT(refresh()));
connect(ui->m_suffix, SIGNAL(textChanged(QString)), this, SLOT(refresh()));
}
dtkPluginGeneratorPage::~dtkPluginGeneratorPage(void)
......@@ -33,12 +33,12 @@ dtkPluginGeneratorPage::~dtkPluginGeneratorPage(void)
void dtkPluginGeneratorPage::initializePage(void)
{
ui->m_prefix->setText(field("new.prefix").toString());
ui->m_name->setText(ui->m_prefix->text()+field("new.name").toString());
ui->m_name->setText(ui->m_prefix->text() + field("new.name").toString());
}
void dtkPluginGeneratorPage::refresh(void)
{
ui->m_name->setText(ui->m_prefix->text()+field("new.name").toString()+ui->m_suffix->text());
ui->m_name->setText(ui->m_prefix->text() + field("new.name").toString() + ui->m_suffix->text());
}
//
......
......@@ -14,22 +14,21 @@
#include "generator.h"
void generate(QString target, QMap<QString,QString> pairs, QString path)
void generate(QString target, QMap<QString, QString> pairs, QString path)
{
QDir dirIn(":/templates/templates/"+target);
QDir dirIn(":/templates/templates/" + target);
QDir dirOut=QDir(path);
QDir dirOut = QDir(path);
dirOut.mkdir(target);
dirOut.cd(target);
qDebug()<<dirIn;
qDebug() << dirIn;
QStringList files=dirIn.entryList(QDir::Files);
QStringList files = dirIn.entryList(QDir::Files);
for(QString file : files)
{
QString inFilePath=dirIn.absoluteFilePath(file);
QString fileOutPath=dirOut.absolutePath()+"/"+file.replace("class",pairs["${PLUGIN_CLASS_NAME}"]).replace("_", ".");
for (QString file : files) {
QString inFilePath = dirIn.absoluteFilePath(file);
QString fileOutPath = dirOut.absolutePath() + "/" + file.replace("class", pairs["${PLUGIN_CLASS_NAME}"]).replace("_", ".");
QFile fileOut(fileOutPath);
if (!fileOut.open(QIODevice::WriteOnly | QIODevice::Text))
......@@ -41,7 +40,7 @@ void generate(QString target, QMap<QString,QString> pairs, QString path)
}
}
QString readAndReplace(QString filePath, QMap<QString,QString> pairs)
QString readAndReplace(QString filePath, QMap<QString, QString> pairs)
{
QFile file(filePath);
......@@ -50,10 +49,10 @@ QString readAndReplace(QString filePath, QMap<QString,QString> pairs)
QTextStream in(&file);
QString content=in.readAll();
QString content = in.readAll();
for(QString key:pairs.keys())
content=content.replace(key,pairs[key]);
for (QString key : pairs.keys())
content = content.replace(key, pairs[key]);
return content;
}
......
......@@ -17,9 +17,9 @@
#include <QtCore>
#include <QtDebug>
void generate(QString target,QMap<QString, QString> pairs,QString path);
void generate(QString target, QMap<QString, QString> pairs, QString path);
QString readAndReplace(QString filePath, QMap<QString,QString> pairs);
QString readAndReplace(QString filePath, QMap<QString, QString> pairs);
//
// generator.h ends here
......@@ -25,12 +25,12 @@ int logLevel = 1;
using std::cout;
using std::endl;
bool operator==(const FrameworkInfo &a, const FrameworkInfo &b)
bool operator==(const FrameworkInfo& a, const FrameworkInfo& b)
{
return ((a.frameworkPath == b.frameworkPath) && (a.binaryPath == b.binaryPath));
}
QDebug operator<<(QDebug debug, const FrameworkInfo &info)
QDebug operator<<(QDebug debug, const FrameworkInfo& info)
{
debug << "Framework name" << info.frameworkName << "\n";
debug << "Framework directory" << info.frameworkDirectory << "\n";
......@@ -50,14 +50,14 @@ QDebug operator<<(QDebug debug, const FrameworkInfo &info)
const QString bundleFrameworkDirectory = "Contents/Frameworks";
const QString bundleBinaryDirectory = "Contents/MacOS";
inline QDebug operator<<(QDebug debug, const ApplicationBundleInfo &info)
inline QDebug operator<<(QDebug debug, const ApplicationBundleInfo& info)
{
debug << "Application bundle path" << info.path << "\n";
debug << "Binary path" << info.binaryPath << "\n";
return debug;
}
bool copyFilePrintStatus(const QString &from, const QString &to)
bool copyFilePrintStatus(const QString& from, const QString& to)
{
if (QFile::copy(from, to)) {
LogNormal() << " copied:" << from;
......@@ -70,7 +70,7 @@ bool copyFilePrintStatus(const QString &from, const QString &to)
}
}
FrameworkInfo parseOtoolLibraryLine(const QString &line, bool useDebugLibs)
FrameworkInfo parseOtoolLibraryLine(const QString& line, bool useDebugLibs)
{
FrameworkInfo info;
QString trimmed = line.trimmed();
......@@ -93,6 +93,7 @@ FrameworkInfo parseOtoolLibraryLine(const QString &line, bool useDebugLibs)
// Split the line into [Qt-path]/lib/qt[Module].framework/Versions/[Version]/
QStringList parts = trimmed.split("/");
while (part < parts.count()) {
const QString currentPart = parts.at(part).simplified() ;
......@@ -107,10 +108,12 @@ FrameworkInfo parseOtoolLibraryLine(const QString &line, bool useDebugLibs)
// Check for library name part
if (part < parts.count() && parts.at(part).contains(".dylib ")) {
state = DylibName;
if(parts.at(part -1) == "bin")
if (parts.at(part - 1) == "bin")
info.installName += "/" + (qtPath + "bin/").simplified();
else
info.installName += "/" + (qtPath + "lib/").simplified();
info.frameworkDirectory = info.installName;
state = DylibName;
......@@ -141,6 +144,7 @@ FrameworkInfo parseOtoolLibraryLine(const QString &line, bool useDebugLibs)
qtPath += (currentPart + "/");
} if (state == FrameworkName) {
// remove ".framework"
name = currentPart;
name.chop(QString(".framework").length());
......@@ -149,6 +153,7 @@ FrameworkInfo parseOtoolLibraryLine(const QString &line, bool useDebugLibs)
++part;
continue;
} if (state == DylibName) {
name = currentPart.split(" (compatibility").at(0);
info.frameworkName = name;
info.binaryName = name.left(name.indexOf('.')) + suffix + name.mid(name.indexOf('.'));
......@@ -181,7 +186,7 @@ FrameworkInfo parseOtoolLibraryLine(const QString &line, bool useDebugLibs)
return info;
}
QString findAppBinary(const QString &appBundlePath)
QString findAppBinary(const QString& appBundlePath)
{
QString appName = QFileInfo(appBundlePath).completeBaseName();
QString binaryPath = appBundlePath + "/Contents/MacOS/" + appName;
......@@ -194,21 +199,24 @@ QString findAppBinary(const QString &appBundlePath)
return QString();
}
QList<FrameworkInfo> getQtFrameworks(const QStringList &otoolLines, bool useDebugLibs)
QList<FrameworkInfo> getQtFrameworks(const QStringList& otoolLines, bool useDebugLibs)
{
QList<FrameworkInfo> libraries;
foreach(const QString line, otoolLines) {
foreach (const QString line, otoolLines) {
FrameworkInfo info = parseOtoolLibraryLine(line, useDebugLibs);
if (info.frameworkName.isEmpty() == false) {
LogDebug() << "Adding framework:";
LogDebug() << info;
libraries.append(info);
}
}
return libraries;
}
QList<FrameworkInfo> getQtFrameworks(const QString &path, bool useDebugLibs)
QList<FrameworkInfo> getQtFrameworks(const QString& path, bool useDebugLibs)
{
LogDebug() << "Using otool:";
LogDebug() << " inspecting" << path;
......@@ -232,11 +240,12 @@ QList<FrameworkInfo> getQtFrameworks(const QString &path, bool useDebugLibs)
}
// copies everything _inside_ sourcePath to destinationPath
void recursiveCopy(const QString &sourcePath, const QString &destinationPath)
void recursiveCopy(const QString& sourcePath, const QString& destinationPath)
{
QDir().mkpath(destinationPath);
QStringList files = QDir(sourcePath).entryList(QStringList() << "*", QDir::Files | QDir::NoDotAndDotDot);
foreach (QString file, files) {
const QString fileSourcePath = sourcePath + "/" + file;
const QString fileDestinationPath = destinationPath + "/" + file;
......@@ -244,12 +253,13 @@ void recursiveCopy(const QString &sourcePath, const QString &destinationPath)
}
QStringList subdirs = QDir(sourcePath).entryList(QStringList() << "*", QDir::Dirs | QDir::NoDotAndDotDot);
foreach (QString dir, subdirs) {
recursiveCopy(sourcePath + "/" + dir, destinationPath + "/" + dir);
}
}
QString copyFramework(const FrameworkInfo &framework, const QString path)
QString copyFramework(const FrameworkInfo& framework, const QString path)
{
QString from = framework.sourceFilePath;
QString toDir = path + "/" + framework.destinationDirectory;
......@@ -261,6 +271,7 @@ QString copyFramework(const FrameworkInfo &framework, const QString path)
}
QDir dir;
if (dir.mkpath(toDir) == false) {
LogError() << "could not create destination directory" << to;
return QString();
......@@ -284,13 +295,14 @@ void runInstallNameTool(QStringList options)
QProcess installNametool;
installNametool.start("install_name_tool", options);
installNametool.waitForFinished();
if (installNametool.exitCode() != 0) {
LogError() << installNametool.readAllStandardError();
LogError() << installNametool.readAllStandardOutput();
}
}
void changeIdentification(const QString &id, const QString &binaryPath)
void changeIdentification(const QString& id, const QString& binaryPath)
{
LogDebug() << "Using install_name_tool:";
LogDebug() << " change identification in" << binaryPath;
......@@ -298,7 +310,7 @@ void changeIdentification(const QString &id, const QString &binaryPath)
runInstallNameTool(QStringList() << "-id" << id << binaryPath);
}
void changeInstallName(const QString &oldName, const QString &newName, const QString &binaryPath)
void changeInstallName(const QString& oldName, const QString& newName, const QString& binaryPath)
{
LogDebug() << "Using install_name_tool:";
LogDebug() << " in" << binaryPath;
......@@ -307,7 +319,7 @@ void changeInstallName(const QString &oldName, const QString &newName, const QSt
runInstallNameTool(QStringList() << "-change" << oldName << newName << binaryPath);
}
void runStrip(const QString &binaryPath)
void runStrip(const QString& binaryPath)
{
if (runStripEnabled == false)
return;
......@@ -317,6 +329,7 @@ void runStrip(const QString &binaryPath)
QProcess strip;
strip.start("strip", QStringList() << "-x" << binaryPath);
strip.waitForFinished();
if (strip.exitCode() != 0) {
LogError() << strip.readAllStandardError();
LogError() << strip.readAllStandardOutput();
......@@ -331,7 +344,7 @@ void runStrip(const QString &binaryPath)
a list of actually deployed frameworks.
*/
DeploymentInfo deployQtFrameworks(QList<FrameworkInfo> frameworks,
const QString &bundlePath, const QString &binaryPath, bool useDebugLibs)
const QString& bundlePath, const QString& binaryPath, bool useDebugLibs)
{
LogNormal();
LogNormal() << "Deploying Qt frameworks found inside:" << binaryPath;
......@@ -345,8 +358,7 @@ DeploymentInfo deployQtFrameworks(QList<FrameworkInfo> frameworks,
// Get the qt path from one of the Qt frameworks;
if (deploymenInfo.qtPath.isNull()
&& framework.frameworkName.contains("Qt")
&& framework.frameworkDirectory.contains("/lib"))
{
&& framework.frameworkDirectory.contains("/lib")) {
deploymenInfo.qtPath = framework.frameworkDirectory;
deploymenInfo.qtPath.chop(5); // remove "/lib/"
}
......@@ -361,6 +373,7 @@ DeploymentInfo deployQtFrameworks(QList<FrameworkInfo> frameworks,
// Copy farmework to app bundle.
const QString deployedBinaryPath = copyFramework(framework, bundlePath);
// Skip the rest if already was deployed.
if (deployedBinaryPath.isNull())
continue;
......@@ -381,16 +394,18 @@ DeploymentInfo deployQtFrameworks(QList<FrameworkInfo> frameworks,
}
}
}