From 9ce9469dd2252327e8fe4bef0cb5401965421bc1 Mon Sep 17 00:00:00 2001 From: royqh1979 Date: Sat, 4 Sep 2021 20:49:44 +0800 Subject: [PATCH] feature: seperate gcc default dirs from user settings --- RedPandaIDE/compiler/executablerunner.cpp | 4 +- RedPandaIDE/mainwindow.cpp | 13 ++++++ RedPandaIDE/settings.cpp | 51 +++++++++++++++-------- RedPandaIDE/settings.h | 6 +++ RedPandaIDE/utils.cpp | 6 +++ 5 files changed, 60 insertions(+), 20 deletions(-) diff --git a/RedPandaIDE/compiler/executablerunner.cpp b/RedPandaIDE/compiler/executablerunner.cpp index 45f89fc6..7e87358c 100644 --- a/RedPandaIDE/compiler/executablerunner.cpp +++ b/RedPandaIDE/compiler/executablerunner.cpp @@ -77,8 +77,8 @@ void ExecutableRunner::run() case QProcess::ReadError: emit runErrorOccurred(tr("An error occurred when attempting to read from the runner process.")); break; - default: - emit runErrorOccurred(tr("An unknown error occurred.")); +// default: +// emit runErrorOccurred(tr("An unknown error occurred.")); } } emit terminated(); diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index b3f3f7db..2c2e0d9c 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -888,6 +888,10 @@ void MainWindow::debug() mDebugger->sendCommand("dir", QString("\"%1\"").arg(dir.replace('\\','/'))); } + foreach (QString dir,compilerSet->defaultLibDirs()) { + mDebugger->sendCommand("dir", + QString("\"%1\"").arg(dir.replace('\\','/'))); + } // Add include folders foreach (QString dir,compilerSet->CIncludeDirs()) { mDebugger->sendCommand("dir", @@ -897,6 +901,15 @@ void MainWindow::debug() mDebugger->sendCommand("dir", QString("\"%1\"").arg(dir.replace('\\','/'))); } + foreach (QString dir,compilerSet->defaultCIncludeDirs()) { + mDebugger->sendCommand("dir", + QString("\"%1\"").arg(dir.replace('\\','/'))); + } + foreach (QString dir,compilerSet->defaultCppIncludeDirs()) { + mDebugger->sendCommand("dir", + QString("\"%1\"").arg(dir.replace('\\','/'))); + } + // Add breakpoints and watch vars // for i := 0 to fDebugger.WatchVarList.Count - 1 do diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 9246070e..ef2de3b7 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -1445,6 +1445,21 @@ QStringList &Settings::CompilerSet::libDirs() return mLibDirs; } +QStringList &Settings::CompilerSet::defaultCIncludeDirs() +{ + return mDefaultCIncludeDirs; +} + +QStringList &Settings::CompilerSet::defaultCppIncludeDirs() +{ + return mDefaultCppIncludeDirs; +} + +QStringList &Settings::CompilerSet::defaultLibDirs() +{ + return mLibDirs; +} + const QString &Settings::CompilerSet::dumpMachine() const { return mDumpMachine; @@ -1642,9 +1657,9 @@ void Settings::CompilerSet::setProperties(const QString &binDir) // Add the default directories addExistingDirectory(mBinDirs, includeTrailingPathDelimiter(folder) + "bin"); - addExistingDirectory(mLibDirs, includeTrailingPathDelimiter(folder) + "lib"); - addExistingDirectory(mCIncludeDirs, includeTrailingPathDelimiter(folder) + "include"); - addExistingDirectory(mCppIncludeDirs, includeTrailingPathDelimiter(folder) + "include"); + addExistingDirectory(mDefaultLibDirs, includeTrailingPathDelimiter(folder) + "lib"); + addExistingDirectory(mDefaultCIncludeDirs, includeTrailingPathDelimiter(folder) + "include"); + addExistingDirectory(mDefaultCppIncludeDirs, includeTrailingPathDelimiter(folder) + "include"); // Find default directories // C include dirs @@ -1664,7 +1679,7 @@ void Settings::CompilerSet::setProperties(const QString &binDir) for (QByteArray& line:lines) { QByteArray trimmedLine = line.trimmed(); if (!trimmedLine.isEmpty()) { - addExistingDirectory(mCIncludeDirs,trimmedLine); + addExistingDirectory(mDefaultCIncludeDirs,trimmedLine); } } } @@ -1687,7 +1702,7 @@ void Settings::CompilerSet::setProperties(const QString &binDir) for (QByteArray& line:lines) { QByteArray trimmedLine = line.trimmed(); if (!trimmedLine.isEmpty()) { - addExistingDirectory(mCppIncludeDirs,trimmedLine); + addExistingDirectory(mDefaultCppIncludeDirs,trimmedLine); } } } @@ -1724,7 +1739,7 @@ void Settings::CompilerSet::setProperties(const QString &binDir) for (QByteArray& line:lines) { QByteArray trimmedLine = line.trimmed(); if (!trimmedLine.isEmpty()) - addExistingDirectory(mLibDirs,trimmedLine); + addExistingDirectory(mDefaultLibDirs,trimmedLine); } } } @@ -1773,44 +1788,44 @@ void Settings::CompilerSet::setDirectories(const QString& folder) + "/" + mVersion); // Regular include folder - addExistingDirectory(mCIncludeDirs, includeTrailingPathDelimiter(folder) + mDumpMachine + "/include"); - addExistingDirectory(mCppIncludeDirs, includeTrailingPathDelimiter(folder)+ mDumpMachine + "/include"); + addExistingDirectory(mDefaultCIncludeDirs, includeTrailingPathDelimiter(folder) + mDumpMachine + "/include"); + addExistingDirectory(mDefaultCppIncludeDirs, includeTrailingPathDelimiter(folder)+ mDumpMachine + "/include"); // Other include folder? - addExistingDirectory(mCIncludeDirs, + addExistingDirectory(mDefaultCIncludeDirs, includeTrailingPathDelimiter(folder) + "lib/gcc/" + mDumpMachine + "/" + mVersion + "/include"); - addExistingDirectory(mCppIncludeDirs, + addExistingDirectory(mDefaultCppIncludeDirs, includeTrailingPathDelimiter(folder) + "lib/gcc/" + mDumpMachine + "/" + mVersion + "/include"); - addExistingDirectory(mCIncludeDirs, + addExistingDirectory(mDefaultCIncludeDirs, includeTrailingPathDelimiter(folder) + "lib/gcc/" + mDumpMachine + "/" + mVersion + "/include-fixed"); - addExistingDirectory(mCppIncludeDirs, + addExistingDirectory(mDefaultCppIncludeDirs, includeTrailingPathDelimiter(folder) + "lib/gcc/" + mDumpMachine + "/" + mVersion + "/include-fixed"); // C++ only folder (mingw.org) - addExistingDirectory(mCppIncludeDirs, + addExistingDirectory(mDefaultCppIncludeDirs, includeTrailingPathDelimiter(folder) + "lib/gcc/" + mDumpMachine + "/" + mVersion + "/include/c++"); - addExistingDirectory(mCppIncludeDirs, + addExistingDirectory(mDefaultCppIncludeDirs, includeTrailingPathDelimiter(folder) + "lib/gcc/" + mDumpMachine + "/" + mVersion + "/include/c++/" + mDumpMachine); - addExistingDirectory(mCppIncludeDirs, + addExistingDirectory(mDefaultCppIncludeDirs, includeTrailingPathDelimiter(folder) + "lib/gcc/" + mDumpMachine + "/" + mVersion + "/include/c++/backward"); // C++ only folder (Mingw-w64) - addExistingDirectory(mCppIncludeDirs, + addExistingDirectory(mDefaultCppIncludeDirs, includeTrailingPathDelimiter(folder) + "include/c++/" + mVersion ); - addExistingDirectory(mCppIncludeDirs, + addExistingDirectory(mDefaultCppIncludeDirs, includeTrailingPathDelimiter(folder) + "include/c++/" + mVersion + "/backward"); - addExistingDirectory(mCppIncludeDirs, + addExistingDirectory(mDefaultCppIncludeDirs, includeTrailingPathDelimiter(folder) + "include/c++/" + mVersion + "/" + mDumpMachine); } diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h index 99b87821..91cae53f 100644 --- a/RedPandaIDE/settings.h +++ b/RedPandaIDE/settings.h @@ -827,6 +827,9 @@ public: QStringList& CIncludeDirs(); QStringList& CppIncludeDirs(); QStringList& libDirs(); + QStringList& defaultCIncludeDirs(); + QStringList& defaultCppIncludeDirs(); + QStringList& defaultLibDirs(); const QString& dumpMachine() const; void setDumpMachine(const QString& value); @@ -890,6 +893,9 @@ public: QStringList mCIncludeDirs; QStringList mCppIncludeDirs; QStringList mLibDirs; + QStringList mDefaultLibDirs; + QStringList mDefaultCIncludeDirs; + QStringList mDefaultCppIncludeDirs; // Misc. properties QString mDumpMachine; // "x86_64-w64-mingw32", "mingw32" etc diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp index 6f57d99d..b8178fa5 100644 --- a/RedPandaIDE/utils.cpp +++ b/RedPandaIDE/utils.cpp @@ -536,6 +536,12 @@ void resetCppParser(std::shared_ptr parser) for (QString file:compilerSet->CppIncludeDirs()) { parser->addIncludePath(file); } + for (QString file:compilerSet->defaultCIncludeDirs()) { + parser->addIncludePath(file); + } + for (QString file:compilerSet->defaultCppIncludeDirs()) { + parser->addIncludePath(file); + } //TODO: Add default include dirs last, just like gcc does // Set defines for (QString define:compilerSet->defines()) {