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:
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();

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -536,6 +536,12 @@ void resetCppParser(std::shared_ptr<CppParser> 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()) {