forked from qt-creator/qt-creator
QBS DefaultPropertyProvider: Separate C and C++ compilers
Task-number: QBS-893 Change-Id: If811a34d6fecba8989b19089e8bac5df5621836f Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
#include "defaultpropertyprovider.h"
|
#include "defaultpropertyprovider.h"
|
||||||
#include "qbsconstants.h"
|
#include "qbsconstants.h"
|
||||||
|
|
||||||
|
#include <coreplugin/messagemanager.h>
|
||||||
#include <projectexplorer/abi.h>
|
#include <projectexplorer/abi.h>
|
||||||
#include <projectexplorer/gcctoolchain.h>
|
#include <projectexplorer/gcctoolchain.h>
|
||||||
#include <projectexplorer/kit.h>
|
#include <projectexplorer/kit.h>
|
||||||
@@ -179,12 +180,16 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor
|
|||||||
if (ProjectExplorer::SysRootKitInformation::hasSysRoot(k))
|
if (ProjectExplorer::SysRootKitInformation::hasSysRoot(k))
|
||||||
data.insert(QLatin1String(QBS_SYSROOT), sysroot);
|
data.insert(QLatin1String(QBS_SYSROOT), sysroot);
|
||||||
|
|
||||||
ProjectExplorer::ToolChain *tc
|
ProjectExplorer::ToolChain *tcC
|
||||||
|
= ProjectExplorer::ToolChainKitInformation::toolChain(k, ProjectExplorer::ToolChain::Language::C);
|
||||||
|
ProjectExplorer::ToolChain *tcCxx
|
||||||
= ProjectExplorer::ToolChainKitInformation::toolChain(k, ProjectExplorer::ToolChain::Language::Cxx);
|
= ProjectExplorer::ToolChainKitInformation::toolChain(k, ProjectExplorer::ToolChain::Language::Cxx);
|
||||||
if (!tc)
|
if (!tcC && !tcCxx)
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
ProjectExplorer::Abi targetAbi = tc->targetAbi();
|
ProjectExplorer::ToolChain *mainTc = tcCxx ? tcCxx : tcC;
|
||||||
|
|
||||||
|
ProjectExplorer::Abi targetAbi = mainTc->targetAbi();
|
||||||
if (targetAbi.architecture() != ProjectExplorer::Abi::UnknownArchitecture) {
|
if (targetAbi.architecture() != ProjectExplorer::Abi::UnknownArchitecture) {
|
||||||
QString architecture = ProjectExplorer::Abi::toString(targetAbi.architecture());
|
QString architecture = ProjectExplorer::Abi::toString(targetAbi.architecture());
|
||||||
|
|
||||||
@@ -215,7 +220,7 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor
|
|||||||
if (!targetOS.isEmpty())
|
if (!targetOS.isEmpty())
|
||||||
data.insert(QLatin1String(QBS_TARGETOS), targetOS);
|
data.insert(QLatin1String(QBS_TARGETOS), targetOS);
|
||||||
|
|
||||||
QStringList toolchain = toolchainList(tc);
|
QStringList toolchain = toolchainList(mainTc);
|
||||||
if (!toolchain.isEmpty())
|
if (!toolchain.isEmpty())
|
||||||
data.insert(QLatin1String(QBS_TOOLCHAIN), toolchain);
|
data.insert(QLatin1String(QBS_TOOLCHAIN), toolchain);
|
||||||
|
|
||||||
@@ -237,27 +242,58 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::FileName cxx = tc->compilerCommand();
|
Utils::FileName cCompilerPath;
|
||||||
const QFileInfo cxxFileInfo = cxx.toFileInfo();
|
if (tcC)
|
||||||
QString compilerName = cxxFileInfo.fileName();
|
cCompilerPath = tcC->compilerCommand();
|
||||||
const QString toolchainPrefix = extractToolchainPrefix(&compilerName);
|
|
||||||
if (!toolchainPrefix.isEmpty())
|
Utils::FileName cxxCompilerPath;
|
||||||
data.insert(QLatin1String(CPP_TOOLCHAINPREFIX), toolchainPrefix);
|
if (tcCxx)
|
||||||
|
cxxCompilerPath = tcCxx->compilerCommand();
|
||||||
|
|
||||||
|
const QFileInfo cFileInfo = cCompilerPath.toFileInfo();
|
||||||
|
const QFileInfo cxxFileInfo = cxxCompilerPath.toFileInfo();
|
||||||
|
QString cCompilerName = cFileInfo.fileName();
|
||||||
|
QString cxxCompilerName = cxxFileInfo.fileName();
|
||||||
|
const QString cToolchainPrefix = extractToolchainPrefix(&cCompilerName);
|
||||||
|
const QString cxxToolchainPrefix = extractToolchainPrefix(&cCompilerName);
|
||||||
|
|
||||||
|
QFileInfo mainFileInfo;
|
||||||
|
QString mainCompilerName;
|
||||||
|
QString mainToolchainPrefix;
|
||||||
|
if (tcCxx) {
|
||||||
|
mainFileInfo = cxxFileInfo;
|
||||||
|
mainCompilerName = cxxCompilerName;
|
||||||
|
mainToolchainPrefix = cxxToolchainPrefix;
|
||||||
|
} else {
|
||||||
|
mainFileInfo = cFileInfo;
|
||||||
|
mainCompilerName = cCompilerName;
|
||||||
|
mainToolchainPrefix = cToolchainPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mainToolchainPrefix.isEmpty())
|
||||||
|
data.insert(QLatin1String(CPP_TOOLCHAINPREFIX), mainToolchainPrefix);
|
||||||
|
|
||||||
if (toolchain.contains(QLatin1String("msvc"))) {
|
if (toolchain.contains(QLatin1String("msvc"))) {
|
||||||
data.insert(QLatin1String(CPP_COMPILERNAME), compilerName);
|
data.insert(QLatin1String(CPP_COMPILERNAME), mainCompilerName);
|
||||||
const MSVCVersion v = msvcCompilerVersion(targetAbi);
|
const MSVCVersion v = msvcCompilerVersion(targetAbi);
|
||||||
data.insert(QLatin1String(CPP_COMPILERVERSIONMAJOR), v.major);
|
data.insert(QLatin1String(CPP_COMPILERVERSIONMAJOR), v.major);
|
||||||
data.insert(QLatin1String(CPP_COMPILERVERSIONMINOR), v.minor);
|
data.insert(QLatin1String(CPP_COMPILERVERSIONMINOR), v.minor);
|
||||||
} else {
|
} else {
|
||||||
data.insert(QLatin1String(CPP_CXXCOMPILERNAME), compilerName);
|
data.insert(QLatin1String(CPP_COMPILERNAME), cCompilerName);
|
||||||
|
data.insert(QLatin1String(CPP_CXXCOMPILERNAME), cxxCompilerName);
|
||||||
}
|
}
|
||||||
if (targetAbi.os() != ProjectExplorer::Abi::WindowsOS
|
if (targetAbi.os() != ProjectExplorer::Abi::WindowsOS
|
||||||
|| targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) {
|
|| targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) {
|
||||||
data.insert(QLatin1String(CPP_LINKERNAME), compilerName);
|
data.insert(QLatin1String(CPP_LINKERNAME), mainCompilerName);
|
||||||
}
|
}
|
||||||
data.insert(QLatin1String(CPP_TOOLCHAINPATH), cxxFileInfo.absolutePath());
|
|
||||||
|
|
||||||
if (ProjectExplorer::GccToolChain *gcc = dynamic_cast<ProjectExplorer::GccToolChain *>(tc)) {
|
if (tcC && tcCxx && cFileInfo.absolutePath() != cxxFileInfo.absolutePath()) {
|
||||||
|
Core::MessageManager::write(tr("C and C++ compiler paths differ. C compiler may not work."),
|
||||||
|
Core::MessageManager::ModeSwitch);
|
||||||
|
}
|
||||||
|
data.insert(QLatin1String(CPP_TOOLCHAINPATH), mainFileInfo.absolutePath());
|
||||||
|
|
||||||
|
if (ProjectExplorer::GccToolChain *gcc = dynamic_cast<ProjectExplorer::GccToolChain *>(mainTc)) {
|
||||||
data.insert(QLatin1String(CPP_PLATFORMCOMMONCOMPILERFLAGS), gcc->platformCodeGenFlags());
|
data.insert(QLatin1String(CPP_PLATFORMCOMMONCOMPILERFLAGS), gcc->platformCodeGenFlags());
|
||||||
data.insert(QLatin1String(CPP_PLATFORMLINKERFLAGS), gcc->platformLinkerFlags());
|
data.insert(QLatin1String(CPP_PLATFORMLINKERFLAGS), gcc->platformLinkerFlags());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user