- fix: Buttons in options -> compiler -> compiler set -> programs are not usable.
- enhancement: Don't check existence of gcc/g++/make/gdb at startup. - enhancement: Auto disable "compile" button if gcc doesn't exist. - enhancement: Auto disable "debug" button if gdb doesn't exist. - enhancement: Auto disable "compile" button for project if make doesn't exist.
This commit is contained in:
parent
e81c08d6c8
commit
02e6748db5
5
NEWS.md
5
NEWS.md
|
@ -14,6 +14,11 @@ Red Panda C++ Version 2.6
|
|||
- enhancement: Show memory usage for problem cases (windows only).
|
||||
- enhancement: Show memory usage after console program exited.
|
||||
- fix: If clang and g++ are in the same folder, only the compiler sets for gcc are auto generated.
|
||||
- fix: Buttons in options -> compiler -> compiler set -> programs are not usable.
|
||||
- enhancement: Don't check existence of gcc/g++/make/gdb at startup.
|
||||
- enhancement: Auto disable "compile" button if gcc doesn't exist.
|
||||
- enhancement: Auto disable "debug" button if gdb doesn't exist.
|
||||
- enhancement: Auto disable "compile" button for project if make doesn't exist.
|
||||
|
||||
Red Panda C++ Version 2.5
|
||||
|
||||
|
|
|
@ -54,7 +54,8 @@ enum class CompilerSetType {
|
|||
enum class CompilerType {
|
||||
GCC,
|
||||
GCC_UTF8,
|
||||
Clang
|
||||
Clang,
|
||||
Unknown
|
||||
};
|
||||
|
||||
using CompileOptionChoiceList = QList<QPair<QString,QString>>;
|
||||
|
|
|
@ -30,7 +30,10 @@ StdinCompiler::StdinCompiler(const QString &filename,const QByteArray& encoding,
|
|||
|
||||
bool StdinCompiler::prepareForCompile()
|
||||
{
|
||||
if (mOnlyCheckSyntax)
|
||||
log(tr("Checking file syntax..."));
|
||||
else
|
||||
log(tr("Compiling..."));
|
||||
log("------------------");
|
||||
log(tr("- Filename: %1").arg(mFilename));
|
||||
log(tr("- Compiler Set Name: %1").arg(compilerSet()->name()));
|
||||
|
@ -68,7 +71,10 @@ bool StdinCompiler::prepareForCompile()
|
|||
mArguments += getLibraryArguments(fileType);
|
||||
|
||||
if (!fileExists(mCompiler)) {
|
||||
if (!mOnlyCheckSyntax)
|
||||
throw CompileError(tr("The Compiler '%1' doesn't exists!").arg(mCompiler));
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
log(tr("Processing %1 source file:").arg(strFileType));
|
||||
|
|
|
@ -650,14 +650,28 @@ void MainWindow::updateCompileActions()
|
|||
bool forProject=false;
|
||||
bool canCompile = false;
|
||||
bool canRun = false;
|
||||
bool canDebug = false;
|
||||
Editor * e = mEditorList->getEditor();
|
||||
if (e) {
|
||||
if (!e->inProject()) {
|
||||
FileType fileType = getFileType(e->filename());
|
||||
if (fileType == FileType::CSource
|
||||
|| fileType == FileType::CppSource || e->isNew()) {
|
||||
canCompile = true;
|
||||
canRun = true;
|
||||
Settings::PCompilerSet set = pSettings->compilerSets().defaultSet();
|
||||
if (set) {
|
||||
canDebug = set->canDebug();
|
||||
switch(fileType) {
|
||||
case FileType::CSource:
|
||||
canCompile = set->canCompileC();
|
||||
break;
|
||||
case FileType::CppSource:
|
||||
canCompile = set->canCompileCPP();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
forProject = (mProject!=nullptr);
|
||||
|
@ -666,9 +680,13 @@ void MainWindow::updateCompileActions()
|
|||
forProject = (mProject!=nullptr);
|
||||
}
|
||||
if (forProject) {
|
||||
canCompile = true;
|
||||
canRun = (mProject->options().type !=ProjectType::DynamicLib)
|
||||
&& (mProject->options().type !=ProjectType::StaticLib);
|
||||
Settings::PCompilerSet set = pSettings->compilerSets().getSet(mProject->options().compilerSet);
|
||||
if (set) {
|
||||
canDebug = set->canDebug();
|
||||
canCompile = set->canMake();
|
||||
}
|
||||
}
|
||||
if (mCompilerManager->compiling() || mCompilerManager->running() || mDebugger->executing()
|
||||
|| (!canCompile)) {
|
||||
|
@ -681,11 +699,11 @@ void MainWindow::updateCompileActions()
|
|||
ui->btnRunAllProblemCases->setEnabled(false);
|
||||
} else {
|
||||
ui->actionCompile->setEnabled(true);
|
||||
ui->actionCompile_Run->setEnabled(canRun);
|
||||
ui->actionCompile_Run->setEnabled(canRun && canCompile);
|
||||
ui->actionRun->setEnabled(canRun);
|
||||
ui->actionRebuild->setEnabled(true);
|
||||
ui->actionGenerate_Assembly->setEnabled(!forProject);
|
||||
ui->actionDebug->setEnabled(canRun);
|
||||
ui->actionDebug->setEnabled(canDebug);
|
||||
ui->btnRunAllProblemCases->setEnabled(canRun);
|
||||
}
|
||||
if (!mDebugger->executing()) {
|
||||
|
@ -5170,6 +5188,7 @@ void MainWindow::onCompilerSetChanged(int index)
|
|||
if (index<0)
|
||||
return;
|
||||
Editor *e = mEditorList->getEditor();
|
||||
updateCompileActions();
|
||||
if ( mProject && (!e || e->inProject())
|
||||
) {
|
||||
if (index==mProject->options().compilerSet)
|
||||
|
|
|
@ -1544,9 +1544,11 @@ void Settings::Editor::setTabToSpaces(bool tabToSpaces)
|
|||
|
||||
Settings::CompilerSet::CompilerSet():
|
||||
mFullLoaded(false),
|
||||
mAutoAddCharsetParams(true),
|
||||
mCompilerType(CompilerType::Unknown),
|
||||
mCompilerSetType(CompilerSetType::RELEASE),
|
||||
mAutoAddCharsetParams(false),
|
||||
mExecCharset(ENCODING_SYSTEM_DEFAULT),
|
||||
mStaticLink(true),
|
||||
mStaticLink(false),
|
||||
mPreprocessingSuffix(DEFAULT_PREPROCESSING_SUFFIX),
|
||||
mCompilationProperSuffix(DEFAULT_COMPILATION_SUFFIX),
|
||||
mAssemblingSuffix(DEFAULT_ASSEMBLING_SUFFIX),
|
||||
|
@ -1770,34 +1772,34 @@ bool Settings::CompilerSet::dirsValid(QString &msg)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Settings::CompilerSet::validateExes(QString &msg)
|
||||
{
|
||||
msg ="";
|
||||
if (!fileExists(mCCompiler)) {
|
||||
msg += QObject::tr("Cannot find the %1 \"%2\"")
|
||||
.arg(QObject::tr("C Compiler"))
|
||||
.arg(mCCompiler);
|
||||
}
|
||||
if (!fileExists(mCppCompiler)) {
|
||||
msg += QObject::tr("Cannot find the %1 \"%2\"")
|
||||
.arg(QObject::tr("C++ Compiler"))
|
||||
.arg(mCppCompiler);
|
||||
}
|
||||
if (!mMake.isEmpty() && !fileExists(mMake)) {
|
||||
msg += QObject::tr("Cannot find the %1 \"%2\"")
|
||||
.arg(QObject::tr("Maker"))
|
||||
.arg(mMake);
|
||||
}
|
||||
if (!fileExists(mDebugger)) {
|
||||
msg += QObject::tr("Cannot find the %1 \"%2\"")
|
||||
.arg(QObject::tr("Debugger"))
|
||||
.arg(mDebugger);
|
||||
}
|
||||
if (!msg.isEmpty())
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
//bool Settings::CompilerSet::validateExes(QString &msg)
|
||||
//{
|
||||
// msg ="";
|
||||
// if (!fileExists(mCCompiler)) {
|
||||
// msg += QObject::tr("Cannot find the %1 \"%2\"")
|
||||
// .arg(QObject::tr("C Compiler"))
|
||||
// .arg(mCCompiler);
|
||||
// }
|
||||
// if (!fileExists(mCppCompiler)) {
|
||||
// msg += QObject::tr("Cannot find the %1 \"%2\"")
|
||||
// .arg(QObject::tr("C++ Compiler"))
|
||||
// .arg(mCppCompiler);
|
||||
// }
|
||||
// if (!mMake.isEmpty() && !fileExists(mMake)) {
|
||||
// msg += QObject::tr("Cannot find the %1 \"%2\"")
|
||||
// .arg(QObject::tr("Maker"))
|
||||
// .arg(mMake);
|
||||
// }
|
||||
// if (!fileExists(mDebugger)) {
|
||||
// msg += QObject::tr("Cannot find the %1 \"%2\"")
|
||||
// .arg(QObject::tr("Debugger"))
|
||||
// .arg(mDebugger);
|
||||
// }
|
||||
// if (!msg.isEmpty())
|
||||
// return false;
|
||||
// else
|
||||
// return true;
|
||||
//}
|
||||
|
||||
const QString &Settings::CompilerSet::CCompiler() const
|
||||
{
|
||||
|
@ -1806,7 +1808,17 @@ const QString &Settings::CompilerSet::CCompiler() const
|
|||
|
||||
void Settings::CompilerSet::setCCompiler(const QString &name)
|
||||
{
|
||||
if (mCCompiler!=name) {
|
||||
mCCompiler = name;
|
||||
if (mCompilerType == CompilerType::Unknown) {
|
||||
QString temp=extractFileName(mCCompiler);
|
||||
if (temp == CLANG_PROGRAM) {
|
||||
setCompilerType(CompilerType::Clang);
|
||||
} else if (temp == GCC_PROGRAM) {
|
||||
setCompilerType(CompilerType::GCC);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const QString &Settings::CompilerSet::cppCompiler() const
|
||||
|
@ -2403,6 +2415,26 @@ int Settings::CompilerSet::mainVersion()
|
|||
|
||||
}
|
||||
|
||||
bool Settings::CompilerSet::canCompileC()
|
||||
{
|
||||
return fileExists(mCCompiler);
|
||||
}
|
||||
|
||||
bool Settings::CompilerSet::canCompileCPP()
|
||||
{
|
||||
return fileExists(mCppCompiler);
|
||||
}
|
||||
|
||||
bool Settings::CompilerSet::canMake()
|
||||
{
|
||||
return fileExists(mMake);
|
||||
}
|
||||
|
||||
bool Settings::CompilerSet::canDebug()
|
||||
{
|
||||
return fileExists(mDebugger);
|
||||
}
|
||||
|
||||
void Settings::CompilerSet::setUserInput()
|
||||
{
|
||||
mUseCustomCompileParams = false;
|
||||
|
@ -2800,7 +2832,7 @@ void Settings::CompilerSets::loadSets()
|
|||
PCompilerSet pCurrentSet = defaultSet();
|
||||
if (pCurrentSet) {
|
||||
QString msg;
|
||||
if (!pCurrentSet->dirsValid(msg) || !pCurrentSet->validateExes(msg)) {
|
||||
if (!pCurrentSet->dirsValid(msg)) {
|
||||
if (QMessageBox::warning(nullptr,QObject::tr("Confirm"),
|
||||
QObject::tr("The following problems were found during validation of compiler set \"%1\":")
|
||||
.arg(pCurrentSet->name())
|
||||
|
|
|
@ -1249,8 +1249,12 @@ public:
|
|||
|
||||
int mainVersion();
|
||||
|
||||
bool canCompileC();
|
||||
bool canCompileCPP();
|
||||
bool canMake();
|
||||
bool canDebug();
|
||||
bool dirsValid(QString& msg);
|
||||
bool validateExes(QString& msg);
|
||||
// bool validateExes(QString& msg);
|
||||
//properties
|
||||
const QString& CCompiler() const;
|
||||
void setCCompiler(const QString& name);
|
||||
|
|
|
@ -51,6 +51,7 @@ CompilerSetOptionWidget::CompilerSetOptionWidget(const QString& name, const QStr
|
|||
#ifdef Q_OS_WIN
|
||||
ui->txtExecutableSuffix->setReadOnly(true);
|
||||
#endif
|
||||
ui->settingTabs->setCurrentWidget(ui->tabGeneral);
|
||||
}
|
||||
|
||||
CompilerSetOptionWidget::~CompilerSetOptionWidget()
|
||||
|
@ -235,6 +236,16 @@ void CompilerSetOptionWidget::saveCurrentCompilerSet()
|
|||
pSet->setExecutableSuffix(ui->txtExecutableSuffix->text());
|
||||
}
|
||||
|
||||
QString CompilerSetOptionWidget::getBinDir()
|
||||
{
|
||||
Settings::PCompilerSet pSet = pSettings->compilerSets().defaultSet();
|
||||
if (!pSet->binDirs().isEmpty())
|
||||
return pSet->binDirs().front();
|
||||
if (!mBinDirWidget->dirList().isEmpty())
|
||||
return mBinDirWidget->dirList().front();
|
||||
return QDir().absolutePath();
|
||||
}
|
||||
|
||||
void CompilerSetOptionWidget::on_btnFindCompilers_pressed()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
|
@ -338,3 +349,87 @@ void CompilerSetOptionWidget::on_cbEncodingDetails_currentTextChanged(const QStr
|
|||
|
||||
}
|
||||
|
||||
|
||||
void CompilerSetOptionWidget::on_btnChooseCCompiler_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr("Locate C Compiler"),
|
||||
getBinDir(),
|
||||
tr("Executable files (*.exe)"));
|
||||
if (fileExists(fileName))
|
||||
ui->txtCCompiler->setText(fileName);
|
||||
}
|
||||
|
||||
|
||||
void CompilerSetOptionWidget::on_btnChooseCppCompiler_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr("Locate C++ Compiler"),
|
||||
getBinDir(),
|
||||
tr("Executable files (*.exe)"));
|
||||
if (fileExists(fileName))
|
||||
ui->txtCppCompiler->setText(fileName);
|
||||
}
|
||||
|
||||
|
||||
void CompilerSetOptionWidget::on_btnChooseMake_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr("Locate Make"),
|
||||
getBinDir(),
|
||||
tr("Executable files (*.exe)"));
|
||||
if (fileExists(fileName))
|
||||
ui->txtMake->setText(fileName);
|
||||
}
|
||||
|
||||
|
||||
void CompilerSetOptionWidget::on_btnChooseGDB_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr("Locate GDB"),
|
||||
getBinDir(),
|
||||
tr("Executable files (*.exe)"));
|
||||
if (fileExists(fileName))
|
||||
ui->txtDebugger->setText(fileName);
|
||||
}
|
||||
|
||||
|
||||
void CompilerSetOptionWidget::on_btnChooseGDBServer_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr("Locate GDB Server"),
|
||||
getBinDir(),
|
||||
tr("Executable files (*.exe)"));
|
||||
if (fileExists(fileName))
|
||||
ui->txtGDBServer->setText(fileName);
|
||||
}
|
||||
|
||||
|
||||
void CompilerSetOptionWidget::on_btnChooseResourceCompiler_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr("Locate windres"),
|
||||
getBinDir(),
|
||||
tr("Executable files (*.exe)"));
|
||||
if (fileExists(fileName))
|
||||
ui->txtResourceCompiler->setText(fileName);
|
||||
}
|
||||
|
||||
|
||||
void CompilerSetOptionWidget::on_btnChooseProfiler_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr("Locate gprof"),
|
||||
getBinDir(),
|
||||
tr("Executable files (*.exe)"));
|
||||
if (fileExists(fileName))
|
||||
ui->txtProfiler->setText(fileName);
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ protected:
|
|||
private:
|
||||
void reloadCurrentCompilerSet();
|
||||
void saveCurrentCompilerSet();
|
||||
QString getBinDir();
|
||||
|
||||
private slots:
|
||||
void on_cbCompilerSet_currentIndexChanged(int index);
|
||||
|
@ -63,6 +64,13 @@ private slots:
|
|||
|
||||
void on_cbEncoding_currentTextChanged(const QString &arg1);
|
||||
void on_cbEncodingDetails_currentTextChanged(const QString &arg1);
|
||||
void on_btnChooseCCompiler_clicked();
|
||||
void on_btnChooseCppCompiler_clicked();
|
||||
void on_btnChooseMake_clicked();
|
||||
void on_btnChooseGDB_clicked();
|
||||
void on_btnChooseGDBServer_clicked();
|
||||
void on_btnChooseResourceCompiler_clicked();
|
||||
void on_btnChooseProfiler_clicked();
|
||||
};
|
||||
|
||||
#endif // COMPILERSETOPTIONWIDGET_H
|
||||
|
|
|
@ -723,6 +723,38 @@
|
|||
<source>Executable suffix</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Locate C Compiler</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable files (*.exe)</source>
|
||||
<translation type="unfinished">Arquivos executáveis (*.exe)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Locate C++ Compiler</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Locate Make</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Locate GDB</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Locate GDB Server</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Locate windres</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Locate gprof</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>CppRefacter</name>
|
||||
|
@ -5977,23 +6009,23 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Cannot find the %1 "%2"</source>
|
||||
<translation>Impossível encontrar %1 "%2"</translation>
|
||||
<translation type="vanished">Impossível encontrar %1 "%2"</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>C Compiler</source>
|
||||
<translation>Compilar C</translation>
|
||||
<translation type="vanished">Compilar C</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>C++ Compiler</source>
|
||||
<translation>Compilador C++</translation>
|
||||
<translation type="vanished">Compilador C++</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Maker</source>
|
||||
<translation>Maker</translation>
|
||||
<translation type="vanished">Maker</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Debugger</source>
|
||||
<translation>Depurador</translation>
|
||||
<translation type="vanished">Depurador</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>C options</source>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -632,6 +632,38 @@
|
|||
<source>Executable suffix</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Locate C Compiler</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable files (*.exe)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Locate C++ Compiler</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Locate Make</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Locate GDB</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Locate GDB Server</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Locate windres</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Locate gprof</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>CppRefacter</name>
|
||||
|
@ -5752,26 +5784,6 @@
|
|||
<source>C++ include</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cannot find the %1 "%2"</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>C Compiler</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>C++ Compiler</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Maker</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Debugger</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>C options</source>
|
||||
<translation type="unfinished"></translation>
|
||||
|
|
Loading…
Reference in New Issue