forked from qt-creator/qt-creator
McuSupport: Identify MinGW toolchain
QtMCUs will support MinGW toolchain for Windows desktop platform, so MinGW toolchain needs to be identified. If the default toolchain or a user configured one is a correct MinGW toolchain, it would be selected. If not, a proper toolchain would be picked up from the registered toolchains in Qt Creator. Task-number: UL-6607 Change-Id: I82580d721d9ed916a6b32d35c124a638d7a3e68e Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -294,7 +294,8 @@ McuToolChainPackage::ToolChainType McuToolChainPackage::toolchainType() const
|
||||
|
||||
bool McuToolChainPackage::isDesktopToolchain() const
|
||||
{
|
||||
return m_type == ToolChainType::MSVC || m_type == ToolChainType::GCC;
|
||||
return m_type == ToolChainType::MSVC || m_type == ToolChainType::GCC
|
||||
|| m_type == ToolChainType::MinGW;
|
||||
}
|
||||
|
||||
ToolChain *McuToolChainPackage::msvcToolChain(Id language)
|
||||
@@ -320,6 +321,28 @@ ToolChain *McuToolChainPackage::gccToolChain(Id language)
|
||||
return toolChain;
|
||||
}
|
||||
|
||||
static ToolChain *mingwToolChain(const FilePath &path, Id language)
|
||||
{
|
||||
ToolChain *toolChain = ToolChainManager::toolChain([&path, language](const ToolChain *t) {
|
||||
// find a MinGW toolchain having the same path from registered toolchains
|
||||
const Abi abi = t->targetAbi();
|
||||
return t->typeId() == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID
|
||||
&& abi.architecture() == Abi::X86Architecture && abi.wordWidth() == 64
|
||||
&& t->language() == language && t->compilerCommand() == path;
|
||||
});
|
||||
if (!toolChain) {
|
||||
// if there's no MinGW toolchain having the same path,
|
||||
// a proper MinGW would be selected from the registered toolchains.
|
||||
toolChain = ToolChainManager::toolChain([language](const ToolChain *t) {
|
||||
const Abi abi = t->targetAbi();
|
||||
return t->typeId() == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID
|
||||
&& abi.architecture() == Abi::X86Architecture && abi.wordWidth() == 64
|
||||
&& t->language() == language;
|
||||
});
|
||||
}
|
||||
return toolChain;
|
||||
}
|
||||
|
||||
static ToolChain *armGccToolChain(const FilePath &path, Id language)
|
||||
{
|
||||
ToolChain *toolChain = ToolChainManager::toolChain([&path, language](const ToolChain *t) {
|
||||
@@ -384,6 +407,12 @@ ToolChain *McuToolChainPackage::toolChain(Id language) const
|
||||
return msvcToolChain(language);
|
||||
case ToolChainType::GCC:
|
||||
return gccToolChain(language);
|
||||
case ToolChainType::MinGW: {
|
||||
const QLatin1String compilerName(
|
||||
language == ProjectExplorer::Constants::C_LANGUAGE_ID ? "gcc" : "g++");
|
||||
const FilePath compilerPath = (path() / "bin" / compilerName).withExecutableSuffix();
|
||||
return mingwToolChain(compilerPath, language);
|
||||
}
|
||||
case ToolChainType::IAR: {
|
||||
const FilePath compiler = (path() / "/bin/iccarm").withExecutableSuffix();
|
||||
return iarToolChain(compiler, language);
|
||||
@@ -414,6 +443,8 @@ QString McuToolChainPackage::toolChainName() const
|
||||
return QLatin1String("msvc");
|
||||
case ToolChainType::GCC:
|
||||
return QLatin1String("gcc");
|
||||
case ToolChainType::MinGW:
|
||||
return QLatin1String("mingw");
|
||||
case ToolChainType::ArmGcc:
|
||||
return QLatin1String("armgcc");
|
||||
case ToolChainType::IAR:
|
||||
|
||||
Reference in New Issue
Block a user