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 "ui_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"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/id.h>
|
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>
|
2018-05-09 09:48:23 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2018-05-25 15:13:16 +02:00
|
|
|
#include <utils/utilsicons.h>
|
|
|
|
|
|
|
|
|
|
#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 {
|
|
|
|
|
|
2019-07-26 13:58:42 +02:00
|
|
|
MakeStep::MakeStep(BuildStepList *parent, Core::Id id)
|
2018-05-09 09:48:23 +02:00
|
|
|
: AbstractProcessStep(parent, id),
|
2018-05-25 15:13:16 +02:00
|
|
|
m_userJobCount(defaultJobCount())
|
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();
|
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-02-19 11:55:48 +01:00
|
|
|
pp->setMacroExpander(macroExpander());
|
|
|
|
|
pp->setWorkingDirectory(buildDirectory());
|
|
|
|
|
pp->setEnvironment(buildEnvironment());
|
2019-05-29 17:23:42 +02:00
|
|
|
pp->setCommandLine(make);
|
2018-05-17 15:58:47 +02:00
|
|
|
pp->resolveAll();
|
|
|
|
|
|
|
|
|
|
// 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(isClean());
|
|
|
|
|
|
|
|
|
|
setOutputParser(new GnuMakeParser());
|
2020-04-08 17:45:39 +02:00
|
|
|
appendOutputParsers(target()->kit()->createOutputParsers());
|
2020-04-07 13:49:34 +02:00
|
|
|
outputParser()->addSearchDir(pp->effectiveWorkingDirectory());
|
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
|
|
|
}
|
|
|
|
|
|
2018-05-09 09:48:23 +02:00
|
|
|
void MakeStep::setClean(bool clean)
|
|
|
|
|
{
|
|
|
|
|
m_clean = clean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MakeStep::isClean() const
|
|
|
|
|
{
|
|
|
|
|
return m_clean;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
return m_userJobCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::setJobCount(int count)
|
|
|
|
|
{
|
|
|
|
|
m_userJobCount = count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MakeStep::jobCountOverridesMakeflags() const
|
|
|
|
|
{
|
|
|
|
|
return m_overrideMakeflags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::setJobCountOverrideMakeflags(bool override)
|
|
|
|
|
{
|
|
|
|
|
m_overrideMakeflags = override;
|
|
|
|
|
}
|
|
|
|
|
|
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));
|
2018-12-18 23:38:07 +02:00
|
|
|
return makeFlagsJobCount.has_value() && *makeFlagsJobCount != m_userJobCount;
|
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
|
|
|
|
|
{
|
2019-09-21 23:45:17 +03:00
|
|
|
return argsJobCount(m_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
|
|
|
{
|
|
|
|
|
m_makeCommand = command;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap MakeStep::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map(AbstractProcessStep::toMap());
|
|
|
|
|
|
|
|
|
|
map.insert(id().withSuffix(BUILD_TARGETS_SUFFIX).toString(), m_buildTargets);
|
2019-09-21 23:45:17 +03:00
|
|
|
map.insert(id().withSuffix(MAKE_ARGUMENTS_SUFFIX).toString(), m_userArguments);
|
2019-05-15 13:59:43 +02:00
|
|
|
map.insert(id().withSuffix(MAKE_COMMAND_SUFFIX).toString(), m_makeCommand.toString());
|
2018-05-09 09:48:23 +02:00
|
|
|
map.insert(id().withSuffix(CLEAN_SUFFIX).toString(), m_clean);
|
2018-05-25 15:13:16 +02:00
|
|
|
const QString jobCountKey = id().withSuffix(JOBCOUNT_SUFFIX).toString();
|
|
|
|
|
if (m_userJobCount != defaultJobCount())
|
|
|
|
|
map.insert(jobCountKey, m_userJobCount);
|
|
|
|
|
else
|
|
|
|
|
map.remove(jobCountKey);
|
|
|
|
|
map.insert(id().withSuffix(OVERRIDE_MAKEFLAGS_SUFFIX).toString(), m_overrideMakeflags);
|
2018-05-09 09:48:23 +02:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MakeStep::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
m_buildTargets = map.value(id().withSuffix(BUILD_TARGETS_SUFFIX).toString()).toStringList();
|
2019-09-21 23:45:17 +03:00
|
|
|
m_userArguments = map.value(id().withSuffix(MAKE_ARGUMENTS_SUFFIX).toString()).toString();
|
2019-05-28 13:49:26 +02:00
|
|
|
m_makeCommand = FilePath::fromString(
|
2019-05-15 13:59:43 +02:00
|
|
|
map.value(id().withSuffix(MAKE_COMMAND_SUFFIX).toString()).toString());
|
2018-05-09 09:48:23 +02:00
|
|
|
m_clean = map.value(id().withSuffix(CLEAN_SUFFIX).toString()).toBool();
|
2018-05-25 15:13:16 +02:00
|
|
|
m_overrideMakeflags = map.value(id().withSuffix(OVERRIDE_MAKEFLAGS_SUFFIX).toString(), false).toBool();
|
|
|
|
|
m_userJobCount = map.value(id().withSuffix(JOBCOUNT_SUFFIX).toString(), defaultJobCount()).toInt();
|
2018-05-09 09:48:23 +02:00
|
|
|
return BuildStep::fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
2018-05-25 15:13:16 +02:00
|
|
|
return {"-j" + QString::number(m_userJobCount)};
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-09 09:48:23 +02:00
|
|
|
QString MakeStep::userArguments() const
|
|
|
|
|
{
|
2019-09-21 23:45:17 +03:00
|
|
|
return m_userArguments;
|
2018-05-09 09:48:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::setUserArguments(const QString &args)
|
|
|
|
|
{
|
2019-09-21 23:45:17 +03:00
|
|
|
m_userArguments = 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
|
|
|
{
|
|
|
|
|
return m_makeCommand;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-07 12:08:48 +03:00
|
|
|
FilePath MakeStep::makeExecutable() const
|
2018-05-09 09:48:23 +02:00
|
|
|
{
|
2019-10-07 12:08:48 +03:00
|
|
|
return m_makeCommand.isEmpty() ? defaultMakeCommand() : m_makeCommand;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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());
|
2019-09-21 23:45:17 +03:00
|
|
|
cmd.addArgs(m_userArguments, CommandLine::Raw);
|
2019-05-29 17:23:42 +02:00
|
|
|
cmd.addArgs(jobArguments());
|
|
|
|
|
cmd.addArgs(m_buildTargets);
|
|
|
|
|
|
|
|
|
|
return cmd;
|
2018-05-09 09:48:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildStepConfigWidget *MakeStep::createConfigWidget()
|
|
|
|
|
{
|
|
|
|
|
return new MakeStepConfigWidget(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
//
|
|
|
|
|
|
2018-09-20 11:19:41 +02:00
|
|
|
MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
|
|
|
|
|
: BuildStepConfigWidget(makeStep), m_makeStep(makeStep)
|
2018-05-09 09:48:23 +02:00
|
|
|
{
|
|
|
|
|
m_ui = new Internal::Ui::MakeStep;
|
|
|
|
|
m_ui->setupUi(this);
|
|
|
|
|
|
2019-10-07 10:51:53 +02:00
|
|
|
if (!makeStep->disablingForSubdirsSupported()) {
|
|
|
|
|
m_ui->disableInSubDirsLabel->hide();
|
|
|
|
|
m_ui->disableInSubDirsCheckBox->hide();
|
|
|
|
|
} else {
|
|
|
|
|
connect(m_ui->disableInSubDirsCheckBox, &QCheckBox::toggled, this, [this] {
|
|
|
|
|
m_makeStep->setEnabledForSubDirs(!m_ui->disableInSubDirsCheckBox->isChecked());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-09 09:48:23 +02:00
|
|
|
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);
|
|
|
|
|
}
|
2018-05-14 16:39:19 +02:00
|
|
|
if (availableTargets.isEmpty()) {
|
|
|
|
|
m_ui->targetsLabel->hide();
|
|
|
|
|
m_ui->targetsList->hide();
|
|
|
|
|
}
|
2018-05-09 09:48:23 +02:00
|
|
|
|
2018-05-14 12:26:52 +02:00
|
|
|
m_ui->makeLineEdit->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
2019-12-17 11:53:58 +01:00
|
|
|
m_ui->makeLineEdit->setBaseDirectory(FilePath::fromString(PathChooser::homePath()));
|
2018-05-14 12:26:52 +02:00
|
|
|
m_ui->makeLineEdit->setHistoryCompleter("PE.MakeCommand.History");
|
2019-05-15 13:59:43 +02:00
|
|
|
m_ui->makeLineEdit->setPath(m_makeStep->makeCommand().toString());
|
2018-05-09 09:48:23 +02:00
|
|
|
m_ui->makeArgumentsLineEdit->setText(m_makeStep->userArguments());
|
2018-05-25 15:13:16 +02:00
|
|
|
m_ui->nonOverrideWarning->setToolTip("<html><body><p>" +
|
|
|
|
|
tr("<code>MAKEFLAGS</code> specifies parallel jobs. Check \"%1\" to override.")
|
|
|
|
|
.arg(m_ui->overrideMakeflags->text()) + "</p></body></html>");
|
|
|
|
|
m_ui->nonOverrideWarning->setPixmap(Utils::Icons::WARNING.pixmap());
|
2018-05-09 09:48:23 +02:00
|
|
|
updateDetails();
|
|
|
|
|
|
|
|
|
|
connect(m_ui->targetsList, &QListWidget::itemChanged,
|
|
|
|
|
this, &MakeStepConfigWidget::itemChanged);
|
2018-05-14 12:26:52 +02:00
|
|
|
connect(m_ui->makeLineEdit, &Utils::PathChooser::rawPathChanged,
|
2018-05-09 09:48:23 +02:00
|
|
|
this, &MakeStepConfigWidget::makeLineEditTextEdited);
|
|
|
|
|
connect(m_ui->makeArgumentsLineEdit, &QLineEdit::textEdited,
|
|
|
|
|
this, &MakeStepConfigWidget::makeArgumentsLineEditTextEdited);
|
2018-05-29 07:31:22 +02:00
|
|
|
connect(m_ui->userJobCount, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int value) {
|
2018-05-25 15:13:16 +02:00
|
|
|
m_makeStep->setJobCount(value);
|
|
|
|
|
updateDetails();
|
|
|
|
|
});
|
|
|
|
|
connect(m_ui->overrideMakeflags, &QCheckBox::stateChanged, this, [this](int state) {
|
|
|
|
|
m_makeStep->setJobCountOverrideMakeflags(state == Qt::Checked);
|
|
|
|
|
updateDetails();
|
|
|
|
|
});
|
2018-05-09 09:48:23 +02:00
|
|
|
|
|
|
|
|
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
|
|
|
|
this, &MakeStepConfigWidget::updateDetails);
|
|
|
|
|
|
|
|
|
|
connect(m_makeStep->target(), &Target::kitChanged,
|
2018-05-14 14:11:10 +02:00
|
|
|
this, &MakeStepConfigWidget::updateDetails);
|
2018-05-09 09:48:23 +02:00
|
|
|
|
2019-08-02 10:33:35 +02:00
|
|
|
connect(m_makeStep->buildConfiguration(), &BuildConfiguration::environmentChanged,
|
|
|
|
|
this, &MakeStepConfigWidget::updateDetails);
|
|
|
|
|
connect(m_makeStep->buildConfiguration(), &BuildConfiguration::buildDirectoryChanged,
|
|
|
|
|
this, &MakeStepConfigWidget::updateDetails);
|
2019-10-25 09:55:32 +02:00
|
|
|
connect(m_makeStep->target(), &Target::parsingFinished,
|
2019-10-07 12:08:48 +03:00
|
|
|
this, &MakeStepConfigWidget::updateDetails);
|
2019-08-02 10:33:35 +02:00
|
|
|
|
2018-05-14 12:33:08 +02:00
|
|
|
Core::VariableChooser::addSupportForChildWidgets(this, m_makeStep->macroExpander());
|
2018-05-09 09:48:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MakeStepConfigWidget::~MakeStepConfigWidget()
|
|
|
|
|
{
|
|
|
|
|
delete m_ui;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-25 15:13:16 +02:00
|
|
|
void MakeStepConfigWidget::setUserJobCountVisible(bool visible)
|
|
|
|
|
{
|
|
|
|
|
m_ui->jobsLabel->setVisible(visible);
|
|
|
|
|
m_ui->userJobCount->setVisible(visible);
|
|
|
|
|
m_ui->overrideMakeflags->setVisible(visible);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-28 12:56:42 +02:00
|
|
|
void MakeStepConfigWidget::setUserJobCountEnabled(bool enabled)
|
|
|
|
|
{
|
|
|
|
|
m_ui->jobsLabel->setEnabled(enabled);
|
|
|
|
|
m_ui->userJobCount->setEnabled(enabled);
|
|
|
|
|
m_ui->overrideMakeflags->setEnabled(enabled);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-09 09:48:23 +02:00
|
|
|
void MakeStepConfigWidget::updateDetails()
|
|
|
|
|
{
|
|
|
|
|
BuildConfiguration *bc = m_makeStep->buildConfiguration();
|
|
|
|
|
|
2019-05-15 13:59:43 +02:00
|
|
|
const QString defaultMake = m_makeStep->defaultMakeCommand().toString();
|
2018-05-17 18:13:26 +02:00
|
|
|
if (defaultMake.isEmpty())
|
2018-05-14 14:11:10 +02:00
|
|
|
m_ui->makeLabel->setText(tr("Make:"));
|
|
|
|
|
else
|
2018-05-17 18:13:26 +02:00
|
|
|
m_ui->makeLabel->setText(tr("Override %1:").arg(QDir::toNativeSeparators(defaultMake)));
|
2018-05-14 14:11:10 +02:00
|
|
|
|
2019-10-07 12:08:48 +03:00
|
|
|
const CommandLine make = m_makeStep->effectiveMakeCommand(MakeStep::Display);
|
2019-05-29 17:23:42 +02:00
|
|
|
if (make.executable().isEmpty()) {
|
2018-05-17 18:13:26 +02:00
|
|
|
setSummaryText(tr("<b>Make:</b> %1").arg(MakeStep::msgNoMakeCommand()));
|
2018-05-14 14:11:10 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!bc) {
|
|
|
|
|
setSummaryText(tr("<b>Make:</b> No build configuration."));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-25 15:13:16 +02:00
|
|
|
setUserJobCountVisible(m_makeStep->isJobCountSupported());
|
2018-10-28 12:56:42 +02:00
|
|
|
setUserJobCountEnabled(!m_makeStep->userArgsContainsJobCount());
|
2018-05-25 15:13:16 +02:00
|
|
|
m_ui->userJobCount->setValue(m_makeStep->jobCount());
|
|
|
|
|
m_ui->overrideMakeflags->setCheckState(
|
|
|
|
|
m_makeStep->jobCountOverridesMakeflags() ? Qt::Checked : Qt::Unchecked);
|
2018-12-18 23:38:07 +02:00
|
|
|
m_ui->nonOverrideWarning->setVisible(m_makeStep->makeflagsJobCountMismatch()
|
2018-05-25 15:13:16 +02:00
|
|
|
&& !m_makeStep->jobCountOverridesMakeflags());
|
2019-10-07 10:51:53 +02:00
|
|
|
m_ui->disableInSubDirsCheckBox->setChecked(!m_makeStep->enabledForSubDirs());
|
2018-05-25 15:13:16 +02:00
|
|
|
|
2018-05-09 09:48:23 +02:00
|
|
|
ProcessParameters param;
|
2020-02-19 11:55:48 +01:00
|
|
|
param.setMacroExpander(m_makeStep->macroExpander());
|
|
|
|
|
param.setWorkingDirectory(m_makeStep->buildDirectory());
|
2019-05-29 17:23:42 +02:00
|
|
|
param.setCommandLine(make);
|
2020-02-19 11:55:48 +01:00
|
|
|
param.setEnvironment(m_makeStep->buildEnvironment());
|
2018-05-14 14:11:10 +02:00
|
|
|
|
|
|
|
|
if (param.commandMissing())
|
2019-05-15 13:59:43 +02:00
|
|
|
setSummaryText(tr("<b>Make:</b> %1 not found in the environment.")
|
2019-06-21 08:31:37 +02:00
|
|
|
.arg(param.command().executable().toUserOutput())); // Override display text
|
2018-05-14 14:11:10 +02:00
|
|
|
else
|
|
|
|
|
setSummaryText(param.summaryInWorkdir(displayName()));
|
2018-05-09 09:48:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStepConfigWidget::itemChanged(QListWidgetItem *item)
|
|
|
|
|
{
|
|
|
|
|
m_makeStep->setBuildTarget(item->text(), item->checkState() & Qt::Checked);
|
|
|
|
|
updateDetails();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStepConfigWidget::makeLineEditTextEdited()
|
|
|
|
|
{
|
2019-05-28 13:49:26 +02:00
|
|
|
m_makeStep->setMakeCommand(FilePath::fromString(m_ui->makeLineEdit->rawPath()));
|
2018-05-09 09:48:23 +02:00
|
|
|
updateDetails();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStepConfigWidget::makeArgumentsLineEditTextEdited()
|
|
|
|
|
{
|
|
|
|
|
m_makeStep->setUserArguments(m_ui->makeArgumentsLineEdit->text());
|
|
|
|
|
updateDetails();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace GenericProjectManager
|