Kits: Save several ToolChains per kit

BREAKS BACKWARD COMPATIBILITY OF TOOLCHAIN SETTINGS!

* Convert old ToolChainKitInformation to new version
* Store several toolchains in one kit (one per language)

Change-Id: Ia59a2ad067c57971ec34ce9b2e43758344443755
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2016-07-12 16:27:45 +02:00
parent ce9ca1f0ef
commit cb14fb0d71
38 changed files with 166 additions and 98 deletions
@@ -1200,8 +1200,8 @@ static bool equalKits(Kit *a, Kit *b)
{
if (QtSupport::QtKitInformation::qtVersion(a) != QtSupport::QtKitInformation::qtVersion(b))
return false;
ToolChain *atc = ToolChainKitInformation::toolChain(a);
ToolChain *btc = ToolChainKitInformation::toolChain(b);
ToolChain *atc = ToolChainKitInformation::toolChain(a, ToolChain::Language::Cxx);
ToolChain *btc = ToolChainKitInformation::toolChain(b, ToolChain::Language::Cxx);
if (atc == btc)
return true;
if (!atc || atc->typeId() != Constants::ANDROID_TOOLCHAIN_ID)
@@ -1267,7 +1267,7 @@ void AndroidConfigurations::updateAutomaticKitList()
continue;
// Update code for 3.0 beta, which shipped with a bug for the debugger settings
ToolChain *tc =ToolChainKitInformation::toolChain(k);
ToolChain *tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx);
if (tc && Debugger::DebuggerKitInformation::debuggerCommand(k) != tc->suggestedDebugger()) {
Debugger::DebuggerItem debugger;
debugger.setCommand(tc->suggestedDebugger());
@@ -1341,7 +1341,7 @@ void AndroidConfigurations::updateAutomaticKitList()
newKits.removeAt(j);
existingKits.at(i)->makeSticky();
existingKits.removeAt(i);
ToolChainKitInformation::setToolChain(existingKit, ToolChainKitInformation::toolChain(newKit));
ToolChainKitInformation::setToolChain(existingKit, ToolChainKitInformation::toolChain(newKit, ToolChain::Language::Cxx));
KitManager::deleteKit(newKit);
j = newKits.count();
}
@@ -1349,7 +1349,7 @@ void AndroidConfigurations::updateAutomaticKitList()
}
foreach (Kit *k, existingKits) {
ToolChain *tc = ToolChainKitInformation::toolChain(k);
ToolChain *tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx);
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(k);
if (tc && tc->typeId() == Constants::ANDROID_TOOLCHAIN_ID
&& tc->isValid()
@@ -1362,7 +1362,7 @@ void AndroidConfigurations::updateAutomaticKitList()
}
foreach (Kit *kit, newKits) {
AndroidToolChain *tc = static_cast<AndroidToolChain *>(ToolChainKitInformation::toolChain(kit));
AndroidToolChain *tc = static_cast<AndroidToolChain *>(ToolChainKitInformation::toolChain(kit, ToolChain::Language::Cxx));
AndroidQtVersion *qt = static_cast<AndroidQtVersion *>(QtSupport::QtKitInformation::qtVersion(kit));
kit->setUnexpandedDisplayName(tr("Android for %1 (GCC %2, Qt %3)")
.arg(qt->targetArch())
@@ -114,7 +114,7 @@ QList<Core::Id> AndroidDeployConfigurationFactory::availableCreationIds(Target *
if (!parent->project()->supportsKit(parent->kit()))
return ids;
ToolChain *tc = ToolChainKitInformation::toolChain(parent->kit());
ToolChain *tc = ToolChainKitInformation::toolChain(parent->kit(), ToolChain::Language::Cxx);
if (!tc || tc->targetAbi().osFlavor() != Abi::AndroidLinuxFlavor)
return ids;
+1 -1
View File
@@ -176,7 +176,7 @@ bool AndroidDeployQtStep::init(QList<const BuildStep *> &earlierSteps)
m_libdir = QLatin1String("lib");
if (info.cpuAbi.contains(QLatin1String("arm64-v8a")) ||
info.cpuAbi.contains(QLatin1String("x86_64"))) {
ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(target()->kit());
ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(target()->kit(), ToolChain::Language::Cxx);
if (tc && tc->targetAbi().wordWidth() == 64) {
m_appProcessBinaries << QLatin1String("/system/bin/app_process64");
m_libdir += QLatin1String("64");
@@ -82,7 +82,7 @@ Core::Id AndroidGdbServerKitInformation::id()
bool AndroidGdbServerKitInformation::isAndroidKit(const Kit *kit)
{
QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(kit);
ToolChain *tc = ToolChainKitInformation::toolChain(kit);
ToolChain *tc = ToolChainKitInformation::toolChain(kit, ToolChain::Language::Cxx);
if (qt && tc)
return qt->type() == QLatin1String(Constants::ANDROIDQT)
&& tc->typeId() == Constants::ANDROID_TOOLCHAIN_ID;
@@ -102,7 +102,7 @@ void AndroidGdbServerKitInformation::setGdbSever(Kit *kit, const FileName &gdbSe
FileName AndroidGdbServerKitInformation::autoDetect(const Kit *kit)
{
ToolChain *tc = ToolChainKitInformation::toolChain(kit);
ToolChain *tc = ToolChainKitInformation::toolChain(kit, ToolChain::Language::Cxx);
if (!tc || tc->typeId() != Constants::ANDROID_TOOLCHAIN_ID)
return FileName();
auto atc = static_cast<AndroidToolChain *>(tc);
+2 -1
View File
@@ -68,7 +68,8 @@ void AutoTestUnitTests::initTestCase()
m_isQt4 = qtVersion->qtVersionString().startsWith(QLatin1Char('4'));
else
QSKIP("Could not figure out which Qt version is used for default kit.");
const ToolChain * const toolchain = ToolChainKitInformation::toolChain(allKits.first());
const ToolChain * const toolchain = ToolChainKitInformation::toolChain(allKits.first(),
ToolChain::Language::Cxx);
if (!toolchain)
QSKIP("This test requires that there is a kit with a toolchain.");
@@ -120,11 +120,11 @@ bool MakeStep::init(QList<const BuildStep *> &earlierSteps)
if (!bc)
emit addTask(Task::buildConfigurationMissingTask());
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
if (!tc)
QList<ToolChain *> tcList = ToolChainKitInformation::toolChains(target()->kit());
if (tcList.isEmpty())
emit addTask(Task::compilerMissingTask());
if (!tc || !bc) {
if (tcList.isEmpty() || !bc) {
emitFaultyConfigurationMessage();
return false;
}
@@ -140,7 +140,7 @@ bool MakeStep::init(QList<const BuildStep *> &earlierSteps)
Utils::Environment::setupEnglishOutput(&env);
pp->setEnvironment(env);
pp->setWorkingDirectory(bc->buildDirectory().toString());
pp->setCommand(tc ? tc->makeCommand(bc->environment()) : QLatin1String("make"));
pp->setCommand(tcList.at(0)->makeCommand(bc->environment()));
pp->setArguments(arguments);
pp->resolveAll();
@@ -255,9 +255,9 @@ void MakeStepConfigWidget::updateDetails()
BuildConfiguration *bc = m_makeStep->buildConfiguration();
if (!bc)
bc = m_makeStep->target()->activeBuildConfiguration();
ToolChain *tc = ToolChainKitInformation::toolChain(m_makeStep->target()->kit());
QList<ToolChain *> tcList = ToolChainKitInformation::toolChains(m_makeStep->target()->kit());
if (tc) {
if (!tcList.isEmpty()) {
QString arguments = Utils::QtcProcess::joinArgs(m_makeStep->m_buildTargets);
Utils::QtcProcess::addArgs(&arguments, m_makeStep->additionalArguments());
@@ -265,7 +265,7 @@ void MakeStepConfigWidget::updateDetails()
param.setMacroExpander(bc->macroExpander());
param.setEnvironment(bc->environment());
param.setWorkingDirectory(bc->buildDirectory().toString());
param.setCommand(tc->makeCommand(bc->environment()));
param.setCommand(tcList.at(0)->makeCommand(bc->environment()));
param.setArguments(arguments);
m_summaryText = param.summary(displayName());
} else {
@@ -83,7 +83,7 @@ ClangStaticAnalyzerRunControl::ClangStaticAnalyzerRunControl(
QTC_ASSERT(buildConfiguration, return);
m_environment = buildConfiguration->environment();
ToolChain *toolChain = ToolChainKitInformation::toolChain(target->kit());
ToolChain *toolChain = ToolChainKitInformation::toolChain(target->kit(), ToolChain::Language::Cxx);
QTC_ASSERT(toolChain, return);
m_extraToolChainInfo.wordWidth = toolChain->targetAbi().wordWidth();
m_extraToolChainInfo.targetTriple = toolChain->originalTargetTriple();
@@ -427,7 +427,7 @@ static QDebug operator<<(QDebug debug, const AnalyzeUnits &analyzeUnits)
static Core::Id toolchainType(ProjectExplorer::RunConfiguration *runConfiguration)
{
QTC_ASSERT(runConfiguration, return Core::Id());
return ToolChainKitInformation::toolChain(runConfiguration->target()->kit())->typeId();
return ToolChainKitInformation::toolChain(runConfiguration->target()->kit(), ToolChain::Language::Cxx)->typeId();
}
void ClangStaticAnalyzerRunControl::start()
@@ -73,7 +73,7 @@ bool ClangStaticAnalyzerRunControlFactory::canRun(RunConfiguration *runConfigura
QTC_ASSERT(target, return false);
Kit *kit = target->kit();
QTC_ASSERT(kit, return false);
ToolChain *toolChain = ToolChainKitInformation::toolChain(kit);
ToolChain *toolChain = ToolChainKitInformation::toolChain(kit, ToolChain::Language::Cxx);
return toolChain;
}
@@ -62,7 +62,8 @@ void ClangStaticAnalyzerUnitTests::initTestCase()
const QList<Kit *> allKits = KitManager::kits();
if (allKits.count() != 1)
QSKIP("This test requires exactly one kit to be present");
const ToolChain * const toolchain = ToolChainKitInformation::toolChain(allKits.first());
const ToolChain * const toolchain = ToolChainKitInformation::toolChain(allKits.first(),
ToolChain::Language::Cxx);
if (!toolchain)
QSKIP("This test requires that there is a kit with a toolchain.");
bool hasClangExecutable;
@@ -187,7 +187,7 @@ QVariant CMakeGeneratorKitInformation::defaultValue(const Kit *k) const
}
if (Utils::HostOsInfo::isWindowsHost()) {
// *sigh* Windows with its zoo of incompatible stuff again...
ToolChain *tc = ToolChainKitInformation::toolChain(k);
ToolChain *tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx);
if (tc && tc->typeId() == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID) {
if (it == known.constEnd())
it = std::find_if(known.constBegin(), known.constEnd(),
@@ -343,7 +343,7 @@ QVariant CMakeConfigurationKitInformation::defaultValue(const Kit *k) const
QList<Task> CMakeConfigurationKitInformation::validate(const Kit *k) const
{
const QtSupport::BaseQtVersion *const version = QtSupport::QtKitInformation::qtVersion(k);
const ToolChain *const tc = ToolChainKitInformation::toolChain(k);
const ToolChain *const tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx);
const CMakeConfig config = configuration(k);
QByteArray qmakePath;
@@ -251,7 +251,7 @@ void CMakeProject::parseCMakeOutput()
createGeneratedCodeModelSupport();
ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k);
ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx);
if (!tc) {
emit fileListChanged();
return;
+2 -2
View File
@@ -273,7 +273,7 @@ QString targetTriple(ProjectExplorer::Project *project, const Core::Id &toolchai
if (project) {
if (Target *target = project->activeTarget()) {
if (ToolChain *toolChain = ToolChainKitInformation::toolChain(target->kit()))
if (ToolChain *toolChain = ToolChainKitInformation::toolChain(target->kit(), ToolChain::Language::Cxx))
return toolChain->originalTargetTriple();
}
}
@@ -361,7 +361,7 @@ void ProjectPartBuilder::createProjectPart(const QVector<ProjectFile> &theSource
QTC_ASSERT(part->project, return);
if (ProjectExplorer::Target *activeTarget = part->project->activeTarget()) {
if (ProjectExplorer::Kit *kit = activeTarget->kit()) {
if (ProjectExplorer::ToolChain *toolChain = ProjectExplorer::ToolChainKitInformation::toolChain(kit)) {
if (ProjectExplorer::ToolChain *toolChain = ProjectExplorer::ToolChainKitInformation::toolChain(kit, ProjectExplorer::ToolChain::Language::Cxx)) {
const QStringList flags = languageVersion >= ProjectPart::CXX98 ? m_cxxFlags
: m_cFlags;
evaluateProjectPartToolchain(part.data(),
+1 -1
View File
@@ -110,7 +110,7 @@ DebuggerKitChooser::DebuggerKitChooser(Mode mode, QWidget *parent)
if (!DebuggerKitInformation::isValidDebugger(k))
return false;
if (m_mode == LocalDebugging) {
const ToolChain *tc = ToolChainKitInformation::toolChain(k);
const ToolChain *tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx);
return tc && tc->targetAbi().os() == m_hostAbi.os();
}
return true;
@@ -57,7 +57,7 @@ DebuggerKitInformation::DebuggerKitInformation()
QVariant DebuggerKitInformation::defaultValue(const Kit *k) const
{
ToolChain *tc = ToolChainKitInformation::toolChain(k);
ToolChain *tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx);
if (!tc)
return QVariant();
@@ -87,7 +87,7 @@ void DebuggerKitInformation::setup(Kit *k)
// </valuemap>
const QVariant rawId = k->value(DebuggerKitInformation::id());
const ToolChain *tc = ToolChainKitInformation::toolChain(k);
const ToolChain *tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx);
// Get the best of the available debugger matching the kit's toolchain.
// The general idea is to find an item that exactly matches what
@@ -237,7 +237,7 @@ static unsigned debuggerConfigurationErrors(const Kit *k)
else if (!fi.isExecutable())
result |= DebuggerNotExecutable;
const ToolChain *tc = ToolChainKitInformation::toolChain(k);
const ToolChain *tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx);
if (tc && item->matchTarget(tc->targetAbi()) == DebuggerItem::DoesNotMatch) {
// currently restricting the check to desktop devices, may be extended to all device types
const IDevice::ConstPtr device = DeviceKitInformation::device(k);
+4 -4
View File
@@ -568,7 +568,7 @@ static std::function<bool(const Kit *)> cdbMatcher(char wordWidth = 0)
return false;
}
if (wordWidth) {
const ToolChain *tc = ToolChainKitInformation::toolChain(k);
const ToolChain *tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx);
return tc && wordWidth == tc->targetAbi().wordWidth();
}
return true;
@@ -1103,14 +1103,14 @@ static Kit *guessKitFromParameters(const DebuggerRunParameters &rp)
if (!abis.isEmpty()) {
// Try exact abis.
kit = KitManager::find(KitMatcher([abis](const Kit *k) -> bool {
if (const ToolChain *tc = ToolChainKitInformation::toolChain(k))
if (const ToolChain *tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx))
return abis.contains(tc->targetAbi()) && DebuggerKitInformation::isValidDebugger(k);
return false;
}));
if (!kit) {
// Or something compatible.
kit = KitManager::find(KitMatcher([abis](const Kit *k) -> bool {
if (const ToolChain *tc = ToolChainKitInformation::toolChain(k))
if (const ToolChain *tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx))
foreach (const Abi &a, abis)
if (a.isCompatibleWith(tc->targetAbi()) && DebuggerKitInformation::isValidDebugger(k))
return true;
@@ -2081,7 +2081,7 @@ DebuggerRunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit,
}
bool isWindows = false;
if (const ToolChain *tc = ToolChainKitInformation::toolChain(kit))
if (const ToolChain *tc = ToolChainKitInformation::toolChain(kit, ToolChain::Language::Cxx))
isWindows = tc->targetAbi().os() == Abi::WindowsOS;
if (isWindows && isWinProcessBeingDebugged(process.pid)) {
AsynchronousMessageBox::warning(tr("Process Already Under Debugger Control"),
+1 -1
View File
@@ -366,7 +366,7 @@ static DebuggerRunControl *doCreate(DebuggerRunParameters rp, RunConfiguration *
}
}
if (ToolChain *tc = ToolChainKitInformation::toolChain(kit))
if (ToolChain *tc = ToolChainKitInformation::toolChain(kit, ToolChain::Language::Cxx))
rp.toolChainAbi = tc->targetAbi();
if (false) {
@@ -95,7 +95,7 @@ bool GenericMakeStep::init(QList<const BuildStep *> &earlierSteps)
if (!bc)
emit addTask(Task::buildConfigurationMissingTask());
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ToolChain::Language::Cxx);
if (!tc)
emit addTask(Task::compilerMissingTask());
@@ -170,7 +170,7 @@ QString GenericMakeStep::makeCommand(const Utils::Environment &environment) cons
{
QString command = m_makeCommand;
if (command.isEmpty()) {
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ToolChain::Language::Cxx);
if (tc)
command = tc->makeCommand(environment);
else
+2 -2
View File
@@ -98,7 +98,7 @@ bool IosBuildStep::init(QList<const BuildStep *> &earlierSteps)
if (!bc)
emit addTask(Task::buildConfigurationMissingTask());
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ToolChain::Language::Cxx);
if (!tc)
emit addTask(Task::compilerMissingTask());
@@ -170,7 +170,7 @@ QStringList IosBuildStep::defaultArguments() const
{
QStringList res;
Kit *kit = target()->kit();
ToolChain *tc = ToolChainKitInformation::toolChain(kit);
ToolChain *tc = ToolChainKitInformation::toolChain(kit, ToolChain::Language::Cxx);
switch (target()->activeBuildConfiguration()->buildType()) {
case BuildConfiguration::Debug :
res << QLatin1String("-configuration") << QLatin1String("Debug");
+1 -1
View File
@@ -238,7 +238,7 @@ void IosConfigurations::updateAutomaticKitList()
// we do not compare the sdk (thus automatically upgrading it in place if a
// new Xcode is used). Change?
return DeviceTypeKitInformation::deviceTypeId(kit) == pDeviceType
&& ToolChainKitInformation::toolChain(kit) == pToolchain
&& ToolChainKitInformation::toolChain(kit, ToolChain::Language::Cxx) == pToolchain
&& QtKitInformation::qtVersion(kit) == qtVersion;
});
QTC_ASSERT(!resultingKits.contains(kit), continue);
+73 -29
View File
@@ -144,28 +144,20 @@ ToolChainKitInformation::ToolChainKitInformation()
QVariant ToolChainKitInformation::defaultValue(const Kit *k) const
{
Q_UNUSED(k);
QList<ToolChain *> tcList = ToolChainManager::toolChains();
if (tcList.isEmpty())
return QString();
Abi abi = Abi::hostAbi();
ToolChain *tc = Utils::findOr(tcList, tcList.first(),
Utils::equal(&ToolChain::targetAbi, abi));
return tc->id();
return defaultValue();
}
QList<Task> ToolChainKitInformation::validate(const Kit *k) const
{
QList<Task> result;
const ToolChain* toolchain = toolChain(k);
if (!toolchain) {
const QList<ToolChain*> tcList = toolChains(k);
if (tcList.isEmpty()) {
result << Task(Task::Error, ToolChainKitInformation::msgNoToolChainInTarget(),
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM));
} else {
result << toolchain->validateKit(k);
foreach (ToolChain *tc, tcList)
result << tc->validateKit(k);
}
return result;
}
@@ -173,12 +165,13 @@ QList<Task> ToolChainKitInformation::validate(const Kit *k) const
void ToolChainKitInformation::fix(Kit *k)
{
QTC_ASSERT(ToolChainManager::isLoaded(), return);
if (toolChain(k))
return;
qWarning("No tool chain set from kit \"%s\".",
qPrintable(k->displayName()));
setToolChain(k, 0); // make sure to clear out no longer known tool chains
foreach (ToolChain::Language l, ToolChain::allLanguages()) {
if (!toolChain(k, l)) {
qWarning("No tool chain set from kit \"%s\".",
qPrintable(k->displayName()));
setToolChain(k, l, nullptr); // make sure to clear out no longer known tool chains
}
}
}
void ToolChainKitInformation::setup(Kit *k)
@@ -206,19 +199,19 @@ KitConfigWidget *ToolChainKitInformation::createConfigWidget(Kit *k) const
QString ToolChainKitInformation::displayNamePostfix(const Kit *k) const
{
ToolChain *tc = toolChain(k);
ToolChain *tc = toolChain(k, ToolChain::Language::Cxx);
return tc ? tc->displayName() : QString();
}
KitInformation::ItemList ToolChainKitInformation::toUserOutput(const Kit *k) const
{
ToolChain *tc = toolChain(k);
ToolChain *tc = toolChain(k, ToolChain::Language::Cxx);
return ItemList() << qMakePair(tr("Compiler"), tc ? tc->displayName() : tr("None"));
}
void ToolChainKitInformation::addToEnvironment(const Kit *k, Utils::Environment &env) const
{
ToolChain *tc = toolChain(k);
ToolChain *tc = toolChain(k, ToolChain::Language::Cxx);
if (tc)
tc->addToEnvironment(env);
}
@@ -228,13 +221,13 @@ void ToolChainKitInformation::addToMacroExpander(Kit *kit, Utils::MacroExpander
// FIXME: Use better strings
expander->registerVariable("Compiler:Name", tr("Compiler"),
[this, kit]() -> QString {
const ToolChain *tc = toolChain(kit);
const ToolChain *tc = toolChain(kit, ToolChain::Language::Cxx);
return tc ? tc->displayName() : tr("None");
});
expander->registerVariable("Compiler:Executable", tr("Path to the compiler executable"),
[this, kit]() -> QString {
const ToolChain *tc = toolChain(kit);
const ToolChain *tc = toolChain(kit, ToolChain::Language::Cxx);
return tc ? tc->compilerCommand().toString() : QString();
});
}
@@ -242,7 +235,7 @@ void ToolChainKitInformation::addToMacroExpander(Kit *kit, Utils::MacroExpander
IOutputParser *ToolChainKitInformation::createOutputParser(const Kit *k) const
{
ToolChain *tc = toolChain(k);
ToolChain *tc = toolChain(k, ToolChain::Language::Cxx);
if (tc)
return tc->outputParser();
return 0;
@@ -253,17 +246,41 @@ Core::Id ToolChainKitInformation::id()
return "PE.Profile.ToolChain";
}
ToolChain *ToolChainKitInformation::toolChain(const Kit *k)
ToolChain *ToolChainKitInformation::toolChain(const Kit *k, ToolChain::Language l)
{
QTC_ASSERT(ToolChainManager::isLoaded(), return 0);
if (!k)
return 0;
return ToolChainManager::findToolChain(k->value(ToolChainKitInformation::id()).toByteArray());
QVariantMap value = readValue(k);
const QByteArray id = value.value(ToolChain::languageId(l), QByteArray()).toByteArray();
return ToolChainManager::findToolChain(id);
}
QList<ToolChain *> ToolChainKitInformation::toolChains(const Kit *k)
{
const QVariantMap value = readValue(k);
const QList<ToolChain *> tcList
= Utils::transform(ToolChain::allLanguages().toList(),
[&value](ToolChain::Language l) -> ToolChain * {
return ToolChainManager::findToolChain(value.value(ToolChain::languageId(l)).toByteArray());
});
return Utils::filtered(tcList, [](ToolChain *tc) { return tc; });
}
void ToolChainKitInformation::setToolChain(Kit *k, ToolChain *tc)
{
k->setValue(ToolChainKitInformation::id(), tc ? QString::fromUtf8(tc->id()) : QString());
QTC_ASSERT(tc, return);
setToolChain(k, tc->language(), tc);
}
void ToolChainKitInformation::setToolChain(Kit *k, ToolChain::Language l, ToolChain *tc)
{
if (l == ToolChain::Language::None)
return;
QVariantMap result = readValue(k);
result.insert(ToolChain::languageId(l), tc ? tc->id() : QByteArray());
k->setValue(id(), result);
}
QString ToolChainKitInformation::msgNoToolChainInTarget()
@@ -271,6 +288,33 @@ QString ToolChainKitInformation::msgNoToolChainInTarget()
return tr("No compiler set in kit.");
}
QVariantMap ToolChainKitInformation::readValue(const Kit *k)
{
QVariant value = k->value(ToolChainKitInformation::id());
if (value.isNull())
value = defaultValue();
else if (value.type() == QVariant::String) {
// Legacy value: Convert...
QVariantMap tmp;
tmp.insert(ToolChain::languageDisplayName(ToolChain::Language::Cxx), value.toString());
value = tmp;
}
return value.toMap();
}
QVariant ToolChainKitInformation::defaultValue()
{
Abi abi = Abi::hostAbi();
QList<ToolChain *> tcList = Utils::filtered(ToolChainManager::toolChains(),
Utils::equal(&ToolChain::targetAbi, abi));
QVariantMap result;
foreach (ToolChain::Language l, ToolChain::allLanguages()) {
ToolChain *tc = Utils::findOrDefault(tcList, Utils::equal(&ToolChain::language, l));
result.insert(ToolChain::languageId(l), tc ? tc->id() : QByteArray());
}
return result;
}
void ToolChainKitInformation::kitsWereLoaded()
{
foreach (Kit *k, KitManager::kits())
@@ -284,7 +328,7 @@ void ToolChainKitInformation::kitsWereLoaded()
void ToolChainKitInformation::toolChainUpdated(ToolChain *tc)
{
auto matcher = KitMatcher([tc, this](const Kit *k) { return toolChain(k) == tc; });
auto matcher = KitMatcher([tc, this](const Kit *k) { return toolChain(k, ToolChain::Language::Cxx) == tc; });
foreach (Kit *k, KitManager::matchingKits(matcher))
notifyAboutUpdate(k);
}
+7 -3
View File
@@ -25,17 +25,17 @@
#pragma once
#include "devicesupport/idevice.h"
#include "kitmanager.h"
#include "kit.h"
#include "toolchain.h"
#include "devicesupport/idevice.h"
#include <utils/environment.h>
#include <QVariant>
namespace ProjectExplorer {
class ToolChain;
class KitConfigWidget;
// --------------------------------------------------------------------------
@@ -92,12 +92,16 @@ public:
IOutputParser *createOutputParser(const Kit *k) const override;
static Core::Id id();
static ToolChain *toolChain(const Kit *k);
static ToolChain *toolChain(const Kit *k, ToolChain::Language l);
static QList<ToolChain *> toolChains(const Kit *k);
static void setToolChain(Kit *k, ToolChain *tc);
static void setToolChain(Kit *k, ToolChain::Language l, ToolChain *tc);
static QString msgNoToolChainInTarget();
private:
static QVariantMap readValue(const Kit *k);
static QVariant defaultValue();
void kitsWereLoaded();
void toolChainUpdated(ProjectExplorer::ToolChain *tc);
void toolChainRemoved(ProjectExplorer::ToolChain *tc);
@@ -171,7 +171,7 @@ void ToolChainInformationConfigWidget::refresh()
m_comboBox->setEnabled(m_comboBox->count() > 1 && !m_isReadOnly);
const int index = indexOf(ToolChainKitInformation::toolChain(m_kit));
const int index = indexOf(ToolChainKitInformation::toolChain(m_kit, ToolChain::Language::Cxx));
m_comboBox->setCurrentIndex(index);
m_ignoreChanges = false;
}
@@ -203,7 +203,7 @@ void ToolChainInformationConfigWidget::currentToolChainChanged(int idx)
return;
const QByteArray id = m_comboBox->itemData(idx).toByteArray();
ToolChainKitInformation::setToolChain(m_kit, ToolChainManager::findToolChain(id));
ToolChainKitInformation::setToolChain(m_kit, ToolChain::Language::Cxx, ToolChainManager::findToolChain(id));
}
int ToolChainInformationConfigWidget::indexOf(const ToolChain *tc)
@@ -318,7 +318,7 @@ Abi RunConfiguration::abi() const
BuildConfiguration *bc = target()->activeBuildConfiguration();
if (!bc)
return Abi::hostAbi();
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ToolChain::Language::Cxx);
if (!tc)
return Abi::hostAbi();
return tc->targetAbi();
+13
View File
@@ -168,6 +168,19 @@ QString ToolChain::languageDisplayName(Language language)
return QString();
}
QString ToolChain::languageId(ToolChain::Language l)
{
switch (l) {
case Language::None:
return "None";
case Language::C:
return "C";
case Language::Cxx:
return "C++";
};
return QString();
}
ToolChain::Language ToolChain::language() const
{
return d->m_language;
+1
View File
@@ -118,6 +118,7 @@ public:
};
static const QSet<Language>& allLanguages();
static QString languageDisplayName(Language language);
static QString languageId(Language l);
Language language() const;
@@ -179,7 +179,8 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor
if (ProjectExplorer::SysRootKitInformation::hasSysRoot(k))
data.insert(QLatin1String(QBS_SYSROOT), sysroot);
ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k);
ProjectExplorer::ToolChain *tc
= ProjectExplorer::ToolChainKitInformation::toolChain(k, ProjectExplorer::ToolChain::Language::Cxx);
if (!tc)
return data;
@@ -134,7 +134,7 @@ Internal::QbsProject *QbsBuildConfiguration::project() const
IOutputParser *QbsBuildConfiguration::createOutputParser() const
{
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ToolChain::Language::Cxx);
return tc ? tc->outputParser() : 0;
}
@@ -64,7 +64,8 @@ bool AndroidPackageInstallationStep::init(QList<const BuildStep *> &earlierSteps
dirPath = QDir::toNativeSeparators(dirPath);
ProjectExplorer::ToolChain *tc
= ProjectExplorer::ToolChainKitInformation::toolChain(target()->kit());
= ProjectExplorer::ToolChainKitInformation::toolChain(target()->kit(),
ProjectExplorer::ToolChain::Language::Cxx);
ProjectExplorer::ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander());
@@ -72,7 +72,7 @@ LibraryDetailsController::LibraryDetailsController(
const Project *project = SessionManager::projectForFile(Utils::FileName::fromString(proFile));
if (project && project->activeTarget()) {
// if its tool chain is maemo behave the same as we would be on linux
ProjectExplorer::ToolChain *tc = ToolChainKitInformation::toolChain(project->activeTarget()->kit());
ProjectExplorer::ToolChain *tc = ToolChainKitInformation::toolChain(project->activeTarget()->kit(), ToolChain::Language::Cxx);
if (tc) {
switch (tc->targetAbi().os()) {
case Abi::WindowsOS:
+4 -4
View File
@@ -113,7 +113,7 @@ QString MakeStep::effectiveMakeCommand() const
QString makeCmd = m_makeCmd;
if (makeCmd.isEmpty()) {
QmakeBuildConfiguration *bc = qmakeBuildConfiguration();
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ToolChain::Language::Cxx);
if (bc && tc)
makeCmd = tc->makeCommand(bc->environment());
@@ -133,7 +133,7 @@ QVariantMap MakeStep::toMap() const
QStringList MakeStep::automaticallyAddedArguments() const
{
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ToolChain::Language::Cxx);
if (!tc || tc->targetAbi().binaryFormat() == Abi::PEFormat)
return QStringList();
return QStringList() << QLatin1String("-w") << QLatin1String("-r");
@@ -163,7 +163,7 @@ bool MakeStep::init(QList<const BuildStep *> &earlierSteps)
if (!bc)
emit addTask(Task::buildConfigurationMissingTask());
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ToolChain::Language::Cxx);
if (!tc)
emit addTask(Task::compilerMissingTask());
@@ -392,7 +392,7 @@ MakeStepConfigWidget::~MakeStepConfigWidget()
void MakeStepConfigWidget::updateDetails()
{
ToolChain *tc
= ToolChainKitInformation::toolChain(m_makeStep->target()->kit());
= ToolChainKitInformation::toolChain(m_makeStep->target()->kit(), ToolChain::Language::Cxx);
QmakeBuildConfiguration *bc = m_makeStep->qmakeBuildConfiguration();
if (!bc)
bc = qobject_cast<QmakeBuildConfiguration *>(m_makeStep->target()->activeBuildConfiguration());
@@ -170,7 +170,7 @@ void QmakeBuildConfiguration::kitChanged()
void QmakeBuildConfiguration::toolChainUpdated(ToolChain *tc)
{
if (ToolChainKitInformation::toolChain(target()->kit()) == tc)
if (ToolChainKitInformation::toolChain(target()->kit(), ToolChain::Language::Cxx) == tc)
emitProFileEvaluateNeeded();
}
@@ -766,7 +766,7 @@ QmakeBuildConfiguration::LastKitState::LastKitState(Kit *k)
m_sysroot(SysRootKitInformation::sysRoot(k).toString()),
m_mkspec(QmakeKitInformation::mkspec(k).toString())
{
ToolChain *tc = ToolChainKitInformation::toolChain(k);
ToolChain *tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx);
m_toolchain = tc ? tc->id() : QByteArray();
}
@@ -76,7 +76,7 @@ void QmakeKitInformation::setup(Kit *k)
if (spec.isEmpty())
spec = version->mkspec();
ToolChain *tc = ToolChainKitInformation::toolChain(k);
ToolChain *tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx);
if (!tc || (!tc->suggestedMkspecList().empty() && !tc->suggestedMkspecList().contains(spec))) {
ToolChain *possibleTc = 0;
@@ -142,7 +142,7 @@ FileName QmakeKitInformation::defaultMkspec(const Kit *k)
if (!version) // No version, so no qmake
return FileName();
return version->mkspecFor(ToolChainKitInformation::toolChain(k));
return version->mkspecFor(ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx));
}
} // namespace QmakeProjectManager
@@ -482,7 +482,7 @@ void QmakeProject::updateCppCodeModel()
const QStringList cxxflags = pro->variableValue(CppFlagsVar);
CppTools::ProjectPartBuilder::evaluateProjectPartToolchain(objcppPart.data(),
ToolChainKitInformation::toolChain(k),
ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx),
cxxflags,
SysRootKitInformation::sysRoot(k));
@@ -524,8 +524,8 @@ void QmakeProject::updateCppCodeModel()
ProjectFile::CXXSource));
const QStringList cxxflags = pro->variableValue(CppFlagsVar);
CppTools::ProjectPartBuilder::evaluateProjectPartToolchain(
cppPart.data(), ToolChainKitInformation::toolChain(k), cxxflags,
SysRootKitInformation::sysRoot(k));
cppPart.data(), ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx),
cxxflags, SysRootKitInformation::sysRoot(k));
if (!cppPart->files.isEmpty()) {
pinfo.appendProjectPart(cppPart);
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, true);
@@ -1440,7 +1440,7 @@ void QmakeProject::collectLibraryData(const QmakeProFileNode *node, DeploymentDa
if (targetPath.isEmpty())
return;
const Kit * const kit = activeTarget()->kit();
const ToolChain * const toolchain = ToolChainKitInformation::toolChain(kit);
const ToolChain * const toolchain = ToolChainKitInformation::toolChain(kit, ToolChain::Language::Cxx);
if (!toolchain)
return;
@@ -1536,7 +1536,7 @@ bool QmakeProject::matchesKit(const Kit *kit)
QString QmakeProject::executableFor(const QmakeProFileNode *node)
{
const Kit * const kit = activeTarget()->kit();
const ToolChain * const toolchain = ToolChainKitInformation::toolChain(kit);
const ToolChain * const toolchain = ToolChainKitInformation::toolChain(kit, ToolChain::Language::Cxx);
if (!toolchain)
return QString();
@@ -177,7 +177,7 @@ QList<BuildInfo *> QmakeProjectImporter::import(const FileName &importPath, bool
foreach (Kit *k, KitManager::kits()) {
BaseQtVersion *kitVersion = QtKitInformation::qtVersion(k);
FileName kitSpec = QmakeKitInformation::mkspec(k);
ToolChain *tc = ToolChainKitInformation::toolChain(k);
ToolChain *tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx);
if (kitSpec.isEmpty() && kitVersion)
kitSpec = kitVersion->mkspecFor(tc);
QMakeStepConfig::TargetArchConfig kitTargetArch = QMakeStepConfig::NoArch;
@@ -161,7 +161,7 @@ QMakeStepConfig QMakeStep::deducedArguments() const
ProjectExplorer::Kit *kit = target()->kit();
QMakeStepConfig config;
ProjectExplorer::ToolChain *tc
= ProjectExplorer::ToolChainKitInformation::toolChain(kit);
= ProjectExplorer::ToolChainKitInformation::toolChain(kit, ToolChain::Language::Cxx);
ProjectExplorer::Abi targetAbi;
if (tc)
targetAbi = tc->targetAbi();
@@ -386,7 +386,9 @@ QString PuppetCreator::buildCommand() const
Utils::Environment environment = Utils::Environment::systemEnvironment();
m_kit->addToEnvironment(environment);
ProjectExplorer::ToolChain *toolChain = ProjectExplorer::ToolChainKitInformation::toolChain(m_kit);
ProjectExplorer::ToolChain *toolChain
= ProjectExplorer::ToolChainKitInformation::toolChain(m_kit,
ProjectExplorer::ToolChain::Language::Cxx);
if (toolChain)
return toolChain->makeCommand(environment);
+1 -1
View File
@@ -218,7 +218,7 @@ void QnxConfiguration::deactivate()
foreach (Kit *kit, KitManager::kits()) {
if (kit->isAutoDetected()
&& DeviceTypeKitInformation::deviceTypeId(kit) == Constants::QNX_QNX_OS_TYPE
&& toolChainsToRemove.contains(ToolChainKitInformation::toolChain(kit)))
&& toolChainsToRemove.contains(ToolChainKitInformation::toolChain(kit, ToolChain::Language::Cxx)))
KitManager::deregisterKit(kit);
}
+1 -1
View File
@@ -493,7 +493,7 @@ QList<Task> BaseQtVersion::validateKit(const Kit *k)
FileName(), -1, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
}
ToolChain *tc = ToolChainKitInformation::toolChain(k);
ToolChain *tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx);
if (tc) {
Abi targetAbi = tc->targetAbi();
bool fuzzyMatch = false;