From 328a24edee3008a8d6bbbc7f57ac064bcd806d37 Mon Sep 17 00:00:00 2001 From: Oleksii Serdiuk Date: Sun, 7 Jul 2013 23:49:13 +0200 Subject: 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: Daniel Teske --- .../cmakeprojectmanager/cmakeopenprojectwizard.cpp | 4 +- src/plugins/cmakeprojectmanager/cmakeproject.cpp | 63 +++++++++++++++++----- src/plugins/cmakeprojectmanager/cmakeproject.h | 1 + 3 files changed, 54 insertions(+), 14 deletions(-) (limited to 'src/plugins/cmakeprojectmanager') diff --git a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp index bbc937d226..790ba14cb4 100644 --- a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -179,7 +180,8 @@ QList 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) { diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index a3801d3e20..ea5cf7b9ff 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -41,11 +41,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -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(); - 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(); - 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(); - 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 uiFileHash; diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h index 804eecc756..c7946d9502 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.h +++ b/src/plugins/cmakeprojectmanager/cmakeproject.h @@ -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; -- cgit v1.2.1