Commit 3cc1a2a9 authored by Daniel Teske's avatar Daniel Teske

Less magic in BuildStep::buildConfiguration() and deployConfiguration()

Where the deploy stuff depends on the activeBuildConfiguration it's
likely to be wrong or worse could be used to crash creator. So make
those places stand out.
Also if we ever move towards supporting meta-builds of multiple
buildconfigurations at once, then using the active build configuration
is wrong.

Change-Id: I754a77a4a8b352e79e8a6703c26ed41a189cf74e
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent eb03e966
......@@ -156,22 +156,22 @@ void AbstractMaemoPackageCreationStep::handleBuildOutput()
const Qt4BuildConfiguration *AbstractMaemoPackageCreationStep::qt4BuildConfiguration() const
{
return static_cast<Qt4BuildConfiguration *>(buildConfiguration());
return static_cast<Qt4BuildConfiguration *>(target()->activeBuildConfiguration());
}
AbstractQt4MaemoTarget *AbstractMaemoPackageCreationStep::maemoTarget() const
{
return qobject_cast<AbstractQt4MaemoTarget *>(buildConfiguration()->target());
return qobject_cast<AbstractQt4MaemoTarget *>(target());
}
AbstractDebBasedQt4MaemoTarget *AbstractMaemoPackageCreationStep::debBasedMaemoTarget() const
{
return qobject_cast<AbstractDebBasedQt4MaemoTarget*>(buildConfiguration()->target());
return qobject_cast<AbstractDebBasedQt4MaemoTarget*>(target());
}
AbstractRpmBasedQt4MaemoTarget *AbstractMaemoPackageCreationStep::rpmBasedMaemoTarget() const
{
return qobject_cast<AbstractRpmBasedQt4MaemoTarget*>(buildConfiguration()->target());
return qobject_cast<AbstractRpmBasedQt4MaemoTarget*>(target());
}
bool AbstractMaemoPackageCreationStep::isPackagingNeeded() const
......@@ -293,7 +293,7 @@ bool MaemoDebianPackageCreationStep::init()
if (!AbstractMaemoPackageCreationStep::init())
return false;
m_maddeRoot = MaemoGlobal::maddeRoot(qt4BuildConfiguration()->qtVersion()->qmakeCommand());
m_projectDirectory = buildConfiguration()->target()->project()->projectDirectory();
m_projectDirectory = project()->projectDirectory();
m_pkgFileName = maemoTarget()->packageFileName();
m_packageName = maemoTarget()->packageName();
m_templatesDirPath = debBasedMaemoTarget()->debianDirPath();
......@@ -364,7 +364,7 @@ bool MaemoDebianPackageCreationStep::isMetaDataNewerThan(const QDateTime &packag
void MaemoDebianPackageCreationStep::checkProjectName()
{
const QRegExp legalName(QLatin1String("[0-9-+a-z\\.]+"));
if (!legalName.exactMatch(buildConfiguration()->target()->project()->displayName())) {
if (!legalName.exactMatch(project()->displayName())) {
emit addTask(Task(Task::Warning,
tr("Your project name contains characters not allowed in "
"Debian packages.\nThey must only use lower-case letters, "
......
......@@ -381,7 +381,7 @@ void AbstractProcessStep::taskAdded(const ProjectExplorer::Task &task)
QList<QFileInfo> possibleFiles;
QString fileName = QFileInfo(filePath).fileName();
foreach (const QString &file, buildConfiguration()->target()->project()->files(ProjectExplorer::Project::AllFiles)) {
foreach (const QString &file, project()->files(ProjectExplorer::Project::AllFiles)) {
QFileInfo candidate(file);
if (candidate.fileName() == fileName)
possibleFiles << candidate;
......
......@@ -42,7 +42,6 @@
#include "target.h"
#include "taskwindow.h"
#include "taskhub.h"
#include "buildconfiguration.h"
#include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h>
......@@ -221,7 +220,7 @@ void BuildManager::cancel()
QTimer::singleShot(0, this, SLOT(emitCancelMessage()));
disconnectOutput(d->m_currentBuildStep);
decrementActiveBuildSteps(d->m_currentBuildStep->buildConfiguration()->target()->project());
decrementActiveBuildSteps(d->m_currentBuildStep->project());
d->m_progressFutureInterface->setProgressValueAndText(d->m_progress*100, tr("Build canceled")); //TODO NBS fix in qtconcurrent
clearBuildQueue();
......@@ -256,7 +255,7 @@ void BuildManager::emitCancelMessage()
void BuildManager::clearBuildQueue()
{
foreach (BuildStep *bs, d->m_buildQueue) {
decrementActiveBuildSteps(bs->buildConfiguration()->target()->project());
decrementActiveBuildSteps(bs->project());
disconnectOutput(bs);
}
......@@ -382,13 +381,13 @@ void BuildManager::nextBuildQueue()
disconnectOutput(d->m_currentBuildStep);
++d->m_progress;
d->m_progressFutureInterface->setProgressValueAndText(d->m_progress*100, msgProgress(d->m_progress, d->m_maxProgress));
decrementActiveBuildSteps(d->m_currentBuildStep->buildConfiguration()->target()->project());
decrementActiveBuildSteps(d->m_currentBuildStep->project());
bool result = d->m_watcher.result();
if (!result) {
// Build Failure
const QString projectName = d->m_currentBuildStep->buildConfiguration()->target()->project()->displayName();
const QString targetName = d->m_currentBuildStep->buildConfiguration()->target()->displayName();
const QString projectName = d->m_currentBuildStep->project()->displayName();
const QString targetName = d->m_currentBuildStep->target()->displayName();
addToOutputWindow(tr("Error while building project %1 (target: %2)").arg(projectName, targetName), BuildStep::ErrorOutput);
addToOutputWindow(tr("When executing build step '%1'").arg(d->m_currentBuildStep->displayName()), BuildStep::ErrorOutput);
// NBS TODO fix in qtconcurrent
......@@ -429,11 +428,11 @@ void BuildManager::nextStep()
d->m_currentBuildStep = d->m_buildQueue.front();
d->m_buildQueue.pop_front();
if (d->m_currentBuildStep->buildConfiguration()->target()->project() != d->m_previousBuildStepProject) {
const QString projectName = d->m_currentBuildStep->buildConfiguration()->target()->project()->displayName();
if (d->m_currentBuildStep->project() != d->m_previousBuildStepProject) {
const QString projectName = d->m_currentBuildStep->project()->displayName();
addToOutputWindow(tr("Running build steps for project %1...")
.arg(projectName), BuildStep::MessageOutput);
d->m_previousBuildStepProject = d->m_currentBuildStep->buildConfiguration()->target()->project();
d->m_previousBuildStepProject = d->m_currentBuildStep->project();
}
if (d->m_currentBuildStep->runInGuiThread()) {
connect (d->m_currentBuildStep, SIGNAL(finished()),
......@@ -476,8 +475,8 @@ bool BuildManager::buildQueueAppend(QList<BuildStep *> steps)
// cleaning up
// print something for the user
const QString projectName = bs->buildConfiguration()->target()->project()->displayName();
const QString targetName = bs->buildConfiguration()->target()->displayName();
const QString projectName = bs->project()->displayName();
const QString targetName = bs->project()->displayName();
addToOutputWindow(tr("Error while building project %1 (target: %2)").arg(projectName, targetName), BuildStep::ErrorOutput);
addToOutputWindow(tr("When executing build step '%1'").arg(bs->displayName()), BuildStep::ErrorOutput);
......@@ -491,7 +490,7 @@ bool BuildManager::buildQueueAppend(QList<BuildStep *> steps)
for (i = 0; i < count; ++i) {
++d->m_maxProgress;
d->m_buildQueue.append(steps.at(i));
incrementActiveBuildSteps(steps.at(i)->buildConfiguration()->target()->project());
incrementActiveBuildSteps(steps.at(i)->target()->project());
}
return true;
}
......
......@@ -142,18 +142,12 @@ BuildStep::~BuildStep()
BuildConfiguration *BuildStep::buildConfiguration() const
{
BuildConfiguration *bc = qobject_cast<BuildConfiguration *>(parent()->parent());
if (!bc)
bc = target()->activeBuildConfiguration();
return bc;
return qobject_cast<BuildConfiguration *>(parent()->parent());
}
DeployConfiguration *BuildStep::deployConfiguration() const
{
DeployConfiguration *dc = qobject_cast<DeployConfiguration *>(parent()->parent());
if (!dc)
dc = target()->activeDeployConfiguration();
return dc;
return qobject_cast<DeployConfiguration *>(parent()->parent());
}
Target *BuildStep::target() const
......@@ -161,6 +155,11 @@ Target *BuildStep::target() const
return qobject_cast<Target *>(parent()->parent()->parent());
}
Project *BuildStep::project() const
{
return target()->project();
}
bool BuildStep::immutable() const
{
return false;
......
......@@ -77,6 +77,7 @@ public:
enum OutputFormat { NormalOutput, ErrorOutput, MessageOutput, ErrorMessageOutput };
enum OutputNewlineSetting { DoAppendNewline, DontAppendNewline };
Project *project() const;
signals:
void addTask(const ProjectExplorer::Task &task);
......
......@@ -132,10 +132,9 @@ QString QMakeStep::allArguments(bool shorted)
if (bc->subNodeBuild())
arguments << QDir::toNativeSeparators(bc->subNodeBuild()->path());
else if (shorted)
arguments << QDir::toNativeSeparators(QFileInfo(
buildConfiguration()->target()->project()->file()->fileName()).fileName());
arguments << QDir::toNativeSeparators(QFileInfo(project()->file()->fileName()).fileName());
else
arguments << QDir::toNativeSeparators(buildConfiguration()->target()->project()->file()->fileName());
arguments << QDir::toNativeSeparators(project()->file()->fileName());
arguments << "-r";
bool userProvidedMkspec = false;
......
......@@ -175,12 +175,12 @@ bool S60CreatePackageStep::fromMap(const QVariantMap &map)
Qt4BuildConfiguration *S60CreatePackageStep::qt4BuildConfiguration() const
{
return static_cast<Qt4BuildConfiguration *>(buildConfiguration());
return static_cast<Qt4BuildConfiguration *>(target()->activeBuildConfiguration());
}
bool S60CreatePackageStep::init()
{
Qt4Project *pro = qobject_cast<Qt4Project *>(buildConfiguration()->target()->project());
Qt4Project *pro = qobject_cast<Qt4Project *>(project());
QList<Qt4ProFileNode *> nodes = pro->allProFiles();
......@@ -200,7 +200,7 @@ bool S60CreatePackageStep::init()
m_makeCmd = qt4BuildConfiguration()->makeCommand();
if (!QFileInfo(m_makeCmd).isAbsolute()) {
// Try to detect command in environment
const QString tmp = buildConfiguration()->environment().searchInPath(m_makeCmd);
const QString tmp = qt4BuildConfiguration()->environment().searchInPath(m_makeCmd);
if (tmp.isEmpty()) {
emit addOutput(tr("Could not find make command '%1' in the build environment").arg(m_makeCmd), BuildStep::ErrorOutput);
return false;
......@@ -711,7 +711,7 @@ bool S60CreatePackageStep::createsSmartInstaller() const
void S60CreatePackageStep::setCreatesSmartInstaller(bool value)
{
m_createSmartInstaller = value;
static_cast<Qt4BuildConfiguration *>(buildConfiguration())->emitS60CreatesSmartInstallerChanged();
qt4BuildConfiguration()->emitS60CreatesSmartInstallerChanged();
}
void S60CreatePackageStep::resetPassphrases()
......
......@@ -150,7 +150,7 @@ S60DeployStep::~S60DeployStep()
bool S60DeployStep::init()
{
Qt4BuildConfiguration *bc = static_cast<Qt4BuildConfiguration *>(buildConfiguration());
Qt4BuildConfiguration *bc = static_cast<Qt4BuildConfiguration *>(target()->activeBuildConfiguration());
S60DeployConfiguration *deployConfiguration = static_cast<S60DeployConfiguration *>(bc->target()->activeDeployConfiguration());
if (!deployConfiguration)
return false;
......
......@@ -36,6 +36,7 @@
#include "remotelinuxdeploystepwidget.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <qt4projectmanager/qt4buildconfiguration.h>
using namespace ProjectExplorer;
......@@ -88,7 +89,7 @@ bool AbstractRemoteLinuxDeployStep::init()
bool AbstractRemoteLinuxDeployStep::isDeploymentPossible(QString *whyNot) const
{
deployService()->setDeviceConfiguration(deployConfiguration()->deviceConfiguration());
deployService()->setBuildConfiguration(qobject_cast<Qt4ProjectManager::Qt4BuildConfiguration *>(buildConfiguration()));
deployService()->setBuildConfiguration(qobject_cast<Qt4ProjectManager::Qt4BuildConfiguration *>(target()->activeBuildConfiguration()));
return deployService()->isDeploymentPossible(whyNot);
}
......
......@@ -297,7 +297,7 @@ bool TarPackageCreationStep::writeHeader(QFile &tarFile, const QFileInfo &fileIn
QString TarPackageCreationStep::packageFileName() const
{
return target()->project()->displayName() + QLatin1String(".tar");
return project()->displayName() + QLatin1String(".tar");
}
BuildStepConfigWidget *TarPackageCreationStep::createConfigWidget()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment