feature: seperate gcc default dirs from user settings

This commit is contained in:
royqh1979 2021-09-04 20:49:44 +08:00
parent 20ee430f29
commit 9ce9469dd2
5 changed files with 60 additions and 20 deletions

View File

@ -77,8 +77,8 @@ void ExecutableRunner::run()
case QProcess::ReadError: case QProcess::ReadError:
emit runErrorOccurred(tr("An error occurred when attempting to read from the runner process.")); emit runErrorOccurred(tr("An error occurred when attempting to read from the runner process."));
break; break;
default: // default:
emit runErrorOccurred(tr("An unknown error occurred.")); // emit runErrorOccurred(tr("An unknown error occurred."));
} }
} }
emit terminated(); emit terminated();

View File

@ -888,6 +888,10 @@ void MainWindow::debug()
mDebugger->sendCommand("dir", mDebugger->sendCommand("dir",
QString("\"%1\"").arg(dir.replace('\\','/'))); QString("\"%1\"").arg(dir.replace('\\','/')));
} }
foreach (QString dir,compilerSet->defaultLibDirs()) {
mDebugger->sendCommand("dir",
QString("\"%1\"").arg(dir.replace('\\','/')));
}
// Add include folders // Add include folders
foreach (QString dir,compilerSet->CIncludeDirs()) { foreach (QString dir,compilerSet->CIncludeDirs()) {
mDebugger->sendCommand("dir", mDebugger->sendCommand("dir",
@ -897,6 +901,15 @@ void MainWindow::debug()
mDebugger->sendCommand("dir", mDebugger->sendCommand("dir",
QString("\"%1\"").arg(dir.replace('\\','/'))); 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 // Add breakpoints and watch vars
// for i := 0 to fDebugger.WatchVarList.Count - 1 do // for i := 0 to fDebugger.WatchVarList.Count - 1 do

View File

@ -1445,6 +1445,21 @@ QStringList &Settings::CompilerSet::libDirs()
return mLibDirs; 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 const QString &Settings::CompilerSet::dumpMachine() const
{ {
return mDumpMachine; return mDumpMachine;
@ -1642,9 +1657,9 @@ void Settings::CompilerSet::setProperties(const QString &binDir)
// Add the default directories // Add the default directories
addExistingDirectory(mBinDirs, includeTrailingPathDelimiter(folder) + "bin"); addExistingDirectory(mBinDirs, includeTrailingPathDelimiter(folder) + "bin");
addExistingDirectory(mLibDirs, includeTrailingPathDelimiter(folder) + "lib"); addExistingDirectory(mDefaultLibDirs, includeTrailingPathDelimiter(folder) + "lib");
addExistingDirectory(mCIncludeDirs, includeTrailingPathDelimiter(folder) + "include"); addExistingDirectory(mDefaultCIncludeDirs, includeTrailingPathDelimiter(folder) + "include");
addExistingDirectory(mCppIncludeDirs, includeTrailingPathDelimiter(folder) + "include"); addExistingDirectory(mDefaultCppIncludeDirs, includeTrailingPathDelimiter(folder) + "include");
// Find default directories // Find default directories
// C include dirs // C include dirs
@ -1664,7 +1679,7 @@ void Settings::CompilerSet::setProperties(const QString &binDir)
for (QByteArray& line:lines) { for (QByteArray& line:lines) {
QByteArray trimmedLine = line.trimmed(); QByteArray trimmedLine = line.trimmed();
if (!trimmedLine.isEmpty()) { if (!trimmedLine.isEmpty()) {
addExistingDirectory(mCIncludeDirs,trimmedLine); addExistingDirectory(mDefaultCIncludeDirs,trimmedLine);
} }
} }
} }
@ -1687,7 +1702,7 @@ void Settings::CompilerSet::setProperties(const QString &binDir)
for (QByteArray& line:lines) { for (QByteArray& line:lines) {
QByteArray trimmedLine = line.trimmed(); QByteArray trimmedLine = line.trimmed();
if (!trimmedLine.isEmpty()) { if (!trimmedLine.isEmpty()) {
addExistingDirectory(mCppIncludeDirs,trimmedLine); addExistingDirectory(mDefaultCppIncludeDirs,trimmedLine);
} }
} }
} }
@ -1724,7 +1739,7 @@ void Settings::CompilerSet::setProperties(const QString &binDir)
for (QByteArray& line:lines) { for (QByteArray& line:lines) {
QByteArray trimmedLine = line.trimmed(); QByteArray trimmedLine = line.trimmed();
if (!trimmedLine.isEmpty()) if (!trimmedLine.isEmpty())
addExistingDirectory(mLibDirs,trimmedLine); addExistingDirectory(mDefaultLibDirs,trimmedLine);
} }
} }
} }
@ -1773,44 +1788,44 @@ void Settings::CompilerSet::setDirectories(const QString& folder)
+ "/" + mVersion); + "/" + mVersion);
// Regular include folder // Regular include folder
addExistingDirectory(mCIncludeDirs, includeTrailingPathDelimiter(folder) + mDumpMachine + "/include"); addExistingDirectory(mDefaultCIncludeDirs, includeTrailingPathDelimiter(folder) + mDumpMachine + "/include");
addExistingDirectory(mCppIncludeDirs, includeTrailingPathDelimiter(folder)+ mDumpMachine + "/include"); addExistingDirectory(mDefaultCppIncludeDirs, includeTrailingPathDelimiter(folder)+ mDumpMachine + "/include");
// Other include folder? // Other include folder?
addExistingDirectory(mCIncludeDirs, addExistingDirectory(mDefaultCIncludeDirs,
includeTrailingPathDelimiter(folder) + "lib/gcc/" includeTrailingPathDelimiter(folder) + "lib/gcc/"
+ mDumpMachine + "/" + mVersion + "/include"); + mDumpMachine + "/" + mVersion + "/include");
addExistingDirectory(mCppIncludeDirs, addExistingDirectory(mDefaultCppIncludeDirs,
includeTrailingPathDelimiter(folder) + "lib/gcc/" includeTrailingPathDelimiter(folder) + "lib/gcc/"
+ mDumpMachine + "/" + mVersion + "/include"); + mDumpMachine + "/" + mVersion + "/include");
addExistingDirectory(mCIncludeDirs, addExistingDirectory(mDefaultCIncludeDirs,
includeTrailingPathDelimiter(folder) + "lib/gcc/" includeTrailingPathDelimiter(folder) + "lib/gcc/"
+ mDumpMachine + "/" + mVersion + "/include-fixed"); + mDumpMachine + "/" + mVersion + "/include-fixed");
addExistingDirectory(mCppIncludeDirs, addExistingDirectory(mDefaultCppIncludeDirs,
includeTrailingPathDelimiter(folder) + "lib/gcc/" includeTrailingPathDelimiter(folder) + "lib/gcc/"
+ mDumpMachine + "/" + mVersion + "/include-fixed"); + mDumpMachine + "/" + mVersion + "/include-fixed");
// C++ only folder (mingw.org) // C++ only folder (mingw.org)
addExistingDirectory(mCppIncludeDirs, addExistingDirectory(mDefaultCppIncludeDirs,
includeTrailingPathDelimiter(folder) + "lib/gcc/" includeTrailingPathDelimiter(folder) + "lib/gcc/"
+ mDumpMachine + "/" + mVersion + "/include/c++"); + mDumpMachine + "/" + mVersion + "/include/c++");
addExistingDirectory(mCppIncludeDirs, addExistingDirectory(mDefaultCppIncludeDirs,
includeTrailingPathDelimiter(folder) + "lib/gcc/" includeTrailingPathDelimiter(folder) + "lib/gcc/"
+ mDumpMachine + "/" + mVersion + "/include/c++/" + mDumpMachine + "/" + mVersion + "/include/c++/"
+ mDumpMachine); + mDumpMachine);
addExistingDirectory(mCppIncludeDirs, addExistingDirectory(mDefaultCppIncludeDirs,
includeTrailingPathDelimiter(folder) + "lib/gcc/" includeTrailingPathDelimiter(folder) + "lib/gcc/"
+ mDumpMachine + "/" + mVersion + "/include/c++/backward"); + mDumpMachine + "/" + mVersion + "/include/c++/backward");
// C++ only folder (Mingw-w64) // C++ only folder (Mingw-w64)
addExistingDirectory(mCppIncludeDirs, addExistingDirectory(mDefaultCppIncludeDirs,
includeTrailingPathDelimiter(folder) + "include/c++/" includeTrailingPathDelimiter(folder) + "include/c++/"
+ mVersion ); + mVersion );
addExistingDirectory(mCppIncludeDirs, addExistingDirectory(mDefaultCppIncludeDirs,
includeTrailingPathDelimiter(folder) + "include/c++/" includeTrailingPathDelimiter(folder) + "include/c++/"
+ mVersion + "/backward"); + mVersion + "/backward");
addExistingDirectory(mCppIncludeDirs, addExistingDirectory(mDefaultCppIncludeDirs,
includeTrailingPathDelimiter(folder) + "include/c++/" includeTrailingPathDelimiter(folder) + "include/c++/"
+ mVersion + "/" + mDumpMachine); + mVersion + "/" + mDumpMachine);
} }

