Initial import for goodies

This commit is contained in:
Damien Dupuis 2010-01-29 13:07:27 +00:00
parent 8246109d3d
commit 59c1ebf1d9
13 changed files with 680 additions and 0 deletions

View File

@ -0,0 +1,266 @@
#include <iostream>
using namespace std;
#include <QWidget>
#include <QPushButton>
#include <QGroupBox>
#include <QCheckBox>
#include <QComboBox>
#include <QProgressBar>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QByteArray>
#include <QTextEdit>
#include <QSettings>
#include <QMessageBox>
#include <QStringList>
#include <QMenu>
#include <QAction>
#include <QScrollBar>
#include "CompilationWidget.h"
#include "CompileHighlighter.h"
#include "ConfigDialog.h"
CompilationWidget::CompilationWidget(QWidget *parent)
: QWidget(parent)
, _cProgram ("")
, _sourceRD ("")
, _hasHurricane (false)
, _hasIo (false)
, _hasTest (false)
, _hasCrlcore (false)
, _hasChams (false)
, _hasHurricaneAMS (false) {
setStyleSheet("font-weight: normal;");
_hurricane = new QCheckBox ( "hurricane" , this );
_io = new QCheckBox ( "io" , this );
_test = new QCheckBox ( "test" , this );
_crlcore = new QCheckBox ( "crlcore" , this );
_chams = new QCheckBox ( "chams" , this );
_hurricaneAMS = new QCheckBox ( "hurricaneAMS", this );
readSettings();
QVBoxLayout* vBoxOutilsGroup = new QVBoxLayout();
vBoxOutilsGroup->addWidget(_hurricane);
vBoxOutilsGroup->addWidget(_io);
vBoxOutilsGroup->addWidget(_test);
vBoxOutilsGroup->addWidget(_crlcore);
vBoxOutilsGroup->addWidget(_chams);
vBoxOutilsGroup->addWidget(_hurricaneAMS);
if (!_hasHurricane) _hurricane->setVisible(false);
if (!_hasIo) _io->setVisible(false);
if (!_hasTest) _test->setVisible(false);
if (!_hasCrlcore) _crlcore->setVisible(false);
if (!_hasChams) _chams->setVisible(false);
if (!_hasHurricaneAMS) _hurricaneAMS->setVisible(false);
QGroupBox* outilsGroup = new QGroupBox ( "Outils", this );
outilsGroup->setLayout(vBoxOutilsGroup);
_mode = new QComboBox (this);
QStringList modes;
modes << "Release" << "Debug";
_mode->addItems(modes);
_static = new QCheckBox ("static", this);
_svnUp = new QCheckBox ("svn update", this);
_doc = new QCheckBox ("build doc", this);
_clean = new QCheckBox ("clean build", this);
QVBoxLayout* vBoxOptionsGroup = new QVBoxLayout();
vBoxOptionsGroup->addWidget(_mode);
vBoxOptionsGroup->addWidget(_static);
vBoxOptionsGroup->addWidget(_doc);
vBoxOptionsGroup->addWidget(_svnUp);
vBoxOptionsGroup->addWidget(_clean);
QGroupBox* optionsGroup = new QGroupBox ( "Options", this );
optionsGroup->setLayout(vBoxOptionsGroup);
_compile = new QPushButton ( "Compile !", this );
connect ( _compile, SIGNAL(clicked()), this, SLOT(compile()) );
_progressBar = new QProgressBar ( this );
_progressBar->setRange(0,100);
_progressBar->setTextVisible(true);
connect ( this, SIGNAL(progress(int)), _progressBar, SLOT(setValue(int)) );
QVBoxLayout* vBoxLayout = new QVBoxLayout();
vBoxLayout->addWidget(outilsGroup);
vBoxLayout->addWidget(optionsGroup);
vBoxLayout->addWidget(_compile);
vBoxLayout->addWidget(_progressBar);
QWidget* menu = new QWidget ( this );
menu->setLayout(vBoxLayout);
_console = new QTextEdit(this);
_console->setFixedSize(800,400);
CompileHighlighter* highlight = new CompileHighlighter(_console->document());
QHBoxLayout* hBoxLayout = new QHBoxLayout();
hBoxLayout->addWidget(menu);
hBoxLayout->addWidget(_console);
setLayout(hBoxLayout);
setWindowTitle("Easy compile for chams");
}
void CompilationWidget::compile() {
QStringList arguments;
_progressBar->reset();
_console->clear();
_myProcess = new QProcess(this);
QStringList env = QProcess::systemEnvironment();
//QString currentInstallRD = _installRD;
//if (_static->isChecked()) currentInstallRD += "/"+_mode->currentText()+".Static";
//else currentInstallRD += "/"+_mode->currentText()+".Shared";
//cerr << _installRD.toStdString() << endl;
//env << "HURRICANE_TOP=" + currentInstallRD;
//env << "CHAMS_TOP=" + currentInstallRD;
//env << "IO_TOP=" + currentInstallRD;
//env << "DYLD_LIBRARY_PATH=" + currentInstallRD + "/lib";
//_myProcess->setEnvironment(env);
connect(_myProcess, SIGNAL(readyReadStandardError()) , this, SLOT(updateError()));
connect(_myProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(updateText()));
connect(_myProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(updateExit(int, QProcess::ExitStatus)));
//arguments << "-s " + _sourceRD;
//arguments << "-i " + currentInstallRD;
//arguments << "-b " + _buildRD;
arguments << "-p" + _sourceRD;
arguments << "-m" + _mode->currentText();
if (_static->isChecked()) arguments << "-s";
if (_svnUp->isChecked()) arguments << "-u";
if (_doc->isChecked()) arguments << "-d";
if (_clean->isChecked()) arguments << "-c";
if (_hurricane->isChecked()) arguments << "-t hurricane";
if (_io->isChecked()) arguments << "-t io";
if (_test->isChecked()) arguments << "-t test";
if (_crlcore->isChecked()) arguments << "-t crlcore";
if (_chams->isChecked()) arguments << "-t chams";
if (_hurricaneAMS->isChecked()) arguments << "-t hurricaneAMS";
for (int i = 0; i < arguments.size(); ++i)
cout << arguments.at(i).toLocal8Bit().constData() << endl;
_myProcess->start(_cProgram, arguments);
}
void CompilationWidget::readSettings() {
_settings = new QSettings ( "chams", "easyChams" );
if ( !_settings->contains("Compilation program") ) {
QMessageBox::warning(this, tr("easyChams"), tr("It seems you do not have configured the application. Let's configure it now."), QMessageBox::Ok, QMessageBox::Ok);
runConfigDialog(true);
}
else {
_cProgram = _settings->value("Compilation program").toString();
_sourceRD = _settings->value("Source root").toString();
_hasHurricane = _settings->value("Hurricane").toBool();
_hasIo = _settings->value("Io").toBool();
_hasTest = _settings->value("Test").toBool();
_hasCrlcore = _settings->value("Crlcore").toBool();
_hasChams = _settings->value("Chams").toBool();
_hasHurricaneAMS = _settings->value("HurricaneAMS").toBool();
}
}
void CompilationWidget::runConfigDialog(bool first) {
ConfigDialog* cfg = new ConfigDialog;
connect ( cfg, SIGNAL(configDone(QStringList)), this, SLOT(updateConfig(QStringList)) );
if (!first) {
cfg->setCompileProgram(_cProgram);
cfg->setSourceRootDirectory(_sourceRD);
cfg->setHasHurricane(_hasHurricane);
cfg->setHasIo(_hasIo);
cfg->setHasTest(_hasTest);
cfg->setHasCrlcore(_hasCrlcore);
cfg->setHasChams(_hasChams);
cfg->setHasHurricaneAMS(_hasHurricaneAMS);
}
cfg->exec();
writeSettings();
}
void CompilationWidget::reconfig() {
runConfigDialog(false);
}
void CompilationWidget::writeSettings() {
_settings->setValue("Compilation program", _cProgram);
_settings->setValue("Source root" , _sourceRD);
_settings->setValue("Hurricane" , _hasHurricane);
_settings->setValue("Io" , _hasIo);
_settings->setValue("Test" , _hasTest);
_settings->setValue("Crlcore" , _hasCrlcore);
_settings->setValue("Chams" , _hasChams);
_settings->setValue("HurricaneAMS" , _hasHurricaneAMS);
}
void CompilationWidget::updateConfig(QStringList list) {
_cProgram = list.value(0); // First value is compilation program
_sourceRD = list.value(1); // Second value is source root directory
_hasHurricane = (list.value(2) == "ON") ? true : false; // Third value is hasHurricane
_hasIo = (list.value(3) == "ON") ? true : false; // Forth value is hasIo
_hasTest = (list.value(4) == "ON") ? true : false; // Fifth value is hasTest
_hasCrlcore = (list.value(5) == "ON") ? true : false; // Sixth value is hasCrlcore
_hasChams = (list.value(6) == "ON") ? true : false; // Seventh value is hasChams
_hasHurricaneAMS = (list.value(7) == "ON") ? true : false; // Eight value is hasHurricaneAMS
// updates Tools visibility :
if (_hasHurricane) { _hurricane->setVisible(true); }
else { _hurricane->setVisible(false); _hurricane->setCheckState(Qt::Unchecked); }
if (_hasIo) { _io->setVisible(true); }
else { _io->setVisible(false); _io->setCheckState(Qt::Unchecked); }
if (_hasTest) { _test->setVisible(true); }
else { _test->setVisible(false); _test->setCheckState(Qt::Unchecked); }
if (_hasCrlcore) { _crlcore->setVisible(true); }
else { _crlcore->setVisible(false); _crlcore->setCheckState(Qt::Unchecked); }
if (_hasChams) { _chams->setVisible(true); }
else { _chams->setVisible(false); _chams->setCheckState(Qt::Unchecked); }
if (_hasHurricaneAMS) { _hurricaneAMS->setVisible(true); }
else { _hurricaneAMS->setVisible(false); _hurricaneAMS->setCheckState(Qt::Unchecked); }
}
void CompilationWidget::updateError() {
QByteArray data = _myProcess->readAllStandardError();
_console->insertPlainText(QString(data));
int end = _console->verticalScrollBar()->maximum();
_console->verticalScrollBar()->setValue(end);
}
void CompilationWidget::updateText() {
QByteArray data = _myProcess->readAllStandardOutput();
QString str(data);
QRegExp rx = QRegExp ( "([0-9]+)%" );
if ( str.contains(rx) ) {
bool ok;
int value = rx.cap(1).toInt ( &ok, 10 );
emit(progress(value));
}
_console->insertPlainText(QString(data));
int end = _console->verticalScrollBar()->maximum();
_console->verticalScrollBar()->setValue(end);
}
void CompilationWidget::updateExit(int exitCode, QProcess::ExitStatus exitStatus)
{
if (exitStatus == QProcess::NormalExit) {
_console->append("Completed Successfully");
}
else {
_console->append("Error");
}
}
void CompilationWidget::about()
{
QMessageBox::about(this, tr("About easyChams"), tr("<p><h1 align=\"center\">easyChams</h1></p>"
"<p>This tool allows every one to easily update and compile chams project's sources.</p>"
"<p align=\"center\">Version 0.6<br>29/01/2010<br>by <b>D.Dupuis</b></p>"));
}

