aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/remotelinux
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2019-04-12 14:49:59 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2019-04-23 15:52:05 +0000
commit261d7752b00dfe7191ebd1436e9e96a5212e1bb3 (patch)
tree08e5040fe25cd244221b0dd5f9b296ef0487a331 /src/plugins/remotelinux
parent8827d83115b5b3c88446dd3ba50341ca3b738c0a (diff)
RemoteLinux: Retrieve deployment info from local install root
This provides correct deployment information as seen by the build system when Qt Creator cannot retrieve it directly. It's most useful for autotools and cmake projects, but can also help with qmake in certain edge cases. [ChangeLog] It is no longer necessary to provide a QtCreatorDeployment.txt file when using CMake projects with remote Linux devices. Fixes: QTCREATORBUG-21855 Change-Id: I27e07a45dd1565e489f4b573cc3fff8191c57d9b Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/remotelinux')
-rw-r--r--src/plugins/remotelinux/genericdirectuploadstep.cpp7
-rw-r--r--src/plugins/remotelinux/genericdirectuploadstep.h1
-rw-r--r--src/plugins/remotelinux/makeinstallstep.cpp205
-rw-r--r--src/plugins/remotelinux/makeinstallstep.h62
-rw-r--r--src/plugins/remotelinux/remotelinux.pro2
-rw-r--r--src/plugins/remotelinux/remotelinux.qbs4
-rw-r--r--src/plugins/remotelinux/remotelinuxdeployconfiguration.cpp6
-rw-r--r--src/plugins/remotelinux/remotelinuxplugin.cpp2
-rw-r--r--src/plugins/remotelinux/rsyncdeploystep.cpp7
-rw-r--r--src/plugins/remotelinux/rsyncdeploystep.h1
10 files changed, 294 insertions, 3 deletions
diff --git a/src/plugins/remotelinux/genericdirectuploadstep.cpp b/src/plugins/remotelinux/genericdirectuploadstep.cpp
index a3f234685ed..54b538ab45c 100644
--- a/src/plugins/remotelinux/genericdirectuploadstep.cpp
+++ b/src/plugins/remotelinux/genericdirectuploadstep.cpp
@@ -73,7 +73,6 @@ GenericDirectUploadStep::~GenericDirectUploadStep()
bool GenericDirectUploadStep::initInternal(QString *error)
{
- d->deployService.setDeployableFiles(target()->deploymentData().allFiles());
d->deployService.setIncrementalDeployment(d->incrementalAspect->value());
d->deployService.setIgnoreMissingFiles(d->ignoreMissingFilesAspect->value());
return d->deployService.isDeploymentPossible(error);
@@ -84,6 +83,12 @@ GenericDirectUploadService *GenericDirectUploadStep::deployService() const
return &d->deployService;
}
+void GenericDirectUploadStep::doRun()
+{
+ d->deployService.setDeployableFiles(target()->deploymentData().allFiles());
+ AbstractRemoteLinuxDeployStep::doRun();
+}
+
Core::Id GenericDirectUploadStep::stepId()
{
return "RemoteLinux.DirectUploadStep";
diff --git a/src/plugins/remotelinux/genericdirectuploadstep.h b/src/plugins/remotelinux/genericdirectuploadstep.h
index 5751e833b6a..a543134e363 100644
--- a/src/plugins/remotelinux/genericdirectuploadstep.h
+++ b/src/plugins/remotelinux/genericdirectuploadstep.h
@@ -47,6 +47,7 @@ public:
private:
GenericDirectUploadService *deployService() const override;
+ void doRun() override;
Internal::GenericDirectUploadStepPrivate *d;
};
diff --git a/src/plugins/remotelinux/makeinstallstep.cpp b/src/plugins/remotelinux/makeinstallstep.cpp
new file mode 100644
index 00000000000..2980ea5ad02
--- /dev/null
+++ b/src/plugins/remotelinux/makeinstallstep.cpp
@@ -0,0 +1,205 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://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.
+**
+****************************************************************************/
+
+#include "makeinstallstep.h"
+
+#include <projectexplorer/buildsteplist.h>
+#include <projectexplorer/deployconfiguration.h>
+#include <projectexplorer/processparameters.h>
+#include <projectexplorer/runconfigurationaspects.h>
+#include <projectexplorer/target.h>
+#include <projectexplorer/task.h>
+#include <utils/fileutils.h>
+#include <utils/qtcassert.h>
+#include <utils/qtcprocess.h>
+
+#include <QDirIterator>
+#include <QFileInfo>
+#include <QFormLayout>
+#include <QTemporaryDir>
+
+using namespace ProjectExplorer;
+using namespace Utils;
+
+namespace RemoteLinux {
+namespace Internal {
+
+const char MakeAspectId[] = "RemoteLinux.MakeInstall.Make";
+const char InstallRootAspectId[] = "RemoteLinux.MakeInstall.InstallRoot";
+const char CleanInstallRootAspectId[] = "RemoteLinux.MakeInstall.CleanInstallRoot";
+const char FullCommandLineAspectId[] = "RemoteLinux.MakeInstall.FullCommandLine";
+
+MakeInstallStep::MakeInstallStep(BuildStepList *parent) : MakeStep(parent, stepId())
+{
+ setDefaultDisplayName(displayName());
+
+ const auto makeAspect = addAspect<ExecutableAspect>();
+ makeAspect->setId(MakeAspectId);
+ makeAspect->setSettingsKey(MakeAspectId);
+ makeAspect->setDisplayStyle(BaseStringAspect::PathChooserDisplay);
+ makeAspect->setLabelText(tr("Command:"));
+ connect(makeAspect, &ExecutableAspect::changed,
+ this, &MakeInstallStep::updateCommandFromAspect);
+
+ const auto installRootAspect = addAspect<BaseStringAspect>();
+ installRootAspect->setId(InstallRootAspectId);
+ installRootAspect->setSettingsKey(InstallRootAspectId);
+ installRootAspect->setDisplayStyle(BaseStringAspect::PathChooserDisplay);
+ installRootAspect->setExpectedKind(PathChooser::Directory);
+ installRootAspect->setLabelText(tr("Install root:"));
+ connect(installRootAspect, &BaseStringAspect::changed,
+ this, &MakeInstallStep::updateArgsFromAspect);
+
+ const auto cleanInstallRootAspect = addAspect<BaseBoolAspect>();
+ cleanInstallRootAspect->setId(CleanInstallRootAspectId);
+ cleanInstallRootAspect->setSettingsKey(CleanInstallRootAspectId);
+ cleanInstallRootAspect->setLabel(tr("Clean install root first"));
+ cleanInstallRootAspect->setValue(false);
+
+ const auto commandLineAspect = addAspect<BaseStringAspect>();
+ commandLineAspect->setId(FullCommandLineAspectId);
+ commandLineAspect->setDisplayStyle(BaseStringAspect::LabelDisplay);
+ commandLineAspect->setLabelText(tr("Full command line:"));
+
+ QTemporaryDir tmpDir;
+ installRootAspect->setFileName(FileName::fromString(tmpDir.path()));
+ const MakeInstallCommand cmd = target()->makeInstallCommand(tmpDir.path());
+ QTC_ASSERT(!cmd.command.isEmpty(), return);
+ makeAspect->setExecutable(cmd.command);
+}
+
+Core::Id MakeInstallStep::stepId()
+{
+ return "RemoteLinux.MakeInstall";
+}
+
+QString MakeInstallStep::displayName()
+{
+ return tr("Install into temporary host directory");
+}
+
+BuildStepConfigWidget *MakeInstallStep::createConfigWidget()
+{
+ return BuildStep::createConfigWidget();
+}
+
+bool MakeInstallStep::init()
+{
+ if (!MakeStep::init())
+ return false;
+ const QString rootDirPath = installRoot().toString();
+ if (rootDirPath.isEmpty()) {
+ emit addTask(Task(Task::Error, tr("You must provide an install root."), FileName(), -1,
+ Constants::TASK_CATEGORY_BUILDSYSTEM));
+ return false;
+ }
+ QDir rootDir(rootDirPath);
+ if (cleanInstallRoot() && !rootDir.removeRecursively()) {
+ emit addTask(Task(Task::Error, tr("The install root '%1' could not be cleaned.")
+ .arg(installRoot().toUserOutput()),
+ FileName(), -1, Constants::TASK_CATEGORY_BUILDSYSTEM));
+ return false;
+ }
+ if (!rootDir.exists() && !QDir::root().mkpath(rootDirPath)) {
+ emit addTask(Task(Task::Error, tr("The install root '%1' could not be created.")
+ .arg(installRoot().toUserOutput()),
+ FileName(), -1, Constants::TASK_CATEGORY_BUILDSYSTEM));
+ return false;
+ }
+ if (this == deployConfiguration()->stepList()->steps().last()) {
+ emit addTask(Task(Task::Warning, tr("The \"make install\" step should probably not be "
+ "last in the list of deploy steps. "
+ "Consider moving it up."), FileName(), -1,
+ Constants::TASK_CATEGORY_BUILDSYSTEM));
+ }
+ const MakeInstallCommand cmd = target()->makeInstallCommand(installRoot().toString());
+ if (cmd.environment.size() > 0) {
+ Environment env = processParameters()->environment();
+ for (auto it = cmd.environment.constBegin(); it != cmd.environment.constEnd(); ++it)
+ env.set(it.key(), it.value());
+ processParameters()->setEnvironment(env);
+ }
+ return true;
+}
+
+void MakeInstallStep::finish(bool success)
+{
+ if (success) {
+ m_deploymentData = DeploymentData();
+ m_deploymentData.setLocalInstallRoot(installRoot());
+ QDirIterator dit(installRoot().toString(), QDir::Files, QDirIterator::Subdirectories);
+ while (dit.hasNext()) {
+ dit.next();
+ const QFileInfo fi = dit.fileInfo();
+ m_deploymentData.addFile(fi.filePath(),
+ fi.dir().path().mid(installRoot().toString().length()));
+ }
+ target()->setDeploymentData(m_deploymentData);
+ }
+ MakeStep::finish(success);
+}
+
+FileName MakeInstallStep::installRoot() const
+{
+ return static_cast<BaseStringAspect *>(aspect(InstallRootAspectId))->fileName();
+}
+
+bool MakeInstallStep::cleanInstallRoot() const
+{
+ return static_cast<BaseBoolAspect *>(aspect(CleanInstallRootAspectId))->value();
+}
+
+void MakeInstallStep::updateCommandFromAspect()
+{
+ setMakeCommand(aspect<ExecutableAspect>()->executable().toString());
+ updateFullCommandLine();
+}
+
+void MakeInstallStep::updateArgsFromAspect()
+{
+ setUserArguments(QtcProcess::joinArgs(target()->makeInstallCommand(
+ static_cast<BaseStringAspect *>(aspect(InstallRootAspectId))->fileName().toString())
+ .arguments));
+ updateFullCommandLine();
+}
+
+void MakeInstallStep::updateFullCommandLine()
+{
+ static_cast<BaseStringAspect *>(aspect(FullCommandLineAspectId))->setValue(
+ QDir::toNativeSeparators(QtcProcess::quoteArg(effectiveMakeCommand()))
+ + ' ' + userArguments());
+}
+
+bool MakeInstallStep::fromMap(const QVariantMap &map)
+{
+ if (!MakeStep::fromMap(map))
+ return false;
+ updateCommandFromAspect();
+ updateArgsFromAspect();
+ return true;
+}
+
+} // namespace Internal
+} // namespace RemoteLinux
diff --git a/src/plugins/remotelinux/makeinstallstep.h b/src/plugins/remotelinux/makeinstallstep.h
new file mode 100644
index 00000000000..e9c4e9e25d1
--- /dev/null
+++ b/src/plugins/remotelinux/makeinstallstep.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://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.
+**
+****************************************************************************/
+
+#pragma once
+
+#include <projectexplorer/deploymentdata.h>
+#include <projectexplorer/makestep.h>
+
+namespace Utils { class FileName; }
+
+namespace RemoteLinux {
+namespace Internal {
+
+class MakeInstallStep : public ProjectExplorer::MakeStep
+{
+ Q_OBJECT
+public:
+ MakeInstallStep(ProjectExplorer::BuildStepList *parent);
+
+ static Core::Id stepId();
+ static QString displayName();
+
+private:
+ bool fromMap(const QVariantMap &map) override;
+ ProjectExplorer::BuildStepConfigWidget * createConfigWidget() override;
+ bool init() override;
+ void finish(bool success) override;
+
+ Utils::FileName installRoot() const;
+ bool cleanInstallRoot() const;
+
+ void updateCommandFromAspect();
+ void updateArgsFromAspect();
+ void updateFullCommandLine();
+
+ ProjectExplorer::DeploymentData m_deploymentData;
+};
+
+} // namespace Internal
+} // namespace RemoteLinux
diff --git a/src/plugins/remotelinux/remotelinux.pro b/src/plugins/remotelinux/remotelinux.pro
index 338461b28b8..4ec8891937f 100644
--- a/src/plugins/remotelinux/remotelinux.pro
+++ b/src/plugins/remotelinux/remotelinux.pro
@@ -4,6 +4,7 @@ include(../../qtcreatorplugin.pri)
HEADERS += \
embeddedlinuxqtversion.h \
+ makeinstallstep.h \
remotelinuxenvironmentaspect.h \
remotelinuxenvironmentaspectwidget.h \
remotelinuxplugin.h \
@@ -47,6 +48,7 @@ HEADERS += \
SOURCES += \
embeddedlinuxqtversion.cpp \
+ makeinstallstep.cpp \
remotelinuxenvironmentaspect.cpp \
remotelinuxenvironmentaspectwidget.cpp \
remotelinuxplugin.cpp \
diff --git a/src/plugins/remotelinux/remotelinux.qbs b/src/plugins/remotelinux/remotelinux.qbs
index f353997fdb9..92e94b65497 100644
--- a/src/plugins/remotelinux/remotelinux.qbs
+++ b/src/plugins/remotelinux/remotelinux.qbs
@@ -47,6 +47,8 @@ Project {
"linuxdeviceprocess.h",
"linuxdevicetester.cpp",
"linuxdevicetester.h",
+ "makeinstallstep.cpp",
+ "makeinstallstep.h",
"packageuploader.cpp",
"packageuploader.h",
"publickeydeploymentdialog.cpp",
@@ -101,7 +103,7 @@ Project {
"typespecificdeviceconfigurationlistmodel.h",
"uploadandinstalltarpackagestep.cpp",
"uploadandinstalltarpackagestep.h",
- "images/embeddedtarget.png"
+ "images/embeddedtarget.png",
]
Export {
diff --git a/src/plugins/remotelinux/remotelinuxdeployconfiguration.cpp b/src/plugins/remotelinux/remotelinuxdeployconfiguration.cpp
index 5f2ad0b5945..88cd76f66d4 100644
--- a/src/plugins/remotelinux/remotelinuxdeployconfiguration.cpp
+++ b/src/plugins/remotelinux/remotelinuxdeployconfiguration.cpp
@@ -27,6 +27,7 @@
#include "genericdirectuploadstep.h"
#include "linuxdevice.h"
+#include "makeinstallstep.h"
#include "remotelinuxcheckforfreediskspacestep.h"
#include "remotelinuxkillappstep.h"
#include "remotelinux_constants.h"
@@ -60,6 +61,11 @@ RemoteLinuxDeployConfigurationFactory::RemoteLinuxDeployConfigurationFactory()
"Deploy to Remote Linux Host"));
setUseDeploymentDataView();
+ addInitialStep(MakeInstallStep::stepId(), [](Target *target) {
+ const Project * const prj = target->project();
+ return prj->deploymentKnowledge() == DeploymentKnowledge::Bad
+ && prj->hasMakeInstallEquivalent();
+ });
addInitialStep(RemoteLinuxCheckForFreeDiskSpaceStep::stepId());
addInitialStep(RemoteLinuxKillAppStep::stepId());
addInitialStep(RsyncDeployStep::stepId(), [](Target *target) {
diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp
index 00fbf0f9a06..1f25666cbfe 100644
--- a/src/plugins/remotelinux/remotelinuxplugin.cpp
+++ b/src/plugins/remotelinux/remotelinuxplugin.cpp
@@ -35,6 +35,7 @@
#include "remotelinuxrunconfiguration.h"
#include "genericdirectuploadstep.h"
+#include "makeinstallstep.h"
#include "remotelinuxcheckforfreediskspacestep.h"
#include "remotelinuxdeployconfiguration.h"
#include "remotelinuxcustomcommanddeploymentstep.h"
@@ -80,6 +81,7 @@ public:
GenericDeployStepFactory<RemoteLinuxCheckForFreeDiskSpaceStep>
checkForFreeDiskSpaceStepFactory;
GenericDeployStepFactory<RemoteLinuxKillAppStep> remoteLinuxKillAppStepFactory;
+ GenericDeployStepFactory<MakeInstallStep> makeInstallStepFactory;
EmbeddedLinuxQtVersionFactory embeddedLinuxQtVersionFactory;
};
diff --git a/src/plugins/remotelinux/rsyncdeploystep.cpp b/src/plugins/remotelinux/rsyncdeploystep.cpp
index 96747de16c9..7b872b5fa35 100644
--- a/src/plugins/remotelinux/rsyncdeploystep.cpp
+++ b/src/plugins/remotelinux/rsyncdeploystep.cpp
@@ -201,7 +201,6 @@ RsyncDeployStep::~RsyncDeployStep()
bool RsyncDeployStep::initInternal(QString *error)
{
- d->deployService.setDeployableFiles(target()->deploymentData().allFiles());
d->deployService.setIgnoreMissingFiles(d->ignoreMissingFilesAspect->value());
return d->deployService.isDeploymentPossible(error);
}
@@ -211,6 +210,12 @@ AbstractRemoteLinuxDeployService *RsyncDeployStep::deployService() const
return &d->deployService;
}
+void RsyncDeployStep::doRun()
+{
+ d->deployService.setDeployableFiles(target()->deploymentData().allFiles());
+ AbstractRemoteLinuxDeployStep::doRun();
+}
+
Core::Id RsyncDeployStep::stepId()
{
return "RemoteLinux.RsyncDeployStep";
diff --git a/src/plugins/remotelinux/rsyncdeploystep.h b/src/plugins/remotelinux/rsyncdeploystep.h
index ddc627e7dca..ec936f6e5eb 100644
--- a/src/plugins/remotelinux/rsyncdeploystep.h
+++ b/src/plugins/remotelinux/rsyncdeploystep.h
@@ -55,6 +55,7 @@ public:
private:
AbstractRemoteLinuxDeployService *deployService() const override;
+ void doRun() override;
bool initInternal(QString *error = nullptr) override;