aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/autotoolsprojectmanager
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2017-02-07 15:00:38 +0100
committerMarco Bubke <marco.bubke@qt.io>2017-09-14 15:23:56 +0000
commitb6e12f4a1c2a8dbc7a672f0cf42ea76ece71b10d (patch)
tree81550e7fce5053ecb1ead60ddf59534d44517a87 /src/plugins/autotoolsprojectmanager
parent3adb71d45ebebd8c8fc2ec6beeb7a5ee67d64e4e (diff)
Convert macros from plain QByteArray to a vector of structs
The old code model expected the macros as C++ formatted text ("#define Foo 42) but newer targets like the Clang codemodel expect key value arguments like "-DFoo=42". So instead of parsing the text again and again we use an abstract data description. Task-number: QTCREATORBUG-17915 Change-Id: I0179fd13c48a581e91ee79bba9d42d501c26f19f Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/autotoolsprojectmanager')
-rw-r--r--src/plugins/autotoolsprojectmanager/autotoolsproject.cpp2
-rw-r--r--src/plugins/autotoolsprojectmanager/makefileparser.cpp10
-rw-r--r--src/plugins/autotoolsprojectmanager/makefileparser.h9
-rw-r--r--src/plugins/autotoolsprojectmanager/makefileparserthread.cpp6
-rw-r--r--src/plugins/autotoolsprojectmanager/makefileparserthread.h11
5 files changed, 22 insertions, 16 deletions
diff --git a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp
index a24993187e..01105d8497 100644
--- a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp
+++ b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp
@@ -298,7 +298,7 @@ void AutotoolsProject::updateCppCodeModel()
? target->activeBuildConfiguration()->buildDirectory().toString() : QString();
rpp.setIncludePaths(filterIncludes(absSrc, absBuild, m_makefileParserThread->includePaths()));
- rpp.setDefines(m_makefileParserThread->defines());
+ rpp.setMacros(m_makefileParserThread->macros());
rpp.setFiles(m_files);
m_cppCodeModelUpdater->update({this, cToolChain, cxxToolChain, k, {rpp}});
diff --git a/src/plugins/autotoolsprojectmanager/makefileparser.cpp b/src/plugins/autotoolsprojectmanager/makefileparser.cpp
index 74e29054ec..9c3e32216b 100644
--- a/src/plugins/autotoolsprojectmanager/makefileparser.cpp
+++ b/src/plugins/autotoolsprojectmanager/makefileparser.cpp
@@ -108,9 +108,9 @@ QStringList MakefileParser::includePaths() const
return m_includePaths;
}
-QByteArray MakefileParser::defines() const
+ProjectExplorer::Macros MakefileParser::macros() const
{
- return m_defines;
+ return m_macros;
}
QStringList MakefileParser::cflags() const
@@ -449,11 +449,7 @@ bool MakefileParser::maybeParseDefine(const QString &term)
{
if (term.startsWith(QLatin1String("-D"))) {
QString def = term.mid(2); // remove the "-D"
- QByteArray data = def.toUtf8();
- int pos = data.indexOf('=');
- if (pos >= 0)
- data[pos] = ' ';
- m_defines += (QByteArray("#define ") + data + '\n');
+ m_macros += ProjectExplorer::Macro::fromKeyValue(def);
return true;
}
return false;
diff --git a/src/plugins/autotoolsprojectmanager/makefileparser.h b/src/plugins/autotoolsprojectmanager/makefileparser.h
index beaa1a57db..d6387bc29c 100644
--- a/src/plugins/autotoolsprojectmanager/makefileparser.h
+++ b/src/plugins/autotoolsprojectmanager/makefileparser.h
@@ -27,10 +27,13 @@
#pragma once
+#include <projectexplorer/projectmacro.h>
+
#include <QMutex>
#include <QStringList>
#include <QTextStream>
#include <QObject>
+#include <QVector>
QT_FORWARD_DECLARE_CLASS(QDir)
@@ -49,6 +52,8 @@ class MakefileParser : public QObject
{
Q_OBJECT
+ using Macros = ProjectExplorer::Macros;
+
public:
/**
* @param makefile Filename including path of the autotools
@@ -98,7 +103,7 @@ public:
* #define X12_HAS_DEPRECATED
* @endcode
*/
- QByteArray defines() const;
+ Macros macros() const;
/**
* @return List of compiler flags for C.
@@ -267,7 +272,7 @@ private:
QStringList m_sources; ///< Return value for MakefileParser::sources()
QStringList m_makefiles; ///< Return value for MakefileParser::makefiles()
QStringList m_includePaths; ///< Return value for MakefileParser::includePaths()
- QByteArray m_defines; ///< Return value for MakefileParser::defines()
+ Macros m_macros; ///< Return value for MakefileParser::macros()
QStringList m_cflags; ///< Return value for MakefileParser::cflags()
QStringList m_cxxflags; ///< Return value for MakefileParser::cxxflags()
QStringList m_cppflags; ///< The cpp flags, which will be part of both cflags and cxxflags
diff --git a/src/plugins/autotoolsprojectmanager/makefileparserthread.cpp b/src/plugins/autotoolsprojectmanager/makefileparserthread.cpp
index cfe7e9757f..a33d39599b 100644
--- a/src/plugins/autotoolsprojectmanager/makefileparserthread.cpp
+++ b/src/plugins/autotoolsprojectmanager/makefileparserthread.cpp
@@ -61,10 +61,10 @@ QStringList MakefileParserThread::includePaths() const
return m_includePaths;
}
-QByteArray MakefileParserThread::defines() const
+ProjectExplorer::Macros MakefileParserThread::macros() const
{
QMutexLocker locker(&m_mutex);
- return m_defines;
+ return m_macros;
}
QStringList MakefileParserThread::cflags() const
@@ -109,7 +109,7 @@ void MakefileParserThread::run()
m_sources = m_parser.sources();
m_makefiles = m_parser.makefiles();
m_includePaths = m_parser.includePaths();
- m_defines = m_parser.defines();
+ m_macros = m_parser.macros();
m_cflags = m_parser.cflags();
m_cxxflags = m_parser.cxxflags();
}
diff --git a/src/plugins/autotoolsprojectmanager/makefileparserthread.h b/src/plugins/autotoolsprojectmanager/makefileparserthread.h
index 94b965d133..3e16bdccc4 100644
--- a/src/plugins/autotoolsprojectmanager/makefileparserthread.h
+++ b/src/plugins/autotoolsprojectmanager/makefileparserthread.h
@@ -29,9 +29,12 @@
#include "makefileparser.h"
+#include <projectexplorer/projectmacro.h>
+
#include <QMutex>
#include <QStringList>
#include <QThread>
+#include <QVector>
namespace AutotoolsProjectManager {
namespace Internal {
@@ -47,6 +50,8 @@ class MakefileParserThread : public QThread
{
Q_OBJECT
+ using Macros = ProjectExplorer::Macros;
+
public:
MakefileParserThread(const QString &makefile);
@@ -82,10 +87,10 @@ public:
QStringList includePaths() const;
/**
- * @return Concatenated defines. Should be invoked, after the signal
+ * @return Concatenated macros. Should be invoked, after the signal
* finished() has been emitted.
*/
- QByteArray defines() const;
+ Macros macros() const;
/**
* @return List of compiler flags for C. Should be invoked, after the signal
@@ -134,7 +139,7 @@ private:
QStringList m_sources; ///< Return value for MakefileParserThread::sources()
QStringList m_makefiles; ///< Return value for MakefileParserThread::makefiles()
QStringList m_includePaths; ///< Return value for MakefileParserThread::includePaths()
- QByteArray m_defines; ///< Return value for MakefileParserThread::defines()
+ Macros m_macros; ///< Return value for MakefileParserThread::macros()
QStringList m_cflags; ///< Return value for MakefileParserThread::cflags()
QStringList m_cxxflags; ///< Return value for MakefileParserThread::cxxflags()
};