View File

@ -0,0 +1,69 @@
#ifndef __COMPILATION_WIDGET_H
#define __COMPILATION_WIDGET_H
#include <QWidget>
#include <QProcess>
class QCheckBox;
class QComboBox;
class QTextEdit;
class QPushButton;
class QProgressBar;
class QSettings;
class QStringList;
class QAction;
class CompilationWidget : public QWidget {
Q_OBJECT
public:
CompilationWidget (QWidget *parent =0);
~CompilationWidget () {};
private:
QCheckBox* _hurricane;
QCheckBox* _io;
QCheckBox* _test;
QCheckBox* _crlcore;
QCheckBox* _chams;
QCheckBox* _hurricaneAMS;
QComboBox* _mode;
QCheckBox* _static;
QCheckBox* _svnUp;
QCheckBox* _doc;
QCheckBox* _clean;
QPushButton* _compile;
QProgressBar* _progressBar;
QTextEdit* _console;
QProcess* _myProcess;
QSettings* _settings;
QString _cProgram;
QString _sourceRD;
bool _hasHurricane;
bool _hasIo;
bool _hasTest;
bool _hasCrlcore;
bool _hasChams;
bool _hasHurricaneAMS;
private:
void readSettings();
void writeSettings();
void runConfigDialog(bool first);
public slots:
void compile();
void updateError();
void updateText();
void updateExit(int exitCode, QProcess::ExitStatus exitStatus);
void updateConfig(QStringList list);
void reconfig();
void about();
signals:
void progress(int value);
};
#endif

