2018-05-09 09:48:23 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** 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 "buildconfiguration.h"
|
2018-05-17 15:58:47 +02:00
|
|
|
#include "gnumakeparser.h"
|
2018-05-09 09:48:23 +02:00
|
|
|
#include "kitinformation.h"
|
|
|
|
|
#include "project.h"
|
2018-11-17 21:19:04 +02:00
|
|
|
#include "processparameters.h"
|
2018-05-09 09:48:23 +02:00
|
|
|
#include "projectexplorer.h"
|
|
|
|
|
#include "projectexplorerconstants.h"
|
|
|
|
|
#include "target.h"
|
|
|
|
|
#include "toolchain.h"
|
2020-07-20 17:02:30 +02:00
|
|
|
#include "projectconfigurationaspects.h"
|
2018-05-09 09:48:23 +02:00
|
|
|
|
2018-05-14 12:33:08 +02:00
|
|
|
#include <coreplugin/variablechooser.h>
|
2018-11-17 21:19:04 +02:00
|
|
|
#include <utils/environment.h>
|
2018-05-25 15:13:16 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2018-12-18 23:38:07 +02:00
|
|
|
#include <utils/optional.h>
|
2020-07-09 17:25:55 +02:00
|
|
|
#include <utils/pathchooser.h>
|
2018-05-09 09:48:23 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2018-05-25 15:13:16 +02:00
|
|
|
#include <utils/utilsicons.h>
|
|
|
|
|
|
2020-07-09 17:25:55 +02:00
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QListWidget>
|
|
|
|
|
#include <QSpinBox>
|
2018-05-25 15:13:16 +02:00
|
|
|
#include <QThread>
|
2018-05-09 09:48:23 +02:00
|
|
|
|
|
|
|
|
using namespace Core;
|
2019-05-15 10:45:36 +02:00
|
|
|
using namespace Utils;
|
2018-05-09 09:48:23 +02:00
|
|
|
|
|
|
|
|
const char BUILD_TARGETS_SUFFIX[] = ".BuildTargets";
|
|
|
|
|
const char MAKE_ARGUMENTS_SUFFIX[] = ".MakeArguments";
|
|
|
|
|
const char MAKE_COMMAND_SUFFIX[] = ".MakeCommand";
|
|
|
|
|
const char CLEAN_SUFFIX[] = ".Clean";
|
2018-05-25 15:13:16 +02:00
|
|
|
const char OVERRIDE_MAKEFLAGS_SUFFIX[] = ".OverrideMakeflags";
|
|
|
|
|
const char JOBCOUNT_SUFFIX[] = ".JobCount";
|
|
|
|
|
|
|
|
|
|
const char MAKEFLAGS[] = "MAKEFLAGS";
|
2018-05-09 09:48:23 +02:00
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
2020-07-09 17:25:55 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class MakeStepConfigWidget : public BuildStepConfigWidget
|
|
|
|
|
{
|
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(ProjectExplorer::MakeStep)
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit MakeStepConfigWidget(MakeStep *makeStep);
|
|
|
|
|
|
|
|
|
|
QLabel *m_targetsLabel;
|
|
|
|
|
QListWidget *m_targetsList;
|
|
|
|
|
QCheckBox *m_disableInSubDirsCheckBox;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
|
2020-07-28 09:20:34 +02:00
|
|
|
: BuildStepConfigWidget(makeStep)
|
2020-07-09 17:25:55 +02:00
|
|
|
{
|
|
|
|
|
m_targetsLabel = new QLabel(this);
|
|
|
|
|
m_targetsLabel->setText(tr("Targets:"));
|
|
|
|
|
|
|
|
|
|
m_targetsList = new QListWidget(this);
|
|
|
|
|
|
|
|
|
|
auto disableInSubDirsLabel = new QLabel(tr("Disable in subdirectories:"), this);
|
|
|
|
|
m_disableInSubDirsCheckBox = new QCheckBox(this);
|
|
|
|
|
m_disableInSubDirsCheckBox->setToolTip(tr("Runs this step only for a top-level build."));
|
|
|
|
|
|
2020-07-20 17:02:30 +02:00
|
|
|
LayoutBuilder builder(this);
|
2020-08-14 08:57:23 +02:00
|
|
|
builder.addRow(makeStep->m_makeCommandAspect);
|
|
|
|
|
builder.addRow(makeStep->m_userArgumentsAspect);
|
|
|
|
|
builder.addRow(makeStep->m_jobCountContainer);
|
2020-07-20 17:02:30 +02:00
|
|
|
builder.startNewRow().addItems(disableInSubDirsLabel, m_disableInSubDirsCheckBox);
|
|
|
|
|
builder.startNewRow().addItems(m_targetsLabel, m_targetsList);
|
2020-07-09 17:25:55 +02:00
|
|
|
|
|
|
|
|
if (!makeStep->disablingForSubdirsSupported()) {
|
|
|
|
|
disableInSubDirsLabel->hide();
|
|
|
|
|
m_disableInSubDirsCheckBox->hide();
|
|
|
|
|
} else {
|
2020-07-28 09:20:34 +02:00
|
|
|
connect(m_disableInSubDirsCheckBox, &QCheckBox::toggled, this, [this, makeStep] {
|
|
|
|
|
makeStep->setEnabledForSubDirs(!m_disableInSubDirsCheckBox->isChecked());
|
2020-07-09 17:25:55 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const auto availableTargets = makeStep->availableTargets();
|
|
|
|
|
for (const QString &target : availableTargets) {
|
|
|
|
|
auto item = new QListWidgetItem(target, m_targetsList);
|
|
|
|
|
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
2020-07-28 09:20:34 +02:00
|
|
|
item->setCheckState(makeStep->buildsTarget(item->text()) ? Qt::Checked : Qt::Unchecked);
|
2020-07-09 17:25:55 +02:00
|
|
|
}
|
|
|
|
|
if (availableTargets.isEmpty()) {
|
|
|
|
|
m_targetsLabel->hide();
|
|
|
|
|
m_targetsList->hide();
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-28 09:20:34 +02:00
|
|
|
Core::VariableChooser::addSupportForChildWidgets(this, makeStep->macroExpander());
|
2020-07-09 17:25:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
|
2018-05-09 09:48:23 +02:00
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
MakeStep::MakeStep(BuildStepList *parent, Utils::Id id)
|
2020-07-20 17:02:30 +02:00
|
|
|
: AbstractProcessStep(parent, id)
|
2018-05-09 09:48:23 +02:00
|
|
|
{
|
2018-05-17 15:42:38 +02:00
|
|
|
setDefaultDisplayName(defaultDisplayName());
|
2019-10-09 21:29:12 +03:00
|
|
|
setLowPriority();
|
2020-07-20 17:02:30 +02:00
|
|
|
|
2020-08-13 09:16:00 +02:00
|
|
|
m_makeCommandAspect = addAspect<StringAspect>();
|
2020-07-20 17:02:30 +02:00
|
|
|
m_makeCommandAspect->setSettingsKey(id.withSuffix(MAKE_COMMAND_SUFFIX).toString());
|
2020-08-13 09:16:00 +02:00
|
|
|
m_makeCommandAspect->setDisplayStyle(StringAspect::PathChooserDisplay);
|
2020-07-20 17:02:30 +02:00
|
|
|
m_makeCommandAspect->setExpectedKind(PathChooser::ExistingCommand);
|
|
|
|
|
m_makeCommandAspect->setBaseFileName(FilePath::fromString(PathChooser::homePath()));
|
|
|
|
|
m_makeCommandAspect->setHistoryCompleter("PE.MakeCommand.History");
|
|
|
|
|
|
2020-08-13 09:16:00 +02:00
|
|
|
m_userArgumentsAspect = addAspect<StringAspect>();
|
2020-07-20 17:02:30 +02:00
|
|
|
m_userArgumentsAspect->setSettingsKey(id.withSuffix(MAKE_ARGUMENTS_SUFFIX).toString());
|
|
|
|
|
m_userArgumentsAspect->setLabelText(tr("Make arguments:"));
|
2020-08-13 09:16:00 +02:00
|
|
|
m_userArgumentsAspect->setDisplayStyle(StringAspect::LineEditDisplay);
|
2020-07-20 17:02:30 +02:00
|
|
|
|
2020-08-14 08:57:23 +02:00
|
|
|
m_jobCountContainer = addAspect<AspectContainer>();
|
|
|
|
|
|
|
|
|
|
m_userJobCountAspect = m_jobCountContainer->addAspect<IntegerAspect>();
|
2020-07-20 17:02:30 +02:00
|
|
|
m_userJobCountAspect->setSettingsKey(id.withSuffix(JOBCOUNT_SUFFIX).toString());
|
|
|
|
|
m_userJobCountAspect->setLabel(tr("Parallel jobs:"));
|
|
|
|
|
m_userJobCountAspect->setRange(1, 999);
|
|
|
|
|
m_userJobCountAspect->setValue(defaultJobCount());
|
|
|
|
|
m_userJobCountAspect->setDefaultValue(defaultJobCount());
|
|
|
|
|
|
2020-08-14 08:57:23 +02:00
|
|
|
const QString text = tr("Override MAKEFLAGS");
|
|
|
|
|
m_overrideMakeflagsAspect = m_jobCountContainer->addAspect<BoolAspect>();
|
2020-07-20 17:02:30 +02:00
|
|
|
m_overrideMakeflagsAspect->setSettingsKey(id.withSuffix(OVERRIDE_MAKEFLAGS_SUFFIX).toString());
|
2020-08-14 08:57:23 +02:00
|
|
|
m_overrideMakeflagsAspect->setLabel(text, BoolAspect::LabelPlacement::AtCheckBox);
|
|
|
|
|
|
|
|
|
|
m_nonOverrideWarning = m_jobCountContainer->addAspect<TextDisplay>();
|
|
|
|
|
m_nonOverrideWarning->setToolTip("<html><body><p>" +
|
|
|
|
|
tr("<code>MAKEFLAGS</code> specifies parallel jobs. Check \"%1\" to override.")
|
|
|
|
|
.arg(text) + "</p></body></html>");
|
|
|
|
|
m_nonOverrideWarning->setIconType(InfoLabel::Warning);
|
2020-07-20 17:02:30 +02:00
|
|
|
|
2020-08-13 09:16:00 +02:00
|
|
|
m_buildTargetsAspect = addAspect<StringListAspect>();
|
2020-07-20 17:02:30 +02:00
|
|
|
m_buildTargetsAspect->setSettingsKey(id.withSuffix(BUILD_TARGETS_SUFFIX).toString());
|
|
|
|
|
|
|
|
|
|
const auto updateMakeLabel = [this] {
|
|
|
|
|
const QString defaultMake = defaultMakeCommand().toString();
|
|
|
|
|
const QString labelText = defaultMake.isEmpty()
|
|
|
|
|
? tr("Make:")
|
|
|
|
|
: tr("Override %1:").arg(QDir::toNativeSeparators(defaultMake));
|
|
|
|
|
m_makeCommandAspect->setLabelText(labelText);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
updateMakeLabel();
|
2020-07-28 09:20:34 +02:00
|
|
|
|
2020-08-13 09:16:00 +02:00
|
|
|
connect(m_makeCommandAspect, &StringAspect::changed, this, updateMakeLabel);
|
2019-07-26 13:58:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::setBuildTarget(const QString &buildTarget)
|
|
|
|
|
{
|
2018-05-09 09:48:23 +02:00
|
|
|
if (!buildTarget.isEmpty())
|
|
|
|
|
setBuildTarget(buildTarget, true);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-26 13:58:42 +02:00
|
|
|
void MakeStep::setAvailableBuildTargets(const QStringList &buildTargets)
|
|
|
|
|
{
|
|
|
|
|
m_availableTargets = buildTargets;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-10 15:31:44 +01:00
|
|
|
bool MakeStep::init()
|
2018-05-17 15:58:47 +02:00
|
|
|
{
|
2019-10-07 12:08:48 +03:00
|
|
|
const CommandLine make = effectiveMakeCommand(Execution);
|
2019-05-29 17:23:42 +02:00
|
|
|
if (make.executable().isEmpty())
|
2018-05-17 18:13:26 +02:00
|
|
|
emit addTask(makeCommandMissingTask());
|
2018-05-17 15:58:47 +02:00
|
|
|
|
2020-02-20 18:13:48 +01:00
|
|
|
if (make.executable().isEmpty()) {
|
2018-05-17 15:58:47 +02:00
|
|
|
emitFaultyConfigurationMessage();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProcessParameters *pp = processParameters();
|
2020-08-13 12:20:41 +02:00
|
|
|
setupProcessParameters(pp);
|
2019-05-29 17:23:42 +02:00
|
|
|
pp->setCommandLine(make);
|
2018-05-17 15:58:47 +02:00
|
|
|
|
2019-01-10 15:31:44 +01:00
|
|
|
return AbstractProcessStep::init();
|
2018-05-17 15:58:47 +02:00
|
|
|
}
|
|
|
|
|
|
2020-04-16 13:53:05 +02:00
|
|
|
void MakeStep::setupOutputFormatter(OutputFormatter *formatter)
|
|
|
|
|
{
|
|
|
|
|
formatter->addLineParser(new GnuMakeParser());
|
|
|
|
|
formatter->addLineParsers(target()->kit()->createOutputParsers());
|
|
|
|
|
formatter->addSearchDir(processParameters()->effectiveWorkingDirectory());
|
|
|
|
|
AbstractProcessStep::setupOutputFormatter(formatter);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 15:42:38 +02:00
|
|
|
QString MakeStep::defaultDisplayName()
|
|
|
|
|
{
|
|
|
|
|
return tr("Make");
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-24 09:37:15 +02:00
|
|
|
static const QList<ToolChain *> preferredToolChains(const Kit *kit)
|
|
|
|
|
{
|
2019-02-06 12:50:51 +01:00
|
|
|
QList<ToolChain *> tcs = ToolChainKitAspect::toolChains(kit);
|
2018-05-24 09:37:15 +02:00
|
|
|
// prefer CXX, then C, then others
|
|
|
|
|
Utils::sort(tcs, [](ToolChain *tcA, ToolChain *tcB) {
|
|
|
|
|
if (tcA->language() == tcB->language())
|
|
|
|
|
return false;
|
|
|
|
|
if (tcA->language() == Constants::CXX_LANGUAGE_ID)
|
|
|
|
|
return true;
|
|
|
|
|
if (tcB->language() == Constants::CXX_LANGUAGE_ID)
|
|
|
|
|
return false;
|
|
|
|
|
if (tcA->language() == Constants::C_LANGUAGE_ID)
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
return tcs;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
FilePath MakeStep::defaultMakeCommand() const
|
2018-05-17 18:13:26 +02:00
|
|
|
{
|
|
|
|
|
BuildConfiguration *bc = buildConfiguration();
|
2018-05-24 09:37:15 +02:00
|
|
|
if (!bc)
|
2019-05-15 13:59:43 +02:00
|
|
|
return {};
|
2020-02-19 11:55:48 +01:00
|
|
|
const Utils::Environment env = makeEnvironment();
|
2018-05-24 09:37:15 +02:00
|
|
|
for (const ToolChain *tc : preferredToolChains(target()->kit())) {
|
2019-05-28 13:49:26 +02:00
|
|
|
FilePath make = tc->makeCommand(env);
|
2018-05-24 09:37:15 +02:00
|
|
|
if (!make.isEmpty())
|
2019-05-15 13:59:43 +02:00
|
|
|
return make;
|
2018-05-24 09:37:15 +02:00
|
|
|
}
|
2019-05-15 13:59:43 +02:00
|
|
|
return {};
|
2018-05-17 18:13:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MakeStep::msgNoMakeCommand()
|
|
|
|
|
{
|
|
|
|
|
return tr("Make command missing. Specify Make command in step configuration.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Task MakeStep::makeCommandMissingTask()
|
|
|
|
|
{
|
2020-01-15 08:56:11 +01:00
|
|
|
return BuildSystemTask(Task::Error, msgNoMakeCommand());
|
2018-05-17 18:13:26 +02:00
|
|
|
}
|
|
|
|
|
|
2018-05-25 15:13:16 +02:00
|
|
|
bool MakeStep::isJobCountSupported() const
|
|
|
|
|
{
|
|
|
|
|
const QList<ToolChain *> tcs = preferredToolChains(target()->kit());
|
|
|
|
|
const ToolChain *tc = tcs.isEmpty() ? nullptr : tcs.constFirst();
|
2019-03-06 07:34:56 +02:00
|
|
|
return tc && tc->isJobCountSupported();
|
2018-05-25 15:13:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int MakeStep::jobCount() const
|
|
|
|
|
{
|
2020-07-20 17:02:30 +02:00
|
|
|
return m_userJobCountAspect->value();
|
2018-05-25 15:13:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MakeStep::jobCountOverridesMakeflags() const
|
|
|
|
|
{
|
2020-07-20 17:02:30 +02:00
|
|
|
return m_overrideMakeflagsAspect->value();
|
2018-05-25 15:13:16 +02:00
|
|
|
}
|
|
|
|
|
|
2018-12-18 23:38:07 +02:00
|
|
|
static Utils::optional<int> argsJobCount(const QString &str)
|
2018-10-28 12:56:42 +02:00
|
|
|
{
|
|
|
|
|
const QStringList args = Utils::QtcProcess::splitArgs(str, Utils::HostOsInfo::hostOs());
|
2018-12-18 23:38:07 +02:00
|
|
|
const int argIndex = Utils::indexOf(args, [](const QString &arg) { return arg.startsWith("-j"); });
|
|
|
|
|
if (argIndex == -1)
|
|
|
|
|
return Utils::nullopt;
|
|
|
|
|
QString arg = args.at(argIndex);
|
|
|
|
|
bool requireNumber = false;
|
|
|
|
|
// -j [4] as separate arguments (or no value)
|
|
|
|
|
if (arg == "-j") {
|
|
|
|
|
if (args.size() <= argIndex + 1)
|
|
|
|
|
return 1000; // unlimited
|
|
|
|
|
arg = args.at(argIndex + 1);
|
|
|
|
|
} else { // -j4
|
|
|
|
|
arg = arg.mid(2).trimmed();
|
|
|
|
|
requireNumber = true;
|
|
|
|
|
}
|
|
|
|
|
bool ok = false;
|
|
|
|
|
const int res = arg.toInt(&ok);
|
|
|
|
|
if (!ok && requireNumber)
|
|
|
|
|
return Utils::nullopt;
|
|
|
|
|
return Utils::make_optional(ok && res > 0 ? res : 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MakeStep::makeflagsJobCountMismatch() const
|
|
|
|
|
{
|
2020-02-19 11:55:48 +01:00
|
|
|
const Environment env = makeEnvironment();
|
2018-12-18 23:38:07 +02:00
|
|
|
if (!env.hasKey(MAKEFLAGS))
|
|
|
|
|
return false;
|
2019-08-19 14:29:14 +02:00
|
|
|
Utils::optional<int> makeFlagsJobCount = argsJobCount(env.expandedValueForKey(MAKEFLAGS));
|
2020-07-20 17:02:30 +02:00
|
|
|
return makeFlagsJobCount.has_value() && *makeFlagsJobCount != m_userJobCountAspect->value();
|
2018-10-28 12:56:42 +02:00
|
|
|
}
|
|
|
|
|
|
2018-05-25 15:13:16 +02:00
|
|
|
bool MakeStep::makeflagsContainsJobCount() const
|
|
|
|
|
{
|
2020-02-19 11:55:48 +01:00
|
|
|
const Environment env = makeEnvironment();
|
2018-05-25 15:13:16 +02:00
|
|
|
if (!env.hasKey(MAKEFLAGS))
|
|
|
|
|
return false;
|
2019-08-19 14:29:14 +02:00
|
|
|
return argsJobCount(env.expandedValueForKey(MAKEFLAGS)).has_value();
|
2018-10-28 12:56:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MakeStep::userArgsContainsJobCount() const
|
|
|
|
|
{
|
2020-07-20 17:02:30 +02:00
|
|
|
return argsJobCount(userArguments()).has_value();
|
2018-05-25 15:13:16 +02:00
|
|
|
}
|
|
|
|
|
|
2020-02-19 11:55:48 +01:00
|
|
|
Environment MakeStep::makeEnvironment() const
|
2018-05-23 15:33:16 +02:00
|
|
|
{
|
2020-02-19 11:55:48 +01:00
|
|
|
Environment env = buildEnvironment();
|
2018-05-23 15:33:16 +02:00
|
|
|
Utils::Environment::setupEnglishOutput(&env);
|
|
|
|
|
if (makeCommand().isEmpty()) {
|
|
|
|
|
// We also prepend "L" to the MAKEFLAGS, so that nmake / jom are less verbose
|
2018-05-24 09:37:15 +02:00
|
|
|
const QList<ToolChain *> tcs = preferredToolChains(target()->kit());
|
|
|
|
|
const ToolChain *tc = tcs.isEmpty() ? nullptr : tcs.constFirst();
|
2018-05-23 15:33:16 +02:00
|
|
|
if (tc && tc->targetAbi().os() == Abi::WindowsOS
|
|
|
|
|
&& tc->targetAbi().osFlavor() != Abi::WindowsMSysFlavor) {
|
2019-08-19 14:29:14 +02:00
|
|
|
env.set(MAKEFLAGS, 'L' + env.expandedValueForKey(MAKEFLAGS));
|
2018-05-23 15:33:16 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return env;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
void MakeStep::setMakeCommand(const FilePath &command)
|
2018-05-09 09:48:23 +02:00
|
|
|
{
|
2020-07-20 17:02:30 +02:00
|
|
|
m_makeCommandAspect->setFilePath(command);
|
2018-05-09 09:48:23 +02:00
|
|
|
}
|
|
|
|
|
|
2018-05-25 15:13:16 +02:00
|
|
|
int MakeStep::defaultJobCount()
|
|
|
|
|
{
|
|
|
|
|
return QThread::idealThreadCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList MakeStep::jobArguments() const
|
|
|
|
|
{
|
2018-10-28 12:56:42 +02:00
|
|
|
if (!isJobCountSupported() || userArgsContainsJobCount()
|
|
|
|
|
|| (makeflagsContainsJobCount() && !jobCountOverridesMakeflags())) {
|
2018-05-25 15:13:16 +02:00
|
|
|
return {};
|
2018-10-28 12:56:42 +02:00
|
|
|
}
|
2020-07-20 17:02:30 +02:00
|
|
|
return {"-j" + QString::number(m_userJobCountAspect->value())};
|
2018-05-25 15:13:16 +02:00
|
|
|
}
|
|
|
|
|
|
2018-05-09 09:48:23 +02:00
|
|
|
QString MakeStep::userArguments() const
|
|
|
|
|
{
|
2020-07-20 17:02:30 +02:00
|
|
|
return m_userArgumentsAspect->value();
|
2018-05-09 09:48:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::setUserArguments(const QString &args)
|
|
|
|
|
{
|
2020-07-20 17:02:30 +02:00
|
|
|
m_userArgumentsAspect->setValue(args);
|
2018-05-09 09:48:23 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-07 12:08:48 +03:00
|
|
|
QStringList MakeStep::displayArguments() const
|
|
|
|
|
{
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
FilePath MakeStep::makeCommand() const
|
2018-05-09 09:48:23 +02:00
|
|
|
{
|
2020-07-20 17:02:30 +02:00
|
|
|
return m_makeCommandAspect->filePath();
|
2018-05-09 09:48:23 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-07 12:08:48 +03:00
|
|
|
FilePath MakeStep::makeExecutable() const
|
2018-05-09 09:48:23 +02:00
|
|
|
{
|
2020-07-20 17:02:30 +02:00
|
|
|
const FilePath cmd = makeCommand();
|
|
|
|
|
return cmd.isEmpty() ? defaultMakeCommand() : cmd;
|
2019-10-07 12:08:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CommandLine MakeStep::effectiveMakeCommand(MakeCommandType type) const
|
|
|
|
|
{
|
|
|
|
|
CommandLine cmd(makeExecutable());
|
2019-05-29 17:23:42 +02:00
|
|
|
|
2019-10-07 12:08:48 +03:00
|
|
|
if (type == Display)
|
|
|
|
|
cmd.addArgs(displayArguments());
|
2020-07-20 17:02:30 +02:00
|
|
|
cmd.addArgs(userArguments(), CommandLine::Raw);
|
2019-05-29 17:23:42 +02:00
|
|
|
cmd.addArgs(jobArguments());
|
2020-07-20 17:02:30 +02:00
|
|
|
cmd.addArgs(m_buildTargetsAspect->value());
|
2019-05-29 17:23:42 +02:00
|
|
|
|
|
|
|
|
return cmd;
|
2018-05-09 09:48:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildStepConfigWidget *MakeStep::createConfigWidget()
|
|
|
|
|
{
|
2020-07-28 09:20:34 +02:00
|
|
|
auto widget = new Internal::MakeStepConfigWidget(this);
|
|
|
|
|
|
|
|
|
|
widget->setSummaryUpdater([this] {
|
|
|
|
|
const CommandLine make = effectiveMakeCommand(MakeStep::Display);
|
|
|
|
|
if (make.executable().isEmpty())
|
|
|
|
|
return tr("<b>Make:</b> %1").arg(MakeStep::msgNoMakeCommand());
|
|
|
|
|
|
|
|
|
|
if (!buildConfiguration())
|
|
|
|
|
return tr("<b>Make:</b> No build configuration.");
|
|
|
|
|
|
|
|
|
|
ProcessParameters param;
|
|
|
|
|
param.setMacroExpander(macroExpander());
|
|
|
|
|
param.setWorkingDirectory(buildDirectory());
|
|
|
|
|
param.setCommandLine(make);
|
|
|
|
|
param.setEnvironment(buildEnvironment());
|
|
|
|
|
|
|
|
|
|
if (param.commandMissing()) {
|
|
|
|
|
return tr("<b>Make:</b> %1 not found in the environment.")
|
|
|
|
|
.arg(param.command().executable().toUserOutput()); // Override display text
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return param.summaryInWorkdir(displayName());
|
|
|
|
|
});
|
|
|
|
|
|
2020-08-12 18:12:08 +02:00
|
|
|
auto updateDetails = [this, widget = QPointer<Internal::MakeStepConfigWidget>(widget)] {
|
|
|
|
|
QTC_ASSERT(widget, return);
|
2020-07-28 09:20:34 +02:00
|
|
|
const bool jobCountVisible = isJobCountSupported();
|
|
|
|
|
m_userJobCountAspect->setVisible(jobCountVisible);
|
|
|
|
|
m_overrideMakeflagsAspect->setVisible(jobCountVisible);
|
|
|
|
|
|
|
|
|
|
const bool jobCountEnabled = !userArgsContainsJobCount();
|
|
|
|
|
m_userJobCountAspect->setEnabled(jobCountEnabled);
|
|
|
|
|
m_overrideMakeflagsAspect->setEnabled(jobCountEnabled);
|
2020-08-14 08:57:23 +02:00
|
|
|
m_nonOverrideWarning->setVisible(makeflagsJobCountMismatch()
|
|
|
|
|
&& !jobCountOverridesMakeflags());
|
2020-07-28 09:20:34 +02:00
|
|
|
widget->m_disableInSubDirsCheckBox->setChecked(!enabledForSubDirs());
|
|
|
|
|
|
|
|
|
|
widget->recreateSummary();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
updateDetails();
|
|
|
|
|
|
2020-08-13 09:16:00 +02:00
|
|
|
connect(m_makeCommandAspect, &StringAspect::changed, widget, updateDetails);
|
|
|
|
|
connect(m_userArgumentsAspect, &StringAspect::changed, widget, updateDetails);
|
|
|
|
|
connect(m_userJobCountAspect, &IntegerAspect::changed, widget, updateDetails);
|
|
|
|
|
connect(m_overrideMakeflagsAspect, &BoolAspect::changed, widget, updateDetails);
|
2020-07-28 09:20:34 +02:00
|
|
|
|
|
|
|
|
connect(widget->m_targetsList, &QListWidget::itemChanged, this,
|
|
|
|
|
[this, updateDetails](QListWidgetItem *item) {
|
|
|
|
|
setBuildTarget(item->text(), item->checkState() & Qt::Checked);
|
|
|
|
|
updateDetails();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
2020-08-12 18:12:08 +02:00
|
|
|
widget, updateDetails);
|
2020-07-28 09:20:34 +02:00
|
|
|
|
2020-08-12 18:12:08 +02:00
|
|
|
connect(target(), &Target::kitChanged, widget, updateDetails);
|
2020-07-28 09:20:34 +02:00
|
|
|
|
2020-08-12 18:12:08 +02:00
|
|
|
connect(buildConfiguration(), &BuildConfiguration::environmentChanged, widget, updateDetails);
|
|
|
|
|
connect(buildConfiguration(), &BuildConfiguration::buildDirectoryChanged, widget, updateDetails);
|
|
|
|
|
connect(target(), &Target::parsingFinished, widget, updateDetails);
|
2020-07-28 09:20:34 +02:00
|
|
|
|
|
|
|
|
return widget;
|
2018-05-09 09:48:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MakeStep::buildsTarget(const QString &target) const
|
|
|
|
|
{
|
2020-07-20 17:02:30 +02:00
|
|
|
return m_buildTargetsAspect->value().contains(target);
|
2018-05-09 09:48:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::setBuildTarget(const QString &target, bool on)
|
|
|
|
|
{
|
2020-07-20 17:02:30 +02:00
|
|
|
QStringList old = m_buildTargetsAspect->value();
|
2018-05-09 09:48:23 +02:00
|
|
|
if (on && !old.contains(target))
|
|
|
|
|
old << target;
|
|
|
|
|
else if (!on && old.contains(target))
|
|
|
|
|
old.removeOne(target);
|
|
|
|
|
|
2020-07-20 17:02:30 +02:00
|
|
|
m_buildTargetsAspect->setValue(old);
|
2018-05-09 09:48:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList MakeStep::availableTargets() const
|
|
|
|
|
{
|
|
|
|
|
return m_availableTargets;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-09 17:25:55 +02:00
|
|
|
} // namespace ProjectExplorer
|