QtSupport: Introduce QtQuickCompilerAspect

... and use it in the qbs build configuration

Change-Id: I53ef4fb8c267e2b4e033c01604bc5b7770b57777
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2019-11-25 16:38:35 +01:00
parent 9e2484052d
commit 572af85224
9 changed files with 103 additions and 6 deletions

View File

@@ -581,6 +581,7 @@ BuildConfiguration *BuildConfigurationFactory::create(Target *parent, const Buil
bc->d->m_initialBuildDirectory = info.buildDirectory; bc->d->m_initialBuildDirectory = info.buildDirectory;
bc->d->m_extraInfo = info.extraInfo; bc->d->m_extraInfo = info.extraInfo;
bc->acquaintAspects();
bc->initialize(); bc->initialize();
return bc; return bc;
@@ -596,6 +597,7 @@ BuildConfiguration *BuildConfigurationFactory::restore(Target *parent, const QVa
if (!id.name().startsWith(factory->m_buildConfigId.name())) if (!id.name().startsWith(factory->m_buildConfigId.name()))
continue; continue;
BuildConfiguration *bc = factory->m_creator(parent); BuildConfiguration *bc = factory->m_creator(parent);
bc->acquaintAspects();
QTC_ASSERT(bc, return nullptr); QTC_ASSERT(bc, return nullptr);
if (!bc->fromMap(map)) { if (!bc->fromMap(map)) {
delete bc; delete bc;

View File

@@ -96,6 +96,11 @@ QbsBuildConfiguration::QbsBuildConfiguration(Target *target, Core::Id id)
connect(qmlDebuggingAspect, &QtSupport::QmlDebuggingAspect::changed, connect(qmlDebuggingAspect, &QtSupport::QmlDebuggingAspect::changed,
this, &QbsBuildConfiguration::qbsConfigurationChanged); this, &QbsBuildConfiguration::qbsConfigurationChanged);
const auto qtQuickCompilerAspect = addAspect<QtSupport::QtQuickCompilerAspect>();
qtQuickCompilerAspect->setKit(target->kit());
connect(qtQuickCompilerAspect, &QtSupport::QtQuickCompilerAspect::changed,
this, &QbsBuildConfiguration::qbsConfigurationChanged);
connect(this, &BuildConfiguration::environmentChanged, connect(this, &BuildConfiguration::environmentChanged,
this, &QbsBuildConfiguration::triggerReparseIfActive); this, &QbsBuildConfiguration::triggerReparseIfActive);
connect(this, &BuildConfiguration::buildDirectoryChanged, connect(this, &BuildConfiguration::buildDirectoryChanged,
@@ -386,6 +391,11 @@ BaseTriStateAspect::Value QbsBuildConfiguration::qmlDebuggingSetting() const
return aspect<QtSupport::QmlDebuggingAspect>()->setting(); return aspect<QtSupport::QmlDebuggingAspect>()->setting();
} }
BaseTriStateAspect::Value QbsBuildConfiguration::qtQuickCompilerSetting() const
{
return aspect<QtSupport::QtQuickCompilerAspect>()->setting();
}
BaseTriStateAspect::Value QbsBuildConfiguration::separateDebugInfoSetting() const BaseTriStateAspect::Value QbsBuildConfiguration::separateDebugInfoSetting() const
{ {
return aspect<SeparateDebugInfoAspect>()->setting(); return aspect<SeparateDebugInfoAspect>()->setting();

View File

@@ -78,7 +78,7 @@ public:
bool isQmlDebuggingEnabled() const; bool isQmlDebuggingEnabled() const;
QtSupport::QmlDebuggingAspect::Value qmlDebuggingSetting() const; QtSupport::QmlDebuggingAspect::Value qmlDebuggingSetting() const;
QtSupport::QtQuickCompilerAspect::Value qtQuickCompilerSetting() const;
ProjectExplorer::SeparateDebugInfoAspect::Value separateDebugInfoSetting() const; ProjectExplorer::SeparateDebugInfoAspect::Value separateDebugInfoSetting() const;
signals: signals:

View File

@@ -236,6 +236,17 @@ QVariantMap QbsBuildStep::qbsConfiguration(VariableHandling variableHandling) co
config.remove(Constants::QBS_CONFIG_QUICK_DEBUG_KEY); config.remove(Constants::QBS_CONFIG_QUICK_DEBUG_KEY);
break; break;
} }
switch (qbsBuildConfig->qtQuickCompilerSetting()) {
case QtSupport::QtQuickCompilerAspect::Value::Enabled:
config.insert(Constants::QBS_CONFIG_QUICK_COMPILER_KEY, true);
break;
case QtSupport::QtQuickCompilerAspect::Value::Disabled:
config.insert(Constants::QBS_CONFIG_QUICK_COMPILER_KEY, false);
break;
default:
config.remove(Constants::QBS_CONFIG_QUICK_COMPILER_KEY);
break;
}
if (variableHandling == ExpandVariables) { if (variableHandling == ExpandVariables) {
const MacroExpander * const expander = buildConfiguration()->macroExpander(); const MacroExpander * const expander = buildConfiguration()->macroExpander();
for (auto it = config.begin(), end = config.end(); it != end; ++it) { for (auto it = config.begin(), end = config.end(); it != end; ++it) {
@@ -706,6 +717,16 @@ void QbsBuildStepConfigWidget::updateState()
default: default:
break; break;
} }
switch (qbsBuildConfig->qtQuickCompilerSetting()) {
case QtSupport::QtQuickCompilerAspect::Value::Enabled:
command.append(' ').append(Constants::QBS_CONFIG_QUICK_COMPILER_KEY).append(":true");
break;
case QtSupport::QtQuickCompilerAspect::Value::Disabled:
command.append(' ').append(Constants::QBS_CONFIG_QUICK_COMPILER_KEY).append(":false");
break;
default:
break;
}
commandLineTextEdit->setPlainText(command); commandLineTextEdit->setPlainText(command);
setSummaryText(tr("<b>Qbs:</b> %1").arg(command)); setSummaryText(tr("<b>Qbs:</b> %1").arg(command));
@@ -722,6 +743,7 @@ void QbsBuildStepConfigWidget::updatePropertyEdit(const QVariantMap &data)
editable.remove(Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY); // For existing .user files editable.remove(Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY); // For existing .user files
editable.remove(Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY); editable.remove(Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY);
editable.remove(Constants::QBS_CONFIG_QUICK_DEBUG_KEY); editable.remove(Constants::QBS_CONFIG_QUICK_DEBUG_KEY);
editable.remove(Constants::QBS_CONFIG_QUICK_COMPILER_KEY);
editable.remove(Constants::QBS_FORCE_PROBES_KEY); editable.remove(Constants::QBS_FORCE_PROBES_KEY);
editable.remove(Constants::QBS_INSTALL_ROOT_KEY); editable.remove(Constants::QBS_INSTALL_ROOT_KEY);
@@ -822,6 +844,7 @@ void QbsBuildStepConfigWidget::applyCachedProperties()
tmp.value(Constants::QBS_CONFIG_VARIANT_KEY)); tmp.value(Constants::QBS_CONFIG_VARIANT_KEY));
const QStringList additionalSpecialKeys({Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY, const QStringList additionalSpecialKeys({Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY,
Constants::QBS_CONFIG_QUICK_DEBUG_KEY, Constants::QBS_CONFIG_QUICK_DEBUG_KEY,
Constants::QBS_CONFIG_QUICK_COMPILER_KEY,
Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY, Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY,
Constants::QBS_INSTALL_ROOT_KEY}); Constants::QBS_INSTALL_ROOT_KEY});
for (const QString &key : additionalSpecialKeys) { for (const QString &key : additionalSpecialKeys) {
@@ -864,8 +887,8 @@ bool QbsBuildStepConfigWidget::validateProperties(Utils::FancyLineEdit *edit, QS
const QString propertyName = rawArg.left(pos); const QString propertyName = rawArg.left(pos);
static const QStringList specialProperties{ static const QStringList specialProperties{
Constants::QBS_CONFIG_PROFILE_KEY, Constants::QBS_CONFIG_VARIANT_KEY, Constants::QBS_CONFIG_PROFILE_KEY, Constants::QBS_CONFIG_VARIANT_KEY,
Constants::QBS_CONFIG_QUICK_DEBUG_KEY, Constants::QBS_INSTALL_ROOT_KEY, Constants::QBS_CONFIG_QUICK_DEBUG_KEY, Constants::QBS_CONFIG_QUICK_COMPILER_KEY,
Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY, Constants::QBS_INSTALL_ROOT_KEY, Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY,
}; };
if (specialProperties.contains(propertyName)) { if (specialProperties.contains(propertyName)) {
if (errorMessage) { if (errorMessage) {

View File

@@ -69,6 +69,7 @@ const char QBS_CONFIG_PROFILE_KEY[] = "qbs.profile";
const char QBS_INSTALL_ROOT_KEY[] = "qbs.installRoot"; const char QBS_INSTALL_ROOT_KEY[] = "qbs.installRoot";
const char QBS_CONFIG_DECLARATIVE_DEBUG_KEY[] = "modules.Qt.declarative.qmlDebugging"; const char QBS_CONFIG_DECLARATIVE_DEBUG_KEY[] = "modules.Qt.declarative.qmlDebugging";
const char QBS_CONFIG_QUICK_DEBUG_KEY[] = "modules.Qt.quick.qmlDebugging"; const char QBS_CONFIG_QUICK_DEBUG_KEY[] = "modules.Qt.quick.qmlDebugging";
const char QBS_CONFIG_QUICK_COMPILER_KEY[] = "modules.Qt.quick.useCompiler";
const char QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY[] = "modules.cpp.separateDebugInformation"; const char QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY[] = "modules.cpp.separateDebugInformation";
const char QBS_FORCE_PROBES_KEY[] = "qbspm.forceProbes"; const char QBS_FORCE_PROBES_KEY[] = "qbspm.forceProbes";

View File

@@ -1966,7 +1966,7 @@ bool BaseQtVersion::isQmlDebuggingSupported(QString *reason) const
return true; return true;
} }
bool BaseQtVersion::isQtQuickCompilerSupported(Kit *k, QString *reason) bool BaseQtVersion::isQtQuickCompilerSupported(const Kit *k, QString *reason)
{ {
QTC_ASSERT(k, return false); QTC_ASSERT(k, return false);
BaseQtVersion *version = QtKitAspect::qtVersion(k); BaseQtVersion *version = QtKitAspect::qtVersion(k);

View File

@@ -176,7 +176,7 @@ public:
static bool isQmlDebuggingSupported(const ProjectExplorer::Kit *k, QString *reason = nullptr); static bool isQmlDebuggingSupported(const ProjectExplorer::Kit *k, QString *reason = nullptr);
bool isQmlDebuggingSupported(QString *reason = nullptr) const; bool isQmlDebuggingSupported(QString *reason = nullptr) const;
static bool isQtQuickCompilerSupported(ProjectExplorer::Kit *k, QString *reason = nullptr); static bool isQtQuickCompilerSupported(const ProjectExplorer::Kit *k, QString *reason = nullptr);
bool isQtQuickCompilerSupported(QString *reason = nullptr) const; bool isQtQuickCompilerSupported(QString *reason = nullptr) const;
QString qmlDumpTool(bool debugVersion) const; QString qmlDumpTool(bool debugVersion) const;

View File

@@ -64,7 +64,7 @@ void QmlDebuggingAspect::addToLayout(LayoutBuilder &builder)
} }
warningTextLabel->setText(warningText); warningTextLabel->setText(warningText);
setVisibleDynamic(supported); setVisibleDynamic(supported);
warningIconLabel->setVisible(supported && !warningText.isEmpty()); warningIconLabel->setVisible(supported && !warningText.isEmpty());
warningTextLabel->setVisible(supported); warningTextLabel->setVisible(supported);
}; };
connect(KitManager::instance(), &KitManager::kitsChanged, builder.layout(), changeHandler); connect(KitManager::instance(), &KitManager::kitsChanged, builder.layout(), changeHandler);
@@ -72,4 +72,49 @@ void QmlDebuggingAspect::addToLayout(LayoutBuilder &builder)
changeHandler(); changeHandler();
} }
QtQuickCompilerAspect::QtQuickCompilerAspect()
{
setSettingsKey("QtQuickCompiler");
setDisplayName(tr("Qt Quick Compiler"));
}
void QtQuickCompilerAspect::addToLayout(LayoutBuilder &builder)
{
BaseSelectionAspect::addToLayout(builder);
const auto warningIconLabel = new QLabel;
warningIconLabel->setAlignment(Qt::AlignTop);
warningIconLabel->setPixmap(Utils::Icons::WARNING.pixmap());
const auto warningTextLabel = new QLabel;
warningTextLabel->setAlignment(Qt::AlignTop);
builder.startNewRow().addItems(QString(), warningIconLabel, warningTextLabel);
const auto changeHandler = [this, warningIconLabel, warningTextLabel] {
QString warningText;
const bool supported = m_kit
&& BaseQtVersion::isQtQuickCompilerSupported(m_kit, &warningText);
if (!supported)
setSetting(Value::Default);
if (setting() == Value::Enabled
&& m_qmlDebuggingAspect && m_qmlDebuggingAspect->setting() == Value::Enabled) {
warningText = tr("Disables QML debugging. QML profiling will still work.");
}
warningTextLabel->setText(warningText);
setVisibleDynamic(supported);
warningIconLabel->setVisible(supported && !warningText.isEmpty());
warningTextLabel->setVisible(supported);
};
connect(KitManager::instance(), &KitManager::kitsChanged, builder.layout(), changeHandler);
connect(this, &QmlDebuggingAspect::changed, builder.layout(), changeHandler);
connect(this, &QtQuickCompilerAspect::changed, builder.layout(), changeHandler);
if (m_qmlDebuggingAspect) {
connect(m_qmlDebuggingAspect, &QmlDebuggingAspect::changed, builder.layout(),
changeHandler);
}
changeHandler();
}
void QtQuickCompilerAspect::acquaintSiblings(const ProjectConfigurationAspects &siblings)
{
m_qmlDebuggingAspect = siblings.aspect<QmlDebuggingAspect>();
}
} // namespace QtSupport } // namespace QtSupport

View File

@@ -45,4 +45,20 @@ private:
const ProjectExplorer::Kit *m_kit = nullptr; const ProjectExplorer::Kit *m_kit = nullptr;
}; };
class QTSUPPORT_EXPORT QtQuickCompilerAspect : public ProjectExplorer::BaseTriStateAspect
{
Q_OBJECT
public:
QtQuickCompilerAspect();
void setKit(const ProjectExplorer::Kit *kit) { m_kit = kit; }
private:
void addToLayout(ProjectExplorer::LayoutBuilder &builder) override;
void acquaintSiblings(const ProjectExplorer::ProjectConfigurationAspects &siblings) override;
const ProjectExplorer::Kit *m_kit = nullptr;
const QmlDebuggingAspect *m_qmlDebuggingAspect = nullptr;
};
} // namespace QtSupport } // namespace QtSupport