View File

@ -0,0 +1,70 @@
// File : CompileHighlighter.cpp
// Date : 01.10.2009
// Author : Dupuis Damien
//
#include "CompileHighlighter.h"
CompileHighlighter::CompileHighlighter(QTextDocument *parent) : QSyntaxHighlighter(parent) {
// defines rules
CompileHighlighterRule rule;
//building/linking/scanning rule : blue Bold
_doingFormat.setForeground(Qt::blue);
_doingFormat.setFontWeight(QFont::Bold);
rule.format = _doingFormat;
rule.pattern = QRegExp("(^Building.*$|^Linking.*$|^Scanning.*$|^Built target.*$)");
_rules.append(rule);
//compile rule : darkBlue Normal
_compileFormat.setForeground(Qt::darkBlue);
rule.format = _compileFormat;
rule.pattern = QRegExp("(^\\[.*$)");
_rules.append(rule);
//install rule : cyan Bold
_installFormat.setForeground(Qt::cyan);
_installFormat.setFontWeight(QFont::Bold);
rule.format = _installFormat;
rule.pattern = QRegExp("(^Install the project.*$)");
_rules.append(rule);
//--install rule : darkCyan
_installingFormat.setForeground(Qt::darkCyan);
rule.format = _installingFormat;
rule.pattern = QRegExp("(^-- Install.*$)");
_rules.append(rule);
//--uptodate : darkCyan Italic
_uptodateFormat.setForeground(Qt::darkCyan);
_uptodateFormat.setFontItalic(true);
rule.format = _uptodateFormat;
rule.pattern = QRegExp("(^-- Up-to-date.*$)");
_rules.append(rule);
//warning rule
_warningFormat.setForeground(QColor("orange"));
rule.format = _warningFormat;
rule.pattern = QRegExp("(^/.*In function.*$|^/.*warning:.*$)");
_rules.append(rule);
//error rule
_errorFormat.setForeground(Qt::red);
rule.format = _errorFormat;
rule.pattern = QRegExp("(^/.*error:.*$|^make\\[.*$)");
_rules.append(rule);
}
void CompileHighlighter::highlightBlock(const QString &text) {
foreach (const CompileHighlighterRule &rule, _rules) {
QRegExp expression (rule.pattern);
int index = expression.indexIn(text);
while (index >= 0) {
int length = expression.matchedLength();
setFormat(index, length, rule.format);
index = expression.indexIn(text, index + length);
}
}
setCurrentBlockState(0);
}

