2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-01-14 17:41:29 +01:00
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
#include "cmakebuildstep.h"
|
2010-01-14 17:41:29 +01:00
|
|
|
|
2013-07-10 21:43:49 +03:00
|
|
|
#include "cmakebuildconfiguration.h"
|
2016-01-07 13:15:29 +01:00
|
|
|
#include "cmakekitinformation.h"
|
2013-07-10 21:43:49 +03:00
|
|
|
#include "cmakeparser.h"
|
2008-12-04 13:06:02 +01:00
|
|
|
#include "cmakeprojectconstants.h"
|
|
|
|
|
#include "cmakeproject.h"
|
2015-11-26 19:50:39 +01:00
|
|
|
#include "cmakerunconfiguration.h"
|
2016-01-07 13:15:29 +01:00
|
|
|
#include "cmaketool.h"
|
2008-12-04 13:06:02 +01:00
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/deployconfiguration.h>
|
2016-02-12 12:34:35 +01:00
|
|
|
#include <projectexplorer/gnumakeparser.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2018-11-17 21:19:04 +02:00
|
|
|
#include <projectexplorer/processparameters.h>
|
2011-11-24 12:42:52 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2013-07-10 21:43:49 +03:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
#include <projectexplorer/toolchain.h>
|
2009-09-29 11:39:55 +02:00
|
|
|
|
2012-09-26 17:53:25 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
|
|
|
|
#include <qtsupport/qtparser.h>
|
|
|
|
|
|
2014-08-04 12:16:04 +02:00
|
|
|
#include <coreplugin/find/itemviewfind.h>
|
|
|
|
|
|
2016-01-07 12:39:48 +01:00
|
|
|
#include <utils/algorithm.h>
|
2010-10-19 11:14:03 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2014-10-02 17:51:02 +02:00
|
|
|
#include <utils/pathchooser.h>
|
2010-10-19 11:14:03 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QGroupBox>
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QListWidget>
|
2008-12-09 15:25:01 +01:00
|
|
|
|
2008-12-04 13:06:02 +01:00
|
|
|
using namespace CMakeProjectManager;
|
|
|
|
|
using namespace CMakeProjectManager::Internal;
|
2009-10-27 14:16:28 +01:00
|
|
|
using namespace ProjectExplorer;
|
2008-12-04 13:06:02 +01:00
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
namespace {
|
2012-08-03 15:24:33 +02:00
|
|
|
const char BUILD_TARGETS_KEY[] = "CMakeProjectManager.MakeStep.BuildTargets";
|
2016-01-07 13:15:29 +01:00
|
|
|
const char TOOL_ARGUMENTS_KEY[] = "CMakeProjectManager.MakeStep.AdditionalArguments";
|
2015-11-26 19:50:39 +01:00
|
|
|
const char ADD_RUNCONFIGURATION_ARGUMENT_KEY[] = "CMakeProjectManager.MakeStep.AddRunConfigurationArgument";
|
|
|
|
|
const char ADD_RUNCONFIGURATION_TEXT[] = "Current executable";
|
2010-01-14 17:41:29 +01:00
|
|
|
}
|
|
|
|
|
|
2016-04-22 15:54:16 +02:00
|
|
|
static bool isCurrentExecutableTarget(const QString &target)
|
|
|
|
|
{
|
2017-06-12 14:23:34 +02:00
|
|
|
return target == ADD_RUNCONFIGURATION_TEXT;
|
2016-04-22 15:54:16 +02:00
|
|
|
}
|
|
|
|
|
|
2016-11-14 15:18:25 +01:00
|
|
|
CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl) :
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
AbstractProcessStep(bsl, Constants::CMAKE_BUILD_STEP_ID)
|
2010-01-14 17:41:29 +01:00
|
|
|
{
|
2017-06-12 14:23:34 +02:00
|
|
|
m_percentProgress = QRegExp("^\\[\\s*(\\d*)%\\]");
|
|
|
|
|
m_ninjaProgress = QRegExp("^\\[\\s*(\\d*)/\\s*(\\d*)");
|
|
|
|
|
m_ninjaProgressString = "[%f/%t "; // ninja: [33/100
|
2010-08-19 12:26:21 +02:00
|
|
|
//: Default display name for the cmake make step.
|
2016-11-14 15:18:25 +01:00
|
|
|
setDefaultDisplayName(tr("CMake Build"));
|
2012-10-02 17:46:12 +02:00
|
|
|
|
2016-02-24 18:00:24 +01:00
|
|
|
auto bc = qobject_cast<CMakeBuildConfiguration *>(bsl->parent());
|
|
|
|
|
if (!bc) {
|
|
|
|
|
auto t = qobject_cast<Target *>(bsl->parent()->parent());
|
|
|
|
|
QTC_ASSERT(t, return);
|
|
|
|
|
bc = qobject_cast<CMakeBuildConfiguration *>(t->activeBuildConfiguration());
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-26 15:34:04 +02:00
|
|
|
// Set a good default build target:
|
2019-07-23 13:05:07 +02:00
|
|
|
if (m_buildTarget.isEmpty())
|
|
|
|
|
setBuildTarget(defaultBuildTarget());
|
2017-04-26 15:34:04 +02:00
|
|
|
|
2016-01-07 13:15:29 +01:00
|
|
|
connect(target(), &Target::kitChanged, this, &CMakeBuildStep::cmakeCommandChanged);
|
2017-07-18 16:48:02 +02:00
|
|
|
connect(project(), &Project::parsingFinished,
|
|
|
|
|
this, &CMakeBuildStep::handleBuildTargetChanges);
|
2009-10-27 14:16:28 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
CMakeBuildConfiguration *CMakeBuildStep::cmakeBuildConfiguration() const
|
2009-11-26 14:43:27 +01:00
|
|
|
{
|
|
|
|
|
return static_cast<CMakeBuildConfiguration *>(buildConfiguration());
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
CMakeRunConfiguration *CMakeBuildStep::targetsActiveRunConfiguration() const
|
2015-11-26 19:50:39 +01:00
|
|
|
{
|
|
|
|
|
return qobject_cast<CMakeRunConfiguration *>(target()->activeRunConfiguration());
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-23 22:41:58 -08:00
|
|
|
void CMakeBuildStep::handleBuildTargetChanges(bool success)
|
2013-08-26 16:01:24 +02:00
|
|
|
{
|
2019-01-23 22:41:58 -08:00
|
|
|
if (!success)
|
|
|
|
|
return; // Do not change when parsing failed.
|
2016-04-22 15:54:16 +02:00
|
|
|
if (isCurrentExecutableTarget(m_buildTarget))
|
|
|
|
|
return; // Do not change just because a different set of build targets is there...
|
|
|
|
|
if (!static_cast<CMakeProject *>(project())->buildTargetTitles().contains(m_buildTarget))
|
2017-04-26 15:27:01 +02:00
|
|
|
setBuildTarget(allTarget());
|
2016-02-24 18:00:24 +01:00
|
|
|
emit buildTargetsChanged();
|
2013-08-26 16:01:24 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
QVariantMap CMakeBuildStep::toMap() const
|
2009-10-15 19:06:51 +02:00
|
|
|
{
|
2010-01-14 17:41:29 +01:00
|
|
|
QVariantMap map(AbstractProcessStep::toMap());
|
2016-03-30 13:06:21 +02:00
|
|
|
// Use QStringList for compatibility with old files
|
2017-06-12 14:23:34 +02:00
|
|
|
map.insert(BUILD_TARGETS_KEY, QStringList(m_buildTarget));
|
|
|
|
|
map.insert(TOOL_ARGUMENTS_KEY, m_toolArguments);
|
2010-01-14 17:41:29 +01:00
|
|
|
return map;
|
2009-10-15 19:06:51 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
bool CMakeBuildStep::fromMap(const QVariantMap &map)
|
2009-10-15 19:06:51 +02:00
|
|
|
{
|
2018-03-22 15:27:55 +01:00
|
|
|
const QStringList targetList = map.value(BUILD_TARGETS_KEY).toStringList();
|
|
|
|
|
if (!targetList.isEmpty())
|
|
|
|
|
m_buildTarget = targetList.last();
|
|
|
|
|
m_toolArguments = map.value(TOOL_ARGUMENTS_KEY).toString();
|
2017-06-12 14:23:34 +02:00
|
|
|
if (map.value(ADD_RUNCONFIGURATION_ARGUMENT_KEY, false).toBool())
|
|
|
|
|
m_buildTarget = ADD_RUNCONFIGURATION_TEXT;
|
2009-10-15 19:06:51 +02:00
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
return BuildStep::fromMap(map);
|
2009-10-15 19:06:51 +02:00
|
|
|
}
|
|
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
|
2019-01-10 15:31:44 +01:00
|
|
|
bool CMakeBuildStep::init()
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
2016-01-07 13:15:29 +01:00
|
|
|
bool canInit = true;
|
2009-11-26 14:43:27 +01:00
|
|
|
CMakeBuildConfiguration *bc = cmakeBuildConfiguration();
|
2016-01-07 13:15:29 +01:00
|
|
|
if (!bc) {
|
2014-06-20 14:32:40 +02:00
|
|
|
emit addTask(Task::buildConfigurationMissingTask());
|
2016-01-07 13:15:29 +01:00
|
|
|
canInit = false;
|
|
|
|
|
}
|
2017-05-02 16:29:56 +02:00
|
|
|
if (bc && !bc->isEnabled()) {
|
2017-04-24 13:37:55 +02:00
|
|
|
emit addTask(Task(Task::Error,
|
|
|
|
|
QCoreApplication::translate("CMakeProjectManager::CMakeBuildStep",
|
|
|
|
|
"The build configuration is currently disabled."),
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath(), -1, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
|
2017-04-24 13:37:55 +02:00
|
|
|
canInit = false;
|
|
|
|
|
}
|
2016-01-07 13:15:29 +01:00
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
CMakeTool *tool = CMakeKitAspect::cmakeTool(target()->kit());
|
2016-01-07 13:15:29 +01:00
|
|
|
if (!tool || !tool->isValid()) {
|
|
|
|
|
emit addTask(Task(Task::Error,
|
2017-08-29 11:48:48 +02:00
|
|
|
tr("A CMake tool must be set up for building. "
|
|
|
|
|
"Configure a CMake tool in the kit options."),
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath(), -1,
|
2016-01-07 13:15:29 +01:00
|
|
|
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
|
|
|
|
|
canInit = false;
|
|
|
|
|
}
|
2009-02-16 13:12:12 +01:00
|
|
|
|
2016-01-07 13:15:29 +01:00
|
|
|
CMakeRunConfiguration *rc = targetsActiveRunConfiguration();
|
2018-04-09 12:33:10 +02:00
|
|
|
if (isCurrentExecutableTarget(m_buildTarget) && (!rc || rc->buildKey().isEmpty())) {
|
2016-01-07 13:15:29 +01:00
|
|
|
emit addTask(Task(Task::Error,
|
|
|
|
|
QCoreApplication::translate("ProjectExplorer::Task",
|
2016-01-11 11:40:24 +01:00
|
|
|
"You asked to build the current Run Configuration's build target only, "
|
|
|
|
|
"but it is not associated with a build target. "
|
|
|
|
|
"Update the Make Step in your build settings."),
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath(), -1,
|
2016-01-07 13:15:29 +01:00
|
|
|
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
|
|
|
|
|
canInit = false;
|
|
|
|
|
}
|
2014-04-03 16:29:37 +02:00
|
|
|
|
2016-01-07 13:15:29 +01:00
|
|
|
if (!canInit) {
|
2014-06-20 14:32:40 +02:00
|
|
|
emitFaultyConfigurationMessage();
|
2014-04-03 15:37:02 +02:00
|
|
|
return false;
|
2012-09-06 13:13:12 +02:00
|
|
|
}
|
|
|
|
|
|
2017-06-22 13:53:48 +02:00
|
|
|
// Warn if doing out-of-source builds with a CMakeCache.txt is the source directory
|
2019-05-28 13:49:26 +02:00
|
|
|
const Utils::FilePath projectDirectory = bc->target()->project()->projectDirectory();
|
2017-06-22 13:53:48 +02:00
|
|
|
if (bc->buildDirectory() != projectDirectory) {
|
2019-05-15 14:54:25 +02:00
|
|
|
if (projectDirectory.pathAppended("CMakeCache.txt").exists()) {
|
2017-06-22 13:53:48 +02:00
|
|
|
emit addTask(Task(Task::Warning,
|
|
|
|
|
tr("There is a CMakeCache.txt file in \"%1\", which suggest an "
|
|
|
|
|
"in-source build was done before. You are now building in \"%2\", "
|
|
|
|
|
"and the CMakeCache.txt file might confuse CMake.")
|
|
|
|
|
.arg(projectDirectory.toUserOutput(), bc->buildDirectory().toUserOutput()),
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath(), -1,
|
2017-06-22 13:53:48 +02:00
|
|
|
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-30 13:06:21 +02:00
|
|
|
setIgnoreReturnValue(m_buildTarget == CMakeBuildStep::cleanTarget());
|
2009-06-22 16:11:45 +02:00
|
|
|
|
2010-11-12 17:23:55 +01:00
|
|
|
ProcessParameters *pp = processParameters();
|
|
|
|
|
pp->setMacroExpander(bc->macroExpander());
|
2012-11-21 12:04:39 +01:00
|
|
|
Utils::Environment env = bc->environment();
|
2016-04-07 13:06:01 +02:00
|
|
|
Utils::Environment::setupEnglishOutput(&env);
|
2017-06-12 14:23:34 +02:00
|
|
|
if (!env.value("NINJA_STATUS").startsWith(m_ninjaProgressString))
|
|
|
|
|
env.set("NINJA_STATUS", m_ninjaProgressString + "%o/sec] ");
|
2012-11-21 12:04:39 +01:00
|
|
|
pp->setEnvironment(env);
|
2019-05-15 13:59:43 +02:00
|
|
|
pp->setWorkingDirectory(bc->buildDirectory());
|
2019-05-29 18:54:45 +02:00
|
|
|
pp->setCommandLine(cmakeCommand(rc));
|
2012-11-28 15:29:55 +01:00
|
|
|
pp->resolveAll();
|
2010-11-12 17:23:55 +01:00
|
|
|
|
2016-02-12 12:34:35 +01:00
|
|
|
setOutputParser(new CMakeParser);
|
|
|
|
|
appendOutputParser(new GnuMakeParser);
|
2012-11-02 12:45:09 +01:00
|
|
|
IOutputParser *parser = target()->kit()->createOutputParser();
|
|
|
|
|
if (parser)
|
|
|
|
|
appendOutputParser(parser);
|
2010-12-06 12:18:38 +01:00
|
|
|
outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory());
|
2009-12-09 13:54:46 +01:00
|
|
|
|
2019-01-10 15:31:44 +01:00
|
|
|
return AbstractProcessStep::init();
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
void CMakeBuildStep::doRun()
|
2016-02-25 14:18:05 +01:00
|
|
|
{
|
|
|
|
|
// Make sure CMake state was written to disk before trying to build:
|
|
|
|
|
CMakeBuildConfiguration *bc = cmakeBuildConfiguration();
|
|
|
|
|
QTC_ASSERT(bc, return);
|
|
|
|
|
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
m_waiting = false;
|
2017-09-28 11:32:39 +02:00
|
|
|
auto p = static_cast<CMakeProject *>(bc->project());
|
|
|
|
|
if (p->persistCMakeState()) {
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("Persisting CMake state..."), BuildStep::OutputFormat::NormalMessage);
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
m_waiting = true;
|
2017-09-28 11:32:39 +02:00
|
|
|
} else if (p->mustUpdateCMakeStateBeforeBuild()) {
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("Running CMake in preparation to build..."), BuildStep::OutputFormat::NormalMessage);
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
m_waiting = true;
|
2016-10-06 15:55:55 +02:00
|
|
|
}
|
2016-02-25 14:18:05 +01:00
|
|
|
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
if (m_waiting) {
|
2017-07-18 16:48:02 +02:00
|
|
|
m_runTrigger = connect(project(), &Project::parsingFinished,
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
this, [this](bool success) { handleProjectWasParsed(success); });
|
2016-02-25 14:18:05 +01:00
|
|
|
} else {
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
runImpl();
|
2016-02-25 14:18:05 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
void CMakeBuildStep::runImpl()
|
2016-02-25 14:18:05 +01:00
|
|
|
{
|
|
|
|
|
// Do the actual build:
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
AbstractProcessStep::doRun();
|
2017-06-19 17:29:35 +02:00
|
|
|
}
|
|
|
|
|
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
void CMakeBuildStep::handleProjectWasParsed(bool success)
|
2017-06-19 17:29:35 +02:00
|
|
|
{
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
m_waiting = false;
|
2016-02-25 14:18:05 +01:00
|
|
|
disconnect(m_runTrigger);
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
if (isCanceled()) {
|
|
|
|
|
emit finished(false);
|
|
|
|
|
} else if (success) {
|
|
|
|
|
runImpl();
|
2017-07-18 16:48:02 +02:00
|
|
|
} else {
|
2017-10-20 14:58:40 +02:00
|
|
|
AbstractProcessStep::stdError(tr("Project did not parse successfully, cannot build."));
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
emit finished(false);
|
2017-07-18 16:48:02 +02:00
|
|
|
}
|
2016-02-25 14:18:05 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
BuildStepConfigWidget *CMakeBuildStep::createConfigWidget()
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
2016-01-07 12:33:52 +01:00
|
|
|
return new CMakeBuildStepConfigWidget(this);
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
2019-07-23 13:05:07 +02:00
|
|
|
QString CMakeBuildStep::defaultBuildTarget() const
|
|
|
|
|
{
|
|
|
|
|
const ProjectConfiguration *const pc = qobject_cast<ProjectConfiguration *>(parent());
|
|
|
|
|
const Core::Id parentId = pc ? pc->id() : Core::Id();
|
|
|
|
|
if (parentId == ProjectExplorer::Constants::BUILDSTEPS_CLEAN)
|
|
|
|
|
return cleanTarget();
|
|
|
|
|
if (parentId == ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)
|
|
|
|
|
return installTarget();
|
|
|
|
|
return allTarget();
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
void CMakeBuildStep::stdOutput(const QString &line)
|
2009-02-16 13:12:12 +01:00
|
|
|
{
|
2009-04-07 13:52:28 +02:00
|
|
|
if (m_percentProgress.indexIn(line) != -1) {
|
2016-03-20 12:15:04 +02:00
|
|
|
AbstractProcessStep::stdOutput(line);
|
2009-04-07 13:52:28 +02:00
|
|
|
bool ok = false;
|
2013-09-03 18:48:02 +02:00
|
|
|
int percent = m_percentProgress.cap(1).toInt(&ok);
|
2009-04-07 13:52:28 +02:00
|
|
|
if (ok)
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
emit progress(percent, QString());
|
2016-03-11 11:02:43 +01:00
|
|
|
return;
|
2012-10-02 17:46:12 +02:00
|
|
|
} else if (m_ninjaProgress.indexIn(line) != -1) {
|
2016-03-20 12:15:04 +02:00
|
|
|
AbstractProcessStep::stdOutput(line);
|
2016-01-07 13:15:29 +01:00
|
|
|
m_useNinja = true;
|
2012-10-02 17:46:12 +02:00
|
|
|
bool ok = false;
|
|
|
|
|
int done = m_ninjaProgress.cap(1).toInt(&ok);
|
|
|
|
|
if (ok) {
|
|
|
|
|
int all = m_ninjaProgress.cap(2).toInt(&ok);
|
|
|
|
|
if (ok && all != 0) {
|
2016-10-07 09:26:41 +02:00
|
|
|
const int percent = static_cast<int>(100.0 * done/all);
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
emit progress(percent, QString());
|
2012-10-02 17:46:12 +02:00
|
|
|
}
|
|
|
|
|
}
|
2016-03-11 11:02:43 +01:00
|
|
|
return;
|
2009-04-07 13:52:28 +02:00
|
|
|
}
|
2012-10-02 17:46:12 +02:00
|
|
|
if (m_useNinja)
|
|
|
|
|
AbstractProcessStep::stdError(line);
|
|
|
|
|
else
|
|
|
|
|
AbstractProcessStep::stdOutput(line);
|
2009-02-16 13:12:12 +01:00
|
|
|
}
|
|
|
|
|
|
2016-03-30 13:06:21 +02:00
|
|
|
QString CMakeBuildStep::buildTarget() const
|
2011-10-21 23:17:58 +02:00
|
|
|
{
|
2016-03-30 13:06:21 +02:00
|
|
|
return m_buildTarget;
|
2011-10-21 23:17:58 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
bool CMakeBuildStep::buildsBuildTarget(const QString &target) const
|
2009-01-12 15:10:33 +01:00
|
|
|
{
|
2016-03-30 13:06:21 +02:00
|
|
|
return target == m_buildTarget;
|
2009-01-12 15:10:33 +01:00
|
|
|
}
|
|
|
|
|
|
2016-03-30 13:06:21 +02:00
|
|
|
void CMakeBuildStep::setBuildTarget(const QString &buildTarget)
|
2011-10-21 23:17:58 +02:00
|
|
|
{
|
2016-03-30 13:06:21 +02:00
|
|
|
if (m_buildTarget == buildTarget)
|
|
|
|
|
return;
|
|
|
|
|
m_buildTarget = buildTarget;
|
|
|
|
|
emit targetToBuildChanged();
|
2011-10-21 23:17:58 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
void CMakeBuildStep::clearBuildTargets()
|
2011-10-21 23:17:58 +02:00
|
|
|
{
|
2016-03-30 13:06:21 +02:00
|
|
|
m_buildTarget.clear();
|
2011-10-21 23:17:58 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 13:15:29 +01:00
|
|
|
QString CMakeBuildStep::toolArguments() const
|
2009-03-12 15:51:44 +01:00
|
|
|
{
|
2016-01-07 13:15:29 +01:00
|
|
|
return m_toolArguments;
|
2009-03-12 15:51:44 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 13:15:29 +01:00
|
|
|
void CMakeBuildStep::setToolArguments(const QString &list)
|
2009-03-12 15:51:44 +01:00
|
|
|
{
|
2016-01-07 13:15:29 +01:00
|
|
|
m_toolArguments = list;
|
2009-03-12 15:51:44 +01:00
|
|
|
}
|
|
|
|
|
|
2019-05-29 18:54:45 +02:00
|
|
|
Utils::CommandLine CMakeBuildStep::cmakeCommand(CMakeRunConfiguration *rc) const
|
2015-11-26 19:50:39 +01:00
|
|
|
{
|
2019-05-29 18:54:45 +02:00
|
|
|
CMakeTool *tool = CMakeKitAspect::cmakeTool(target()->kit());
|
2015-11-26 19:50:39 +01:00
|
|
|
|
2019-05-29 18:54:45 +02:00
|
|
|
Utils::CommandLine cmd(tool ? tool->cmakeExecutable() : Utils::FilePath(), {});
|
|
|
|
|
cmd.addArgs({"--build", "."});
|
2015-11-26 19:50:39 +01:00
|
|
|
|
2016-03-30 13:06:21 +02:00
|
|
|
QString target;
|
|
|
|
|
|
2016-04-22 15:54:16 +02:00
|
|
|
if (isCurrentExecutableTarget(m_buildTarget)) {
|
2016-01-07 13:15:29 +01:00
|
|
|
if (rc)
|
2018-07-12 10:40:34 +02:00
|
|
|
target = rc->buildKey().section('\n', 0, 0);
|
2016-01-07 13:15:29 +01:00
|
|
|
else
|
2017-06-12 14:23:34 +02:00
|
|
|
target = "<i><" + tr(ADD_RUNCONFIGURATION_TEXT) + "></i>";
|
2016-03-30 13:06:21 +02:00
|
|
|
} else {
|
|
|
|
|
target = m_buildTarget;
|
2016-01-07 13:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
2019-05-29 18:54:45 +02:00
|
|
|
cmd.addArgs({"--target", target});
|
2016-03-30 13:06:21 +02:00
|
|
|
|
2016-01-07 13:15:29 +01:00
|
|
|
if (!m_toolArguments.isEmpty()) {
|
2019-05-29 18:54:45 +02:00
|
|
|
cmd.addArg("--");
|
2019-06-05 15:35:15 +02:00
|
|
|
cmd.addArgs(m_toolArguments, Utils::CommandLine::Raw);
|
2016-01-07 13:15:29 +01:00
|
|
|
}
|
2014-04-03 16:33:04 +02:00
|
|
|
|
2019-05-29 18:54:45 +02:00
|
|
|
return cmd;
|
2014-10-02 17:51:02 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
QString CMakeBuildStep::cleanTarget()
|
2016-01-07 12:09:59 +01:00
|
|
|
{
|
2017-04-28 08:23:57 +02:00
|
|
|
return QString("clean");
|
2016-01-07 12:09:59 +01:00
|
|
|
}
|
|
|
|
|
|
2016-03-30 13:06:21 +02:00
|
|
|
QString CMakeBuildStep::allTarget()
|
|
|
|
|
{
|
2017-04-28 08:23:57 +02:00
|
|
|
return QString("all");
|
2017-04-26 15:27:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString CMakeBuildStep::installTarget()
|
|
|
|
|
{
|
2017-04-28 08:23:57 +02:00
|
|
|
return QString("install");
|
2017-04-26 15:27:01 +02:00
|
|
|
}
|
|
|
|
|
|
2017-06-02 09:11:39 +02:00
|
|
|
QString CMakeBuildStep::testTarget()
|
|
|
|
|
{
|
|
|
|
|
return QString("test");
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-26 15:27:01 +02:00
|
|
|
QStringList CMakeBuildStep::specialTargets()
|
|
|
|
|
{
|
2017-06-02 09:11:39 +02:00
|
|
|
return { allTarget(), cleanTarget(), installTarget(), testTarget() };
|
2016-03-30 13:06:21 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-04 13:06:02 +01:00
|
|
|
//
|
2016-01-07 12:33:52 +01:00
|
|
|
// CMakeBuildStepConfigWidget
|
2008-12-04 13:06:02 +01:00
|
|
|
//
|
2009-03-12 15:51:44 +01:00
|
|
|
|
2016-01-07 15:22:53 +01:00
|
|
|
CMakeBuildStepConfigWidget::CMakeBuildStepConfigWidget(CMakeBuildStep *buildStep) :
|
2018-09-20 11:19:41 +02:00
|
|
|
BuildStepConfigWidget(buildStep),
|
2016-01-07 15:22:53 +01:00
|
|
|
m_buildStep(buildStep),
|
|
|
|
|
m_toolArguments(new QLineEdit),
|
|
|
|
|
m_buildTargetsList(new QListWidget)
|
2009-01-12 15:10:33 +01:00
|
|
|
{
|
2018-10-12 17:52:09 +02:00
|
|
|
setDisplayName(tr("Build", "CMakeProjectManager::CMakeBuildStepConfigWidget display name."));
|
|
|
|
|
|
2016-01-07 15:22:53 +01:00
|
|
|
auto fl = new QFormLayout(this);
|
2009-07-23 17:00:38 +02:00
|
|
|
fl->setMargin(0);
|
|
|
|
|
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
2009-01-12 15:10:33 +01:00
|
|
|
setLayout(fl);
|
|
|
|
|
|
2016-01-07 13:15:29 +01:00
|
|
|
fl->addRow(tr("Tool arguments:"), m_toolArguments);
|
|
|
|
|
m_toolArguments->setText(m_buildStep->toolArguments());
|
2009-03-12 15:51:44 +01:00
|
|
|
|
2014-08-04 12:16:04 +02:00
|
|
|
m_buildTargetsList->setFrameStyle(QFrame::NoFrame);
|
2010-02-02 12:01:11 +01:00
|
|
|
m_buildTargetsList->setMinimumHeight(200);
|
2014-08-04 12:16:04 +02:00
|
|
|
|
2016-01-07 15:22:53 +01:00
|
|
|
auto frame = new QFrame(this);
|
2014-08-04 12:16:04 +02:00
|
|
|
frame->setFrameStyle(QFrame::StyledPanel);
|
2016-01-07 15:22:53 +01:00
|
|
|
auto frameLayout = new QVBoxLayout(frame);
|
2014-08-04 12:16:04 +02:00
|
|
|
frameLayout->setMargin(0);
|
2014-08-11 17:31:27 +02:00
|
|
|
frameLayout->addWidget(Core::ItemViewFind::createSearchableWrapper(m_buildTargetsList,
|
|
|
|
|
Core::ItemViewFind::LightColored));
|
2014-08-04 12:16:04 +02:00
|
|
|
|
|
|
|
|
fl->addRow(tr("Targets:"), frame);
|
2009-01-12 15:10:33 +01:00
|
|
|
|
2016-03-30 13:06:21 +02:00
|
|
|
buildTargetsChanged();
|
2011-05-30 13:30:10 +02:00
|
|
|
updateDetails();
|
|
|
|
|
|
2016-01-07 13:15:29 +01:00
|
|
|
connect(m_toolArguments, &QLineEdit::textEdited, this, &CMakeBuildStepConfigWidget::toolArgumentsEdited);
|
2016-01-07 12:33:52 +01:00
|
|
|
connect(m_buildTargetsList, &QListWidget::itemChanged, this, &CMakeBuildStepConfigWidget::itemChanged);
|
|
|
|
|
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
|
|
|
|
this, &CMakeBuildStepConfigWidget::updateDetails);
|
2011-05-30 13:30:10 +02:00
|
|
|
|
2016-02-24 18:00:24 +01:00
|
|
|
connect(m_buildStep, &CMakeBuildStep::buildTargetsChanged, this, &CMakeBuildStepConfigWidget::buildTargetsChanged);
|
2016-03-30 13:06:21 +02:00
|
|
|
connect(m_buildStep, &CMakeBuildStep::targetToBuildChanged, this, &CMakeBuildStepConfigWidget::selectedBuildTargetsChanged);
|
2017-07-29 23:34:56 +02:00
|
|
|
m_buildStep->project()->subscribeSignal(&BuildConfiguration::environmentChanged, this, [this]() {
|
|
|
|
|
if (static_cast<BuildConfiguration *>(sender())->isActive())
|
|
|
|
|
updateDetails();
|
|
|
|
|
});
|
|
|
|
|
connect(m_buildStep->project(), &Project::activeProjectConfigurationChanged,
|
|
|
|
|
this, [this](ProjectConfiguration *pc) {
|
2017-09-07 10:28:47 -04:00
|
|
|
if (pc && pc->isActive())
|
2017-07-29 23:34:56 +02:00
|
|
|
updateDetails();
|
|
|
|
|
});
|
2014-10-02 17:51:02 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 13:15:29 +01:00
|
|
|
void CMakeBuildStepConfigWidget::toolArgumentsEdited()
|
2009-03-12 15:51:44 +01:00
|
|
|
{
|
2016-01-07 13:15:29 +01:00
|
|
|
m_buildStep->setToolArguments(m_toolArguments->text());
|
2009-08-06 17:26:38 +02:00
|
|
|
updateDetails();
|
2009-03-12 15:51:44 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
void CMakeBuildStepConfigWidget::itemChanged(QListWidgetItem *item)
|
2009-01-12 15:10:33 +01:00
|
|
|
{
|
2016-03-30 13:06:21 +02:00
|
|
|
const QString target =
|
|
|
|
|
(item->checkState() == Qt::Checked) ? item->data(Qt::UserRole).toString() : CMakeBuildStep::allTarget();
|
|
|
|
|
m_buildStep->setBuildTarget(target);
|
2009-08-06 17:26:38 +02:00
|
|
|
updateDetails();
|
2009-01-12 15:10:33 +01:00
|
|
|
}
|
2008-12-04 13:06:02 +01:00
|
|
|
|
2017-03-31 17:17:20 +02:00
|
|
|
void CMakeBuildStepConfigWidget::buildTargetsChanged()
|
|
|
|
|
{
|
2017-09-30 07:12:57 +02:00
|
|
|
{
|
|
|
|
|
QSignalBlocker blocker(m_buildTargetsList);
|
|
|
|
|
m_buildTargetsList->clear();
|
2017-03-31 17:17:20 +02:00
|
|
|
|
2017-09-30 07:12:57 +02:00
|
|
|
auto pro = static_cast<CMakeProject *>(m_buildStep->project());
|
|
|
|
|
QStringList targetList = pro->buildTargetTitles();
|
|
|
|
|
targetList.sort();
|
2016-03-30 13:06:21 +02:00
|
|
|
|
2017-09-30 07:12:57 +02:00
|
|
|
QFont italics;
|
|
|
|
|
italics.setItalic(true);
|
2017-04-26 15:29:54 +02:00
|
|
|
|
2017-09-30 07:12:57 +02:00
|
|
|
auto exeItem = new QListWidgetItem(tr(ADD_RUNCONFIGURATION_TEXT), m_buildTargetsList);
|
|
|
|
|
exeItem->setData(Qt::UserRole, ADD_RUNCONFIGURATION_TEXT);
|
2017-04-26 15:29:54 +02:00
|
|
|
|
2017-09-30 07:12:57 +02:00
|
|
|
foreach (const QString &buildTarget, targetList) {
|
|
|
|
|
auto item = new QListWidgetItem(buildTarget, m_buildTargetsList);
|
|
|
|
|
item->setData(Qt::UserRole, buildTarget);
|
|
|
|
|
}
|
2016-03-30 13:06:21 +02:00
|
|
|
|
2017-09-30 07:12:57 +02:00
|
|
|
for (int i = 0; i < m_buildTargetsList->count(); ++i) {
|
|
|
|
|
QListWidgetItem *item = m_buildTargetsList->item(i);
|
|
|
|
|
const QString title = item->data(Qt::UserRole).toString();
|
2017-04-26 15:29:54 +02:00
|
|
|
|
2017-09-30 07:12:57 +02:00
|
|
|
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
|
|
|
|
item->setCheckState(m_buildStep->buildsBuildTarget(title) ? Qt::Checked : Qt::Unchecked);
|
2017-04-26 15:29:54 +02:00
|
|
|
|
2017-09-30 07:12:57 +02:00
|
|
|
// Print utility targets in italics:
|
|
|
|
|
if (CMakeBuildStep::specialTargets().contains(title) || title == ADD_RUNCONFIGURATION_TEXT)
|
|
|
|
|
item->setFont(italics);
|
|
|
|
|
}
|
2009-12-03 19:45:09 +01:00
|
|
|
}
|
2017-04-26 15:32:44 +02:00
|
|
|
updateDetails();
|
2009-08-06 17:26:38 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
void CMakeBuildStepConfigWidget::selectedBuildTargetsChanged()
|
2013-08-26 16:01:24 +02:00
|
|
|
{
|
2017-09-30 07:12:57 +02:00
|
|
|
{
|
|
|
|
|
QSignalBlocker blocker(m_buildTargetsList);
|
|
|
|
|
for (int y = 0; y < m_buildTargetsList->count(); ++y) {
|
|
|
|
|
QListWidgetItem *item = m_buildTargetsList->item(y);
|
|
|
|
|
item->setCheckState(m_buildStep->buildsBuildTarget(item->data(Qt::UserRole).toString())
|
|
|
|
|
? Qt::Checked : Qt::Unchecked);
|
|
|
|
|
}
|
2013-08-26 16:01:24 +02:00
|
|
|
}
|
2017-04-26 15:32:44 +02:00
|
|
|
updateDetails();
|
2013-08-26 16:01:24 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
void CMakeBuildStepConfigWidget::updateDetails()
|
2009-08-06 17:26:38 +02:00
|
|
|
{
|
2016-01-07 12:33:52 +01:00
|
|
|
BuildConfiguration *bc = m_buildStep->buildConfiguration();
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!bc) {
|
2018-10-15 17:52:15 +02:00
|
|
|
setSummaryText(tr("<b>No build configuration found on this kit.</b>"));
|
2012-04-24 15:49:09 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-07 13:15:29 +01:00
|
|
|
ProcessParameters param;
|
|
|
|
|
param.setMacroExpander(bc->macroExpander());
|
|
|
|
|
param.setEnvironment(bc->environment());
|
2019-05-15 13:59:43 +02:00
|
|
|
param.setWorkingDirectory(bc->buildDirectory());
|
2019-05-29 18:54:45 +02:00
|
|
|
param.setCommandLine(m_buildStep->cmakeCommand(nullptr));
|
2016-01-07 13:15:29 +01:00
|
|
|
|
2018-10-15 17:52:15 +02:00
|
|
|
setSummaryText(param.summary(displayName()));
|
2009-08-06 15:31:32 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-04 13:06:02 +01:00
|
|
|
//
|
2016-01-07 12:33:52 +01:00
|
|
|
// CMakeBuildStepFactory
|
2008-12-04 13:06:02 +01:00
|
|
|
//
|
|
|
|
|
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
CMakeBuildStepFactory::CMakeBuildStepFactory()
|
2010-01-14 17:41:29 +01:00
|
|
|
{
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
registerStep<CMakeBuildStep>(Constants::CMAKE_BUILD_STEP_ID);
|
2018-05-14 17:50:56 +02:00
|
|
|
setDisplayName(CMakeBuildStep::tr("Build", "Display name for CMakeProjectManager::CMakeBuildStep id."));
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
setSupportedProjectType(Constants::CMAKEPROJECT_ID);
|
2010-01-14 17:41:29 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
void CMakeBuildStep::processStarted()
|
2013-02-18 11:14:41 +01:00
|
|
|
{
|
2016-01-07 13:15:29 +01:00
|
|
|
m_useNinja = false;
|
2013-02-18 11:14:41 +01:00
|
|
|
AbstractProcessStep::processStarted();
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-07 12:33:52 +01:00
|
|
|
void CMakeBuildStep::processFinished(int exitCode, QProcess::ExitStatus status)
|
2013-02-18 11:14:41 +01:00
|
|
|
{
|
2013-02-20 13:11:34 +01:00
|
|
|
AbstractProcessStep::processFinished(exitCode, status);
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
emit progress(100, QString());
|
2013-02-18 11:14:41 +01:00
|
|
|
}
|