2013-08-13 10:52:57 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-08-13 10:52:57 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2013-08-13 10:52:57 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2013-08-13 10:52:57 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qmakeprojectimporter.h"
|
|
|
|
|
|
|
|
|
|
#include "qmakebuildinfo.h"
|
|
|
|
|
#include "qmakekitinformation.h"
|
2013-10-16 12:10:22 +02:00
|
|
|
#include "qmakebuildconfiguration.h"
|
|
|
|
|
#include "qmakeproject.h"
|
2015-03-04 17:14:28 +01:00
|
|
|
#include "makefileparse.h"
|
|
|
|
|
#include "qmakestep.h"
|
2013-08-13 10:52:57 +02:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/idocument.h>
|
|
|
|
|
#include <projectexplorer/kitmanager.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
2014-08-04 15:17:28 +02:00
|
|
|
#include <projectexplorer/toolchain.h>
|
|
|
|
|
#include <projectexplorer/toolchainmanager.h>
|
2013-08-13 10:52:57 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
|
|
|
|
#include <qtsupport/qtsupportconstants.h>
|
|
|
|
|
#include <qtsupport/qtversionfactory.h>
|
|
|
|
|
#include <qtsupport/qtversionmanager.h>
|
|
|
|
|
#include <utils/qtcprocess.h>
|
2014-08-04 15:17:28 +02:00
|
|
|
#include <utils/algorithm.h>
|
2013-08-13 10:52:57 +02:00
|
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QMessageBox>
|
2014-10-23 18:13:15 +02:00
|
|
|
#include <QStringList>
|
2015-03-04 17:14:28 +01:00
|
|
|
#include <QLoggingCategory>
|
2013-08-13 10:52:57 +02:00
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace QtSupport;
|
|
|
|
|
using namespace Utils;
|
2013-08-13 10:52:57 +02:00
|
|
|
|
2013-10-16 11:02:37 +02:00
|
|
|
namespace QmakeProjectManager {
|
2013-08-13 10:52:57 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
const Core::Id QT_IS_TEMPORARY("Qmake.TempQt");
|
2015-03-04 17:14:28 +01:00
|
|
|
const char IOSQT[] = "Qt4ProjectManager.QtVersion.Ios"; // ugly
|
2014-10-23 18:13:15 +02:00
|
|
|
|
2013-08-13 10:52:57 +02:00
|
|
|
QmakeProjectImporter::QmakeProjectImporter(const QString &path) :
|
2014-10-23 18:13:15 +02:00
|
|
|
ProjectImporter(path)
|
2013-08-13 10:52:57 +02:00
|
|
|
{ }
|
|
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
QList<BuildInfo *> QmakeProjectImporter::import(const FileName &importPath, bool silent)
|
2013-08-13 10:52:57 +02:00
|
|
|
{
|
2015-03-04 17:14:28 +01:00
|
|
|
const auto &logs = MakeFileParse::logging();
|
|
|
|
|
qCDebug(logs) << "QmakeProjectImporter::import" << importPath << silent;
|
|
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
QList<BuildInfo *> result;
|
2013-08-13 10:52:57 +02:00
|
|
|
QFileInfo fi = importPath.toFileInfo();
|
2015-03-04 17:14:28 +01:00
|
|
|
if (!fi.exists() && !fi.isDir()) {
|
|
|
|
|
qCDebug(logs) << "**doesn't exist";
|
2013-08-13 10:52:57 +02:00
|
|
|
return result;
|
2015-03-04 17:14:28 +01:00
|
|
|
}
|
2013-08-13 10:52:57 +02:00
|
|
|
|
|
|
|
|
QStringList makefiles = QDir(importPath.toString()).entryList(QStringList(QLatin1String("Makefile*")));
|
2015-03-04 17:14:28 +01:00
|
|
|
qCDebug(logs) << " Makefiles:" << makefiles;
|
2013-08-13 10:52:57 +02:00
|
|
|
|
|
|
|
|
bool temporaryVersion = false;
|
|
|
|
|
|
|
|
|
|
foreach (const QString &file, makefiles) {
|
2015-03-04 17:14:28 +01:00
|
|
|
qCDebug(logs) << " Parsing makefile" << file;
|
2013-08-13 10:52:57 +02:00
|
|
|
// find interesting makefiles
|
|
|
|
|
QString makefile = importPath.toString() + QLatin1Char('/') + file;
|
2015-03-04 17:14:28 +01:00
|
|
|
MakeFileParse parse(makefile);
|
2015-07-24 16:16:35 +02:00
|
|
|
if (parse.makeFileState() != MakeFileParse::Okay)
|
|
|
|
|
continue;
|
2015-03-04 17:14:28 +01:00
|
|
|
QFileInfo qmakeFi = parse.qmakePath().toFileInfo();
|
2014-10-23 18:13:15 +02:00
|
|
|
FileName canonicalQmakeBinary = FileName::fromString(qmakeFi.canonicalFilePath());
|
2015-03-04 17:14:28 +01:00
|
|
|
if (canonicalQmakeBinary.isEmpty()) {
|
|
|
|
|
qCDebug(logs) << " " << parse.qmakePath() << "doesn't exist anymore";
|
2013-08-13 10:52:57 +02:00
|
|
|
continue;
|
2015-03-04 17:14:28 +01:00
|
|
|
}
|
|
|
|
|
if (parse.srcProFile() != projectFilePath()) {
|
|
|
|
|
qCDebug(logs) << " pro files doesn't match" << parse.srcProFile() << projectFilePath();
|
2013-08-13 10:52:57 +02:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-04 17:14:28 +01:00
|
|
|
qCDebug(logs) << " QMake:" << canonicalQmakeBinary;
|
|
|
|
|
|
|
|
|
|
BaseQtVersion *version
|
2015-11-23 15:34:09 +01:00
|
|
|
= Utils::findOrDefault(QtVersionManager::unsortedVersions(),
|
2015-03-12 11:20:18 +01:00
|
|
|
[&canonicalQmakeBinary](BaseQtVersion *v) -> bool {
|
2015-03-04 17:14:28 +01:00
|
|
|
QFileInfo vfi = v->qmakeCommand().toFileInfo();
|
|
|
|
|
FileName current = FileName::fromString(vfi.canonicalFilePath());
|
|
|
|
|
return current == canonicalQmakeBinary;
|
|
|
|
|
});
|
|
|
|
|
|
2014-08-06 16:54:18 +02:00
|
|
|
if (version) {
|
|
|
|
|
// Check if version is a temporary qt
|
|
|
|
|
int qtId = version->uniqueId();
|
2014-10-23 18:13:15 +02:00
|
|
|
temporaryVersion = Utils::anyOf(KitManager::kits(), [&qtId](Kit *k){
|
2014-08-06 16:54:18 +02:00
|
|
|
return k->value(QT_IS_TEMPORARY, -1).toInt() == qtId;
|
|
|
|
|
});
|
2015-03-04 17:14:28 +01:00
|
|
|
qCDebug(logs) << " qt version already exist. Temporary:" << temporaryVersion;
|
2014-08-06 16:54:18 +02:00
|
|
|
} else {
|
|
|
|
|
// Create a new version if not found:
|
2013-08-13 10:52:57 +02:00
|
|
|
// Do not use the canonical path here...
|
2015-03-04 17:14:28 +01:00
|
|
|
version = QtVersionFactory::createQtVersionFromQMakePath(parse.qmakePath());
|
2013-08-13 10:52:57 +02:00
|
|
|
if (!version)
|
|
|
|
|
continue;
|
|
|
|
|
|
2014-08-06 16:54:18 +02:00
|
|
|
bool oldIsUpdating = setIsUpdating(true);
|
2014-10-23 18:13:15 +02:00
|
|
|
QtVersionManager::addVersion(version);
|
2014-08-06 16:54:18 +02:00
|
|
|
setIsUpdating(oldIsUpdating);
|
2013-08-13 10:52:57 +02:00
|
|
|
temporaryVersion = true;
|
2015-03-04 17:14:28 +01:00
|
|
|
qCDebug(logs) << " created new qt version";
|
2013-08-13 10:52:57 +02:00
|
|
|
}
|
|
|
|
|
|
2015-03-04 17:14:28 +01:00
|
|
|
QMakeStepConfig::TargetArchConfig archConfig = parse.config().archConfig;
|
|
|
|
|
QMakeStepConfig::OsType osType = parse.config().osType;
|
|
|
|
|
qCDebug(logs) << " archConfig:" << archConfig;
|
|
|
|
|
qCDebug(logs) << " osType: " << osType;
|
|
|
|
|
if (version->type() == QLatin1String(IOSQT)
|
|
|
|
|
&& osType == QMakeStepConfig::NoOsType) {
|
|
|
|
|
osType = QMakeStepConfig::IphoneOS;
|
|
|
|
|
qCDebug(logs) << " IOS found without osType, adjusting osType" << osType;
|
|
|
|
|
}
|
2013-08-13 10:52:57 +02:00
|
|
|
|
2015-03-04 17:14:28 +01:00
|
|
|
if (version->type() == QLatin1String(Constants::DESKTOPQT)) {
|
|
|
|
|
QList<ProjectExplorer::Abi> abis = version->qtAbis();
|
|
|
|
|
if (!abis.isEmpty()) {
|
|
|
|
|
ProjectExplorer::Abi abi = abis.first();
|
|
|
|
|
if (abi.os() == ProjectExplorer::Abi::MacOS) {
|
|
|
|
|
if (abi.wordWidth() == 64)
|
|
|
|
|
archConfig = QMakeStepConfig::X86_64;
|
|
|
|
|
else
|
|
|
|
|
archConfig = QMakeStepConfig::X86;
|
|
|
|
|
qCDebug(logs) << " OS X found without targetarch, adjusting archType" << archConfig;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// find qmake arguments and mkspec
|
|
|
|
|
QString additionalArguments = parse.unparsedArguments();
|
|
|
|
|
qCDebug(logs) << " Unparsed arguments:" << additionalArguments;
|
2014-10-23 18:13:15 +02:00
|
|
|
FileName parsedSpec =
|
2013-10-16 14:00:45 +02:00
|
|
|
QmakeBuildConfiguration::extractSpecFromArguments(&additionalArguments, importPath.toString(), version);
|
2015-03-04 17:14:28 +01:00
|
|
|
qCDebug(logs) << " Extracted spec:" << parsedSpec;
|
|
|
|
|
qCDebug(logs) << " Arguments now:" << additionalArguments;
|
2014-08-04 15:17:28 +02:00
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
FileName versionSpec = version->mkspec();
|
2015-03-04 17:14:28 +01:00
|
|
|
if (parsedSpec.isEmpty() || parsedSpec == FileName::fromLatin1("default")) {
|
2013-08-13 10:52:57 +02:00
|
|
|
parsedSpec = versionSpec;
|
2015-03-04 17:14:28 +01:00
|
|
|
qCDebug(logs) << " No parsed spec or default spec => parsed spec now:" << parsedSpec;
|
|
|
|
|
}
|
2013-08-13 10:52:57 +02:00
|
|
|
|
2015-03-04 17:14:28 +01:00
|
|
|
qCDebug(logs) << "*******************";
|
|
|
|
|
qCDebug(logs) << "* Looking for kits";
|
2013-08-13 10:52:57 +02:00
|
|
|
// Find kits (can be more than one, e.g. (Linux-)Desktop and embedded linux):
|
2014-11-10 16:45:18 +01:00
|
|
|
QList<Kit *> kitList;
|
|
|
|
|
foreach (Kit *k, KitManager::kits()) {
|
2014-10-23 18:13:15 +02:00
|
|
|
BaseQtVersion *kitVersion = QtKitInformation::qtVersion(k);
|
|
|
|
|
FileName kitSpec = QmakeKitInformation::mkspec(k);
|
2016-07-12 16:27:45 +02:00
|
|
|
ToolChain *tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx);
|
2013-08-13 10:52:57 +02:00
|
|
|
if (kitSpec.isEmpty() && kitVersion)
|
|
|
|
|
kitSpec = kitVersion->mkspecFor(tc);
|
2015-03-16 19:12:27 +01:00
|
|
|
QMakeStepConfig::TargetArchConfig kitTargetArch = QMakeStepConfig::NoArch;
|
|
|
|
|
QMakeStepConfig::OsType kitOsType = QMakeStepConfig::NoOsType;
|
|
|
|
|
if (tc) {
|
|
|
|
|
kitTargetArch = QMakeStepConfig::targetArchFor(tc->targetAbi(), kitVersion);
|
|
|
|
|
kitOsType = QMakeStepConfig::osTypeFor(tc->targetAbi(), kitVersion);
|
|
|
|
|
}
|
2015-03-04 17:14:28 +01:00
|
|
|
qCDebug(logs) << k->displayName()
|
|
|
|
|
<< "version:" << (kitVersion == version)
|
|
|
|
|
<< "spec:" << (kitSpec == parsedSpec)
|
|
|
|
|
<< "targetarch:" << (kitTargetArch == archConfig)
|
|
|
|
|
<< "ostype:" << (kitOsType == osType);
|
2013-08-13 10:52:57 +02:00
|
|
|
if (kitVersion == version
|
2014-08-04 15:17:28 +02:00
|
|
|
&& kitSpec == parsedSpec
|
2015-03-04 17:14:28 +01:00
|
|
|
&& kitTargetArch == archConfig
|
|
|
|
|
&& kitOsType == osType)
|
2013-08-13 10:52:57 +02:00
|
|
|
kitList.append(k);
|
|
|
|
|
}
|
2015-03-04 17:14:28 +01:00
|
|
|
if (kitList.isEmpty()) {
|
|
|
|
|
kitList.append(createTemporaryKit(version, temporaryVersion, parsedSpec, archConfig, osType));
|
|
|
|
|
qCDebug(logs) << " No matching kits found, created new kit";
|
|
|
|
|
}
|
2013-08-13 10:52:57 +02:00
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
foreach (Kit *k, kitList) {
|
2013-08-13 10:52:57 +02:00
|
|
|
addProject(k);
|
|
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
auto factory = qobject_cast<QmakeBuildConfigurationFactory *>(
|
|
|
|
|
IBuildConfigurationFactory::find(k, projectFilePath()));
|
2013-08-13 10:52:57 +02:00
|
|
|
|
|
|
|
|
if (!factory)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// create info:
|
|
|
|
|
QmakeBuildInfo *info = new QmakeBuildInfo(factory);
|
2015-03-04 17:14:28 +01:00
|
|
|
BaseQtVersion::QmakeBuildConfigs buildConfig = parse.effectiveBuildConfig(version->defaultBuildConfig());
|
|
|
|
|
if (buildConfig & BaseQtVersion::DebugBuild) {
|
2015-10-22 16:55:17 +02:00
|
|
|
info->buildType = BuildConfiguration::Debug;
|
2013-10-16 11:02:37 +02:00
|
|
|
info->displayName = QCoreApplication::translate("QmakeProjectManager::Internal::QmakeProjectImporter", "Debug");
|
2013-08-13 10:52:57 +02:00
|
|
|
} else {
|
2015-10-22 16:55:17 +02:00
|
|
|
info->buildType = BuildConfiguration::Release;
|
2013-10-16 11:02:37 +02:00
|
|
|
info->displayName = QCoreApplication::translate("QmakeProjectManager::Internal::QmakeProjectImporter", "Release");
|
2013-08-13 10:52:57 +02:00
|
|
|
}
|
|
|
|
|
info->kitId = k->id();
|
2014-10-23 18:13:15 +02:00
|
|
|
info->buildDirectory = FileName::fromString(fi.absoluteFilePath());
|
2013-08-13 10:52:57 +02:00
|
|
|
info->additionalArguments = additionalArguments;
|
2015-03-04 17:14:28 +01:00
|
|
|
info->config = parse.config();
|
2013-08-13 10:52:57 +02:00
|
|
|
info->makefile = makefile;
|
|
|
|
|
|
2013-12-09 15:40:23 +01:00
|
|
|
bool found = false;
|
2014-10-23 18:13:15 +02:00
|
|
|
foreach (BuildInfo *bInfo, result) {
|
2013-12-09 15:40:23 +01:00
|
|
|
if (*static_cast<QmakeBuildInfo *>(bInfo) == *info) {
|
|
|
|
|
found = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (found)
|
|
|
|
|
delete info;
|
|
|
|
|
else
|
|
|
|
|
result << info;
|
2013-08-13 10:52:57 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (result.isEmpty() && !silent)
|
|
|
|
|
QMessageBox::critical(Core::ICore::mainWindow(),
|
2013-10-16 11:02:37 +02:00
|
|
|
QCoreApplication::translate("QmakeProjectManager::Internal::QmakeProjectImporter", "No Build Found"),
|
|
|
|
|
QCoreApplication::translate("QmakeProjectManager::Internal::QmakeProjectImporter", "No build found in %1 matching project %2.")
|
2014-04-18 00:39:27 +02:00
|
|
|
.arg(importPath.toUserOutput()).arg(QDir::toNativeSeparators(projectFilePath())));
|
2013-08-13 10:52:57 +02:00
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
QStringList QmakeProjectImporter::importCandidates(const FileName &projectPath)
|
2013-08-13 10:52:57 +02:00
|
|
|
{
|
|
|
|
|
QStringList candidates;
|
|
|
|
|
|
|
|
|
|
QFileInfo pfi = projectPath.toFileInfo();
|
|
|
|
|
const QString prefix = pfi.baseName();
|
|
|
|
|
candidates << pfi.absolutePath();
|
|
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
foreach (Kit *k, KitManager::kits()) {
|
2015-10-22 17:26:33 +02:00
|
|
|
QFileInfo fi(QmakeBuildConfiguration::shadowBuildDirectory(projectPath.toString(), k,
|
|
|
|
|
QString(), BuildConfiguration::Unknown));
|
2013-08-13 10:52:57 +02:00
|
|
|
const QString baseDir = fi.absolutePath();
|
|
|
|
|
|
|
|
|
|
foreach (const QString &dir, QDir(baseDir).entryList()) {
|
|
|
|
|
const QString path = baseDir + QLatin1Char('/') + dir;
|
|
|
|
|
if (dir.startsWith(prefix) && !candidates.contains(path))
|
|
|
|
|
candidates << path;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return candidates;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
Target *QmakeProjectImporter::preferredTarget(const QList<Target *> &possibleTargets)
|
2013-08-13 10:52:57 +02:00
|
|
|
{
|
|
|
|
|
// Select active target
|
|
|
|
|
// a) The default target
|
|
|
|
|
// b) Simulator target
|
|
|
|
|
// c) Desktop target
|
|
|
|
|
// d) the first target
|
2014-10-23 18:13:15 +02:00
|
|
|
Target *activeTarget = possibleTargets.isEmpty() ? 0 : possibleTargets.at(0);
|
2013-08-13 10:52:57 +02:00
|
|
|
int activeTargetPriority = 0;
|
2014-10-23 18:13:15 +02:00
|
|
|
foreach (Target *t, possibleTargets) {
|
|
|
|
|
BaseQtVersion *version = QtKitInformation::qtVersion(t->kit());
|
|
|
|
|
if (t->kit() == KitManager::defaultKit()) {
|
2013-08-13 10:52:57 +02:00
|
|
|
activeTarget = t;
|
|
|
|
|
activeTargetPriority = 3;
|
|
|
|
|
} else if (activeTargetPriority < 1 && version && version->type() == QLatin1String(QtSupport::Constants::DESKTOPQT)) {
|
|
|
|
|
activeTarget = t;
|
|
|
|
|
activeTargetPriority = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return activeTarget;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
void QmakeProjectImporter::cleanupKit(Kit *k)
|
2013-08-13 10:52:57 +02:00
|
|
|
{
|
2014-10-23 18:13:15 +02:00
|
|
|
BaseQtVersion *version = QtVersionManager::version(k->value(QT_IS_TEMPORARY, -1).toInt());
|
2014-08-06 16:54:18 +02:00
|
|
|
if (!version)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// count how many kits are using this version
|
|
|
|
|
int qtId = version->uniqueId();
|
2014-10-23 18:13:15 +02:00
|
|
|
int users = Utils::count(KitManager::kits(), [qtId](Kit *k) {
|
2014-08-06 16:54:18 +02:00
|
|
|
return k->value(QT_IS_TEMPORARY, -1).toInt() == qtId;
|
|
|
|
|
});
|
|
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
if (users == 0) // Remove if no other kit is using it. (The Kit k is not in KitManager::kits()
|
|
|
|
|
QtVersionManager::removeVersion(version);
|
2013-08-13 10:52:57 +02:00
|
|
|
}
|
|
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
void QmakeProjectImporter::makePermanent(Kit *k)
|
2014-06-18 17:48:02 +02:00
|
|
|
{
|
2014-08-06 16:54:18 +02:00
|
|
|
if (!isTemporaryKit(k))
|
|
|
|
|
return;
|
|
|
|
|
setIsUpdating(true);
|
2014-06-18 17:48:02 +02:00
|
|
|
int tempId = k->value(QT_IS_TEMPORARY, -1).toInt();
|
2014-10-23 18:13:15 +02:00
|
|
|
int qtId = QtKitInformation::qtVersionId(k);
|
2014-06-18 17:48:02 +02:00
|
|
|
if (tempId != qtId) {
|
2014-10-23 18:13:15 +02:00
|
|
|
BaseQtVersion *version = QtVersionManager::version(tempId);
|
|
|
|
|
int users = count(KitManager::kits(), [tempId](Kit *k) {
|
2014-08-06 16:54:18 +02:00
|
|
|
return k->value(QT_IS_TEMPORARY, -1).toInt() == tempId;
|
|
|
|
|
});
|
2014-10-23 18:13:15 +02:00
|
|
|
if (users == 0)
|
|
|
|
|
QtVersionManager::removeVersion(version);
|
2014-06-18 17:48:02 +02:00
|
|
|
}
|
|
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
foreach (Kit *kit, KitManager::kits())
|
2014-08-06 16:54:18 +02:00
|
|
|
if (kit->value(QT_IS_TEMPORARY, -1).toInt() == tempId)
|
|
|
|
|
kit->removeKeySilently(QT_IS_TEMPORARY);
|
|
|
|
|
setIsUpdating(false);
|
2014-06-18 17:48:02 +02:00
|
|
|
ProjectImporter::makePermanent(k);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-04 17:14:28 +01:00
|
|
|
static ToolChain *preferredToolChain(BaseQtVersion *qtVersion, const FileName &ms, const QMakeStepConfig::TargetArchConfig &archConfig)
|
2014-08-04 15:17:28 +02:00
|
|
|
{
|
2014-10-23 18:13:15 +02:00
|
|
|
const FileName spec = ms.isEmpty() ? qtVersion->mkspec() : ms;
|
2014-08-04 15:17:28 +02:00
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
QList<ToolChain *> toolchains = ToolChainManager::toolChains();
|
|
|
|
|
QList<Abi> qtAbis = qtVersion->qtAbis();
|
|
|
|
|
return findOr(toolchains,
|
2014-08-04 15:17:28 +02:00
|
|
|
toolchains.isEmpty() ? 0 : toolchains.first(),
|
2015-03-04 17:14:28 +01:00
|
|
|
[&spec, &archConfig, &qtAbis, &qtVersion](ToolChain *tc) -> bool{
|
2014-08-04 15:17:28 +02:00
|
|
|
return qtAbis.contains(tc->targetAbi())
|
|
|
|
|
&& tc->suggestedMkspecList().contains(spec)
|
2015-03-04 17:14:28 +01:00
|
|
|
&& QMakeStepConfig::targetArchFor(tc->targetAbi(), qtVersion) == archConfig;
|
2014-08-04 15:17:28 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
Kit *QmakeProjectImporter::createTemporaryKit(BaseQtVersion *version,
|
|
|
|
|
bool temporaryVersion,
|
|
|
|
|
const FileName &parsedSpec,
|
2015-03-04 17:14:28 +01:00
|
|
|
const QMakeStepConfig::TargetArchConfig &archConfig,
|
|
|
|
|
const QMakeStepConfig::OsType &osType)
|
2013-08-13 10:52:57 +02:00
|
|
|
{
|
2015-03-04 17:14:28 +01:00
|
|
|
Q_UNUSED(osType); // TODO use this to select the right toolchain?
|
2014-10-23 18:13:15 +02:00
|
|
|
Kit *k = new Kit;
|
2014-08-06 16:54:18 +02:00
|
|
|
bool oldIsUpdating = setIsUpdating(true);
|
|
|
|
|
{
|
2014-10-23 18:13:15 +02:00
|
|
|
KitGuard guard(k);
|
2014-08-06 16:54:18 +02:00
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
QtKitInformation::setQtVersion(k, version);
|
2015-03-04 17:14:28 +01:00
|
|
|
ToolChainKitInformation::setToolChain(k, preferredToolChain(version, parsedSpec, archConfig));
|
2015-07-24 16:30:13 +02:00
|
|
|
if (parsedSpec != version->mkspec())
|
|
|
|
|
QmakeKitInformation::setMkspec(k, parsedSpec);
|
2014-08-06 16:54:18 +02:00
|
|
|
|
|
|
|
|
markTemporary(k);
|
|
|
|
|
if (temporaryVersion)
|
|
|
|
|
k->setValue(QT_IS_TEMPORARY, version->uniqueId());
|
|
|
|
|
|
|
|
|
|
// Set up other values:
|
2014-10-23 18:13:15 +02:00
|
|
|
foreach (KitInformation *ki, KitManager::kitInformation()) {
|
|
|
|
|
if (ki->id() == ToolChainKitInformation::id() || ki->id() == QtKitInformation::id())
|
2014-08-06 16:54:18 +02:00
|
|
|
continue;
|
|
|
|
|
ki->setup(k);
|
|
|
|
|
}
|
|
|
|
|
k->setUnexpandedDisplayName(version->displayName());;
|
|
|
|
|
} // ~KitGuard, sending kitUpdated
|
2014-06-19 15:34:44 +02:00
|
|
|
|
2014-10-23 18:13:15 +02:00
|
|
|
KitManager::registerKit(k); // potentially adds kits to other targetsetuppages
|
2014-08-06 16:54:18 +02:00
|
|
|
setIsUpdating(oldIsUpdating);
|
2013-08-13 10:52:57 +02:00
|
|
|
return k;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
2013-10-16 11:02:37 +02:00
|
|
|
} // namespace QmakeProjectManager
|