summaryrefslogtreecommitdiff
path: root/src/plugins/cmakeprojectmanager/cmakecbpparser.cpp
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/cmakeprojectmanager/cmakecbpparser.cpp
parent3adb71d45ebebd8c8fc2ec6beeb7a5ee67d64e4e (diff)
downloadqt-creator-b6e12f4a1c2a8dbc7a672f0cf42ea76ece71b10d.tar.gz
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/cmakeprojectmanager/cmakecbpparser.cpp')
-rw-r--r--src/plugins/cmakeprojectmanager/cmakecbpparser.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakecbpparser.cpp b/src/plugins/cmakeprojectmanager/cmakecbpparser.cpp
index 591768f515..96cf7d138d 100644
--- a/src/plugins/cmakeprojectmanager/cmakecbpparser.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakecbpparser.cpp
@@ -30,6 +30,7 @@
#include <utils/fileutils.h>
#include <utils/stringutils.h>
#include <utils/algorithm.h>
+#include <projectexplorer/projectmacro.h>
#include <projectexplorer/projectnodes.h>
#include <QLoggingCategory>
@@ -71,8 +72,9 @@ void CMakeCbpParser::sortFiles()
qCDebug(log) << "# Pre Dump #";
qCDebug(log) << "###############";
foreach (const CMakeBuildTarget &target, m_buildTargets)
- qCDebug(log) << target.title << target.sourceDirectory <<
- target.includeFiles << target.defines << target.files << "\n";
+ qCDebug(log) << target.title << target.sourceDirectory << target.includeFiles
+ << ProjectExplorer::Macro::toByteArray(target.macros)
+ << target.files << "\n";
// find a good build target to fall back
int fallbackIndex = 0;
@@ -153,7 +155,9 @@ void CMakeCbpParser::sortFiles()
qCDebug(log) << "# After Dump #";
qCDebug(log) << "###############";
foreach (const CMakeBuildTarget &target, m_buildTargets)
- qCDebug(log) << target.title << target.sourceDirectory << target.includeFiles << target.defines << target.files << "\n";
+ qCDebug(log) << target.title << target.sourceDirectory << target.includeFiles
+ << ProjectExplorer::Macro::toByteArray(target.macros)
+ << target.files << "\n";
}
bool CMakeCbpParser::parseCbpFile(CMakeTool::PathMapper mapper, const FileName &fileName,
@@ -397,12 +401,8 @@ void CMakeCbpParser::parseAdd()
m_buildTarget.compilerOptions.append(compilerOption);
int macroNameIndex = compilerOption.indexOf("-D") + 2;
if (macroNameIndex != 1) {
- int assignIndex = compilerOption.indexOf('=', macroNameIndex);
- if (assignIndex != -1)
- compilerOption[assignIndex] = ' ';
- m_buildTarget.defines.append("#define ");
- m_buildTarget.defines.append(compilerOption.mid(macroNameIndex).toUtf8());
- m_buildTarget.defines.append('\n');
+ const QString keyValue = compilerOption.mid(macroNameIndex);
+ m_buildTarget.macros.append(ProjectExplorer::Macro::fromKeyValue(keyValue));
}
}