Commit 6a786692 authored by Leander Schulten's avatar Leander Schulten
Browse files

Add includePath Setting variable.

Smal changes
parent f2348688
......@@ -152,5 +152,5 @@ win32-g++{
unix{
#installed with brew install boost
LIBS += -L/usr/local/Cellar/boost/1.66.0/lib -lboost_coroutine -lboost_context-mt
LIBS += -L/usr/local/lib -lboost_coroutine -lboost_context-mt
}
......@@ -66,7 +66,7 @@ Pane{
TextInputField{
Layout.fillWidth: true
text: Settings.moduleDirPath
onAccepted: Settings.moduleDirPath = text;
//onAccepted: Settings.moduleDirPath = text;
MouseArea{
anchors.fill: parent
onClicked: {
......@@ -78,6 +78,7 @@ Pane{
fileDialog.callback = function(file){
console.log(file);
Settings.moduleDirPath = file;
parent.text = file;
};
}
}
......@@ -110,6 +111,35 @@ Pane{
}
}
}
Label{
Layout.fillWidth: true
text: "Include Path:"
}
TextInputField{
Layout.fillWidth: true
text: Settings.includePath
onAccepted: Settings.includePath = text;
Button{
anchors.top: parent.top
anchors.right: parent.right
anchors.topMargin: -5
anchors.bottomMargin: -5
anchors.bottom: parent.bottom
text: "File Chooser"
onClicked: {
fileDialog.selectFolder = true;
fileDialog.selectMultiple = false;
fileDialog.folder = Settings.includePath;
fileDialog.open();
fileDialog.addSelection(Settings.includePath);
fileDialog.callback = function(file){
console.log(file);
Settings.includePath = file;
};
}
}
}
Label{
Layout.fillWidth: true
text: "Compiler Flags:"
......
......@@ -404,7 +404,11 @@ void CodeEditorHelper::compile(){
stream << "}" << endl;
stream.flush();
file.close();
#ifdef Q_OS_WIN
auto result = Modules::Compiler::compileToLibrary(file,module->getName()+".dll");
#else
auto result = Modules::Compiler::compileToLibrary(file,module->getName()+".so");
#endif
if(result.first){
QFileInfo finfo = file;
emit information(result.second.replace(finfo.absoluteFilePath(),""));
......@@ -422,5 +426,7 @@ void CodeEditorHelper::compile(){
for(const auto & m : c){
qDebug()<< QString::fromStdString(m.name());
}
}else{
emit information("Cant open file : " + s.getModuleDirPath() + "/" + module->getName() + ".cpp");
}
}
......@@ -40,8 +40,6 @@
#include "programblockeditor.h"
namespace Modules {
Q_NAMESPACE
Q_ENUM_NS(Property::Type)
}
int main(int argc, char *argv[])
......@@ -50,7 +48,7 @@ int main(int argc, char *argv[])
testModulSystem.runTest();
return 0;*/
//Modules::rgb_t t = {{{{1},{4},{3}}}};
Test::createProgrammBlockAndTestRunIt();
/*{
using namespace std;
......@@ -128,7 +126,7 @@ int main(int argc, char *argv[])
qRegisterMetaType<UserManagment::Permission>("Permission");
qRegisterMetaType<Modules::detail::PropertyInformation::Type>("Type");
//qmlRegisterType<Modules::detail::PropertyInformation::Type>("custom.licht", 1, 0, "PropertyType");
qmlRegisterUncreatableMetaObject(Modules::detail::PropertyInformation::staticMetaObject,"test",1,0,"we","no enum");
//qmlRegisterUncreatableMetaObject(Modules::detail::PropertyInformation::staticMetaObject,"test",1,0,"we","no enum");
//qmlRegisterUncreatableMetaObject(Modules::Property::Type,"test",1,0,"we","no enum");
qRegisterMetaType<Modules::ValueType>("ValueType");
qRegisterMetaType<Modules::PropertiesVector*>("PropertiesVector*");
......
......@@ -3,7 +3,7 @@
#include <vector>
#include <QAbstractListModel>
#include <QDebug>
#include <shared_ptr.hpp>
#include <memory>
namespace detail {
......
......@@ -9,7 +9,7 @@ ProgramBlockEditor::ProgramBlockEditor():programBlockEntry(engine,QUrl("qrc:/Pro
programBlockConnection(engine,QUrl("qrc:/ProgramBlockConnection.qml"))
{
setAcceptedMouseButtons(Qt::AllButtons);
QQuickItem *c1 ;
/*QQuickItem *c1 ;
if(programBlockEntry.isReady()){
QQuickItem* component = qobject_cast<QQuickItem*>(programBlockEntry.create());
component->setParentItem(this);
......@@ -58,7 +58,7 @@ ProgramBlockEditor::ProgramBlockEditor():programBlockEntry(engine,QUrl("qrc:/Pro
});
QObject::connect(c1,&QQuickItem::yChanged,[=](){
component->setProperty("targetBaseline",c1->y()+c1->height());
});
});*/
/*
property alias targetStartIndex: path.startX
property alias targetLength: topRight.relativeX
......
......@@ -13,6 +13,7 @@ namespace Modules{
QString Compiler::compilerCmd = "g++";
QString Compiler::compilerLibraryFlags = "-shared -fPIC";
QString Compiler::compilerFlags = "-std=c++14 -O3";
QString Compiler::includePath = QDir::currentPath();
Compiler::Compiler()
......@@ -33,11 +34,12 @@ std::pair<int,QString> Compiler::compileToLibrary(const QFileInfo &file,const QS
QProcess p;
#ifdef Q_OS_MAC
p.setEnvironment(QProcess::systemEnvironment()<<"PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/TeX/texbin:/usr/local/MacGPG2/bin:/usr/local/share/dotnet:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands");
p.start("bash", QStringList() << "-c" << compilerCmd + " "+ compilerLibraryFlags + " " + compilerFlags + " " + file.fileName() + " -o " + newLibraryFile);
QString cmd = compilerCmd + " "+ compilerLibraryFlags + " " + compilerFlags + " " + file.absoluteFilePath() + " -o " + file.absolutePath()+"/"+newLibraryFile + " -I\"/"+includePath + "\" ";
p.start("bash", QStringList() << "-c" << cmd);
#elif defined(Q_OS_WIN)
QString tempName=newLibraryFile + ".o";
QString compilerCMD = compilerCmd.right(compilerCmd.length()-compilerCmd.lastIndexOf('/')-1);
QString cmd = /*".\\" + */ compilerCMD + " -c \"" + file.absoluteFilePath() + "\" " + compilerFlags + " -o \"" + file.absolutePath() + "/" + tempName+"\" -I\"" + QDir::currentPath() + "\" ";
QString cmd = /*".\\" + */ compilerCMD + " -c \"" + file.absoluteFilePath() + "\" " + compilerFlags + " -o \"" + file.absolutePath() + "/" + tempName+"\" -I\"" + includePath + "\" ";
cmd = "\" " + cmd + " \"";
qDebug().noquote() << cmd;
/*
......@@ -61,7 +63,7 @@ std::pair<int,QString> Compiler::compileToLibrary(const QFileInfo &file,const QS
if(p.exitCode() != 0){
qDebug() << p.errorString();
qDebug() << p.error();
qDebug().noquote() << cmd;
//qDebug().noquote() << cmd;
}else{
#ifdef Q_OS_WIN
// we have to unload the existing lib first
......@@ -77,6 +79,13 @@ std::pair<int,QString> Compiler::compileToLibrary(const QFileInfo &file,const QS
}
return{oToDll.exitCode(),oToDll.readAllStandardError()};
#endif
#ifdef Q_OS_MAC
// we have to unload the existing lib first
if(p.exitCode()==0){
ModuleManager::singletone()->singletone()->unloadLibrary(file.absolutePath() + "/" + newLibraryFile);
ModuleManager::singletone()->singletone()->loadModule(file.absolutePath() + "/" + newLibraryFile);
}
#endif
}
return {p.exitCode(),QString(err)};
......
......@@ -10,6 +10,7 @@ public:
static QString compilerCmd;
static QString compilerLibraryFlags;
static QString compilerFlags;
static QString includePath;
public:
Compiler();
......
......@@ -178,9 +178,10 @@ typedef Modules::Program* (*CreateProgramm)(unsigned int index);
if(s.suffix() == "old"){
QFile::remove(s.filePath());
}
if(s.suffix() == "dll")
#endif
loadModule(s.absoluteFilePath());
if(QLibrary::isLibrary(s.fileName())){
loadModule(s.absoluteFilePath());
}
//qDebug()<<"found : " << s;
}
for(auto s : dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)){
......
......@@ -234,9 +234,9 @@ namespace Modules {
}
namespace std {
/*namespace std {
template<>
struct __is_pointer_helper<std::shared_ptr<Modules::ProgramBlock>>
: public true_type { };
}
}*/
#endif // PROGRAMBLOCK_H
......@@ -6,4 +6,5 @@ Settings::Settings(QObject *parent) : QObject(parent), settings("Turmstraße 1 e
Modules::Compiler::compilerCmd = settings.value("compilerCmd",Modules::Compiler::compilerCmd).toString();
Modules::Compiler::compilerFlags = settings.value("compilerFlags",Modules::Compiler::compilerFlags).toString();
Modules::Compiler::compilerLibraryFlags = settings.value("compilerLibraryFlags",Modules::Compiler::compilerLibraryFlags).toString();
Modules::Compiler::includePath = settings.value("includePath",Modules::Compiler::includePath).toString();
}
......@@ -4,6 +4,7 @@
#include <QObject>
#include <QSettings>
#include <QFile>
#include <QDir>
#include "programms/compiler.h"
class Settings : public QObject
......@@ -16,6 +17,7 @@ class Settings : public QObject
Q_PROPERTY(QString compilerPath READ getCompilerPath WRITE setCompilerPath NOTIFY compilerPathChanged)
Q_PROPERTY(QString compilerFlags READ getCompilerFlags WRITE setCompilerFlags NOTIFY compilerFlagsChanged)
Q_PROPERTY(QString compilerLibraryFlags READ getCompilerLibraryFlags WRITE setCompilerLibraryFlags NOTIFY compilerLibraryFlagsChanged)
Q_PROPERTY(QString includePath READ getIncludePath WRITE setIncludePath NOTIFY includePathChanged)
Q_PROPERTY(unsigned int updatePauseInMs READ getUpdatePauseInMs WRITE setUpdatePauseInMs NOTIFY updatePauseInMsChanged)
public:
explicit Settings(QObject *parent = nullptr);
......@@ -26,9 +28,14 @@ public:
void setUpdatePauseInMs(unsigned int pause){settings.setValue("updatePauseInMs",pause);emit updatePauseInMsChanged();}
unsigned int getUpdatePauseInMs()const{return settings.value("updatePauseInMs").toUInt();}
void setModuleDirPath( const QString _moduleDirPath){
if(!QFile::exists(_moduleDirPath))return;
#ifdef Q_OS_MAC
if(!QDir("/" + _moduleDirPath).exists())return;
settings.setValue("moduleDirPath","/" + _moduleDirPath);
#else
if(!QDir(_moduleDirPath).exists())return;
settings.setValue("moduleDirPath",_moduleDirPath);
emit moduleDirPathChanged();
#endif
emit moduleDirPathChanged();
}
QString getModuleDirPath() const {
......@@ -45,6 +52,16 @@ public:
QString getCompilerPath() const {
return Modules::Compiler::compilerCmd;
}
void setIncludePath( const QString _includePath){
if(_includePath != Modules::Compiler::includePath){
Modules::Compiler::includePath = _includePath;
settings.setValue("includePath",_includePath);
emit includePathChanged();
}
}
QString getIncludePath() const {
return Modules::Compiler::includePath;
}
void setCompilerFlags( const QString _compilerFlags){
if(_compilerFlags != Modules::Compiler::compilerFlags){
......@@ -74,6 +91,7 @@ signals:
void compilerPathChanged();
void compilerFlagsChanged();
void compilerLibraryFlagsChanged();
void includePathChanged();
public slots:
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment