- implement: correctly recognize clang (msys2 build)

This commit is contained in:
royqh1979@gmail.com 2021-10-03 23:46:40 +08:00
parent f872512574
commit bed1dab265
3 changed files with 58 additions and 27 deletions

View File

@ -6,6 +6,7 @@ Version 0.6.0
- change: auto open a new editor at start - change: auto open a new editor at start
- enhancement: todo view - enhancement: todo view
- add: about dialog - add: about dialog
- implement: correctly recognize clang (msys2 build)
Version 0.5.0 Version 0.5.0
- enhancement: support C++ using type alias; - enhancement: support C++ using type alias;

View File

@ -1282,6 +1282,7 @@ Settings::CompilerSet::CompilerSet(const Settings::CompilerSet &set):
mName(set.mName), mName(set.mName),
mDefines(set.mDefines), mDefines(set.mDefines),
mTarget(set.mTarget), mTarget(set.mTarget),
mCompilerType(set.mCompilerType),
mUseCustomCompileParams(set.mUseCustomCompileParams), mUseCustomCompileParams(set.mUseCustomCompileParams),
mUseCustomLinkParams(set.mUseCustomLinkParams), mUseCustomLinkParams(set.mUseCustomLinkParams),
mCustomCompileParams(set.mCustomCompileParams), mCustomCompileParams(set.mCustomCompileParams),
@ -1726,6 +1727,19 @@ void Settings::CompilerSet::setProperties(const QString &binDir)
mTarget = "i686"; mTarget = "i686";
//Find version number //Find version number
targetStr = "clang version ";
delimPos1 = output.indexOf(targetStr);
if (delimPos1>=0) {
mCompilerType = "Clang";
delimPos1+=strlen(targetStr);
delimPos2 = delimPos1;
while (delimPos2<output.length() && !isNonPrintableAsciiChar(output[delimPos2]))
delimPos2++;
mVersion = output.mid(delimPos1,delimPos2-delimPos1);
mName = "Clang " + mVersion;
} else {
mCompilerType = "GCC";
targetStr = "gcc version "; targetStr = "gcc version ";
delimPos1 = output.indexOf(targetStr); delimPos1 = output.indexOf(targetStr);
if (delimPos1<0) if (delimPos1<0)
@ -1758,6 +1772,7 @@ void Settings::CompilerSet::setProperties(const QString &binDir)
mName = "MinGW GCC " + mVersion; mName = "MinGW GCC " + mVersion;
} }
} }
}
// Set compiler folder // Set compiler folder
QDir tmpDir(binDir); QDir tmpDir(binDir);
@ -2131,6 +2146,16 @@ QByteArray Settings::CompilerSet::getCompilerOutput(const QString &binDir, const
return result.trimmed(); return result.trimmed();
} }
void Settings::CompilerSet::setCompilerType(const QString &newCompilerType)
{
mCompilerType = newCompilerType;
}
const QString &Settings::CompilerSet::compilerType() const
{
return mCompilerType;
}
bool Settings::CompilerSet::staticLink() const bool Settings::CompilerSet::staticLink() const
{ {
return mStaticLink; return mStaticLink;

View File

@ -937,6 +937,10 @@ public:
static int charToValue(char valueChar); static int charToValue(char valueChar);
static char valueToChar(int val); static char valueToChar(int val);
const QString &compilerType() const;
void setCompilerType(const QString &newCompilerType);
private: private:
// Initialization // Initialization
void setExecutables(); void setExecutables();
@ -972,6 +976,7 @@ public:
QString mName; // "TDM-GCC 4.7.1 Release" QString mName; // "TDM-GCC 4.7.1 Release"
QStringList mDefines; // list of predefined constants QStringList mDefines; // list of predefined constants
QString mTarget; // 'X86_64' / 'i686' QString mTarget; // 'X86_64' / 'i686'
QString mCompilerType;
// User settings // User settings
bool mUseCustomCompileParams; bool mUseCustomCompileParams;