summaryrefslogtreecommitdiff
path: root/src/plugins/remotelinux/abstractpackagingstep.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@nokia.com>2011-07-15 16:57:25 +0200
committerChristian Kandeler <christian.kandeler@nokia.com>2011-07-15 17:06:29 +0200
commit076064ce306a91879eaeac2420c4ec7b19fa7b5e (patch)
tree473071f3ffe9678ac3646f43234446809bc3b226 /src/plugins/remotelinux/abstractpackagingstep.cpp
parent89ac110ab066f3183725f574a237f9ef4c92192f (diff)
downloadqt-creator-076064ce306a91879eaeac2420c4ec7b19fa7b5e.tar.gz
RemoteLinux: Introduce abstract packaging step.
This removes the dependency of the tar packaging step on Maemo-specific code. Change-Id: I863b13e643a5028edaf2f571f63b1a52d229812b Reviewed-on: http://codereview.qt.nokia.com/1709 Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
Diffstat (limited to 'src/plugins/remotelinux/abstractpackagingstep.cpp')
-rw-r--r--src/plugins/remotelinux/abstractpackagingstep.cpp159
1 files changed, 159 insertions, 0 deletions
diff --git a/src/plugins/remotelinux/abstractpackagingstep.cpp b/src/plugins/remotelinux/abstractpackagingstep.cpp
new file mode 100644
index 0000000000..4f5bd6a0d0
--- /dev/null
+++ b/src/plugins/remotelinux/abstractpackagingstep.cpp
@@ -0,0 +1,159 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (info@qt.nokia.com)
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** Other Usage
+**
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at info@qt.nokia.com.
+**
+**************************************************************************/
+#include "abstractpackagingstep.h"
+
+#include "deploymentinfo.h"
+#include "remotelinuxdeployconfiguration.h"
+
+#include <projectexplorer/buildconfiguration.h>
+#include <projectexplorer/projectexplorerconstants.h>
+#include <projectexplorer/target.h>
+#include <utils/fileutils.h>
+
+#include <QtCore/QFileInfo>
+
+using namespace ProjectExplorer;
+
+namespace RemoteLinux {
+namespace Internal {
+
+class AbstractPackagingStepPrivate
+{
+public:
+ AbstractPackagingStepPrivate() : currentBuildConfiguration(0), running(false) { }
+
+ BuildConfiguration *currentBuildConfiguration;
+ bool running;
+ QString cachedPackageDirectory;
+};
+
+} // namespace Internal
+
+AbstractPackagingStep::AbstractPackagingStep(BuildStepList *bsl, const QString &id)
+ : BuildStep(bsl, id)
+{
+ ctor();
+}
+
+AbstractPackagingStep::AbstractPackagingStep(BuildStepList *bsl, AbstractPackagingStep *other)
+ : BuildStep(bsl, other)
+{
+ ctor();
+}
+
+void AbstractPackagingStep::ctor()
+{
+ m_d = new Internal::AbstractPackagingStepPrivate;
+ connect(target(), SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
+ SLOT(handleBuildConfigurationChanged()));
+ handleBuildConfigurationChanged();
+}
+
+AbstractPackagingStep::~AbstractPackagingStep()
+{
+ delete m_d;
+}
+
+void AbstractPackagingStep::handleBuildConfigurationChanged()
+{
+ if (m_d->currentBuildConfiguration)
+ disconnect(m_d->currentBuildConfiguration, 0, this, 0);
+ m_d->currentBuildConfiguration = target()->activeBuildConfiguration();
+ if (m_d->currentBuildConfiguration) {
+ connect(m_d->currentBuildConfiguration, SIGNAL(buildDirectoryChanged()), this,
+ SIGNAL(packageFilePathChanged()));
+ }
+ emit packageFilePathChanged();
+}
+
+QString AbstractPackagingStep::packageFilePath() const
+{
+ if (packageDirectory().isEmpty())
+ return QString();
+ return packageDirectory() + QLatin1Char('/') + packageFileName();
+}
+
+QString AbstractPackagingStep::packageDirectory() const
+{
+ if (m_d->running)
+ return m_d->cachedPackageDirectory;
+ return m_d->currentBuildConfiguration
+ ? m_d->currentBuildConfiguration->buildDirectory() : QString();
+}
+
+RemoteLinuxDeployConfiguration *AbstractPackagingStep::deployConfiguration() const
+{
+ return qobject_cast<RemoteLinuxDeployConfiguration *>(parent()->parent());
+}
+
+bool AbstractPackagingStep::isPackagingNeeded() const
+{
+ const QSharedPointer<DeploymentInfo> &deploymentInfo = deployConfiguration()->deploymentInfo();
+ QFileInfo packageInfo(packageFilePath());
+ if (!packageInfo.exists() || deploymentInfo->isModified())
+ return true;
+
+ const int deployableCount = deploymentInfo->deployableCount();
+ for (int i = 0; i < deployableCount; ++i) {
+ if (Utils::FileUtils::isFileNewerThan(deploymentInfo->deployableAt(i).localFilePath,
+ packageInfo.lastModified()))
+ return true;
+ }
+
+ return false;
+}
+
+bool AbstractPackagingStep::init()
+{
+ m_d->cachedPackageDirectory = packageDirectory();
+ return true;
+}
+
+void AbstractPackagingStep::setPackagingStarted()
+{
+ m_d->running = true;
+}
+
+void AbstractPackagingStep::setPackagingFinished(bool success)
+{
+ m_d->running = false;
+ if (success)
+ deployConfiguration()->deploymentInfo()->setUnmodified();
+}
+
+void AbstractPackagingStep::raiseError(const QString &errorMessage)
+{
+ emit addOutput(errorMessage, BuildStep::ErrorOutput);
+ emit addTask(Task(Task::Error, errorMessage, QString(), -1,
+ Constants::TASK_CATEGORY_BUILDSYSTEM));
+}
+
+} // namespace RemoteLinux