forked from qt-creator/qt-creator
QtSupport: Use the new MacroExpander base
Change-Id: I8a3f3d461179ab1abf1704166ad3861645d49f99 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -895,7 +895,11 @@ void BaseQtVersion::parseMkSpec(ProFileEvaluator *evaluator) const
|
|||||||
|
|
||||||
AbstractMacroExpander *BaseQtVersion::createMacroExpander() const
|
AbstractMacroExpander *BaseQtVersion::createMacroExpander() const
|
||||||
{
|
{
|
||||||
return QtKitInformation::createMacroExpander(this);
|
return new MacroExpander([this](const QString &name, QString *ret) -> bool {
|
||||||
|
if (name == QLatin1String("Qt:name"))
|
||||||
|
return false;
|
||||||
|
return QtKitInformation::resolveQtMacro(this, name, ret);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
FileName BaseQtVersion::mkspec() const
|
FileName BaseQtVersion::mkspec() const
|
||||||
|
@@ -40,12 +40,37 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace QtSupport {
|
namespace QtSupport {
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static bool resolveQtMacro(const BaseQtVersion *version, const QString &name, QString *ret)
|
class QtKitInformationMacroExpander : public ProjectExplorer::KitInformationMacroExpander
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QtKitInformationMacroExpander(const ProjectExplorer::Kit *k) :
|
||||||
|
ProjectExplorer::KitInformationMacroExpander(k)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
bool resolveMacro(const QString &name, QString *ret)
|
||||||
|
{
|
||||||
|
return QtKitInformation::resolveQtMacro(QtKitInformation::qtVersion(kit()), name, ret);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
|
||||||
|
QtKitInformation::QtKitInformation()
|
||||||
|
{
|
||||||
|
setObjectName(QLatin1String("QtKitInformation"));
|
||||||
|
setId(QtKitInformation::id());
|
||||||
|
setPriority(26000);
|
||||||
|
|
||||||
|
connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsLoaded()),
|
||||||
|
this, SLOT(kitsWereLoaded()));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QtKitInformation::resolveQtMacro(const BaseQtVersion *version, const QString &name, QString *ret)
|
||||||
{
|
{
|
||||||
const QString noInfo = QCoreApplication::translate("QtSupport::QtKitInformation", "none");
|
const QString noInfo = QCoreApplication::translate("QtSupport::QtKitInformation", "none");
|
||||||
|
|
||||||
@@ -65,50 +90,6 @@ static bool resolveQtMacro(const BaseQtVersion *version, const QString &name, QS
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
class QtVersionMacroExpander : public Utils::AbstractMacroExpander
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QtVersionMacroExpander(const BaseQtVersion *v) :
|
|
||||||
qtVersion(v)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
bool resolveMacro(const QString &name, QString *ret)
|
|
||||||
{
|
|
||||||
if (name == QLatin1String("Qt:name"))
|
|
||||||
return false;
|
|
||||||
return resolveQtMacro(qtVersion, name, ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const BaseQtVersion *qtVersion;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class QtKitInformationMacroExpander : public ProjectExplorer::KitInformationMacroExpander
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QtKitInformationMacroExpander(const ProjectExplorer::Kit *k) :
|
|
||||||
ProjectExplorer::KitInformationMacroExpander(k)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
bool resolveMacro(const QString &name, QString *ret)
|
|
||||||
{
|
|
||||||
return resolveQtMacro(QtKitInformation::qtVersion(kit()), name, ret);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
|
|
||||||
QtKitInformation::QtKitInformation()
|
|
||||||
{
|
|
||||||
setObjectName(QLatin1String("QtKitInformation"));
|
|
||||||
setId(QtKitInformation::id());
|
|
||||||
setPriority(26000);
|
|
||||||
|
|
||||||
connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsLoaded()),
|
|
||||||
this, SLOT(kitsWereLoaded()));
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant QtKitInformation::defaultValue(ProjectExplorer::Kit *k) const
|
QVariant QtKitInformation::defaultValue(ProjectExplorer::Kit *k) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(k);
|
Q_UNUSED(k);
|
||||||
@@ -190,11 +171,6 @@ Utils::AbstractMacroExpander *QtKitInformation::createMacroExpander(const Projec
|
|||||||
return new Internal::QtKitInformationMacroExpander(k);
|
return new Internal::QtKitInformationMacroExpander(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::AbstractMacroExpander *QtKitInformation::createMacroExpander(const BaseQtVersion *v)
|
|
||||||
{
|
|
||||||
return new Internal::QtVersionMacroExpander(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::Id QtKitInformation::id()
|
Core::Id QtKitInformation::id()
|
||||||
{
|
{
|
||||||
return "QtSupport.QtInformation";
|
return "QtSupport.QtInformation";
|
||||||
|
@@ -62,7 +62,7 @@ public:
|
|||||||
|
|
||||||
Utils::AbstractMacroExpander *createMacroExpander(const ProjectExplorer::Kit *k) const;
|
Utils::AbstractMacroExpander *createMacroExpander(const ProjectExplorer::Kit *k) const;
|
||||||
|
|
||||||
static Utils::AbstractMacroExpander *createMacroExpander(const BaseQtVersion *v);
|
static bool resolveQtMacro(const BaseQtVersion *version, const QString &name, QString *ret);
|
||||||
|
|
||||||
static Core::Id id();
|
static Core::Id id();
|
||||||
static int qtVersionId(const ProjectExplorer::Kit *k);
|
static int qtVersionId(const ProjectExplorer::Kit *k);
|
||||||
|
Reference in New Issue
Block a user