Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
treefrogframework committed Apr 12, 2024
1 parent 360f67e commit 6469c38
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 20 deletions.
3 changes: 2 additions & 1 deletion compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ bool Compiler::compile(const QString &cc, const QStringList &options, const QStr
}
}

//qDebug() << cc << ccOptions;
// qDebug() << cc << ccOptions;
// qDebug() << code;
QProcess compileProc;
compileProc.start(cc, ccOptions);

Expand Down
7 changes: 7 additions & 0 deletions cpi.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

set VCVARSBAT=""
set VSVER=
set VSVER2022=2022
set VSVER2019=2019
set VSVER2017=2017
set VSWHERE="%PROGRAMFILES(X86)%\Microsoft Visual Studio\Installer\vswhere.exe"

if exist %VSWHERE% (
for /f "usebackq tokens=*" %%i in (`%VSWHERE% -find **\vcvarsall.bat`) do (
echo %%i | find "%VSVER2022%" >NUL
if not ERRORLEVEL 1 (
set VCVARSBAT="%%i"
set VSVER=%VSVER2022%
goto :break
)
echo %%i | find "%VSVER2019%" >NUL
if not ERRORLEVEL 1 (
set VCVARSBAT="%%i"
Expand Down
2 changes: 1 addition & 1 deletion cpi.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TEMPLATE = app
TARGET = cpi
CONFIG += console c++11
CONFIG += console c++17
CONFIG -= app_bundle
QT -= gui
DEPENDPATH += .
Expand Down
3 changes: 2 additions & 1 deletion global.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include <QtCore>
#include <QString>
#include <memory>


namespace cpi {
Expand All @@ -17,6 +18,6 @@ const auto endl = Qt::endl;
}


extern QSettings *conf;
extern std::unique_ptr<QSettings> conf;
extern QStringList cppsArgs;
extern QString aoutName();
44 changes: 27 additions & 17 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using namespace cpi;

// Version
constexpr auto CPI_VERSION_STR = "2.0.4";
constexpr auto CPI_VERSION_STR = "2.1.0";

#ifdef Q_CC_MSVC
constexpr auto DEFAULT_CONFIG = "[General]\n"
Expand All @@ -28,24 +28,24 @@ constexpr auto DEFAULT_CONFIG = "[General]\n"
constexpr auto DEFAULT_CONFIG = "[General]\n"
"### Example option for Qt5\n"
"#CXX=%1\n"
"#CXXFLAGS=-fPIC -pipe -std=c++14 -D_REENTRANT -I/usr/include/qt5\n"
"#CXXFLAGS=-pipe -std=c++14 -D_REENTRANT -I/usr/include/qt5\n"
"#LDFLAGS=-lQt5Core\n"
"#COMMON_INCLUDES=\n"
"\n"
"CXX=\n"
"CXXFLAGS=-fPIC -pipe -std=c++14 -D_REENTRANT\n"
"CXXFLAGS=-pipe -std=c++14 -D_REENTRANT\n"
"LDFLAGS=\n"
"COMMON_INCLUDES=\n";
#else
constexpr auto DEFAULT_CONFIG = "[General]\n"
"### Example option for Qt6\n"
"#CXX=\n"
"#CXXFLAGS=-fPIC -pipe -std=c++17 -D_REENTRANT -I/usr/include/qt6\n"
"#CXXFLAGS=-pipe -std=c++2a -D_REENTRANT -I/usr/include/qt6\n"
"#LDFLAGS=-lQt6Core\n"
"#COMMON_INCLUDES=\n"
"\n"
"CXX=\n"
"CXXFLAGS=-fPIC -pipe -std=c++17 -D_REENTRANT\n"
"CXXFLAGS=-pipe -std=c++2a -D_REENTRANT\n"
"LDFLAGS=\n"
"COMMON_INCLUDES=\n";
#endif
Expand All @@ -54,7 +54,7 @@ constexpr auto DEFAULT_CONFIG = "[General]\n"
// Entered headers and code
static QStringList headers, code;
static int lastLineNumber = 0; // line number added recently
QSettings *conf = nullptr;
std::unique_ptr<QSettings> conf;
QStringList cppsArgs;


Expand Down Expand Up @@ -352,9 +352,9 @@ int main(int argv, char *argc[])
QCoreApplication app(argv, argc);

#if (defined Q_OS_WIN) || (defined Q_OS_DARWIN)
conf = new QSettings(QSettings::IniFormat, QSettings::UserScope, "cpi/cpi");
conf = std::make_unique<QSettings>(QSettings::IniFormat, QSettings::UserScope, "cpi/cpi");
#else
conf = new QSettings(QSettings::NativeFormat, QSettings::UserScope, "cpi/cpi");
conf = std::make_unique<QSettings>(QSettings::NativeFormat, QSettings::UserScope, "cpi/cpi");
#endif

QFile confFile(conf->fileName());
Expand All @@ -375,21 +375,31 @@ int main(int argv, char *argc[])
watchUnixSignal(SIGINT);
#endif

int ret;
QString file = isSetFileOption();
Compiler compiler;

if (!file.isEmpty()) {
Compiler compiler;
int ret = compiler.compileFileAndExecute(file);
ret = compiler.compileFileAndExecute(file);
if (ret) {
compiler.printLastCompilationError();
}
return ret;
}

// Check compiler
Compiler::cxx();
} else if (QCoreApplication::arguments().contains("-")) { // Check pipe option
QString src;
QTextStream tsstdin(stdin);
while(!tsstdin.atEnd()) {
src += tsstdin.readLine();
src += "\n";
}

int ret = interpreter();
delete conf;
ret = compiler.compileAndExecute(src);
if (ret) {
compiler.printLastCompilationError();
}
} else {
// Check compiler
Compiler::cxx();
ret = interpreter();
}
return ret;
}

0 comments on commit 6469c38

Please sign in to comment.