forked from qt-creator/qt-creator
Qbs: Allow setting of properties
This enables support for e.g. setting CFLAGS, custom defines, etc. Task-number: QTCREATORBUG-9380 Change-Id: I9d4a560ac5ba8a40c51c15fdf8009c0dba5eeef1 Reviewed-by: Eike Ziller <eike.ziller@digia.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
#include <qbs.h>
|
||||
|
||||
@@ -332,7 +333,8 @@ void QbsBuildStep::setMaxJobs(int jobcount)
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
QbsBuildStepConfigWidget::QbsBuildStepConfigWidget(QbsBuildStep *step) :
|
||||
m_step(step)
|
||||
m_step(step),
|
||||
m_ignoreChange(false)
|
||||
{
|
||||
connect(m_step, SIGNAL(displayNameChanged()), this, SLOT(updateState()));
|
||||
connect(m_step, SIGNAL(qbsConfigurationChanged()), this, SLOT(updateState()));
|
||||
@@ -348,6 +350,7 @@ QbsBuildStepConfigWidget::QbsBuildStepConfigWidget(QbsBuildStep *step) :
|
||||
connect(m_ui->dryRunCheckBox, SIGNAL(toggled(bool)), this, SLOT(changeDryRun(bool)));
|
||||
connect(m_ui->keepGoingCheckBox, SIGNAL(toggled(bool)), this, SLOT(changeKeepGoing(bool)));
|
||||
connect(m_ui->jobSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeJobCount(int)));
|
||||
connect(m_ui->propertyEdit, SIGNAL(propertiesChanged()), this, SLOT(changeProperties()));
|
||||
|
||||
updateState();
|
||||
}
|
||||
@@ -364,9 +367,12 @@ QString QbsBuildStepConfigWidget::displayName() const
|
||||
|
||||
void QbsBuildStepConfigWidget::updateState()
|
||||
{
|
||||
m_ui->dryRunCheckBox->setChecked(m_step->dryRun());
|
||||
m_ui->keepGoingCheckBox->setChecked(m_step->keepGoing());
|
||||
m_ui->jobSpinBox->setValue(m_step->maxJobs());
|
||||
if (!m_ignoreChange) {
|
||||
m_ui->dryRunCheckBox->setChecked(m_step->dryRun());
|
||||
m_ui->keepGoingCheckBox->setChecked(m_step->keepGoing());
|
||||
m_ui->jobSpinBox->setValue(m_step->maxJobs());
|
||||
updatePropertyEdit(m_step->qbsConfiguration());
|
||||
}
|
||||
|
||||
const QString buildVariant = m_step->buildVariant();
|
||||
const int idx = (buildVariant == QLatin1String(Constants::QBS_VARIANT_DEBUG)) ? 0 : 1;
|
||||
@@ -380,13 +386,34 @@ void QbsBuildStepConfigWidget::updateState()
|
||||
command += QString::fromLatin1("--jobs %1 ").arg(m_step->maxJobs());
|
||||
command += QString::fromLatin1("profile:%1 %2").arg(m_step->profile(), buildVariant);
|
||||
|
||||
QList<QPair<QString, QString> > propertyList = m_ui->propertyEdit->properties();
|
||||
for (int i = 0; i < propertyList.count(); ++i) {
|
||||
command += QLatin1Char(' ') + propertyList.at(i).first
|
||||
+ QLatin1Char(':') + propertyList.at(i).second;
|
||||
}
|
||||
|
||||
QString summary = tr("<b>Qbs:</b> %1").arg(command);
|
||||
if (m_summary != summary) {
|
||||
if (m_summary != summary) {
|
||||
m_summary = summary;
|
||||
emit updateSummary();
|
||||
}
|
||||
}
|
||||
|
||||
void QbsBuildStepConfigWidget::updatePropertyEdit(const QVariantMap &data)
|
||||
{
|
||||
QVariantMap editable = data;
|
||||
|
||||
// remove data that is edited with special UIs:
|
||||
editable.remove(QLatin1String(Constants::QBS_CONFIG_PROFILE_KEY));
|
||||
editable.remove(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY));
|
||||
|
||||
QStringList propertyList;
|
||||
for (QVariantMap::const_iterator i = editable.constBegin(); i != editable.constEnd(); ++i)
|
||||
propertyList.append(i.key() + QLatin1Char(':') + i.value().toString());
|
||||
|
||||
m_ui->propertyEdit->setText(Utils::QtcProcess::joinArgs(propertyList));
|
||||
}
|
||||
|
||||
void QbsBuildStepConfigWidget::changeBuildVariant(int idx)
|
||||
{
|
||||
QString variant;
|
||||
@@ -394,22 +421,49 @@ void QbsBuildStepConfigWidget::changeBuildVariant(int idx)
|
||||
variant = QLatin1String(Constants::QBS_VARIANT_RELEASE);
|
||||
else
|
||||
variant = QLatin1String(Constants::QBS_VARIANT_DEBUG);
|
||||
m_ignoreChange = true;
|
||||
m_step->setBuildVariant(variant);
|
||||
m_ignoreChange = false;
|
||||
}
|
||||
|
||||
void QbsBuildStepConfigWidget::changeDryRun(bool dr)
|
||||
{
|
||||
m_ignoreChange = true;
|
||||
m_step->setDryRun(dr);
|
||||
m_ignoreChange = false;
|
||||
}
|
||||
|
||||
void QbsBuildStepConfigWidget::changeKeepGoing(bool kg)
|
||||
{
|
||||
m_ignoreChange = true;
|
||||
m_step->setKeepGoing(kg);
|
||||
m_ignoreChange = false;
|
||||
}
|
||||
|
||||
void QbsBuildStepConfigWidget::changeJobCount(int count)
|
||||
{
|
||||
m_ignoreChange = true;
|
||||
m_step->setMaxJobs(count);
|
||||
m_ignoreChange = false;
|
||||
}
|
||||
|
||||
void QbsBuildStepConfigWidget::changeProperties()
|
||||
{
|
||||
QVariantMap data;
|
||||
QVariantMap tmp = m_step->qbsConfiguration();
|
||||
|
||||
// Insert values set up with special UIs:
|
||||
data.insert(QLatin1String(Constants::QBS_CONFIG_PROFILE_KEY),
|
||||
tmp.value(QLatin1String(Constants::QBS_CONFIG_PROFILE_KEY)));
|
||||
data.insert(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY),
|
||||
tmp.value(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY)));
|
||||
QList<QPair<QString, QString> > propertyList = m_ui->propertyEdit->properties();
|
||||
for (int i = 0; i < propertyList.count(); ++i)
|
||||
data.insert(propertyList.at(i).first, propertyList.at(i).second);
|
||||
|
||||
m_ignoreChange = true;
|
||||
m_step->setQbsConfiguration(data);
|
||||
m_ignoreChange = false;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
@@ -118,17 +118,20 @@ public:
|
||||
|
||||
private slots:
|
||||
void updateState();
|
||||
void updatePropertyEdit(const QVariantMap &data);
|
||||
|
||||
void changeBuildVariant(int);
|
||||
void changeDryRun(bool dr);
|
||||
void changeKeepGoing(bool kg);
|
||||
void changeJobCount(int count);
|
||||
void changeProperties();
|
||||
|
||||
private:
|
||||
Ui::QbsBuildStepConfigWidget *m_ui;
|
||||
|
||||
QbsBuildStep *m_step;
|
||||
QString m_summary;
|
||||
bool m_ignoreChange;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -6,11 +6,11 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>428</width>
|
||||
<height>102</height>
|
||||
<width>281</width>
|
||||
<height>79</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@@ -23,61 +23,70 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="buildVariantLabel">
|
||||
<property name="text">
|
||||
<string>Build variant:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="buildVariantComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Debug</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Release</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="jobSpinBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>jobs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<property name="horizontalSpacing">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="buildVariantLabel">
|
||||
<property name="text">
|
||||
<string>Build variant:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="buildVariantComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Debug</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Release</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QSpinBox" name="jobSpinBox"/>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="jobsLabel">
|
||||
<property name="text">
|
||||
<string>jobs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<spacer name="spacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>15</width>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="propertyLabel">
|
||||
<property name="text">
|
||||
<string>Properties:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="4">
|
||||
<widget class="QbsPropertyLineEdit" name="propertyEdit"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="5">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="dryRunCheckBox">
|
||||
@@ -94,14 +103,14 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<spacer name="checkBoxSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
@@ -110,6 +119,13 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QbsPropertyLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>qbspropertylineedit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@@ -29,6 +29,7 @@ HEADERS = \
|
||||
qbsprojectmanager_global.h \
|
||||
qbsprojectmanagerconstants.h \
|
||||
qbsprojectmanagerplugin.h \
|
||||
qbspropertylineedit.h \
|
||||
qbsrunconfiguration.h \
|
||||
qbsstep.h
|
||||
|
||||
@@ -46,6 +47,7 @@ SOURCES = \
|
||||
qbsprojectfile.cpp \
|
||||
qbsprojectmanager.cpp \
|
||||
qbsprojectmanagerplugin.cpp \
|
||||
qbspropertylineedit.cpp \
|
||||
qbsrunconfiguration.cpp \
|
||||
qbsstep.cpp
|
||||
|
||||
|
@@ -79,6 +79,8 @@ QtcPlugin {
|
||||
"qbsprojectmanagerconstants.h",
|
||||
"qbsprojectmanagerplugin.cpp",
|
||||
"qbsprojectmanagerplugin.h",
|
||||
"qbspropertylineedit.cpp",
|
||||
"qbspropertylineedit.h",
|
||||
"qbsrunconfiguration.cpp",
|
||||
"qbsrunconfiguration.h",
|
||||
"qbsstep.cpp",
|
||||
|
83
src/plugins/qbsprojectmanager/qbspropertylineedit.cpp
Normal file
83
src/plugins/qbsprojectmanager/qbspropertylineedit.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qbspropertylineedit.h"
|
||||
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
namespace QbsProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
QbsPropertyLineEdit::QbsPropertyLineEdit(QWidget *parent) :
|
||||
Utils::BaseValidatingLineEdit(parent)
|
||||
{ }
|
||||
|
||||
QList<QPair<QString, QString> > QbsPropertyLineEdit::properties() const
|
||||
{
|
||||
return m_propertyCache;
|
||||
}
|
||||
|
||||
bool QbsPropertyLineEdit::validate(const QString &value, QString *errorMessage) const
|
||||
{
|
||||
Utils::QtcProcess::SplitError err;
|
||||
QStringList argList = Utils::QtcProcess::splitArgs(value, false, &err);
|
||||
if (err != Utils::QtcProcess::SplitOk) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("Could not split properties.");
|
||||
return false;
|
||||
}
|
||||
|
||||
QList<QPair<QString, QString> > properties;
|
||||
foreach (const QString &arg, argList) {
|
||||
int pos = arg.indexOf(QLatin1Char(':'));
|
||||
QString key;
|
||||
QString value;
|
||||
if (pos > 0) {
|
||||
key = arg.left(pos);
|
||||
value = arg.mid(pos + 1);
|
||||
properties.append(qMakePair(key, value));
|
||||
} else {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("No ':' found in property definition.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_propertyCache != properties) {
|
||||
m_propertyCache = properties;
|
||||
emit propertiesChanged();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QbsProjectManager
|
||||
|
62
src/plugins/qbsprojectmanager/qbspropertylineedit.h
Normal file
62
src/plugins/qbsprojectmanager/qbspropertylineedit.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QBSPROPERTYLINEEDIT_H
|
||||
#define QBSPROPERTYLINEEDIT_H
|
||||
|
||||
#include <utils/basevalidatinglineedit.h>
|
||||
|
||||
#include <QList>
|
||||
#include <QPair>
|
||||
|
||||
namespace QbsProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class QbsPropertyLineEdit : public Utils::BaseValidatingLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QbsPropertyLineEdit(QWidget *parent = 0);
|
||||
|
||||
QList<QPair<QString, QString> > properties() const;
|
||||
|
||||
signals:
|
||||
void propertiesChanged() const;
|
||||
|
||||
private:
|
||||
bool validate(const QString &value, QString *errorMessage) const;
|
||||
|
||||
mutable QList<QPair<QString, QString> > m_propertyCache;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QbsProjectManager
|
||||
|
||||
#endif // QBSPROPERTYLINEEDIT_H
|
Reference in New Issue
Block a user