Merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/cmakecache-4.1 into lp:qtcreator-plugin-ubuntu

Proposed by Benjamin Zeller
Status: Merged
Approved by: Zoltan Balogh
Approved revision: 474
Merged at revision: 469
Proposed branch: lp:~zeller-benjamin/qtcreator-plugin-ubuntu/cmakecache-4.1
Merge into: lp:qtcreator-plugin-ubuntu
Diff against target: 411 lines (+36/-219)
10 files modified
UbuntuPlugin.pro (+0/-2)
src/ubuntu/device/container/ubuntulocalrunconfiguration.cpp (+0/-1)
src/ubuntu/device/container/ubuntulocalrunconfigurationfactory.cpp (+0/-1)
src/ubuntu/ubuntucmakecache.cpp (+0/-130)
src/ubuntu/ubuntucmakecache.h (+0/-58)
src/ubuntu/ubuntupackagingmodel.cpp (+0/-1)
src/ubuntu/ubuntuplugin.cpp (+0/-2)
src/ubuntu/ubuntuprojecthelper.cpp (+18/-5)
src/ubuntu/wizards/ubuntuprojectapplicationwizard.cpp (+17/-18)
src/ubuntu/wizards/ubuntuprojectapplicationwizard.h (+1/-1)
To merge this branch: bzr merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/cmakecache-4.1
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Needs Fixing
Zoltan Balogh Approve
Review via email: mp+304946@code.launchpad.net

Commit message

Refactored CMakePlugin uses a temporary dir as long as the builddir was not created.
We can now get the CMakeCache information directly from the plugin.

Description of the change

Refactored CMakePlugin uses a temporary dir as long as the builddir was not created.
We can now get the CMakeCache information directly from the plugin.

