Commit 5ac6fccd authored by Daniel Teske's avatar Daniel Teske
Browse files

QmakeProject: Take deduced arguments into consideration on import



That is try to find a kit that matches the deduced arguments found
in the Makefile.

Task-number: QTCREATORBUG-11067
Change-Id: I01dc122ffcba8ccb71b112c271a0ae2cf860328d
Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@digia.com>
parent e97e566e
......@@ -507,6 +507,52 @@ FileName QmakeBuildConfiguration::extractSpecFromArguments(QString *args,
return parsedSpec;
}
QStringList QmakeBuildConfiguration::extractDeducedArguments(QString *args)
{
QStringList allPossibleDeducedArguments;
allPossibleDeducedArguments << QLatin1String("CONFIG+=x86")
<< QLatin1String("CONFIG+=x86_64")
<< QLatin1String("CONFIG+=iphonesimulator")
<< QLatin1String("CONFIG+=ppc")
<< QLatin1String("CONFIG+=ppc64")
<< QLatin1String("CONFIG+=iphoneos");
QStringList result;
for (QtcProcess::ArgIterator ait(args); ait.next(); ) {
QString arg = ait.value();
if (allPossibleDeducedArguments.contains(arg)) {
result << arg;
ait.deleteArg();
}
}
return result;
}
QStringList QmakeBuildConfiguration::deduceArgumnetsForTargetAbi(const ProjectExplorer::Abi &targetAbi, const BaseQtVersion *version)
{
QStringList arguments;
if ((targetAbi.os() == ProjectExplorer::Abi::MacOS)
&& (targetAbi.binaryFormat() == ProjectExplorer::Abi::MachOFormat)) {
if (targetAbi.architecture() == ProjectExplorer::Abi::X86Architecture) {
if (targetAbi.wordWidth() == 32)
arguments << QLatin1String("CONFIG+=x86");
else if (targetAbi.wordWidth() == 64)
arguments << QLatin1String("CONFIG+=x86_64");
const char IOSQT[] = "Qt4ProjectManager.QtVersion.Ios";
if (version && version->type() == QLatin1String(IOSQT)) // ugly, we can't distinguish between ios and mac toolchains
arguments << QLatin1String("CONFIG+=iphonesimulator");
} else if (targetAbi.architecture() == ProjectExplorer::Abi::PowerPCArchitecture) {
if (targetAbi.wordWidth() == 32)
arguments << QLatin1String("CONFIG+=ppc");
else if (targetAbi.wordWidth() == 64)
arguments << QLatin1String("CONFIG+=ppc64");
} else if (targetAbi.architecture() == ProjectExplorer::Abi::ArmArchitecture) {
arguments << QLatin1String("CONFIG+=iphoneos");
}
}
return arguments;
}
bool QmakeBuildConfiguration::isEnabled() const
{
return m_isEnabled;
......
......@@ -91,6 +91,8 @@ public:
static Utils::FileName extractSpecFromArguments(QString *arguments,
const QString &directory, const QtSupport::BaseQtVersion *version,
QStringList *outArgs = 0);
static QStringList extractDeducedArguments(QString *args);
static QStringList deduceArgumnetsForTargetAbi(const ProjectExplorer::Abi &targetAbi, const QtSupport::BaseQtVersion *version);
QVariantMap toMap() const;
......
......@@ -38,11 +38,14 @@
#include <coreplugin/idocument.h>
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/toolchainmanager.h>
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtsupportconstants.h>
#include <qtsupport/qtversionfactory.h>
#include <qtsupport/qtversionmanager.h>
#include <utils/qtcprocess.h>
#include <utils/algorithm.h>
#include <QDir>
#include <QFileInfo>
......@@ -113,6 +116,9 @@ QList<ProjectExplorer::BuildInfo *> QmakeProjectImporter::import(const Utils::Fi
QString additionalArguments = makefileBuildConfig.second;
Utils::FileName parsedSpec =
QmakeBuildConfiguration::extractSpecFromArguments(&additionalArguments, importPath.toString(), version);
QStringList deducedArguments =
QmakeBuildConfiguration::extractDeducedArguments(&additionalArguments);
Utils::FileName versionSpec = version->mkspec();
if (parsedSpec.isEmpty() || parsedSpec == Utils::FileName::fromLatin1("default"))
parsedSpec = versionSpec;
......@@ -131,13 +137,17 @@ QList<ProjectExplorer::BuildInfo *> QmakeProjectImporter::import(const Utils::Fi
ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k);
if (kitSpec.isEmpty() && kitVersion)
kitSpec = kitVersion->mkspecFor(tc);
QStringList kitDeducedArguments;
if (tc)
kitDeducedArguments = QmakeBuildConfiguration::deduceArgumnetsForTargetAbi(tc->targetAbi(), kitVersion);
if (kitVersion == version
&& kitSpec == parsedSpec)
&& kitSpec == parsedSpec
&& kitDeducedArguments == deducedArguments)
kitList.append(k);
}
if (kitList.isEmpty())
kitList.append(createTemporaryKit(version, temporaryVersion, parsedSpec));
kitList.append(createTemporaryKit(version, temporaryVersion, parsedSpec, deducedArguments));
foreach (ProjectExplorer::Kit *k, kitList) {
addProject(k);
......@@ -254,16 +264,34 @@ void QmakeProjectImporter::makePermanent(ProjectExplorer::Kit *k)
ProjectImporter::makePermanent(k);
}
namespace {
ProjectExplorer::ToolChain *preferredToolChain(QtSupport::BaseQtVersion *qtVersion, const Utils::FileName &ms, const QStringList &deducedArguments)
{
const Utils::FileName spec = ms.isEmpty() ? qtVersion->mkspec() : ms;
QList<ProjectExplorer::ToolChain *> toolchains = ProjectExplorer::ToolChainManager::toolChains();
QList<ProjectExplorer::Abi> qtAbis = qtVersion->qtAbis();
return Utils::findOr(toolchains,
toolchains.isEmpty() ? 0 : toolchains.first(),
[&spec, &deducedArguments, &qtAbis](ProjectExplorer::ToolChain *tc) -> bool{
return qtAbis.contains(tc->targetAbi())
&& tc->suggestedMkspecList().contains(spec)
&& QmakeBuildConfiguration::deduceArgumnetsForTargetAbi(tc->targetAbi(), 0) == deducedArguments;
});
}
}
ProjectExplorer::Kit *QmakeProjectImporter::createTemporaryKit(QtSupport::BaseQtVersion *version,
bool temporaryVersion,
const Utils::FileName &parsedSpec)
const Utils::FileName &parsedSpec,
const QStringList &deducedQmakeArguments)
{
ProjectExplorer::Kit *k = new ProjectExplorer::Kit;
ProjectExplorer::KitGuard guard(k);
QtSupport::QtKitInformation::setQtVersion(k, version);
ProjectExplorer::ToolChainKitInformation::setToolChain(k, version->preferredToolChain(parsedSpec));
ProjectExplorer::ToolChainKitInformation::setToolChain(k, preferredToolChain(version, parsedSpec, deducedQmakeArguments));
QmakeKitInformation::setMkspec(k, parsedSpec);
markTemporary(k);
......
......@@ -57,7 +57,7 @@ public:
private:
ProjectExplorer::Kit *createTemporaryKit(QtSupport::BaseQtVersion *version,
bool temporaryVersion,
const Utils::FileName &parsedSpec);
const Utils::FileName &parsedSpec, const QStringList &deducedQmakeArguments);
};
} // namespace Internal
......
......@@ -170,29 +170,9 @@ QStringList QMakeStep::deducedArguments()
targetAbi = tc->targetAbi();
// explicitly add architecture to CONFIG
if ((targetAbi.os() == ProjectExplorer::Abi::MacOS)
&& (targetAbi.binaryFormat() == ProjectExplorer::Abi::MachOFormat)) {
if (targetAbi.architecture() == ProjectExplorer::Abi::X86Architecture) {
if (targetAbi.wordWidth() == 32)
arguments << QLatin1String("CONFIG+=x86");
else if (targetAbi.wordWidth() == 64)
arguments << QLatin1String("CONFIG+=x86_64");
const char IOSQT[] = "Qt4ProjectManager.QtVersion.Ios"; // from Ios::Constants (include header?)
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit());
if (version && version->type() == QLatin1String(IOSQT))
arguments << QLatin1String("CONFIG+=iphonesimulator");
} else if (targetAbi.architecture() == ProjectExplorer::Abi::PowerPCArchitecture) {
if (targetAbi.wordWidth() == 32)
arguments << QLatin1String("CONFIG+=ppc");
else if (targetAbi.wordWidth() == 64)
arguments << QLatin1String("CONFIG+=ppc64");
} else if (targetAbi.architecture() == ProjectExplorer::Abi::ArmArchitecture) {
arguments << QLatin1String("CONFIG+=iphoneos");
}
}
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit());
arguments << QmakeBuildConfiguration::deduceArgumnetsForTargetAbi(targetAbi, version);
if (linkQmlDebuggingLibrary() && version) {
arguments << QLatin1String(Constants::QMAKEVAR_QUICK1_DEBUG);
if (version->qtVersion().majorVersion >= 5)
......
......@@ -478,19 +478,6 @@ QStringList BaseQtVersion::warningReason() const
return ret;
}
ToolChain *BaseQtVersion::preferredToolChain(const FileName &ms) const
{
const FileName spec = ms.isEmpty() ? mkspec() : ms;
QList<ToolChain *> toolchains = ToolChainManager::toolChains();
return Utils::findOr(toolchains,
toolchains.isEmpty() ? 0 : toolchains.first(),
[&spec, this](ToolChain *tc) {
return qtAbis().contains(tc->targetAbi())
&& tc->suggestedMkspecList().contains(spec);
});
}
FileName BaseQtVersion::qmakeCommand() const
{
return m_qmakeCommand;
......
......@@ -108,8 +108,6 @@ public:
virtual QString invalidReason() const;
virtual QStringList warningReason() const;
virtual ProjectExplorer::ToolChain *preferredToolChain(const Utils::FileName &ms) const;
virtual QString description() const = 0;
virtual QString toHtml(bool verbose) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment