From 2d65e1d93b494b8f0d95ad224152bb6bebba8ef6 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 16 Dec 2021 11:36:52 +0800 Subject: [PATCH] - fix: can't correctly set TDM-GCC compiler - fix: auto add 32-bit compiler sets for TDM64-GCC --- NEWS.md | 5 ++++- RedPandaIDE/settings.cpp | 38 +++++++++++++++++++++++++++++++++++++- RedPandaIDE/utils.cpp | 14 ++++++++++---- RedPandaIDE/utils.h | 4 +++- 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/NEWS.md b/NEWS.md index 866a4e51..861cb0b1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,9 +1,12 @@ Version 0.11.2 For Dev-C++ 7 Beta - fix: button "run all problem cases" not disabled when compiling or debugging - enhancement: set font for problem case input/output textedits - - enhancement: when run problem cases, updates output immediately + - enhancement: when run program with problem cases, updates output immediately (note: stdout of the program running with problem cases is fully buffered, + so we need to fflush after each time output to stdout, or use setbuf(stdout,NULL) to turn the buffer off) - fix: current line of the disassembly in the cpu window not correctly setted - enhancement: add "step into one machine instruction" and "step over one machine instruction" in the cpu window + - fix: can't correctly set TDM-GCC compiler + - fix: auto add 32-bit compiler sets for TDM64-GCC Version 0.11.1 For Dev-C++ 7 Beta - enhancement: Problem's test case shouldn't accept rich text inputs diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index a6499ae7..9c5d5bb5 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -2232,7 +2232,15 @@ void Settings::CompilerSet::setIniOptions(const QByteArray &value) QByteArray Settings::CompilerSet::getCompilerOutput(const QString &binDir, const QString &binFile, const QStringList &arguments) { - QByteArray result = runAndGetOutput(includeTrailingPathDelimiter(binDir)+binFile, binDir, arguments); + QProcessEnvironment env; + env.insert("LANG","en"); + QByteArray result = runAndGetOutput( + includeTrailingPathDelimiter(binDir)+binFile, + binDir, + arguments, + QByteArray(), + false, + env); return result.trimmed(); } @@ -2292,6 +2300,13 @@ Settings::PCompilerSet Settings::CompilerSets::addSet(const QString &folder) return p; } +static void set64_32Options(Settings::PCompilerSet pSet) { + PCompilerOption pOption = pSet->findOption("-"); + if (pOption) { + pSet->setOption(pOption,'1'); + } +} + static void setReleaseOptions(Settings::PCompilerSet pSet) { PCompilerOption pOption = pSet->findOption("-O"); if (pOption) { @@ -2370,6 +2385,27 @@ void Settings::CompilerSets::addSets(const QString &folder) QString baseName = baseSet->name(); QString platformName; if (baseSet->target() == "x86_64") { + if (baseName.startsWith("TDM-GCC ")) { + platformName = "32-bit"; + baseSet->setName(baseName + " " + platformName + " Release"); + baseSet->setCompilerSetType(CompilerSetType::CST_RELEASE); + set64_32Options(baseSet); + setReleaseOptions(baseSet); + + baseSet = addSet(folder); + baseSet->setName(baseName + " " + platformName + " Debug"); + baseSet->setCompilerSetType(CompilerSetType::CST_DEBUG); + set64_32Options(baseSet); + setDebugOptions(baseSet); + + baseSet = addSet(folder); + baseSet->setName(baseName + " " + platformName + " Profiling"); + baseSet->setCompilerSetType(CompilerSetType::CST_PROFILING); + set64_32Options(baseSet); + setProfileOptions(baseSet); + + baseSet = addSet(folder); + } platformName = "64-bit"; } else { platformName = "32-bit"; diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp index 7127fec6..809d3e16 100644 --- a/RedPandaIDE/utils.cpp +++ b/RedPandaIDE/utils.cpp @@ -115,14 +115,20 @@ bool isGreenEdition() return gIsGreenEdition; } -QByteArray runAndGetOutput(const QString &cmd, const QString& workingDir, const QStringList& arguments, const QByteArray &inputContent, bool inheritEnvironment) +QByteArray runAndGetOutput(const QString &cmd, const QString& workingDir, const QStringList& arguments, + const QByteArray &inputContent, bool inheritEnvironment, + const QProcessEnvironment& env) { QProcess process; QByteArray result; - if (inheritEnvironment) { - process.setProcessEnvironment(QProcessEnvironment::systemEnvironment()); + if (env.isEmpty()) { + if (inheritEnvironment) { + process.setProcessEnvironment(QProcessEnvironment::systemEnvironment()); + } else { + process.setProcessEnvironment(QProcessEnvironment()); + } } else { - process.setProcessEnvironment(QProcessEnvironment()); + process.setProcessEnvironment(env); } process.setWorkingDirectory(workingDir); process.connect(&process,&QProcess::readyReadStandardError, diff --git a/RedPandaIDE/utils.h b/RedPandaIDE/utils.h index ee7f9669..15a4fdd1 100644 --- a/RedPandaIDE/utils.h +++ b/RedPandaIDE/utils.h @@ -9,6 +9,7 @@ #include #include #include +#include #include "SimpleIni.h" using SimpleIni = CSimpleIniA; @@ -120,7 +121,8 @@ bool isTextAllAscii(const QString& text); QByteArray runAndGetOutput(const QString& cmd, const QString& workingDir, const QStringList& arguments, const QByteArray& inputContent = QByteArray(), - bool inheritEnvironment = false); + bool inheritEnvironment = false, + const QProcessEnvironment& env = QProcessEnvironment() ); void executeFile(const QString& fileName, const QString& params,