Commit 328a24ed authored by Oleksii Serdiuk's avatar Oleksii Serdiuk
Browse files

CMake: Make CMake plugin work with RemoteLinux plugin.



Modified CMake plugin to work correctly with RemoteLinux plugin.
Because of not being able to extract files to be installed from CMake
project, only executable targets are automatically added to deployment
files. All other files have to be specified in CMakeDeployment.txt file
which should be placed into root of CMake project. The file format is:
> deployment/prefix
> relative/source/file1:relative/destination/dir1
> ...
> relative/source/filen:relative/destination/dirn

Where:
- deployment/prefix is (absolute) path prefix to which files will be
  deployed on the remote machine.
- relative/source/file is file path relative to CMake project root.
  Plain files - no directories or wildcards supported.
- relative/destination/dir is destination directory path relative to
  deployment/prefix.

Change-Id: I0831636c1b9aac3ff16bb6293104c512d2abfb5a
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 0392435d
......@@ -42,6 +42,7 @@
#include <projectexplorer/abi.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <texteditor/fontsettings.h>
#include <remotelinux/remotelinux_constants.h>
#include <QVBoxLayout>
#include <QFormLayout>
......@@ -179,7 +180,8 @@ QList<GeneratorInfo> GeneratorInfo::generatorInfosFor(ProjectExplorer::Kit *k, N
if (!tc)
return results;
Core::Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(k);
if (deviceType != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
if (deviceType != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE
&& deviceType != RemoteLinux::Constants::GenericLinuxOsType)
return results;
ProjectExplorer::Abi targetAbi = tc->targetAbi();
if (n != ForceNinja) {
......
......@@ -41,11 +41,13 @@
#include <projectexplorer/headerpath.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/buildmanager.h>
#include <projectexplorer/buildtargetinfo.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/target.h>
#include <projectexplorer/deployconfiguration.h>
#include <projectexplorer/deploymentdata.h>
#include <projectexplorer/projectmacroexpander.h>
#include <qtsupport/customexecutablerunconfiguration.h>
#include <qtsupport/baseqtversion.h>
......@@ -261,6 +263,7 @@ bool CMakeProject::parseCMakeLists()
// qDebug()<<"";
// }
updateApplicationAndDeploymentTargets();
createUiCodeModelSupport();
......@@ -562,9 +565,7 @@ bool CMakeProject::fromMap(const QVariantMap &map)
t->addBuildConfiguration(bc);
DeployConfigurationFactory *fac = ExtensionSystem::PluginManager::getObject<DeployConfigurationFactory>();
ProjectExplorer::DeployConfiguration *dc = fac->create(t, ProjectExplorer::Constants::DEFAULT_DEPLOYCONFIGURATION_ID);
t->addDeployConfiguration(dc);
t->updateDefaultDeployConfigurations();
addTarget(t);
} else {
......@@ -608,17 +609,9 @@ bool CMakeProject::fromMap(const QVariantMap &map)
bool CMakeProject::setupTarget(Target *t)
{
CMakeBuildConfigurationFactory *factory
= ExtensionSystem::PluginManager::getObject<CMakeBuildConfigurationFactory>();
CMakeBuildConfiguration *bc = factory->create(t, Constants::CMAKE_BC_ID, QLatin1String("all"));
if (!bc)
return false;
t->addBuildConfiguration(bc);
t->updateDefaultBuildConfigurations();
t->updateDefaultDeployConfigurations();
DeployConfigurationFactory *fac = ExtensionSystem::PluginManager::getObject<DeployConfigurationFactory>();
ProjectExplorer::DeployConfiguration *dc = fac->create(t, ProjectExplorer::Constants::DEFAULT_DEPLOYCONFIGURATION_ID);
t->addDeployConfiguration(dc);
return true;
}
......@@ -720,6 +713,50 @@ void CMakeProject::updateRunConfigurations(Target *t)
}
}
void CMakeProject::updateApplicationAndDeploymentTargets()
{
Target *t = activeTarget();
QFile deploymentFile;
QTextStream deploymentStream;
QString deploymentPrefix;
QDir sourceDir;
sourceDir.setPath(t->project()->projectDirectory());
deploymentFile.setFileName(sourceDir.filePath(QLatin1String("QtCreatorDeployment.txt")));
if (deploymentFile.open(QFile::ReadOnly | QFile::Text)) {
deploymentStream.setDevice(&deploymentFile);
deploymentPrefix = deploymentStream.readLine();
if (!deploymentPrefix.endsWith(QLatin1Char('/')))
deploymentPrefix.append(QLatin1Char('/'));
}
BuildTargetInfoList appTargetList;
DeploymentData deploymentData;
QDir buildDir(t->activeBuildConfiguration()->buildDirectory().toString());
foreach (const CMakeBuildTarget &ct, m_buildTargets) {
if (ct.executable.isEmpty())
continue;
deploymentData.addFile(ct.executable, deploymentPrefix + buildDir.relativeFilePath(QFileInfo(ct.executable).dir().path()), DeployableFile::TypeExecutable);
if (!ct.library) {
// TODO: Put a path to corresponding .cbp file into projectFilePath?
appTargetList.list << BuildTargetInfo(ct.executable, ct.executable);
}
}
QString absoluteSourcePath = sourceDir.absolutePath();
if (!absoluteSourcePath.endsWith(QLatin1Char('/')))
absoluteSourcePath.append(QLatin1Char('/'));
while (!deploymentStream.atEnd()) {
QStringList file = deploymentStream.readLine().split(QLatin1Char(':'));
deploymentData.addFile(absoluteSourcePath + file.at(0), deploymentPrefix + file.at(1));
}
t->setApplicationTargets(appTargetList);
t->setDeploymentData(deploymentData);
}
void CMakeProject::createUiCodeModelSupport()
{
QHash<QString, QString> uiFileHash;
......
......@@ -125,6 +125,7 @@ private:
void createUiCodeModelSupport();
QString uiHeaderFile(const QString &uiFile);
void updateRunConfigurations(ProjectExplorer::Target *t);
void updateApplicationAndDeploymentTargets();
CMakeManager *m_manager;
ProjectExplorer::Target *m_activeTarget;
......
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