2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-09 14:53:06 +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-09 14:53:06 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-09 14:53:06 +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-09 14:53:06 +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
|
|
|
****************************************************************************/
|
2008-12-09 14:53:06 +01:00
|
|
|
|
|
|
|
|
#include "cmakerunconfiguration.h"
|
2008-12-09 15:25:01 +01:00
|
|
|
|
|
|
|
|
#include "cmakeprojectconstants.h"
|
2008-12-09 14:53:06 +01:00
|
|
|
|
2013-04-09 12:05:15 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2017-11-03 12:40:49 +01:00
|
|
|
#include <qtsupport/qtoutputformatter.h>
|
2018-03-23 09:32:52 +01:00
|
|
|
|
2013-11-01 14:13:41 +01:00
|
|
|
#include <projectexplorer/localenvironmentaspect.h>
|
2018-03-23 09:32:52 +01:00
|
|
|
#include <projectexplorer/project.h>
|
2015-04-30 13:11:25 +02:00
|
|
|
#include <projectexplorer/runconfigurationaspects.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2011-02-28 16:50:14 +01:00
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
using namespace ProjectExplorer;
|
2008-12-09 14:53:06 +01:00
|
|
|
|
2018-03-23 09:32:52 +01:00
|
|
|
namespace CMakeProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2018-04-25 10:26:08 +02:00
|
|
|
CMakeRunConfiguration::CMakeRunConfiguration(Target *target, Core::Id id)
|
|
|
|
|
: RunConfiguration(target, id)
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
2017-11-23 14:06:48 +01:00
|
|
|
// Workaround for QTCREATORBUG-19354:
|
|
|
|
|
auto cmakeRunEnvironmentModifier = [](RunConfiguration *rc, Utils::Environment &env) {
|
|
|
|
|
if (!Utils::HostOsInfo::isWindowsHost() || !rc)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const Kit *k = rc->target()->kit();
|
|
|
|
|
const QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(k);
|
|
|
|
|
if (qt)
|
|
|
|
|
env.prependOrSetPath(qt->qmakeProperty("QT_INSTALL_BINS"));
|
|
|
|
|
};
|
|
|
|
|
addExtraAspect(new LocalEnvironmentAspect(this, cmakeRunEnvironmentModifier));
|
2018-03-23 09:32:52 +01:00
|
|
|
addExtraAspect(new ExecutableAspect(this));
|
2018-07-30 13:10:38 +02:00
|
|
|
addExtraAspect(new ArgumentsAspect(this));
|
|
|
|
|
addExtraAspect(new TerminalAspect(this));
|
|
|
|
|
addExtraAspect(new WorkingDirectoryAspect(this));
|
2018-03-23 09:32:52 +01:00
|
|
|
|
|
|
|
|
connect(target->project(), &Project::parsingFinished,
|
|
|
|
|
this, &CMakeRunConfiguration::updateTargetInformation);
|
2018-04-06 09:21:44 +02:00
|
|
|
|
|
|
|
|
if (QtSupport::QtKitInformation::qtVersion(target->kit()))
|
|
|
|
|
setOutputFormatter<QtSupport::QtOutputFormatter>();
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
2009-11-26 14:43:27 +01:00
|
|
|
|
2018-03-12 16:33:28 +01:00
|
|
|
void CMakeRunConfiguration::doAdditionalSetup(const RunConfigurationCreationInfo &info)
|
|
|
|
|
{
|
2018-04-24 16:52:29 +02:00
|
|
|
Q_UNUSED(info);
|
2018-03-23 09:32:52 +01:00
|
|
|
updateTargetInformation();
|
2010-08-19 12:26:21 +02:00
|
|
|
}
|
|
|
|
|
|
2018-03-12 16:33:28 +01:00
|
|
|
bool CMakeRunConfiguration::isBuildTargetValid() const
|
|
|
|
|
{
|
|
|
|
|
return Utils::anyOf(target()->applicationTargets().list, [this](const BuildTargetInfo &bti) {
|
2018-04-09 12:33:10 +02:00
|
|
|
return bti.buildKey == buildKey();
|
2018-03-12 16:33:28 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-17 14:34:05 +02:00
|
|
|
void CMakeRunConfiguration::updateEnabledState()
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
2018-03-12 16:33:28 +01:00
|
|
|
if (!isBuildTargetValid())
|
2017-07-17 14:34:05 +02:00
|
|
|
setEnabled(false);
|
|
|
|
|
else
|
|
|
|
|
RunConfiguration::updateEnabledState();
|
2009-03-25 18:29:42 +01:00
|
|
|
}
|
|
|
|
|
|
2011-05-26 16:30:35 +02:00
|
|
|
QString CMakeRunConfiguration::disabledReason() const
|
|
|
|
|
{
|
2018-03-12 16:33:28 +01:00
|
|
|
if (!isBuildTargetValid())
|
2017-07-17 14:34:05 +02:00
|
|
|
return tr("The project no longer builds the target associated with this run configuration.");
|
|
|
|
|
return RunConfiguration::disabledReason();
|
2011-05-26 16:30:35 +02:00
|
|
|
}
|
|
|
|
|
|
2018-03-23 09:32:52 +01:00
|
|
|
void CMakeRunConfiguration::updateTargetInformation()
|
2017-07-12 12:52:06 +02:00
|
|
|
{
|
2018-04-09 12:33:10 +02:00
|
|
|
BuildTargetInfo bti = target()->applicationTargets().buildTargetInfo(buildKey());
|
2018-03-23 09:32:52 +01:00
|
|
|
extraAspect<ExecutableAspect>()->setExecutable(bti.targetFilePath);
|
|
|
|
|
extraAspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(bti.workingDirectory);
|
|
|
|
|
extraAspect<LocalEnvironmentAspect>()->buildEnvironmentHasChanged();
|
|
|
|
|
|
|
|
|
|
auto terminalAspect = extraAspect<TerminalAspect>();
|
|
|
|
|
if (!terminalAspect->isUserSet())
|
|
|
|
|
terminalAspect->setUseTerminal(bti.usesTerminal);
|
2013-01-29 18:00:30 +01:00
|
|
|
}
|
2009-09-17 13:59:10 +02:00
|
|
|
|
2008-12-09 14:53:06 +01:00
|
|
|
// Factory
|
2018-03-06 17:14:43 +01:00
|
|
|
CMakeRunConfigurationFactory::CMakeRunConfigurationFactory()
|
2017-11-10 15:43:23 +01:00
|
|
|
{
|
2018-04-25 10:26:08 +02:00
|
|
|
registerRunConfiguration<CMakeRunConfiguration>("CMakeProjectManager.CMakeRunConfiguration.");
|
2017-12-08 14:50:57 +01:00
|
|
|
addSupportedProjectType(CMakeProjectManager::Constants::CMAKEPROJECT_ID);
|
2018-03-14 08:38:34 +01:00
|
|
|
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
|
2018-05-29 12:51:40 +02:00
|
|
|
|
|
|
|
|
addRunWorkerFactory<SimpleTargetRunner>(ProjectExplorer::Constants::NORMAL_RUN_MODE);
|
2017-11-10 15:43:23 +01:00
|
|
|
}
|
2018-03-23 09:32:52 +01:00
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
} // CMakeProjectManager
|