View File

@ -827,6 +827,9 @@ public:
QStringList& CIncludeDirs(); QStringList& CIncludeDirs();
QStringList& CppIncludeDirs(); QStringList& CppIncludeDirs();
QStringList& libDirs(); QStringList& libDirs();
QStringList& defaultCIncludeDirs();
QStringList& defaultCppIncludeDirs();
QStringList& defaultLibDirs();
const QString& dumpMachine() const; const QString& dumpMachine() const;
void setDumpMachine(const QString& value); void setDumpMachine(const QString& value);
@ -890,6 +893,9 @@ public:
QStringList mCIncludeDirs; QStringList mCIncludeDirs;
QStringList mCppIncludeDirs; QStringList mCppIncludeDirs;
QStringList mLibDirs; QStringList mLibDirs;
QStringList mDefaultLibDirs;
QStringList mDefaultCIncludeDirs;
QStringList mDefaultCppIncludeDirs;
// Misc. properties // Misc. properties
QString mDumpMachine; // "x86_64-w64-mingw32", "mingw32" etc QString mDumpMachine; // "x86_64-w64-mingw32", "mingw32" etc

View File

@ -536,6 +536,12 @@ void resetCppParser(std::shared_ptr<CppParser> parser)
for (QString file:compilerSet->CppIncludeDirs()) { for (QString file:compilerSet->CppIncludeDirs()) {
parser->addIncludePath(file); 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 //TODO: Add default include dirs last, just like gcc does
// Set defines // Set defines
for (QString define:compilerSet->defines()) { for (QString define:compilerSet->defines()) {