View File

@ -0,0 +1,38 @@
// File : CompileHighlighter.h
// Date : 01.10.2009
// Author : Dupuis Damien
//
#ifndef COMPILEHIGHLIGHTER_H
#define COMPILEHIGHLIGHTER_H
#include <QSyntaxHighlighter>
#include <QTextCharFormat>
#include <QTextDocument>
class CompileHighlighter : public QSyntaxHighlighter {
Q_OBJECT
public:
CompileHighlighter ( QTextDocument *parent = 0 );
protected:
void highlightBlock ( const QString &text );
private:
struct CompileHighlighterRule {
QTextCharFormat format;
QRegExp pattern;
};
QVector<CompileHighlighterRule> _rules;
QTextCharFormat _compileFormat;
QTextCharFormat _warningFormat;
QTextCharFormat _errorFormat;
QTextCharFormat _installFormat;
QTextCharFormat _installingFormat;
QTextCharFormat _uptodateFormat;
QTextCharFormat _doingFormat;
};
#endif

View File

@ -0,0 +1,83 @@
#include <QGridLayout>
#include <QDialogButtonBox>
#include <QLabel>
#include <QPushButton>
#include <QFileDialog>
#include <QGroupBox>
#include "configDialog.h"
#define LINEEDITWIDTH 300
ConfigDialog::ConfigDialog() {
// First GroupBox : Directories
// Create Widgets
QLabel* compileL = new QLabel(tr("Compilation script:"), this);
QLabel* sourceL = new QLabel(tr("Chams source root directory:"), this);
_compileE = new QLineEdit ("", this);
_sourceE = new QLineEdit ("", this);
_compileE->setFixedWidth(LINEEDITWIDTH);
_sourceE->setFixedWidth (LINEEDITWIDTH);
QPushButton* compileB = new QPushButton(tr("&Browse"));
QPushButton* sourceB = new QPushButton(tr("&Browse"));
QDialogButtonBox* bBox = new QDialogButtonBox(QDialogButtonBox::Ok);
// Connect SIGNAL/SLOTS
connect(compileB, SIGNAL(clicked()) , this, SLOT(chooseCProgram()));
connect(sourceB , SIGNAL(clicked()) , this, SLOT(chooseSourceRD()));
connect(bBox , SIGNAL(accepted()), this, SLOT(doConfig()));
// Create GroupBox
QGroupBox* directories = new QGroupBox("Directories", this);
QGridLayout* gLayout = new QGridLayout(this);
gLayout->addWidget( compileL, 0, 0, 1, 1);
gLayout->addWidget(_compileE, 0, 1, 1, 2);
gLayout->addWidget( compileB, 0, 3, 1, 1);
gLayout->addWidget( sourceL , 1, 0, 1, 1);
gLayout->addWidget(_sourceE , 1, 1, 1, 2);
gLayout->addWidget( sourceB , 1, 3, 1, 1);
directories->setLayout(gLayout);
// Second GroupBox : Tools
// Create Widgets
_hurCB = new QCheckBox("Hurricane" , this);
_ioCB = new QCheckBox("Io" , this);
_testCB = new QCheckBox("Test (not in svn)", this);
_crlCB = new QCheckBox("Crlcore" , this);
_chamsCB = new QCheckBox("Chams" , this);
_hurAMSCB = new QCheckBox("HurricaneAMS" , this);
// Create GroupBox
QGroupBox* tools = new QGroupBox("Available Tools", this);
QGridLayout* grLayout = new QGridLayout(this);
grLayout->addWidget(_hurCB , 0, 0, 1, 1);
grLayout->addWidget(_ioCB , 1, 0, 1, 1);
grLayout->addWidget(_testCB , 2, 0, 1, 1);
grLayout->addWidget(_crlCB , 0, 1, 1, 1);
grLayout->addWidget(_chamsCB , 1, 1, 1, 1);
grLayout->addWidget(_hurAMSCB, 2, 1, 1, 1);
tools->setLayout(grLayout);
// ConfigDialog Layout
QVBoxLayout* vLayout = new QVBoxLayout;
vLayout->addWidget(directories);
vLayout->addWidget(tools);
vLayout->addWidget(bBox);
setLayout(vLayout);
}
void ConfigDialog::chooseCProgram() {
_compileE->setText(QFileDialog::getOpenFileName(this, tr("Select chams.sh"), "", tr("Shell script (*.sh)")));
}
void ConfigDialog::chooseSourceRD() {
_sourceE->setText(QFileDialog::getExistingDirectory(this, tr("Select the chams source root directory")));
}
void ConfigDialog::doConfig() {
QStringList list;
QString hur = (_hurCB->isChecked()) ? "ON" : "OFF";
QString io = (_ioCB->isChecked()) ? "ON" : "OFF";
QString test = (_testCB->isChecked()) ? "ON" : "OFF";
QString crl = (_crlCB->isChecked()) ? "ON" : "OFF";
QString chams = (_chamsCB->isChecked()) ? "ON" : "OFF";
QString hurAMS = (_hurAMSCB->isChecked()) ? "ON" : "OFF";
list << _compileE->text() << _sourceE->text() << hur << io << test << crl << chams << hurAMS;
emit configDone(list);
accept();
}

