forked from qt-creator/qt-creator
Move generic make step to project explorer
As a first step of creating a generic base for the 3 existing implementations. Change-Id: I2456db74cb635316f97a247e2a2b6bdb34931440 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -25,28 +25,13 @@
|
||||
|
||||
#include "genericmakestep.h"
|
||||
#include "genericprojectconstants.h"
|
||||
#include "genericproject.h"
|
||||
#include "ui_genericmakestep.h"
|
||||
#include "genericbuildconfiguration.h"
|
||||
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <projectexplorer/gnumakeparser.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/qtparser.h>
|
||||
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
#include <QDir>
|
||||
|
||||
using namespace Core;
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace GenericProjectManager {
|
||||
@@ -56,17 +41,11 @@ const char GENERIC_MS_ID[] = "GenericProjectManager.GenericMakeStep";
|
||||
const char GENERIC_MS_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("GenericProjectManager::Internal::GenericMakeStep",
|
||||
"Make");
|
||||
|
||||
const char BUILD_TARGETS_KEY[] = "GenericProjectManager.GenericMakeStep.BuildTargets";
|
||||
const char MAKE_ARGUMENTS_KEY[] = "GenericProjectManager.GenericMakeStep.MakeArguments";
|
||||
const char MAKE_COMMAND_KEY[] = "GenericProjectManager.GenericMakeStep.MakeCommand";
|
||||
const char CLEAN_KEY[] = "GenericProjectManager.GenericMakeStep.Clean";
|
||||
|
||||
GenericMakeStep::GenericMakeStep(BuildStepList *parent, const QString &buildTarget)
|
||||
: AbstractProcessStep(parent, GENERIC_MS_ID)
|
||||
: MakeStep(parent, GENERIC_MS_ID, buildTarget, {"all", "clean"})
|
||||
{
|
||||
setDefaultDisplayName(QCoreApplication::translate("GenericProjectManager::Internal::GenericMakeStep",
|
||||
GENERIC_MS_DISPLAY_NAME));
|
||||
setBuildTarget(buildTarget, true);
|
||||
}
|
||||
|
||||
bool GenericMakeStep::init(QList<const BuildStep *> &earlierSteps)
|
||||
@@ -99,7 +78,7 @@ bool GenericMakeStep::init(QList<const BuildStep *> &earlierSteps)
|
||||
// If we are cleaning, then make can fail with an error code, but that doesn't mean
|
||||
// we should stop the clean queue
|
||||
// That is mostly so that rebuild works on an already clean project
|
||||
setIgnoreReturnValue(m_clean);
|
||||
setIgnoreReturnValue(isClean());
|
||||
|
||||
setOutputParser(new GnuMakeParser());
|
||||
IOutputParser *parser = target()->kit()->createOutputParser();
|
||||
@@ -110,199 +89,6 @@ bool GenericMakeStep::init(QList<const BuildStep *> &earlierSteps)
|
||||
return AbstractProcessStep::init(earlierSteps);
|
||||
}
|
||||
|
||||
void GenericMakeStep::setClean(bool clean)
|
||||
{
|
||||
m_clean = clean;
|
||||
}
|
||||
|
||||
bool GenericMakeStep::isClean() const
|
||||
{
|
||||
return m_clean;
|
||||
}
|
||||
|
||||
QVariantMap GenericMakeStep::toMap() const
|
||||
{
|
||||
QVariantMap map(AbstractProcessStep::toMap());
|
||||
|
||||
map.insert(BUILD_TARGETS_KEY, m_buildTargets);
|
||||
map.insert(MAKE_ARGUMENTS_KEY, m_makeArguments);
|
||||
map.insert(MAKE_COMMAND_KEY, m_makeCommand);
|
||||
map.insert(CLEAN_KEY, m_clean);
|
||||
return map;
|
||||
}
|
||||
|
||||
bool GenericMakeStep::fromMap(const QVariantMap &map)
|
||||
{
|
||||
m_buildTargets = map.value(BUILD_TARGETS_KEY).toStringList();
|
||||
m_makeArguments = map.value(MAKE_ARGUMENTS_KEY).toString();
|
||||
m_makeCommand = map.value(MAKE_COMMAND_KEY).toString();
|
||||
m_clean = map.value(CLEAN_KEY).toBool();
|
||||
|
||||
return BuildStep::fromMap(map);
|
||||
}
|
||||
|
||||
QString GenericMakeStep::allArguments() const
|
||||
{
|
||||
QString args = m_makeArguments;
|
||||
Utils::QtcProcess::addArgs(&args, m_buildTargets);
|
||||
return args;
|
||||
}
|
||||
|
||||
QString GenericMakeStep::makeCommand(const Utils::Environment &environment) const
|
||||
{
|
||||
QString command = m_makeCommand;
|
||||
if (command.isEmpty()) {
|
||||
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
||||
if (tc)
|
||||
command = tc->makeCommand(environment);
|
||||
else
|
||||
command = "make";
|
||||
}
|
||||
return command;
|
||||
}
|
||||
|
||||
void GenericMakeStep::run(QFutureInterface<bool> &fi)
|
||||
{
|
||||
AbstractProcessStep::run(fi);
|
||||
}
|
||||
|
||||
BuildStepConfigWidget *GenericMakeStep::createConfigWidget()
|
||||
{
|
||||
return new GenericMakeStepConfigWidget(this);
|
||||
}
|
||||
|
||||
bool GenericMakeStep::immutable() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GenericMakeStep::buildsTarget(const QString &target) const
|
||||
{
|
||||
return m_buildTargets.contains(target);
|
||||
}
|
||||
|
||||
void GenericMakeStep::setBuildTarget(const QString &target, bool on)
|
||||
{
|
||||
QStringList old = m_buildTargets;
|
||||
if (on && !old.contains(target))
|
||||
old << target;
|
||||
else if (!on && old.contains(target))
|
||||
old.removeOne(target);
|
||||
|
||||
m_buildTargets = old;
|
||||
}
|
||||
|
||||
//
|
||||
// GenericMakeStepConfigWidget
|
||||
//
|
||||
|
||||
GenericMakeStepConfigWidget::GenericMakeStepConfigWidget(GenericMakeStep *makeStep) :
|
||||
m_makeStep(makeStep)
|
||||
{
|
||||
m_ui = new Ui::GenericMakeStep;
|
||||
m_ui->setupUi(this);
|
||||
|
||||
const auto pro = static_cast<GenericProject *>(m_makeStep->target()->project());
|
||||
const auto buildTargets = pro->buildTargets();
|
||||
for (const QString &target : buildTargets) {
|
||||
auto item = new QListWidgetItem(target, m_ui->targetsList);
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
item->setCheckState(m_makeStep->buildsTarget(item->text()) ? Qt::Checked : Qt::Unchecked);
|
||||
}
|
||||
|
||||
m_ui->makeLineEdit->setText(m_makeStep->m_makeCommand);
|
||||
m_ui->makeArgumentsLineEdit->setText(m_makeStep->m_makeArguments);
|
||||
updateMakeOverrideLabel();
|
||||
updateDetails();
|
||||
|
||||
connect(m_ui->targetsList, &QListWidget::itemChanged,
|
||||
this, &GenericMakeStepConfigWidget::itemChanged);
|
||||
connect(m_ui->makeLineEdit, &QLineEdit::textEdited,
|
||||
this, &GenericMakeStepConfigWidget::makeLineEditTextEdited);
|
||||
connect(m_ui->makeArgumentsLineEdit, &QLineEdit::textEdited,
|
||||
this, &GenericMakeStepConfigWidget::makeArgumentsLineEditTextEdited);
|
||||
|
||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
||||
this, &GenericMakeStepConfigWidget::updateMakeOverrideLabel);
|
||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
||||
this, &GenericMakeStepConfigWidget::updateDetails);
|
||||
|
||||
connect(m_makeStep->target(), &Target::kitChanged,
|
||||
this, &GenericMakeStepConfigWidget::updateMakeOverrideLabel);
|
||||
|
||||
pro->subscribeSignal(&BuildConfiguration::environmentChanged, this, [this]() {
|
||||
if (static_cast<BuildConfiguration *>(sender())->isActive()) {
|
||||
updateMakeOverrideLabel();
|
||||
updateDetails();
|
||||
}
|
||||
});
|
||||
connect(pro, &Project::activeProjectConfigurationChanged,
|
||||
this, [this](ProjectConfiguration *pc) {
|
||||
if (pc && pc->isActive()) {
|
||||
updateMakeOverrideLabel();
|
||||
updateDetails();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
GenericMakeStepConfigWidget::~GenericMakeStepConfigWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
QString GenericMakeStepConfigWidget::displayName() const
|
||||
{
|
||||
return tr("Make", "GenericMakestep display name.");
|
||||
}
|
||||
|
||||
void GenericMakeStepConfigWidget::updateMakeOverrideLabel()
|
||||
{
|
||||
BuildConfiguration *bc = m_makeStep->buildConfiguration();
|
||||
if (!bc)
|
||||
bc = m_makeStep->target()->activeBuildConfiguration();
|
||||
|
||||
m_ui->makeLabel->setText(tr("Override %1:").arg(QDir::toNativeSeparators(m_makeStep->makeCommand(bc->environment()))));
|
||||
}
|
||||
|
||||
void GenericMakeStepConfigWidget::updateDetails()
|
||||
{
|
||||
BuildConfiguration *bc = m_makeStep->buildConfiguration();
|
||||
if (!bc)
|
||||
bc = m_makeStep->target()->activeBuildConfiguration();
|
||||
|
||||
ProcessParameters param;
|
||||
param.setMacroExpander(bc->macroExpander());
|
||||
param.setWorkingDirectory(bc->buildDirectory().toString());
|
||||
param.setEnvironment(bc->environment());
|
||||
param.setCommand(m_makeStep->makeCommand(bc->environment()));
|
||||
param.setArguments(m_makeStep->allArguments());
|
||||
m_summaryText = param.summary(displayName());
|
||||
emit updateSummary();
|
||||
}
|
||||
|
||||
QString GenericMakeStepConfigWidget::summaryText() const
|
||||
{
|
||||
return m_summaryText;
|
||||
}
|
||||
|
||||
void GenericMakeStepConfigWidget::itemChanged(QListWidgetItem *item)
|
||||
{
|
||||
m_makeStep->setBuildTarget(item->text(), item->checkState() & Qt::Checked);
|
||||
updateDetails();
|
||||
}
|
||||
|
||||
void GenericMakeStepConfigWidget::makeLineEditTextEdited()
|
||||
{
|
||||
m_makeStep->m_makeCommand = m_ui->makeLineEdit->text();
|
||||
updateDetails();
|
||||
}
|
||||
|
||||
void GenericMakeStepConfigWidget::makeArgumentsLineEditTextEdited()
|
||||
{
|
||||
m_makeStep->m_makeArguments = m_ui->makeArgumentsLineEdit->text();
|
||||
updateDetails();
|
||||
}
|
||||
|
||||
//
|
||||
// GenericMakeAllStepFactory
|
||||
//
|
||||
|
||||
@@ -25,70 +25,21 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/abstractprocessstep.h>
|
||||
#include <projectexplorer/makestep.h>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QListWidgetItem);
|
||||
|
||||
namespace GenericProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class GenericMakeStepConfigWidget;
|
||||
|
||||
namespace Ui { class GenericMakeStep; }
|
||||
|
||||
class GenericMakeStep : public ProjectExplorer::AbstractProcessStep
|
||||
class GenericMakeStep : public ProjectExplorer::MakeStep
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class GenericMakeStepConfigWidget;
|
||||
|
||||
public:
|
||||
explicit GenericMakeStep(ProjectExplorer::BuildStepList *parent, const QString &buildTarget = {});
|
||||
|
||||
bool init(QList<const BuildStep *> &earlierSteps) override;
|
||||
void run(QFutureInterface<bool> &fi) override;
|
||||
|
||||
ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override;
|
||||
bool immutable() const override;
|
||||
bool buildsTarget(const QString &target) const;
|
||||
void setBuildTarget(const QString &target, bool on);
|
||||
QString allArguments() const;
|
||||
QString makeCommand(const Utils::Environment &environment) const;
|
||||
|
||||
void setClean(bool clean);
|
||||
bool isClean() const;
|
||||
|
||||
private:
|
||||
QVariantMap toMap() const override;
|
||||
bool fromMap(const QVariantMap &map) override;
|
||||
|
||||
QStringList m_buildTargets;
|
||||
QString m_makeArguments;
|
||||
QString m_makeCommand;
|
||||
bool m_clean = false;
|
||||
};
|
||||
|
||||
class GenericMakeStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GenericMakeStepConfigWidget(GenericMakeStep *makeStep);
|
||||
~GenericMakeStepConfigWidget() override;
|
||||
|
||||
QString displayName() const override;
|
||||
QString summaryText() const override;
|
||||
|
||||
private:
|
||||
void itemChanged(QListWidgetItem *item);
|
||||
void makeLineEditTextEdited();
|
||||
void makeArgumentsLineEditTextEdited();
|
||||
void updateMakeOverrideLabel();
|
||||
void updateDetails();
|
||||
|
||||
Ui::GenericMakeStep *m_ui;
|
||||
GenericMakeStep *m_makeStep;
|
||||
QString m_summaryText;
|
||||
};
|
||||
|
||||
class GenericMakeAllStepFactory : public ProjectExplorer::BuildStepFactory
|
||||
|
||||
@@ -475,12 +475,6 @@ void GenericProject::activeBuildConfigurationWasChanged()
|
||||
refresh(Everything);
|
||||
}
|
||||
|
||||
QStringList GenericProject::buildTargets() const
|
||||
{
|
||||
const QStringList targets = { "all", "clean" };
|
||||
return targets;
|
||||
}
|
||||
|
||||
Project::RestoreResult GenericProject::fromMap(const QVariantMap &map, QString *errorMessage)
|
||||
{
|
||||
const RestoreResult result = Project::fromMap(map, errorMessage);
|
||||
|
||||
@@ -40,8 +40,6 @@ public:
|
||||
explicit GenericProject(const Utils::FileName &filename);
|
||||
~GenericProject() override;
|
||||
|
||||
QStringList buildTargets() const;
|
||||
|
||||
bool addFiles(const QStringList &filePaths);
|
||||
bool removeFiles(const QStringList &filePaths);
|
||||
bool setFiles(const QStringList &filePaths);
|
||||
|
||||
@@ -17,8 +17,6 @@ SOURCES = genericproject.cpp \
|
||||
genericbuildconfiguration.cpp \
|
||||
filesselectionwizardpage.cpp
|
||||
|
||||
FORMS += genericmakestep.ui
|
||||
|
||||
equals(TEST, 1) {
|
||||
SOURCES += genericprojectplugin_test.cpp
|
||||
DEFINES += SRCDIR=\\\"$$PWD\\\"
|
||||
|
||||
@@ -25,7 +25,6 @@ QtcPlugin {
|
||||
"genericbuildconfiguration.h",
|
||||
"genericmakestep.cpp",
|
||||
"genericmakestep.h",
|
||||
"genericmakestep.ui",
|
||||
"genericproject.cpp",
|
||||
"genericproject.h",
|
||||
"genericprojectconstants.h",
|
||||
|
||||
273
src/plugins/projectexplorer/makestep.cpp
Normal file
273
src/plugins/projectexplorer/makestep.cpp
Normal file
@@ -0,0 +1,273 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Contact: https://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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "makestep.h"
|
||||
#include "ui_makestep.h"
|
||||
|
||||
#include "buildconfiguration.h"
|
||||
#include "kitinformation.h"
|
||||
#include "project.h"
|
||||
#include "projectexplorer.h"
|
||||
#include "projectexplorerconstants.h"
|
||||
#include "target.h"
|
||||
#include "toolchain.h"
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
const char BUILD_TARGETS_SUFFIX[] = ".BuildTargets";
|
||||
const char MAKE_ARGUMENTS_SUFFIX[] = ".MakeArguments";
|
||||
const char MAKE_COMMAND_SUFFIX[] = ".MakeCommand";
|
||||
const char CLEAN_SUFFIX[] = ".Clean";
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
MakeStep::MakeStep(BuildStepList *parent,
|
||||
Core::Id id,
|
||||
const QString &buildTarget,
|
||||
const QStringList &availableTargets)
|
||||
: AbstractProcessStep(parent, id),
|
||||
m_availableTargets(availableTargets)
|
||||
{
|
||||
if (!buildTarget.isEmpty())
|
||||
setBuildTarget(buildTarget, true);
|
||||
}
|
||||
|
||||
void MakeStep::setClean(bool clean)
|
||||
{
|
||||
m_clean = clean;
|
||||
}
|
||||
|
||||
bool MakeStep::isClean() const
|
||||
{
|
||||
return m_clean;
|
||||
}
|
||||
|
||||
void MakeStep::setMakeCommand(const QString &command)
|
||||
{
|
||||
m_makeCommand = command;
|
||||
}
|
||||
|
||||
QVariantMap MakeStep::toMap() const
|
||||
{
|
||||
QVariantMap map(AbstractProcessStep::toMap());
|
||||
|
||||
map.insert(id().withSuffix(BUILD_TARGETS_SUFFIX).toString(), m_buildTargets);
|
||||
map.insert(id().withSuffix(MAKE_ARGUMENTS_SUFFIX).toString(), m_makeArguments);
|
||||
map.insert(id().withSuffix(MAKE_COMMAND_SUFFIX).toString(), m_makeCommand);
|
||||
map.insert(id().withSuffix(CLEAN_SUFFIX).toString(), m_clean);
|
||||
return map;
|
||||
}
|
||||
|
||||
bool MakeStep::fromMap(const QVariantMap &map)
|
||||
{
|
||||
m_buildTargets = map.value(id().withSuffix(BUILD_TARGETS_SUFFIX).toString()).toStringList();
|
||||
m_makeArguments = map.value(id().withSuffix(MAKE_ARGUMENTS_SUFFIX).toString()).toString();
|
||||
m_makeCommand = map.value(id().withSuffix(MAKE_COMMAND_SUFFIX).toString()).toString();
|
||||
m_clean = map.value(id().withSuffix(CLEAN_SUFFIX).toString()).toBool();
|
||||
|
||||
return BuildStep::fromMap(map);
|
||||
}
|
||||
|
||||
QString MakeStep::allArguments() const
|
||||
{
|
||||
QString args = m_makeArguments;
|
||||
Utils::QtcProcess::addArgs(&args, m_buildTargets);
|
||||
return args;
|
||||
}
|
||||
|
||||
QString MakeStep::userArguments() const
|
||||
{
|
||||
return m_makeArguments;
|
||||
}
|
||||
|
||||
void MakeStep::setUserArguments(const QString &args)
|
||||
{
|
||||
m_makeArguments = args;
|
||||
}
|
||||
|
||||
QString MakeStep::makeCommand() const
|
||||
{
|
||||
return m_makeCommand;
|
||||
}
|
||||
|
||||
QString MakeStep::makeCommand(const Utils::Environment &environment) const
|
||||
{
|
||||
QString command = m_makeCommand;
|
||||
if (command.isEmpty()) {
|
||||
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
||||
if (tc)
|
||||
command = tc->makeCommand(environment);
|
||||
else
|
||||
command = "make";
|
||||
}
|
||||
return command;
|
||||
}
|
||||
|
||||
BuildStepConfigWidget *MakeStep::createConfigWidget()
|
||||
{
|
||||
return new MakeStepConfigWidget(this);
|
||||
}
|
||||
|
||||
bool MakeStep::immutable() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MakeStep::buildsTarget(const QString &target) const
|
||||
{
|
||||
return m_buildTargets.contains(target);
|
||||
}
|
||||
|
||||
void MakeStep::setBuildTarget(const QString &target, bool on)
|
||||
{
|
||||
QStringList old = m_buildTargets;
|
||||
if (on && !old.contains(target))
|
||||
old << target;
|
||||
else if (!on && old.contains(target))
|
||||
old.removeOne(target);
|
||||
|
||||
m_buildTargets = old;
|
||||
}
|
||||
|
||||
QStringList MakeStep::availableTargets() const
|
||||
{
|
||||
return m_availableTargets;
|
||||
}
|
||||
|
||||
//
|
||||
// GenericMakeStepConfigWidget
|
||||
//
|
||||
|
||||
MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep) :
|
||||
m_makeStep(makeStep)
|
||||
{
|
||||
m_ui = new Internal::Ui::MakeStep;
|
||||
m_ui->setupUi(this);
|
||||
|
||||
const auto availableTargets = makeStep->availableTargets();
|
||||
for (const QString &target : availableTargets) {
|
||||
auto item = new QListWidgetItem(target, m_ui->targetsList);
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
item->setCheckState(m_makeStep->buildsTarget(item->text()) ? Qt::Checked : Qt::Unchecked);
|
||||
}
|
||||
|
||||
m_ui->makeLineEdit->setText(m_makeStep->makeCommand());
|
||||
m_ui->makeArgumentsLineEdit->setText(m_makeStep->userArguments());
|
||||
updateMakeOverrideLabel();
|
||||
updateDetails();
|
||||
|
||||
connect(m_ui->targetsList, &QListWidget::itemChanged,
|
||||
this, &MakeStepConfigWidget::itemChanged);
|
||||
connect(m_ui->makeLineEdit, &QLineEdit::textEdited,
|
||||
this, &MakeStepConfigWidget::makeLineEditTextEdited);
|
||||
connect(m_ui->makeArgumentsLineEdit, &QLineEdit::textEdited,
|
||||
this, &MakeStepConfigWidget::makeArgumentsLineEditTextEdited);
|
||||
|
||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
||||
this, &MakeStepConfigWidget::updateMakeOverrideLabel);
|
||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
||||
this, &MakeStepConfigWidget::updateDetails);
|
||||
|
||||
connect(m_makeStep->target(), &Target::kitChanged,
|
||||
this, &MakeStepConfigWidget::updateMakeOverrideLabel);
|
||||
|
||||
const auto pro = m_makeStep->target()->project();
|
||||
pro->subscribeSignal(&BuildConfiguration::environmentChanged, this, [this]() {
|
||||
if (static_cast<BuildConfiguration *>(sender())->isActive()) {
|
||||
updateMakeOverrideLabel();
|
||||
updateDetails();
|
||||
}
|
||||
});
|
||||
connect(pro, &Project::activeProjectConfigurationChanged,
|
||||
this, [this](ProjectConfiguration *pc) {
|
||||
if (pc && pc->isActive()) {
|
||||
updateMakeOverrideLabel();
|
||||
updateDetails();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
MakeStepConfigWidget::~MakeStepConfigWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
QString MakeStepConfigWidget::displayName() const
|
||||
{
|
||||
return m_makeStep->displayName();
|
||||
}
|
||||
|
||||
void MakeStepConfigWidget::updateMakeOverrideLabel()
|
||||
{
|
||||
BuildConfiguration *bc = m_makeStep->buildConfiguration();
|
||||
if (!bc)
|
||||
bc = m_makeStep->target()->activeBuildConfiguration();
|
||||
|
||||
m_ui->makeLabel->setText(tr("Override %1:").arg(QDir::toNativeSeparators(m_makeStep->makeCommand(bc->environment()))));
|
||||
}
|
||||
|
||||
void MakeStepConfigWidget::updateDetails()
|
||||
{
|
||||
BuildConfiguration *bc = m_makeStep->buildConfiguration();
|
||||
if (!bc)
|
||||
bc = m_makeStep->target()->activeBuildConfiguration();
|
||||
|
||||
ProcessParameters param;
|
||||
param.setMacroExpander(bc->macroExpander());
|
||||
param.setWorkingDirectory(bc->buildDirectory().toString());
|
||||
param.setEnvironment(bc->environment());
|
||||
param.setCommand(m_makeStep->makeCommand(bc->environment()));
|
||||
param.setArguments(m_makeStep->allArguments());
|
||||
m_summaryText = param.summary(displayName());
|
||||
emit updateSummary();
|
||||
}
|
||||
|
||||
QString MakeStepConfigWidget::summaryText() const
|
||||
{
|
||||
return m_summaryText;
|
||||
}
|
||||
|
||||
void MakeStepConfigWidget::itemChanged(QListWidgetItem *item)
|
||||
{
|
||||
m_makeStep->setBuildTarget(item->text(), item->checkState() & Qt::Checked);
|
||||
updateDetails();
|
||||
}
|
||||
|
||||
void MakeStepConfigWidget::makeLineEditTextEdited()
|
||||
{
|
||||
m_makeStep->setMakeCommand(m_ui->makeLineEdit->text());
|
||||
updateDetails();
|
||||
}
|
||||
|
||||
void MakeStepConfigWidget::makeArgumentsLineEditTextEdited()
|
||||
{
|
||||
m_makeStep->setUserArguments(m_ui->makeArgumentsLineEdit->text());
|
||||
updateDetails();
|
||||
}
|
||||
|
||||
} // namespace GenericProjectManager
|
||||
98
src/plugins/projectexplorer/makestep.h
Normal file
98
src/plugins/projectexplorer/makestep.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Contact: https://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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "abstractprocessstep.h"
|
||||
#include "projectexplorer_global.h"
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QListWidgetItem);
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
namespace Internal {
|
||||
namespace Ui { class MakeStep; }
|
||||
} // namespace Internal
|
||||
|
||||
class PROJECTEXPLORER_EXPORT MakeStep : public ProjectExplorer::AbstractProcessStep
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MakeStep(ProjectExplorer::BuildStepList *parent,
|
||||
Core::Id id,
|
||||
const QString &buildTarget = QString(),
|
||||
const QStringList &availableTargets = {});
|
||||
|
||||
ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override;
|
||||
bool immutable() const override;
|
||||
bool buildsTarget(const QString &target) const;
|
||||
void setBuildTarget(const QString &target, bool on);
|
||||
QStringList availableTargets() const;
|
||||
QString allArguments() const;
|
||||
QString userArguments() const;
|
||||
void setUserArguments(const QString &args);
|
||||
QString makeCommand() const;
|
||||
void setMakeCommand(const QString &command);
|
||||
QString makeCommand(const Utils::Environment &environment) const;
|
||||
|
||||
void setClean(bool clean);
|
||||
bool isClean() const;
|
||||
|
||||
private:
|
||||
QVariantMap toMap() const override;
|
||||
bool fromMap(const QVariantMap &map) override;
|
||||
|
||||
QStringList m_buildTargets;
|
||||
QStringList m_availableTargets;
|
||||
QString m_makeArguments;
|
||||
QString m_makeCommand;
|
||||
bool m_clean = false;
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT MakeStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MakeStepConfigWidget(MakeStep *makeStep);
|
||||
~MakeStepConfigWidget() override;
|
||||
|
||||
QString displayName() const override;
|
||||
QString summaryText() const override;
|
||||
|
||||
private:
|
||||
void itemChanged(QListWidgetItem *item);
|
||||
void makeLineEditTextEdited();
|
||||
void makeArgumentsLineEditTextEdited();
|
||||
void updateMakeOverrideLabel();
|
||||
void updateDetails();
|
||||
|
||||
Internal::Ui::MakeStep *m_ui;
|
||||
MakeStep *m_makeStep;
|
||||
QString m_summaryText;
|
||||
};
|
||||
|
||||
} // namespace GenericProjectManager
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GenericProjectManager::Internal::GenericMakeStep</class>
|
||||
<widget class="QWidget" name="GenericProjectManager::Internal::GenericMakeStep">
|
||||
<class>ProjectExplorer::Internal::MakeStep</class>
|
||||
<widget class="QWidget" name="ProjectExplorer::Internal::MakeStep">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@@ -14,7 +14,16 @@
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
@@ -150,7 +150,8 @@ HEADERS += projectexplorer.h \
|
||||
projectexplorer_global.h \
|
||||
extracompiler.h \
|
||||
customexecutablerunconfiguration.h \
|
||||
projectmacro.h
|
||||
projectmacro.h \
|
||||
makestep.h
|
||||
|
||||
SOURCES += projectexplorer.cpp \
|
||||
abi.cpp \
|
||||
@@ -286,7 +287,8 @@ SOURCES += projectexplorer.cpp \
|
||||
projectexplorericons.cpp \
|
||||
extracompiler.cpp \
|
||||
customexecutablerunconfiguration.cpp \
|
||||
projectmacro.cpp
|
||||
projectmacro.cpp \
|
||||
makestep.cpp
|
||||
|
||||
FORMS += processstep.ui \
|
||||
editorsettingspropertiespage.ui \
|
||||
@@ -299,7 +301,8 @@ FORMS += processstep.ui \
|
||||
devicesupport/devicesettingswidget.ui \
|
||||
devicesupport/devicetestdialog.ui \
|
||||
devicesupport/desktopdeviceconfigurationwidget.ui \
|
||||
customparserconfigdialog.ui
|
||||
customparserconfigdialog.ui \
|
||||
makestep.ui
|
||||
|
||||
WINSOURCES += \
|
||||
windebuginterface.cpp \
|
||||
|
||||
@@ -87,6 +87,7 @@ Project {
|
||||
"ldparser.cpp", "ldparser.h",
|
||||
"linuxiccparser.cpp", "linuxiccparser.h",
|
||||
"localenvironmentaspect.cpp", "localenvironmentaspect.h",
|
||||
"makestep.cpp", "makestep.h",
|
||||
"miniprojecttargetselector.cpp", "miniprojecttargetselector.h",
|
||||
"msvcparser.cpp", "msvcparser.h",
|
||||
"namedwidget.cpp", "namedwidget.h",
|
||||
|
||||
Reference in New Issue
Block a user