Skip to content

Commit

Permalink
Merge branch 'master' of github.com:treefrogframework/cpi
Browse files Browse the repository at this point in the history
  • Loading branch information
treefrogframework committed Feb 22, 2022
2 parents 35afd60 + 8edff19 commit 5a456e0
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 AOYAMA Kazuharu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
18 changes: 17 additions & 1 deletion compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "global.h"
#include "print.h"
#include <QtCore/QtCore>
#include <cstdlib>
#include <iostream>
#ifdef Q_OS_WINDOWS
#include <windows.h>
Expand Down Expand Up @@ -32,7 +33,21 @@ QString Compiler::cxx()
#elif defined(Q_CC_MSVC)
compiler = "cl.exe";
#else
compiler = "g++";
auto searchCommand = [](const QString &command) {
QProcess which;
which.start("which", QStringList(command));
which.waitForFinished();
return which.exitCode() == 0;
};

if (searchCommand("g++")) {
compiler = "g++";
} else if (searchCommand("clang++")) {
compiler = "clang++";
} else {
qCritical() << "Not found compiler";
std::exit(1);
}
#endif
}
return compiler;
Expand Down Expand Up @@ -86,6 +101,7 @@ bool Compiler::compile(const QString &cmd, const QString &code)
}
}

//qDebug() << cccmd;
QProcess compileProc;
auto cmdlst = cccmd.split(" ", SkipEmptyParts);
compileProc.start(cmdlst[0], cmdlst.mid(1));
Expand Down
11 changes: 6 additions & 5 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "global.h"
#include "codegenerator.h"
#include "compiler.h"
#include "global.h"
#include "print.h"
#include <QtCore/QtCore>
#include <cstdlib>
#include <iostream>
#include <list>
#ifdef Q_OS_WINDOWS
Expand All @@ -13,8 +14,8 @@
#endif
using namespace cpi;

#define CPI_VERSION_STR "2.0.2"
#define CPI_VERSION_NUMBER 0x020002
#define CPI_VERSION_STR "2.0.3"
#define CPI_VERSION_NUMBER 0x020003

#ifdef Q_CC_MSVC
#define DEFAULT_CONFIG \
Expand Down Expand Up @@ -108,7 +109,7 @@ static void signalHandler(int)
if (QFileInfo(aoutName()).exists()) {
QFile::remove(aoutName());
}
_exit(0);
std::exit(0);
}

static void watchUnixSignal(int sig)
Expand Down Expand Up @@ -274,7 +275,7 @@ static int interpreter()
if (line.startsWith(".del ") || line.startsWith(".rm ")) { // Deletes code
int n = line.indexOf(' ');
line.remove(0, n + 1);
QStringList list = line.split(QRegularExpression ("[,\\s]"), SkipEmptyParts);
QStringList list = line.split(QRegularExpression("[,\\s]"), SkipEmptyParts);

std::list<int> numbers; // line-numbers
for (QStringListIterator it(list); it.hasNext();) {
Expand Down

0 comments on commit 5a456e0

Please sign in to comment.