View File

@ -0,0 +1,88 @@
#ifndef CONFIGDIALOG_H
#define CONFIGDIALOG_H
#include <QDialog>
#include <QLineEdit>
#include <QCheckBox>
class QLabel;
class QStringList;
class ConfigDialog : public QDialog {
Q_OBJECT
public:
ConfigDialog();
inline void setCompileProgram(QString);
inline void setSourceRootDirectory(QString);
inline void setHasHurricane(bool);
inline void setHasIo(bool);
inline void setHasTest(bool);
inline void setHasCrlcore(bool);
inline void setHasChams(bool);
inline void setHasHurricaneAMS(bool);
public slots:
void chooseCProgram();
void chooseSourceRD();
void doConfig();
signals:
void configDone (QStringList list);
private:
QLineEdit* _compileE;
QLineEdit* _sourceE;
QCheckBox* _hurCB;
QCheckBox* _ioCB;
QCheckBox* _testCB;
QCheckBox* _crlCB;
QCheckBox* _chamsCB;
QCheckBox* _hurAMSCB;
};
inline void ConfigDialog::setCompileProgram (QString cProgram ) { _compileE->setText(cProgram); };
inline void ConfigDialog::setSourceRootDirectory (QString rDirectory) { _sourceE->setText(rDirectory); };
inline void ConfigDialog::setHasHurricane(bool state) {
if (state)
_hurCB->setCheckState(Qt::Checked);
else
_hurCB->setCheckState(Qt::Unchecked);
};
inline void ConfigDialog::setHasIo(bool state) {
if (state)
_ioCB->setCheckState(Qt::Checked);
else
_ioCB->setCheckState(Qt::Unchecked);
};
inline void ConfigDialog::setHasTest(bool state) {
if (state)
_testCB->setCheckState(Qt::Checked);
else
_testCB->setCheckState(Qt::Unchecked);
};
inline void ConfigDialog::setHasCrlcore(bool state) {
if (state)
_crlCB->setCheckState(Qt::Checked);
else
_crlCB->setCheckState(Qt::Unchecked);
};
inline void ConfigDialog::setHasChams(bool state) {
if (state)
_chamsCB->setCheckState(Qt::Checked);
else
_chamsCB->setCheckState(Qt::Unchecked);
};
inline void ConfigDialog::setHasHurricaneAMS(bool state) {
if (state)
_hurAMSCB->setCheckState(Qt::Checked);
else
_hurAMSCB->setCheckState(Qt::Unchecked);
};
#endif

View File

@ -0,0 +1,22 @@
#include<QMenu>
#include<QMenuBar>
#include<QAction>
#include "MainWindow.h"
MainWindow::MainWindow()
{
CompilationWidget* cWidget = new CompilationWidget(this);
setCentralWidget(cWidget);
QAction* configAct = new QAction(tr("&Configure"), this);
configAct->setStatusTip(tr("Configure the application"));
connect(configAct, SIGNAL(triggered()), cWidget, SLOT(reconfig()));
QAction* aboutAct = new QAction(tr("&About"), this);
aboutAct->setStatusTip(tr("Show the about dialog box"));
connect(aboutAct, SIGNAL(triggered()), cWidget, SLOT(about()));
QMenu* editMenu = menuBar()->addMenu(tr("&Edit"));
editMenu->addAction(configAct);
QMenu* helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addAction(aboutAct);
}

View File

@ -0,0 +1,15 @@
#ifndef __MAINWINDOW_H
#define __MAINWINDOW_H
#include <QMainWindow>
#include "CompilationWidget.h"
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow ();
~MainWindow () {};
};
#endif

View File

@ -0,0 +1,5 @@
easyChams readme
This tool allows every one to easily compile & install chams project's sources.
To compile this tool use ./compile.sh which is platform independant.

8
bootstrap/easyChams/compile.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
qmake -project
case "`uname -s`" in
Linux) qmake;;
Darwin) qmake -spec macx-g++;;
esac
make -j2 && make clean

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

View File

@ -0,0 +1,16 @@
#include <iostream>
using namespace std;
#include <QApplication>
#include <QAction>
#include <QMenu>
#include "MainWindow.h"
int main ( int argc, char **argv ) {
QApplication app ( argc, argv );
MainWindow mWindow;
mWindow.show();
return app.exec();
}