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-09-18 12:11:40 +02:00
|
|
|
#include <utils/aspects.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>
|
2020-09-18 12:11:40 +02:00
|
|
|
#include <utils/layoutbuilder.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-09-18 12:11:40 +02:00
|
|
|
#include <utils/variablechooser.h>
|
2018-05-25 15:13:16 +02:00
|
|
|
|
2020-07-09 17:25:55 +02:00
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
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";
|
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
|
|
|
|
2020-09-02 15:46:12 +02:00
|
|
|
MakeStep::MakeStep(BuildStepList *parent, Id id)
|
2020-07-20 17:02:30 +02:00
|
|
|
: AbstractProcessStep(parent, id)
|
2018-05-09 09:48:23 +02:00
|
|
|
{
|
2019-10-09 21:29:12 +03:00
|
|
|
setLowPriority();
|
2020-07-20 17:02:30 +02:00
|
|
|
|
2020-09-14 17:17:55 +02:00
|
|
|
setCommandLineProvider([this] { return effectiveMakeCommand(Execution); });
|
|
|
|
|
|
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
|
|
|
|
2021-03-04 08:03:49 +01:00
|
|
|
m_userJobCountAspect = 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");
|
2021-03-04 08:03:49 +01:00
|
|
|
m_overrideMakeflagsAspect = 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);
|
|
|
|
|
|
2021-03-04 08:03:49 +01:00
|
|
|
m_nonOverrideWarning = addAspect<TextDisplay>();
|
2020-08-14 08:57:23 +02:00
|
|
|
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
|
|
|
|
2021-02-09 12:51:56 +01:00
|
|
|
m_disabledForSubdirsAspect = addAspect<BoolAspect>();
|
|
|
|
|
m_disabledForSubdirsAspect->setSettingsKey(id.withSuffix(".disabledForSubdirs").toString());
|
|
|
|
|
m_disabledForSubdirsAspect->setLabel(tr("Disable in subdirectories:"));
|
|
|
|
|
m_disabledForSubdirsAspect->setToolTip(tr("Runs this step only for a top-level build."));
|
|
|
|
|
|
2020-12-17 13:28:48 +01:00
|
|
|
m_buildTargetsAspect = addAspect<MultiSelectionAspect>();
|
2020-07-20 17:02:30 +02:00
|
|
|
m_buildTargetsAspect->setSettingsKey(id.withSuffix(BUILD_TARGETS_SUFFIX).toString());
|
2020-12-17 13:28:48 +01:00
|
|
|
m_buildTargetsAspect->setLabelText(tr("Targets:"));
|
2020-07-20 17:02:30 +02:00
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2020-12-17 13:28:48 +01:00
|
|
|
void MakeStep::setSelectedBuildTarget(const QString &buildTarget)
|
2019-07-26 13:58:42 +02:00
|
|
|
{
|
2020-12-17 13:28:48 +01:00
|
|
|
m_buildTargetsAspect->setValue({buildTarget});
|
2018-05-09 09:48:23 +02:00
|
|
|
}
|
|
|
|
|
|
2019-07-26 13:58:42 +02:00
|
|
|
void MakeStep::setAvailableBuildTargets(const QStringList &buildTargets)
|
|
|
|
|
{
|
2020-12-17 13:28:48 +01:00
|
|
|
m_buildTargetsAspect->setAllValues(buildTargets);
|
2019-07-26 13:58:42 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-10 15:31:44 +01:00
|
|
|
bool MakeStep::init()
|
2018-05-17 15:58:47 +02:00
|
|
|
{
|
2020-09-14 17:17:55 +02:00
|
|
|
if (!AbstractProcessStep::init())
|
|
|
|
|
return false;
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-14 17:17:55 +02:00
|
|
|
return true;
|
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());
|
2020-09-07 15:56:18 +02:00
|
|
|
formatter->addLineParsers(kit()->createOutputParsers());
|
2020-04-16 13:53:05 +02:00
|
|
|
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
|
|
|
{
|
2020-02-19 11:55:48 +01:00
|
|
|
const Utils::Environment env = makeEnvironment();
|
2020-09-07 15:56:18 +02:00
|
|
|
for (const ToolChain *tc : preferredToolChains(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
|
|
|
|
|
{
|
2020-09-07 15:56:18 +02:00
|
|
|
const QList<ToolChain *> tcs = preferredToolChains(kit());
|
2018-05-25 15:13:16 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2021-02-09 12:51:56 +01:00
|
|
|
bool MakeStep::enabledForSubDirs() const
|
|
|
|
|
{
|
|
|
|
|
return !m_disabledForSubdirsAspect->value();
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2020-10-02 17:53:39 +02:00
|
|
|
QWidget *MakeStep::createConfigWidget()
|
2018-05-09 09:48:23 +02:00
|
|
|
{
|
2020-10-02 17:53:39 +02:00
|
|
|
auto widget = new QWidget;
|
2020-09-02 15:46:12 +02:00
|
|
|
|
|
|
|
|
LayoutBuilder builder(widget);
|
|
|
|
|
builder.addRow(m_makeCommandAspect);
|
|
|
|
|
builder.addRow(m_userArgumentsAspect);
|
2021-03-04 08:03:49 +01:00
|
|
|
builder.addRow({m_userJobCountAspect, m_overrideMakeflagsAspect, m_nonOverrideWarning});
|
2021-02-09 12:51:56 +01:00
|
|
|
if (m_disablingForSubDirsSupported)
|
|
|
|
|
builder.addRow(m_disabledForSubdirsAspect);
|
2020-12-17 13:28:48 +01:00
|
|
|
builder.addRow(m_buildTargetsAspect);
|
2020-09-02 15:46:12 +02:00
|
|
|
|
2020-09-18 12:11:40 +02:00
|
|
|
VariableChooser::addSupportForChildWidgets(widget, macroExpander());
|
2020-07-28 09:20:34 +02:00
|
|
|
|
2020-09-14 12:37:32 +02:00
|
|
|
setSummaryUpdater([this] {
|
2020-07-28 09:20:34 +02:00
|
|
|
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());
|
|
|
|
|
});
|
|
|
|
|
|
2021-02-09 12:51:56 +01:00
|
|
|
auto updateDetails = [this] {
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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-12-17 13:28:48 +01:00
|
|
|
connect(m_buildTargetsAspect, &BaseAspect::changed, widget, updateDetails);
|
2020-07-28 09:20:34 +02:00
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2021-01-06 08:49:48 +01:00
|
|
|
bool MakeStep::buildsTarget(const QString &target) const
|
|
|
|
|
{
|
|
|
|
|
return m_buildTargetsAspect->value().contains(target);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::setBuildTarget(const QString &target, bool on)
|
|
|
|
|
{
|
|
|
|
|
QStringList old = m_buildTargetsAspect->value();
|
|
|
|
|
if (on && !old.contains(target))
|
|
|
|
|
old << target;
|
|
|
|
|
else if (!on && old.contains(target))
|
|
|
|
|
old.removeOne(target);
|
|
|
|
|
|
|
|
|
|
m_buildTargetsAspect->setValue(old);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-09 09:48:23 +02:00
|
|
|
QStringList MakeStep::availableTargets() const
|
|
|
|
|
{
|
2020-12-17 13:28:48 +01:00
|
|
|
return m_buildTargetsAspect->allValues();
|
2018-05-09 09:48:23 +02:00
|
|
|
}
|
|
|
|
|
|
2020-07-09 17:25:55 +02:00
|
|
|
} // namespace ProjectExplorer
|