2015-08-26 09:37:55 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) Filippo Cucchetto <filippocucchetto@gmail.com>
|
|
|
|
|
** Contact: http://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.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-06-14 20:33:55 +03:00
|
|
|
#include "nimrunconfiguration.h"
|
|
|
|
|
#include "nimbuildconfiguration.h"
|
2015-08-26 09:37:55 +02:00
|
|
|
|
2016-06-14 20:33:55 +03:00
|
|
|
#include "../nimconstants.h"
|
2015-08-26 09:37:55 +02:00
|
|
|
|
|
|
|
|
#include <projectexplorer/localenvironmentaspect.h>
|
|
|
|
|
#include <projectexplorer/runconfigurationaspects.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/environment.h>
|
|
|
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
|
|
|
|
namespace Nim {
|
|
|
|
|
|
2018-04-25 10:26:08 +02:00
|
|
|
NimRunConfiguration::NimRunConfiguration(Target *target, Core::Id id)
|
|
|
|
|
: RunConfiguration(target, id)
|
2015-08-26 09:37:55 +02:00
|
|
|
{
|
2018-04-06 17:43:47 +02:00
|
|
|
addExtraAspect(new ExecutableAspect(this));
|
|
|
|
|
addExtraAspect(new ArgumentsAspect(this, "Nim.NimRunConfiguration.ArgumentAspect"));
|
|
|
|
|
addExtraAspect(new WorkingDirectoryAspect(this, "Nim.NimRunConfiguration.WorkingDirectoryAspect"));
|
|
|
|
|
addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier()));
|
2018-05-03 18:15:49 +02:00
|
|
|
addExtraAspect(new TerminalAspect(this, "Nim.NimRunConfiguration.TerminalAspect"));
|
2015-08-26 09:37:55 +02:00
|
|
|
|
2018-04-06 17:43:47 +02:00
|
|
|
setDisplayName(tr("Current Build Target"));
|
|
|
|
|
setDefaultDisplayName(tr("Current Build Target"));
|
2015-08-26 09:37:55 +02:00
|
|
|
|
|
|
|
|
// Connect target signals
|
2017-09-01 13:23:02 +02:00
|
|
|
connect(target, &Target::activeBuildConfigurationChanged,
|
2015-08-26 09:37:55 +02:00
|
|
|
this, &NimRunConfiguration::updateConfiguration);
|
|
|
|
|
updateConfiguration();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NimRunConfiguration::updateConfiguration()
|
|
|
|
|
{
|
|
|
|
|
auto buildConfiguration = qobject_cast<NimBuildConfiguration *>(activeBuildConfiguration());
|
|
|
|
|
QTC_ASSERT(buildConfiguration, return);
|
|
|
|
|
setActiveBuildConfiguration(buildConfiguration);
|
|
|
|
|
const QFileInfo outFileInfo = buildConfiguration->outFilePath().toFileInfo();
|
2018-04-06 17:43:47 +02:00
|
|
|
extraAspect<ExecutableAspect>()->setExecutable(FileName::fromString(outFileInfo.absoluteFilePath()));
|
2017-11-21 16:22:34 +01:00
|
|
|
const QString workingDirectory = outFileInfo.absoluteDir().absolutePath();
|
2018-04-06 17:43:47 +02:00
|
|
|
extraAspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(FileName::fromString(workingDirectory));
|
2015-08-26 09:37:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NimRunConfiguration::setActiveBuildConfiguration(NimBuildConfiguration *activeBuildConfiguration)
|
|
|
|
|
{
|
|
|
|
|
if (m_buildConfiguration == activeBuildConfiguration)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (m_buildConfiguration) {
|
|
|
|
|
disconnect(m_buildConfiguration, &NimBuildConfiguration::buildDirectoryChanged,
|
|
|
|
|
this, &NimRunConfiguration::updateConfiguration);
|
|
|
|
|
disconnect(m_buildConfiguration, &NimBuildConfiguration::outFilePathChanged,
|
|
|
|
|
this, &NimRunConfiguration::updateConfiguration);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_buildConfiguration = activeBuildConfiguration;
|
|
|
|
|
|
|
|
|
|
if (m_buildConfiguration) {
|
|
|
|
|
connect(m_buildConfiguration, &NimBuildConfiguration::buildDirectoryChanged,
|
|
|
|
|
this, &NimRunConfiguration::updateConfiguration);
|
|
|
|
|
connect(m_buildConfiguration, &NimBuildConfiguration::outFilePathChanged,
|
|
|
|
|
this, &NimRunConfiguration::updateConfiguration);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-17 19:05:42 +01:00
|
|
|
// NimRunConfigurationFactory
|
|
|
|
|
|
2018-04-06 17:43:47 +02:00
|
|
|
NimRunConfigurationFactory::NimRunConfigurationFactory() : FixedRunConfigurationFactory(QString())
|
2018-01-17 19:05:42 +01:00
|
|
|
{
|
2018-04-25 10:26:08 +02:00
|
|
|
registerRunConfiguration<NimRunConfiguration>("Nim.NimRunConfiguration");
|
2018-01-17 19:05:42 +01:00
|
|
|
addSupportedProjectType(Constants::C_NIMPROJECT_ID);
|
2018-05-11 16:59:36 +02:00
|
|
|
addRunWorkerFactory<SimpleTargetRunner>(ProjectExplorer::Constants::NORMAL_RUN_MODE);
|
2018-01-17 19:05:42 +01:00
|
|
|
}
|
|
|
|
|
|
2018-04-06 17:43:47 +02:00
|
|
|
} // Nim
|