To post a comment you must log in.
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Zoltan Balogh (bzoltan) :
review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'UbuntuPlugin.pro'
--- UbuntuPlugin.pro 2016-07-20 14:56:52 +0000
+++ UbuntuPlugin.pro 2016-09-05 17:16:02 +0000
@@ -88,7 +88,6 @@
88 src/ubuntu/ubuntuabstractguieditordocument.cpp \88 src/ubuntu/ubuntuabstractguieditordocument.cpp \
89 src/ubuntu/ubuntuapparmoreditor.cpp \89 src/ubuntu/ubuntuapparmoreditor.cpp \
90 src/ubuntu/ubuntueditorfactory.cpp \90 src/ubuntu/ubuntueditorfactory.cpp \
91 src/ubuntu/ubuntucmakecache.cpp \
92 src/ubuntu/ubuntutestcontrol.cpp \91 src/ubuntu/ubuntutestcontrol.cpp \
93 src/ubuntu/ubuntupackageoutputparser.cpp \92 src/ubuntu/ubuntupackageoutputparser.cpp \
94 src/ubuntu/ubuntuprojecthelper.cpp \93 src/ubuntu/ubuntuprojecthelper.cpp \
@@ -156,7 +155,6 @@
156 src/ubuntu/ubuntuabstractguieditordocument.h \155 src/ubuntu/ubuntuabstractguieditordocument.h \
157 src/ubuntu/ubuntuapparmoreditor.h \156 src/ubuntu/ubuntuapparmoreditor.h \
158 src/ubuntu/ubuntueditorfactory.h \157 src/ubuntu/ubuntueditorfactory.h \
159 src/ubuntu/ubuntucmakecache.h \
160 src/ubuntu/ubuntutestcontrol.h \158 src/ubuntu/ubuntutestcontrol.h \
161 src/ubuntu/ubuntupackageoutputparser.h \159 src/ubuntu/ubuntupackageoutputparser.h \
162 src/ubuntu/ubuntuprojecthelper.h \160 src/ubuntu/ubuntuprojecthelper.h \
163161
=== modified file 'src/ubuntu/device/container/ubuntulocalrunconfiguration.cpp'
--- src/ubuntu/device/container/ubuntulocalrunconfiguration.cpp 2016-08-29 15:46:17 +0000
+++ src/ubuntu/device/container/ubuntulocalrunconfiguration.cpp 2016-09-05 17:16:02 +0000
@@ -21,7 +21,6 @@
21#include <ubuntu/ubuntuprojecthelper.h>21#include <ubuntu/ubuntuprojecthelper.h>
22#include <ubuntu/ubuntuclickmanifest.h>22#include <ubuntu/ubuntuclickmanifest.h>
23#include <ubuntu/device/remote/ubunturemoterunconfiguration.h>23#include <ubuntu/device/remote/ubunturemoterunconfiguration.h>
24#include <ubuntu/ubuntucmakecache.h>
25#include <ubuntu/ubuntuprojecthelper.h>24#include <ubuntu/ubuntuprojecthelper.h>
26#include <ubuntu/ubuntuclicktool.h>25#include <ubuntu/ubuntuclicktool.h>
27#include <ubuntu/clicktoolchain.h>26#include <ubuntu/clicktoolchain.h>
2827
=== modified file 'src/ubuntu/device/container/ubuntulocalrunconfigurationfactory.cpp'
--- src/ubuntu/device/container/ubuntulocalrunconfigurationfactory.cpp 2016-07-20 14:56:52 +0000
+++ src/ubuntu/device/container/ubuntulocalrunconfigurationfactory.cpp 2016-09-05 17:16:02 +0000
@@ -20,7 +20,6 @@
20#include <ubuntu/ubuntuprojecthelper.h>20#include <ubuntu/ubuntuprojecthelper.h>
21#include <ubuntu/clicktoolchain.h>21#include <ubuntu/clicktoolchain.h>
22#include <ubuntu/ubuntuclickmanifest.h>22#include <ubuntu/ubuntuclickmanifest.h>
23#include <ubuntu/ubuntucmakecache.h>
24#include <ubuntu/ubuntushared.h>23#include <ubuntu/ubuntushared.h>
2524
26#include <ubuntu/device/remote/ubunturemoterunconfiguration.h>25#include <ubuntu/device/remote/ubunturemoterunconfiguration.h>
2726
=== removed file 'src/ubuntu/ubuntucmakecache.cpp'
--- src/ubuntu/ubuntucmakecache.cpp 2016-07-20 14:56:52 +0000
+++ src/ubuntu/ubuntucmakecache.cpp 1970-01-01 00:00:00 +0000
@@ -1,130 +0,0 @@
1#include "ubuntucmakecache.h"
2
3#include <projectexplorer/session.h>
4#include <projectexplorer/project.h>
5#include <projectexplorer/target.h>
6#include <projectexplorer/buildconfiguration.h>
7#include <cmakeprojectmanager/cmakeprojectconstants.h>
8
9#include <QRegularExpression>
10#include <QDir>
11#include <QDebug>
12
13namespace Ubuntu{
14namespace Internal {
15
16enum {
17 debug = 0
18};
19
20/*!
21 * \class UbuntuCMakeCache::UbuntuCMakeCache
22 * Automatic updating value cache, this reads all relevant CMakeCache files
23 * and stores some for quick querying
24 */
25
26UbuntuCMakeCache * UbuntuCMakeCache::m_instance = nullptr;
27
28UbuntuCMakeCache::UbuntuCMakeCache(QObject *parent) :
29 QObject(parent)
30{
31 Q_ASSERT_X(m_instance == nullptr,Q_FUNC_INFO,"There can be only one UbuntuCMakeCache instance");
32 m_instance = this;
33
34 connect(ProjectExplorer::SessionManager::instance(),SIGNAL(aboutToRemoveProject(ProjectExplorer::Project *)),
35 this,SLOT(onAboutToRemoveProject(ProjectExplorer::Project*)));
36}
37
38QVariant UbuntuCMakeCache::getValue(const QString &key, ProjectExplorer::BuildConfiguration *bc, const QVariant defaultValue)
39{
40 UbuntuCMakeCache *inst = instance();
41 if(!inst || !bc)
42 return defaultValue;
43
44 Utils::FileName cacheFile = bc->buildDirectory().appendPath(QStringLiteral("CMakeCache.txt"));
45 QString cacheKey = inst->normalize(cacheFile.toString());
46
47 bool needsRefresh = false;
48 if(!inst->m_map.contains(cacheKey)) {
49 //we need to read it
50 needsRefresh = true;
51 } else {
52 //check if the file has changed since the last read
53 inst->m_map[cacheKey].cacheFile.refresh();
54 if(debug) qDebug()<<"File Last Read "<<inst->m_map[cacheKey].cacheFile.lastModified()
55 <<"Cache Last Read "<<inst->m_map[cacheKey].lastRead;
56 if(inst->m_map[cacheKey].cacheFile.lastModified() != inst->m_map[cacheKey].lastRead) {
57 needsRefresh = true;
58 }
59 }
60
61 if(needsRefresh)
62 inst->refreshCache(cacheKey, cacheFile);
63
64 if(inst->m_map[cacheKey].values.contains(key))
65 return inst->m_map[cacheKey].values[key];
66
67 return defaultValue;
68}
69
70UbuntuCMakeCache *UbuntuCMakeCache::instance()
71{
72 return m_instance;
73}
74
75void UbuntuCMakeCache::onAboutToRemoveProject(ProjectExplorer::Project *p)
76{
77 if(!p)
78 return;
79
80 //remove all values that belong to the project
81 for (ProjectExplorer::Target *t : p->targets()) {
82 for(ProjectExplorer::BuildConfiguration *bc : t->buildConfigurations()) {
83 Utils::FileName cacheFile = bc->buildDirectory().appendPath(QStringLiteral("CMakeCache.txt"));
84 m_map.remove(normalize(cacheFile.toString()));
85 }
86 }
87}
88
89QString UbuntuCMakeCache::normalize(const QString &path) const
90{
91 return QDir::cleanPath(path);
92}
93
94void UbuntuCMakeCache::refreshCache(const QString &key, const Utils::FileName &fName)
95{
96 if(debug) qDebug()<<"Rebuilding cache for: "<<key;
97 UbuntuCMakeCacheEntry *entry = nullptr;
98 if(m_map.contains(key)) {
99 entry = &m_map[key];
100 entry->lastRead = fName.toFileInfo().lastModified();
101 } else {
102 QFileInfo fInfo = fName.toFileInfo();
103 entry = &m_map.insert(key,UbuntuCMakeCacheEntry{fInfo,fInfo.lastModified(),CMakeCacheValueMap()}).value();
104 }
105
106 QFile cache(fName.toString());
107 if(cache.exists() && cache.open(QIODevice::ReadOnly)) {
108 static const QRegularExpression regExpPType(QLatin1String("^UBUNTU_PROJECT_TYPE:(.*)=\\s*(\\S*)\\s*$"));
109 static const QRegularExpression regExpManifestPath (QLatin1String("^UBUNTU_MANIFEST_PATH:(.*)=\\s*(\\S*)\\s*$"));
110 QTextStream in(&cache);
111 while (!in.atEnd()) {
112 QString contents = in.readLine();
113 QRegularExpressionMatch m = regExpPType.match(contents);
114 if(m.hasMatch()) {
115 entry->values.insert(QStringLiteral("UBUNTU_PROJECT_TYPE"),m.captured(2));
116 continue;
117 }
118 m = regExpManifestPath.match(contents);
119 if(m.hasMatch()) {
120 entry->values.insert(QStringLiteral("UBUNTU_MANIFEST_PATH"),m.captured(2));
121 continue;
122 }
123 }
124
125
126 }
127}
128
129}}
130
1310
=== removed file 'src/ubuntu/ubuntucmakecache.h'
--- src/ubuntu/ubuntucmakecache.h 2014-08-20 07:38:07 +0000
+++ src/ubuntu/ubuntucmakecache.h 1970-01-01 00:00:00 +0000
@@ -1,58 +0,0 @@
1#ifndef UBUNTUCMAKECACHE_H
2#define UBUNTUCMAKECACHE_H
3
4#include <QObject>
5#include <QHash>
6#include <QMap>
7#include <QVariant>
8#include <QDateTime>
9#include <QFileInfo>
10
11#include <utils/fileutils.h>
12
13namespace ProjectExplorer {
14 class Project;
15 class Target;
16 class BuildConfiguration;
17}
18
19namespace Ubuntu{
20namespace Internal {
21
22typedef QMap<QString,QVariant> CMakeCacheValueMap;
23
24struct UbuntuCMakeCacheEntry {
25 QFileInfo cacheFile;
26 QDateTime lastRead;
27 CMakeCacheValueMap values;
28};
29
30typedef QMap<QString,UbuntuCMakeCacheEntry> CMakeCache;
31
32class UbuntuCMakeCache : public QObject
33{
34 Q_OBJECT
35public:
36 explicit UbuntuCMakeCache(QObject *parent = 0);
37
38 static QVariant getValue (const QString &key, ProjectExplorer::BuildConfiguration *bc, const QVariant defaultValue = QVariant());
39 static UbuntuCMakeCache *instance();
40
41private slots:
42 void onAboutToRemoveProject (ProjectExplorer::Project *p);
43
44private:
45 QString normalize (const QString &path) const;
46 void refreshCache (const QString &key, const Utils::FileName &fName);
47
48private:
49 CMakeCache m_map;
50 static UbuntuCMakeCache *m_instance;
51
52};
53
54}}
55
56
57
58#endif // UBUNTUCMAKECACHE_H
590
=== modified file 'src/ubuntu/ubuntupackagingmodel.cpp'
--- src/ubuntu/ubuntupackagingmodel.cpp 2016-07-20 14:56:52 +0000
+++ src/ubuntu/ubuntupackagingmodel.cpp 2016-09-05 17:16:02 +0000
@@ -23,7 +23,6 @@
23#include "ubuntuvalidationresultmodel.h"23#include "ubuntuvalidationresultmodel.h"
24#include "ubuntupackagestep.h"24#include "ubuntupackagestep.h"
25#include "ubuntushared.h"25#include "ubuntushared.h"
26#include "ubuntucmakecache.h"
27#include "ubuntuprojecthelper.h"26#include "ubuntuprojecthelper.h"
28#include "ubuntufixmanifeststep.h"27#include "ubuntufixmanifeststep.h"
29#include "wizards/ubuntufatpackagingwizard.h"28#include "wizards/ubuntufatpackagingwizard.h"
3029
=== modified file 'src/ubuntu/ubuntuplugin.cpp'
--- src/ubuntu/ubuntuplugin.cpp 2016-07-20 14:56:52 +0000
+++ src/ubuntu/ubuntuplugin.cpp 2016-09-05 17:16:02 +0000
@@ -29,7 +29,6 @@
29#include "ubuntuqtversion.h"29#include "ubuntuqtversion.h"
30#include "ubuntuqmlbuildconfiguration.h"30#include "ubuntuqmlbuildconfiguration.h"
31#include "ubuntueditorfactory.h"31#include "ubuntueditorfactory.h"
32#include "ubuntucmakecache.h"
33#include "ubuntutestcontrol.h"32#include "ubuntutestcontrol.h"
34#include "ubuntupackageoutputparser.h"33#include "ubuntupackageoutputparser.h"
35#include "ubuntuprojecthelper.h"34#include "ubuntuprojecthelper.h"
@@ -175,7 +174,6 @@
175174
176 // Build support175 // Build support
177 addAutoReleasedObject(new ClickToolChainFactory);176 addAutoReleasedObject(new ClickToolChainFactory);
178 addAutoReleasedObject(new UbuntuCMakeCache);
179 addAutoReleasedObject(new UbuntuHtmlBuildConfigurationFactory);177 addAutoReleasedObject(new UbuntuHtmlBuildConfigurationFactory);
180 addAutoReleasedObject(new UbuntuQmlBuildConfigurationFactory);178 addAutoReleasedObject(new UbuntuQmlBuildConfigurationFactory);
181 addAutoReleasedObject(new UbuntuQmlBuildStepFactory);179 addAutoReleasedObject(new UbuntuQmlBuildStepFactory);
182180
=== modified file 'src/ubuntu/ubuntuprojecthelper.cpp'
--- src/ubuntu/ubuntuprojecthelper.cpp 2015-06-30 13:34:14 +0000
+++ src/ubuntu/ubuntuprojecthelper.cpp 2016-09-05 17:16:02 +0000
@@ -16,7 +16,6 @@
16 * Author: Benjamin Zeller <benjamin.zeller@canonical.com>16 * Author: Benjamin Zeller <benjamin.zeller@canonical.com>
17 */17 */
18#include "ubuntuprojecthelper.h"18#include "ubuntuprojecthelper.h"
19#include "ubuntucmakecache.h"
2019
21#include <projectexplorer/project.h>20#include <projectexplorer/project.h>
22#include <projectexplorer/target.h>21#include <projectexplorer/target.h>
@@ -24,6 +23,7 @@
2423
25#include <cmakeprojectmanager/cmakeproject.h>24#include <cmakeprojectmanager/cmakeproject.h>
26#include <cmakeprojectmanager/cmakeprojectconstants.h>25#include <cmakeprojectmanager/cmakeprojectconstants.h>
26#include <cmakeprojectmanager/cmakebuildconfiguration.h>
2727
28#include <qmakeprojectmanager/qmakeproject.h>28#include <qmakeprojectmanager/qmakeproject.h>
29#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>29#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
@@ -33,6 +33,7 @@
33#include <QDebug>33#include <QDebug>
3434
35#include <QFile>35#include <QFile>
36#include <QDir>
36#include <QTextStream>37#include <QTextStream>
37#include <QRegularExpression>38#include <QRegularExpression>
3839
@@ -124,12 +125,24 @@
124QString UbuntuProjectHelper::getManifestPath(ProjectExplorer::Target *target, const QString &defaultValue)125QString UbuntuProjectHelper::getManifestPath(ProjectExplorer::Target *target, const QString &defaultValue)
125{126{
126 if(target && target->project()->id() == CMakeProjectManager::Constants::CMAKEPROJECT_ID ) {127 if(target && target->project()->id() == CMakeProjectManager::Constants::CMAKEPROJECT_ID ) {
127 QVariant manifestPath = UbuntuCMakeCache::getValue(QStringLiteral("UBUNTU_MANIFEST_PATH"),128
128 target->activeBuildConfiguration(),129 CMakeProjectManager::CMakeConfig fullCache = CMakeProjectManager::CMakeProject::activeCmakeCacheForTarget(target);
129 defaultValue);130
131 QString manifestPath;
132
133 QByteArray fromCache = CMakeProjectManager::CMakeConfigItem::valueOf("UBUNTU_MANIFEST_PATH", fullCache );
134 if (!fromCache.isEmpty()) {
135 manifestPath = QString::fromUtf8(fromCache);
136 } else {
137 manifestPath = defaultValue;
138 }
139
140 if(QDir::isAbsolutePath(manifestPath))
141 return manifestPath;
130142
131 Utils::FileName projectDir = target->project()->projectDirectory();143 Utils::FileName projectDir = target->project()->projectDirectory();
132 return projectDir.appendPath(manifestPath.toString()).toString();144 return projectDir.appendPath(manifestPath).toString();
145
133 } else if (target && target->project()->id() == QmakeProjectManager::Constants::QMAKEPROJECT_ID ) {146 } else if (target && target->project()->id() == QmakeProjectManager::Constants::QMAKEPROJECT_ID ) {
134 QmakeProjectManager::QmakeProject *qmakeProj = static_cast<QmakeProjectManager::QmakeProject *>(target->project());147 QmakeProjectManager::QmakeProject *qmakeProj = static_cast<QmakeProjectManager::QmakeProject *>(target->project());
135 QList<QmakeProjectManager::QmakeProFileNode *> nodes = qmakeProj->allProFiles();148 QList<QmakeProjectManager::QmakeProFileNode *> nodes = qmakeProj->allProFiles();
136149
=== modified file 'src/ubuntu/wizards/ubuntuprojectapplicationwizard.cpp'
--- src/ubuntu/wizards/ubuntuprojectapplicationwizard.cpp 2016-07-20 14:56:52 +0000
+++ src/ubuntu/wizards/ubuntuprojectapplicationwizard.cpp 2016-09-05 17:16:02 +0000
@@ -27,6 +27,7 @@
27#include <utils/qtcassert.h>27#include <utils/qtcassert.h>
28#include <utils/pathchooser.h>28#include <utils/pathchooser.h>
29#include <utils/mimetypes/mimedatabase.h>29#include <utils/mimetypes/mimedatabase.h>
30#include <utils/algorithm.h>
30#include <qtsupport/qtkitinformation.h>31#include <qtsupport/qtkitinformation.h>
31#include <qtsupport/qtsupportconstants.h>32#include <qtsupport/qtsupportconstants.h>
32#include <projectexplorer/kitmanager.h>33#include <projectexplorer/kitmanager.h>
@@ -171,39 +172,37 @@
171 delete m_targetSetupPage;172 delete m_targetSetupPage;
172}173}
173174
174bool UbuntuProjectApplicationWizardDialog::writeUserFile(const QString &projectFileName) const175void UbuntuProjectApplicationWizardDialog::writeUserFile(const QString &projectFileName) const
175{176{
176 if (!m_targetSetupPage)177 if (!m_targetSetupPage)
177 return false;178 return;
178179
179 QFileInfo fi = QFileInfo(projectFileName);180 QFileInfo fi = QFileInfo(projectFileName);
180 if (!fi.exists())181 if (!fi.exists())
181 return false;182 return;
182183
183 QString filePath = fi.canonicalFilePath();184 QString filePath = fi.canonicalFilePath();
184185
185 Utils::MimeDatabase mimeDb;186 Utils::MimeDatabase mimeDb;
186 const Utils::MimeType mt = mimeDb.mimeTypeForFile(fi);187 const Utils::MimeType mt = mimeDb.mimeTypeForFile(fi);
187 if (mt.isValid()) {188 if (mt.isValid()) {
188 QList<ProjectExplorer::IProjectManager*> allProjectManagers = ExtensionSystem::PluginManager::getObjects<ProjectExplorer::IProjectManager>();
189 foreach (ProjectExplorer::IProjectManager *manager, allProjectManagers) {
190 if (manager->mimeType() == mt.name()) {
191 QString tmp;
192 if (ProjectExplorer::Project *pro = manager->openProject(filePath, &tmp)) {
193 if(debug) qDebug()<<"Storing project type settings: "<<pro->id().toSetting();
194189
195 bool success = m_targetSetupPage->setupProject(pro);190 QString tmp;
196 if(success) {191 QList<ProjectExplorer::IProjectManager *> managerList = ExtensionSystem::PluginManager::getObjects<ProjectExplorer::IProjectManager>();
197 pro->saveSettings();192 auto manager = Utils::findOrDefault(managerList, Utils::equal(&ProjectExplorer::IProjectManager::mimeType, mt.name()));
198 }193 ProjectExplorer::Project *project = manager ? manager->openProject(filePath, &tmp) : 0;
199 delete pro;194 if(project) {
200 return success;195 if (m_targetSetupPage->setupProject(project)) {
201 }196 if(debug) qDebug()<<"Storing project type settings: "<<project->id().toSetting();
202 break;197 project->saveSettings();
203 }198 }
199 delete project;
200 project = nullptr;
204 }201 }
202
203 return;
205 }204 }
206 return false;205 return;
207}206}
208207
209208
210209
=== modified file 'src/ubuntu/wizards/ubuntuprojectapplicationwizard.h'
--- src/ubuntu/wizards/ubuntuprojectapplicationwizard.h 2016-07-20 14:56:52 +0000
+++ src/ubuntu/wizards/ubuntuprojectapplicationwizard.h 2016-09-05 17:16:02 +0000
@@ -76,7 +76,7 @@
76 void addTargetSetupPage(int id = -1);76 void addTargetSetupPage(int id = -1);
7777
78 QList<Core::Id> selectedKits() const;78 QList<Core::Id> selectedKits() const;
79 bool writeUserFile(const QString &projectFileName) const;79 void writeUserFile(const QString &projectFileName) const;
80private slots:80private slots:
81 void generateProfileName(const QString &projectName, const QString &path);81 void generateProfileName(const QString &projectName, const QString &path);
82private:82private:

Subscribers

People subscribed via source and target branches