Commit 51e6fc94 authored by Daniel Teske's avatar Daniel Teske

Fix importing creating additional kits on OS X

Extract the whole makefile parsing code into a separate class, to
make the code more manageable. Also fix some bugs on importing additional
flags like qt quick compiler or separate debug info.

Task-number: QTCREATORBUG-13947
Change-Id: Id04bff191c188f95230274d990b1676e9b2f419d
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@theqtcompany.com>
parent cb42ff0d
This diff is collapsed.
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** 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
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef MAKEFILEPARSE_H
#define MAKEFILEPARSE_H
#include <utils/fileutils.h>
#include <qtsupport/baseqtversion.h>
#include <qmakeprojectmanager/qmakestep.h>
QT_BEGIN_NAMESPACE
class QLogggingCategory;
QT_END_NAMESPACE
namespace QmakeProjectManager {
namespace Internal {
struct QMakeAssignment
{
QString variable;
QString op;
QString value;
};
class MakeFileParse
{
public:
MakeFileParse(const QString &makefile);
enum MakefileState { MakefileMissing, CouldNotParse, Okay };
MakefileState makeFileState() const;
Utils::FileName qmakePath() const;
QString srcProFile() const;
QMakeStepConfig config() const;
QString unparsedArguments() const;
QtSupport::BaseQtVersion::QmakeBuildConfigs
effectiveBuildConfig(QtSupport::BaseQtVersion::QmakeBuildConfigs defaultBuildConfig) const;
static const QLoggingCategory &logging();
private:
void parseArgs(const QString &args, QList<QMakeAssignment> *assignments, QList<QMakeAssignment> *afterAssignments);
void parseAssignments(QList<QMakeAssignment> *assignments);
class QmakeBuildConfig
{
public:
QmakeBuildConfig()
: explicitDebug(false),
explicitRelease(false),
explicitBuildAll(false),
explicitNoBuildAll(false)
{}
bool explicitDebug;
bool explicitRelease;
bool explicitBuildAll;
bool explicitNoBuildAll;
};
MakefileState m_state;
Utils::FileName m_qmakePath;
QString m_srcProFile;
QmakeBuildConfig m_qmakeBuildConfig;
QMakeStepConfig m_config;
QString m_unparsedArguments;
};
} // namespace Internal
} // namespace QmakeProjectManager
#endif // MAKEFILEPARSE_H
......@@ -92,12 +92,9 @@ public:
enum MakefileState { MakefileMatches, MakefileForWrongProject, MakefileIncompatible, MakefileMissing };
MakefileState compareToImportFrom(const QString &makefile);
static bool removeQMLInspectorFromArguments(QString *args);
static Utils::FileName extractSpecFromArguments(QString *arguments,
const QString &directory, const QtSupport::BaseQtVersion *version,
QStringList *outArgs = 0);
static QStringList extractDeducedArguments(QString *args);
static QStringList deduceArgumentsForTargetAbi(const ProjectExplorer::Abi &targetAbi, const QtSupport::BaseQtVersion *version);
QVariantMap toMap() const;
......
......@@ -32,6 +32,7 @@
#define QMAKEBUILDINFO_H
#include "qmakebuildconfiguration.h"
#include "qmakestep.h"
#include <projectexplorer/buildinfo.h>
#include <projectexplorer/kitmanager.h>
......@@ -48,6 +49,7 @@ public:
ProjectExplorer::BuildConfiguration::BuildType type;
QString additionalArguments;
QString makefile;
QMakeStepConfig config;
bool operator==(const QmakeBuildInfo &o) {
return displayName == o.displayName
......@@ -55,7 +57,8 @@ public:
&& buildDirectory == o.buildDirectory
&& kitId == o.kitId
&& type == o.type
&& additionalArguments == o.additionalArguments;
&& additionalArguments == o.additionalArguments
&& config == o.config;
}
QList<ProjectExplorer::Task> reportIssues(const QString &projectPath,
......
......@@ -32,6 +32,7 @@
#define QMAKEPROJECTIMPORTER_H
#include <projectexplorer/projectimporter.h>
#include <qmakestep.h>
namespace QtSupport { class BaseQtVersion; }
......@@ -58,7 +59,8 @@ public:
private:
ProjectExplorer::Kit *createTemporaryKit(QtSupport::BaseQtVersion *version,
bool temporaryVersion,
const Utils::FileName &parsedSpec, const QStringList &deducedQmakeArguments);
const Utils::FileName &parsedSpec,
const QmakeProjectManager::QMakeStepConfig::TargetArchConfig &archConfig, const QMakeStepConfig::OsType &osType);
};
} // namespace Internal
......
......@@ -51,7 +51,8 @@ HEADERS += \
findqmakeprofiles.h \
qmakeprojectmanager_global.h \
desktopqmakerunconfiguration.h \
profilecompletionassist.h
profilecompletionassist.h \
makefileparse.h
SOURCES += \
qmakekitconfigwidget.cpp \
......@@ -98,6 +99,7 @@ SOURCES += \
findqmakeprofiles.cpp \
desktopqmakerunconfiguration.cpp \
profilecompletionassist.cpp \
makefileparse.cpp
FORMS += makestep.ui \
qmakestep.ui \
......
......@@ -72,11 +72,6 @@ const char QMAKEPROJECT_ID[] = "Qt4ProjectManager.Qt4Project";
// ICONS
const char ICON_QTQUICK_APP[] = ":/wizards/images/qtquickapp.png";
// Env variables
const char QMAKEVAR_QMLJSDEBUGGER_PATH[] = "QMLJSDEBUGGER_PATH";
const char QMAKEVAR_QUICK1_DEBUG[] = "CONFIG+=declarative_debug";
const char QMAKEVAR_QUICK2_DEBUG[] = "CONFIG+=qml_debug";
} // namespace Constants
} // namespace QmakeProjectManager
......
......@@ -49,6 +49,7 @@
#include <qtsupport/debugginghelperbuildtask.h>
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtversionmanager.h>
#include <qtsupport/qtsupportconstants.h>
#include <utils/algorithm.h>
#include <utils/hostosinfo.h>
#include <utils/qtcprocess.h>
......@@ -58,6 +59,7 @@
using namespace QmakeProjectManager;
using namespace QmakeProjectManager::Internal;
using namespace QtSupport;
using namespace ProjectExplorer;
using namespace Utils;
......@@ -154,7 +156,7 @@ QString QMakeStep::allArguments(bool shorted)
// Find out what flags we pass on to qmake
arguments << bc->configCommandLineArguments();
arguments << deducedArguments();
arguments << deducedArguments().toArguments();
QString args = QtcProcess::joinArgs(arguments);
// User arguments
......@@ -162,40 +164,36 @@ QString QMakeStep::allArguments(bool shorted)
return args;
}
///
/// moreArguments,
/// iphoneos/iphonesimulator for ios
/// QMAKE_VAR_QMLJSDEBUGGER_PATH
QStringList QMakeStep::deducedArguments()
QMakeStepConfig QMakeStep::deducedArguments()
{
QStringList arguments;
ProjectExplorer::Kit *kit = target()->kit();
QMakeStepConfig config;
ProjectExplorer::ToolChain *tc
= ProjectExplorer::ToolChainKitInformation::toolChain(target()->kit());
= ProjectExplorer::ToolChainKitInformation::toolChain(kit);
ProjectExplorer::Abi targetAbi;
if (tc)
targetAbi = tc->targetAbi();
// explicitly add architecture to CONFIG
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit());
arguments << QmakeBuildConfiguration::deduceArgumentsForTargetAbi(targetAbi, version);
config.archConfig = QMakeStepConfig::targetArchFor(targetAbi, version);
config.osType = QMakeStepConfig::osTypeFor(targetAbi, version);
if (linkQmlDebuggingLibrary() && version) {
arguments << QLatin1String(Constants::QMAKEVAR_QUICK1_DEBUG);
config.linkQmlDebuggingQQ1 = true;
if (version->qtVersion().majorVersion >= 5)
arguments << QLatin1String(Constants::QMAKEVAR_QUICK2_DEBUG);
config.linkQmlDebuggingQQ2 = true;
}
if (useQtQuickCompiler() && version)
arguments << QLatin1String("CONFIG+=qtquickcompiler");
config.useQtQuickCompiler = true;
if (separateDebugInfo()) {
arguments << QLatin1String("CONFIG+=force_debug_info")
<< QLatin1String("CONFIG+=separate_debug_info");
}
if (separateDebugInfo())
config.separateDebugInfo = true;
return arguments;
return config;
}
bool QMakeStep::init()
{
QmakeBuildConfiguration *qt4bc = qmakeBuildConfiguration();
......@@ -822,3 +820,76 @@ QString QMakeStepFactory::displayNameForId(Core::Id id) const
return tr("qmake");
return QString();
}
QMakeStepConfig::TargetArchConfig QMakeStepConfig::targetArchFor(const Abi &targetAbi, const BaseQtVersion *version)
{
QMakeStepConfig::TargetArchConfig arch = QMakeStepConfig::NoArch;
if (!version || version->type() != QLatin1String(QtSupport::Constants::DESKTOPQT))
return arch;
if ((targetAbi.os() == ProjectExplorer::Abi::MacOS)
&& (targetAbi.binaryFormat() == ProjectExplorer::Abi::MachOFormat)) {
if (targetAbi.architecture() == ProjectExplorer::Abi::X86Architecture) {
if (targetAbi.wordWidth() == 32)
arch = QMakeStepConfig::X86;
else if (targetAbi.wordWidth() == 64)
arch = QMakeStepConfig::X86_64;
} else if (targetAbi.architecture() == ProjectExplorer::Abi::PowerPCArchitecture) {
if (targetAbi.wordWidth() == 32)
arch = QMakeStepConfig::PPC;
else if (targetAbi.wordWidth() == 64)
arch = QMakeStepConfig::PPC64;
}
}
return arch;
}
QMakeStepConfig::OsType QMakeStepConfig::osTypeFor(const ProjectExplorer::Abi &targetAbi, const BaseQtVersion *version)
{
QMakeStepConfig::OsType os = QMakeStepConfig::NoOsType;
const char IOSQT[] = "Qt4ProjectManager.QtVersion.Ios";
if (!version || version->type() != QLatin1String(IOSQT))
return os;
if ((targetAbi.os() == ProjectExplorer::Abi::MacOS)
&& (targetAbi.binaryFormat() == ProjectExplorer::Abi::MachOFormat)) {
if (targetAbi.architecture() == ProjectExplorer::Abi::X86Architecture) {
os = QMakeStepConfig::IphoneSimulator;
} else if (targetAbi.architecture() == ProjectExplorer::Abi::ArmArchitecture) {
os = QMakeStepConfig::IphoneOS;
}
}
return os;
}
QStringList QMakeStepConfig::toArguments() const
{
QStringList arguments;
if (archConfig == X86)
arguments << QLatin1String("CONFIG+=x86");
else if (archConfig == X86_64)
arguments << QLatin1String("CONFIG+=x86_64");
else if (archConfig == PPC)
arguments << QLatin1String("CONFIG+=ppc");
else if (archConfig == PPC64)
arguments << QLatin1String("CONFIG+=ppc64");
if (osType == IphoneSimulator)
arguments << QLatin1String("CONFIG+=iphonesimulator");
else if (osType == IphoneOS)
arguments << QLatin1String("CONFIG+=iphoneos");
if (linkQmlDebuggingQQ1)
arguments << QLatin1String("CONFIG+=declarative_debug");
if (linkQmlDebuggingQQ2)
arguments << QLatin1String("CONFIG+=qml_debug");
if (useQtQuickCompiler)
arguments << QLatin1String("CONFIG+=qtquickcompiler");
if (separateDebugInfo)
arguments << QLatin1String("CONFIG+=force_debug_info")
<< QLatin1String("CONFIG+=separate_debug_info");
return arguments;
}
......@@ -39,11 +39,15 @@
namespace Utils { class FileName; }
namespace ProjectExplorer {
class Abi;
class BuildStep;
class IBuildStepFactory;
class Project;
class Kit;
}
namespace QtSupport { class BaseQtVersion; }
namespace QmakeProjectManager {
class QmakeBuildConfiguration;
class QmakeProject;
......@@ -71,6 +75,56 @@ public:
} // namespace Internal
class QMAKEPROJECTMANAGER_EXPORT QMakeStepConfig
{
public:
enum TargetArchConfig {
NoArch, X86, X86_64, PPC, PPC64
};
enum OsType {
NoOsType, IphoneSimulator, IphoneOS
};
static TargetArchConfig targetArchFor(const ProjectExplorer::Abi &targetAbi, const QtSupport::BaseQtVersion *version);
static OsType osTypeFor(const ProjectExplorer::Abi &targetAbi, const QtSupport::BaseQtVersion *version);
QMakeStepConfig()
: archConfig(NoArch),
osType(NoOsType),
linkQmlDebuggingQQ1(false),
linkQmlDebuggingQQ2(false),
useQtQuickCompiler(false),
separateDebugInfo(false)
{}
QStringList toArguments() const;
// Actual data
TargetArchConfig archConfig;
OsType osType;
bool linkQmlDebuggingQQ1;
bool linkQmlDebuggingQQ2;
bool useQtQuickCompiler;
bool separateDebugInfo;
};
inline bool operator ==(const QMakeStepConfig &a, const QMakeStepConfig &b) {
return std::tie(a.archConfig, a.osType, a.linkQmlDebuggingQQ1, a.linkQmlDebuggingQQ2, a.useQtQuickCompiler, a.separateDebugInfo)
== std::tie(b.archConfig, b.osType, b.linkQmlDebuggingQQ1, b.linkQmlDebuggingQQ2, b.useQtQuickCompiler, b.separateDebugInfo);
}
inline bool operator !=(const QMakeStepConfig &a, const QMakeStepConfig &b) {
return !(a == b);
}
inline QDebug operator<<(QDebug dbg, const QMakeStepConfig &c)
{
dbg << c.archConfig << c.osType << c.linkQmlDebuggingQQ1 << c.linkQmlDebuggingQQ2 << c.useQtQuickCompiler << c.separateDebugInfo;
return dbg;
}
class QMAKEPROJECTMANAGER_EXPORT QMakeStep : public ProjectExplorer::AbstractProcessStep
{
......@@ -100,8 +154,7 @@ public:
// the complete argument line
QString allArguments(bool shorted = false);
// deduced arguments e.g. qmljs debugging
QStringList deducedArguments();
QMakeStepConfig deducedArguments();
// arguments passed to the pro file parser
QStringList parserArguments();
// arguments set by the user
......
This diff is collapsed.
......@@ -66,11 +66,6 @@ public:
static void addVersion(BaseQtVersion *version);
static void removeVersion(BaseQtVersion *version);
enum MakefileCompatible { CouldNotParse, DifferentProject, SameProject };
static MakefileCompatible makefileIsFor(const QString &makefile, const QString &proFile);
static QPair<BaseQtVersion::QmakeBuildConfigs, QString> scanMakeFile(const QString &makefile,
BaseQtVersion::QmakeBuildConfigs defaultBuildConfig);
static Utils::FileName findQMakeBinaryFromMakefile(const QString &directory);
static bool isValidId(int id);
signals:
......
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