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

Proposed by Benjamin Zeller on 2016-09-05
Status: Merged
Approved by: Zoltan Balogh on 2016-09-06
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 on 2016-09-06
Zoltan Balogh (community) 2016-09-05 Approve on 2016-09-05
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.
review: Needs Fixing (continuous-integration)
Zoltan Balogh (bzoltan) :
review: Approve
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UbuntuPlugin.pro'
2--- UbuntuPlugin.pro 2016-07-20 14:56:52 +0000
3+++ UbuntuPlugin.pro 2016-09-05 17:16:02 +0000
4@@ -88,7 +88,6 @@
5 src/ubuntu/ubuntuabstractguieditordocument.cpp \
6 src/ubuntu/ubuntuapparmoreditor.cpp \
7 src/ubuntu/ubuntueditorfactory.cpp \
8- src/ubuntu/ubuntucmakecache.cpp \
9 src/ubuntu/ubuntutestcontrol.cpp \
10 src/ubuntu/ubuntupackageoutputparser.cpp \
11 src/ubuntu/ubuntuprojecthelper.cpp \
12@@ -156,7 +155,6 @@
13 src/ubuntu/ubuntuabstractguieditordocument.h \
14 src/ubuntu/ubuntuapparmoreditor.h \
15 src/ubuntu/ubuntueditorfactory.h \
16- src/ubuntu/ubuntucmakecache.h \
17 src/ubuntu/ubuntutestcontrol.h \
18 src/ubuntu/ubuntupackageoutputparser.h \
19 src/ubuntu/ubuntuprojecthelper.h \
20
21=== modified file 'src/ubuntu/device/container/ubuntulocalrunconfiguration.cpp'
22--- src/ubuntu/device/container/ubuntulocalrunconfiguration.cpp 2016-08-29 15:46:17 +0000
23+++ src/ubuntu/device/container/ubuntulocalrunconfiguration.cpp 2016-09-05 17:16:02 +0000
24@@ -21,7 +21,6 @@
25 #include <ubuntu/ubuntuprojecthelper.h>
26 #include <ubuntu/ubuntuclickmanifest.h>
27 #include <ubuntu/device/remote/ubunturemoterunconfiguration.h>
28-#include <ubuntu/ubuntucmakecache.h>
29 #include <ubuntu/ubuntuprojecthelper.h>
30 #include <ubuntu/ubuntuclicktool.h>
31 #include <ubuntu/clicktoolchain.h>
32
33=== modified file 'src/ubuntu/device/container/ubuntulocalrunconfigurationfactory.cpp'
34--- src/ubuntu/device/container/ubuntulocalrunconfigurationfactory.cpp 2016-07-20 14:56:52 +0000
35+++ src/ubuntu/device/container/ubuntulocalrunconfigurationfactory.cpp 2016-09-05 17:16:02 +0000
36@@ -20,7 +20,6 @@
37 #include <ubuntu/ubuntuprojecthelper.h>
38 #include <ubuntu/clicktoolchain.h>
39 #include <ubuntu/ubuntuclickmanifest.h>
40-#include <ubuntu/ubuntucmakecache.h>
41 #include <ubuntu/ubuntushared.h>
42
43 #include <ubuntu/device/remote/ubunturemoterunconfiguration.h>
44
45=== removed file 'src/ubuntu/ubuntucmakecache.cpp'
46--- src/ubuntu/ubuntucmakecache.cpp 2016-07-20 14:56:52 +0000
47+++ src/ubuntu/ubuntucmakecache.cpp 1970-01-01 00:00:00 +0000
48@@ -1,130 +0,0 @@
49-#include "ubuntucmakecache.h"
50-
51-#include <projectexplorer/session.h>
52-#include <projectexplorer/project.h>
53-#include <projectexplorer/target.h>
54-#include <projectexplorer/buildconfiguration.h>
55-#include <cmakeprojectmanager/cmakeprojectconstants.h>
56-
57-#include <QRegularExpression>
58-#include <QDir>
59-#include <QDebug>
60-
61-namespace Ubuntu{
62-namespace Internal {
63-
64-enum {
65- debug = 0
66-};
67-
68-/*!
69- * \class UbuntuCMakeCache::UbuntuCMakeCache
70- * Automatic updating value cache, this reads all relevant CMakeCache files
71- * and stores some for quick querying
72- */
73-
74-UbuntuCMakeCache * UbuntuCMakeCache::m_instance = nullptr;
75-
76-UbuntuCMakeCache::UbuntuCMakeCache(QObject *parent) :
77- QObject(parent)
78-{
79- Q_ASSERT_X(m_instance == nullptr,Q_FUNC_INFO,"There can be only one UbuntuCMakeCache instance");
80- m_instance = this;
81-
82- connect(ProjectExplorer::SessionManager::instance(),SIGNAL(aboutToRemoveProject(ProjectExplorer::Project *)),
83- this,SLOT(onAboutToRemoveProject(ProjectExplorer::Project*)));
84-}
85-
86-QVariant UbuntuCMakeCache::getValue(const QString &key, ProjectExplorer::BuildConfiguration *bc, const QVariant defaultValue)
87-{
88- UbuntuCMakeCache *inst = instance();
89- if(!inst || !bc)
90- return defaultValue;
91-
92- Utils::FileName cacheFile = bc->buildDirectory().appendPath(QStringLiteral("CMakeCache.txt"));
93- QString cacheKey = inst->normalize(cacheFile.toString());
94-
95- bool needsRefresh = false;
96- if(!inst->m_map.contains(cacheKey)) {
97- //we need to read it
98- needsRefresh = true;
99- } else {
100- //check if the file has changed since the last read
101- inst->m_map[cacheKey].cacheFile.refresh();
102- if(debug) qDebug()<<"File Last Read "<<inst->m_map[cacheKey].cacheFile.lastModified()
103- <<"Cache Last Read "<<inst->m_map[cacheKey].lastRead;
104- if(inst->m_map[cacheKey].cacheFile.lastModified() != inst->m_map[cacheKey].lastRead) {
105- needsRefresh = true;
106- }
107- }
108-
109- if(needsRefresh)
110- inst->refreshCache(cacheKey, cacheFile);
111-
112- if(inst->m_map[cacheKey].values.contains(key))
113- return inst->m_map[cacheKey].values[key];
114-
115- return defaultValue;
116-}
117-
118-UbuntuCMakeCache *UbuntuCMakeCache::instance()
119-{
120- return m_instance;
121-}
122-
123-void UbuntuCMakeCache::onAboutToRemoveProject(ProjectExplorer::Project *p)
124-{
125- if(!p)
126- return;
127-
128- //remove all values that belong to the project
129- for (ProjectExplorer::Target *t : p->targets()) {
130- for(ProjectExplorer::BuildConfiguration *bc : t->buildConfigurations()) {
131- Utils::FileName cacheFile = bc->buildDirectory().appendPath(QStringLiteral("CMakeCache.txt"));
132- m_map.remove(normalize(cacheFile.toString()));
133- }
134- }
135-}
136-
137-QString UbuntuCMakeCache::normalize(const QString &path) const
138-{
139- return QDir::cleanPath(path);
140-}
141-
142-void UbuntuCMakeCache::refreshCache(const QString &key, const Utils::FileName &fName)
143-{
144- if(debug) qDebug()<<"Rebuilding cache for: "<<key;
145- UbuntuCMakeCacheEntry *entry = nullptr;
146- if(m_map.contains(key)) {
147- entry = &m_map[key];
148- entry->lastRead = fName.toFileInfo().lastModified();
149- } else {
150- QFileInfo fInfo = fName.toFileInfo();
151- entry = &m_map.insert(key,UbuntuCMakeCacheEntry{fInfo,fInfo.lastModified(),CMakeCacheValueMap()}).value();
152- }
153-
154- QFile cache(fName.toString());
155- if(cache.exists() && cache.open(QIODevice::ReadOnly)) {
156- static const QRegularExpression regExpPType(QLatin1String("^UBUNTU_PROJECT_TYPE:(.*)=\\s*(\\S*)\\s*$"));
157- static const QRegularExpression regExpManifestPath (QLatin1String("^UBUNTU_MANIFEST_PATH:(.*)=\\s*(\\S*)\\s*$"));
158- QTextStream in(&cache);
159- while (!in.atEnd()) {
160- QString contents = in.readLine();
161- QRegularExpressionMatch m = regExpPType.match(contents);
162- if(m.hasMatch()) {
163- entry->values.insert(QStringLiteral("UBUNTU_PROJECT_TYPE"),m.captured(2));
164- continue;
165- }
166- m = regExpManifestPath.match(contents);
167- if(m.hasMatch()) {
168- entry->values.insert(QStringLiteral("UBUNTU_MANIFEST_PATH"),m.captured(2));
169- continue;
170- }
171- }
172-
173-
174- }
175-}
176-
177-}}
178-
179
180=== removed file 'src/ubuntu/ubuntucmakecache.h'
181--- src/ubuntu/ubuntucmakecache.h 2014-08-20 07:38:07 +0000
182+++ src/ubuntu/ubuntucmakecache.h 1970-01-01 00:00:00 +0000
183@@ -1,58 +0,0 @@
184-#ifndef UBUNTUCMAKECACHE_H
185-#define UBUNTUCMAKECACHE_H
186-
187-#include <QObject>
188-#include <QHash>
189-#include <QMap>
190-#include <QVariant>
191-#include <QDateTime>
192-#include <QFileInfo>
193-
194-#include <utils/fileutils.h>
195-
196-namespace ProjectExplorer {
197- class Project;
198- class Target;
199- class BuildConfiguration;
200-}
201-
202-namespace Ubuntu{
203-namespace Internal {
204-
205-typedef QMap<QString,QVariant> CMakeCacheValueMap;
206-
207-struct UbuntuCMakeCacheEntry {
208- QFileInfo cacheFile;
209- QDateTime lastRead;
210- CMakeCacheValueMap values;
211-};
212-
213-typedef QMap<QString,UbuntuCMakeCacheEntry> CMakeCache;
214-
215-class UbuntuCMakeCache : public QObject
216-{
217- Q_OBJECT
218-public:
219- explicit UbuntuCMakeCache(QObject *parent = 0);
220-
221- static QVariant getValue (const QString &key, ProjectExplorer::BuildConfiguration *bc, const QVariant defaultValue = QVariant());
222- static UbuntuCMakeCache *instance();
223-
224-private slots:
225- void onAboutToRemoveProject (ProjectExplorer::Project *p);
226-
227-private:
228- QString normalize (const QString &path) const;
229- void refreshCache (const QString &key, const Utils::FileName &fName);
230-
231-private:
232- CMakeCache m_map;
233- static UbuntuCMakeCache *m_instance;
234-
235-};
236-
237-}}
238-
239-
240-
241-#endif // UBUNTUCMAKECACHE_H
242
243=== modified file 'src/ubuntu/ubuntupackagingmodel.cpp'
244--- src/ubuntu/ubuntupackagingmodel.cpp 2016-07-20 14:56:52 +0000
245+++ src/ubuntu/ubuntupackagingmodel.cpp 2016-09-05 17:16:02 +0000
246@@ -23,7 +23,6 @@
247 #include "ubuntuvalidationresultmodel.h"
248 #include "ubuntupackagestep.h"
249 #include "ubuntushared.h"
250-#include "ubuntucmakecache.h"
251 #include "ubuntuprojecthelper.h"
252 #include "ubuntufixmanifeststep.h"
253 #include "wizards/ubuntufatpackagingwizard.h"
254
255=== modified file 'src/ubuntu/ubuntuplugin.cpp'
256--- src/ubuntu/ubuntuplugin.cpp 2016-07-20 14:56:52 +0000
257+++ src/ubuntu/ubuntuplugin.cpp 2016-09-05 17:16:02 +0000
258@@ -29,7 +29,6 @@
259 #include "ubuntuqtversion.h"
260 #include "ubuntuqmlbuildconfiguration.h"
261 #include "ubuntueditorfactory.h"
262-#include "ubuntucmakecache.h"
263 #include "ubuntutestcontrol.h"
264 #include "ubuntupackageoutputparser.h"
265 #include "ubuntuprojecthelper.h"
266@@ -175,7 +174,6 @@
267
268 // Build support
269 addAutoReleasedObject(new ClickToolChainFactory);
270- addAutoReleasedObject(new UbuntuCMakeCache);
271 addAutoReleasedObject(new UbuntuHtmlBuildConfigurationFactory);
272 addAutoReleasedObject(new UbuntuQmlBuildConfigurationFactory);
273 addAutoReleasedObject(new UbuntuQmlBuildStepFactory);
274
275=== modified file 'src/ubuntu/ubuntuprojecthelper.cpp'
276--- src/ubuntu/ubuntuprojecthelper.cpp 2015-06-30 13:34:14 +0000
277+++ src/ubuntu/ubuntuprojecthelper.cpp 2016-09-05 17:16:02 +0000
278@@ -16,7 +16,6 @@
279 * Author: Benjamin Zeller <benjamin.zeller@canonical.com>
280 */
281 #include "ubuntuprojecthelper.h"
282-#include "ubuntucmakecache.h"
283
284 #include <projectexplorer/project.h>
285 #include <projectexplorer/target.h>
286@@ -24,6 +23,7 @@
287
288 #include <cmakeprojectmanager/cmakeproject.h>
289 #include <cmakeprojectmanager/cmakeprojectconstants.h>
290+#include <cmakeprojectmanager/cmakebuildconfiguration.h>
291
292 #include <qmakeprojectmanager/qmakeproject.h>
293 #include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
294@@ -33,6 +33,7 @@
295 #include <QDebug>
296
297 #include <QFile>
298+#include <QDir>
299 #include <QTextStream>
300 #include <QRegularExpression>
301
302@@ -124,12 +125,24 @@
303 QString UbuntuProjectHelper::getManifestPath(ProjectExplorer::Target *target, const QString &defaultValue)
304 {
305 if(target && target->project()->id() == CMakeProjectManager::Constants::CMAKEPROJECT_ID ) {
306- QVariant manifestPath = UbuntuCMakeCache::getValue(QStringLiteral("UBUNTU_MANIFEST_PATH"),
307- target->activeBuildConfiguration(),
308- defaultValue);
309+
310+ CMakeProjectManager::CMakeConfig fullCache = CMakeProjectManager::CMakeProject::activeCmakeCacheForTarget(target);
311+
312+ QString manifestPath;
313+
314+ QByteArray fromCache = CMakeProjectManager::CMakeConfigItem::valueOf("UBUNTU_MANIFEST_PATH", fullCache );
315+ if (!fromCache.isEmpty()) {
316+ manifestPath = QString::fromUtf8(fromCache);
317+ } else {
318+ manifestPath = defaultValue;
319+ }
320+
321+ if(QDir::isAbsolutePath(manifestPath))
322+ return manifestPath;
323
324 Utils::FileName projectDir = target->project()->projectDirectory();
325- return projectDir.appendPath(manifestPath.toString()).toString();
326+ return projectDir.appendPath(manifestPath).toString();
327+
328 } else if (target && target->project()->id() == QmakeProjectManager::Constants::QMAKEPROJECT_ID ) {
329 QmakeProjectManager::QmakeProject *qmakeProj = static_cast<QmakeProjectManager::QmakeProject *>(target->project());
330 QList<QmakeProjectManager::QmakeProFileNode *> nodes = qmakeProj->allProFiles();
331
332=== modified file 'src/ubuntu/wizards/ubuntuprojectapplicationwizard.cpp'
333--- src/ubuntu/wizards/ubuntuprojectapplicationwizard.cpp 2016-07-20 14:56:52 +0000
334+++ src/ubuntu/wizards/ubuntuprojectapplicationwizard.cpp 2016-09-05 17:16:02 +0000
335@@ -27,6 +27,7 @@
336 #include <utils/qtcassert.h>
337 #include <utils/pathchooser.h>
338 #include <utils/mimetypes/mimedatabase.h>
339+#include <utils/algorithm.h>
340 #include <qtsupport/qtkitinformation.h>
341 #include <qtsupport/qtsupportconstants.h>
342 #include <projectexplorer/kitmanager.h>
343@@ -171,39 +172,37 @@
344 delete m_targetSetupPage;
345 }
346
347-bool UbuntuProjectApplicationWizardDialog::writeUserFile(const QString &projectFileName) const
348+void UbuntuProjectApplicationWizardDialog::writeUserFile(const QString &projectFileName) const
349 {
350 if (!m_targetSetupPage)
351- return false;
352+ return;
353
354 QFileInfo fi = QFileInfo(projectFileName);
355 if (!fi.exists())
356- return false;
357+ return;
358
359 QString filePath = fi.canonicalFilePath();
360
361 Utils::MimeDatabase mimeDb;
362 const Utils::MimeType mt = mimeDb.mimeTypeForFile(fi);
363 if (mt.isValid()) {
364- QList<ProjectExplorer::IProjectManager*> allProjectManagers = ExtensionSystem::PluginManager::getObjects<ProjectExplorer::IProjectManager>();
365- foreach (ProjectExplorer::IProjectManager *manager, allProjectManagers) {
366- if (manager->mimeType() == mt.name()) {
367- QString tmp;
368- if (ProjectExplorer::Project *pro = manager->openProject(filePath, &tmp)) {
369- if(debug) qDebug()<<"Storing project type settings: "<<pro->id().toSetting();
370
371- bool success = m_targetSetupPage->setupProject(pro);
372- if(success) {
373- pro->saveSettings();
374- }
375- delete pro;
376- return success;
377- }
378- break;
379+ QString tmp;
380+ QList<ProjectExplorer::IProjectManager *> managerList = ExtensionSystem::PluginManager::getObjects<ProjectExplorer::IProjectManager>();
381+ auto manager = Utils::findOrDefault(managerList, Utils::equal(&ProjectExplorer::IProjectManager::mimeType, mt.name()));
382+ ProjectExplorer::Project *project = manager ? manager->openProject(filePath, &tmp) : 0;
383+ if(project) {
384+ if (m_targetSetupPage->setupProject(project)) {
385+ if(debug) qDebug()<<"Storing project type settings: "<<project->id().toSetting();
386+ project->saveSettings();
387 }
388+ delete project;
389+ project = nullptr;
390 }
391+
392+ return;
393 }
394- return false;
395+ return;
396 }
397
398
399
400=== modified file 'src/ubuntu/wizards/ubuntuprojectapplicationwizard.h'
401--- src/ubuntu/wizards/ubuntuprojectapplicationwizard.h 2016-07-20 14:56:52 +0000
402+++ src/ubuntu/wizards/ubuntuprojectapplicationwizard.h 2016-09-05 17:16:02 +0000
403@@ -76,7 +76,7 @@
404 void addTargetSetupPage(int id = -1);
405
406 QList<Core::Id> selectedKits() const;
407- bool writeUserFile(const QString &projectFileName) const;
408+ void writeUserFile(const QString &projectFileName) const;
409 private slots:
410 void generateProfileName(const QString &projectName, const QString &path);
411 private:

Subscribers

People subscribed via source and target branches