From f27b738f65a045b4a063d6c29f74606c4ec6b98f Mon Sep 17 00:00:00 2001 From: Christian Kandeler <christian.kandeler@digia.com> Date: Mon, 2 Sep 2013 10:12:37 +0200 Subject: [PATCH] QbsProjectManager: Add support for remote targets. After parsing, we tell the target about deployable files and executables, so it can make use of that information for deployment and remote execution, respectively. In addition, the current default deploy configuration (consisting of just an install step) is now set up only for the desktop device, since other targets will likely provide specialized deployment solutions. The most noticeable effect of this patch is that the RemoteLinux target and its descendants now work out of the box with qbs projects. Change-Id: I512d4e215f2fa540efd4de5f5c1e53abaa0596d1 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com> --- .../qbsdeployconfigurationfactory.cpp | 7 +++- src/plugins/qbsprojectmanager/qbsproject.cpp | 35 +++++++++++++++++++ src/plugins/qbsprojectmanager/qbsproject.h | 2 ++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.cpp b/src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.cpp index 911e05631fe..abd0028eb75 100644 --- a/src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.cpp +++ b/src/plugins/qbsprojectmanager/qbsdeployconfigurationfactory.cpp @@ -33,6 +33,8 @@ #include "qbsproject.h" #include <projectexplorer/buildsteplist.h> +#include <projectexplorer/kitinformation.h> +#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/target.h> namespace QbsProjectManager { @@ -88,8 +90,11 @@ QbsDeployConfigurationFactory::QbsDeployConfigurationFactory(QObject *parent) : QList<Core::Id> QbsDeployConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent) const { QList<Core::Id> ids; - if (qobject_cast<QbsProject *>(parent->project())) + const Core::Id deviceId = ProjectExplorer::DeviceKitInformation::deviceId(parent->kit()); + if (qobject_cast<QbsProject *>(parent->project()) + && deviceId == ProjectExplorer::Constants::DESKTOP_DEVICE_ID) { ids << genericQbsDeployConfigurationId(); + } return ids; } diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp index 119c522a15b..87389db717b 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.cpp +++ b/src/plugins/qbsprojectmanager/qbsproject.cpp @@ -47,6 +47,8 @@ #include <coreplugin/mimedatabase.h> #include <cpptools/cppmodelmanager.h> #include <projectexplorer/buildenvironmentwidget.h> +#include <projectexplorer/buildtargetinfo.h> +#include <projectexplorer/deploymentdata.h> #include <projectexplorer/kit.h> #include <projectexplorer/kitinformation.h> #include <projectexplorer/projectexplorer.h> @@ -280,6 +282,8 @@ void QbsProject::handleQbsParsingDone(bool success) updateCppCodeModel(m_rootProjectNode->qbsProjectData()); updateQmlJsCodeModel(m_rootProjectNode->qbsProjectData()); + updateApplicationTargets(m_rootProjectNode->qbsProjectData()); + updateDeploymentInfo(m_rootProjectNode->qbsProject()); foreach (Target *t, targets()) t->updateDefaultRunConfigurations(); @@ -617,6 +621,37 @@ void QbsProject::updateQmlJsCodeModel(const qbs::ProjectData &prj) modelManager->updateProjectInfo(projectInfo); } +void QbsProject::updateApplicationTargets(const qbs::ProjectData &projectData) +{ + ProjectExplorer::BuildTargetInfoList applications; + foreach (const qbs::ProductData &productData, projectData.allProducts()) { + foreach (const qbs::TargetArtifact &ta, productData.targetArtifacts()) { + QTC_ASSERT(ta.isValid(), continue); + if (!ta.isExecutable()) + continue; + applications.list << ProjectExplorer::BuildTargetInfo(Utils::FileName::fromString(ta.filePath()), + Utils::FileName::fromString(productData.location().fileName())); + } + } + activeTarget()->setApplicationTargets(applications); +} + +void QbsProject::updateDeploymentInfo(const qbs::Project *project) +{ + ProjectExplorer::DeploymentData deploymentData; + if (project) { + qbs::InstallOptions installOptions; + installOptions.setInstallRoot(QLatin1String("/")); + foreach (const qbs::InstallableFile &f, + project->installableFilesForProject(project->projectData(), installOptions)) { + deploymentData.addFile(f.sourceFilePath(), f.targetDirectory(), f.isExecutable() + ? ProjectExplorer::DeployableFile::TypeExecutable + : ProjectExplorer::DeployableFile::TypeNormal); + } + } + activeTarget()->setDeploymentData(deploymentData); +} + QString QbsProject::qbsBuildDir() const { QString buildDir = Environment::systemEnvironment().value(QLatin1String("QBS_BUILD_DIR")); diff --git a/src/plugins/qbsprojectmanager/qbsproject.h b/src/plugins/qbsprojectmanager/qbsproject.h index 205dcb69962..53f07f40f4e 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.h +++ b/src/plugins/qbsprojectmanager/qbsproject.h @@ -128,6 +128,8 @@ private: void updateDocuments(const QSet<QString> &files); void updateCppCodeModel(const qbs::ProjectData &prj); void updateQmlJsCodeModel(const qbs::ProjectData &prj); + void updateApplicationTargets(const qbs::ProjectData &projectData); + void updateDeploymentInfo(const qbs::Project *project); QString qbsBuildDir() const; QbsManager *const m_manager; -- GitLab