CMakeProjectManager: Support mapping chroot include paths

Provide a way for plugins to map include paths into a build chroot.
Plugins can register a path mapper if required, otherwise the paths
are not touched.

Change-Id: I621982831fa354d6d0f558a6c1dce4e014421f12
Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
Benjamin Zeller
2015-03-10 15:47:09 +01:00
parent 9f7c801e4d
commit 255b5850e2
7 changed files with 62 additions and 8 deletions

View File

@@ -29,6 +29,8 @@
****************************************************************************/
#include "cmakecbpparser.h"
#include "cmakekitinformation.h"
#include "cmaketool.h"
#include <utils/fileutils.h>
#include <utils/stringutils.h>
@@ -147,8 +149,9 @@ void CMakeCbpParser::sortFiles()
qCDebug(log) << target.title << target.sourceDirectory << target.includeFiles << target.defines << target.files << "\n";
}
bool CMakeCbpParser::parseCbpFile(const QString &fileName, const QString &sourceDirectory)
bool CMakeCbpParser::parseCbpFile(Kit *kit, const QString &fileName, const QString &sourceDirectory)
{
m_kit = kit;
m_buildDirectory = QFileInfo(fileName).absolutePath();
m_sourceDirectory = sourceDirectory;
@@ -245,6 +248,9 @@ void CMakeCbpParser::parseBuildTargetOption()
{
if (attributes().hasAttribute(QLatin1String("output"))) {
m_buildTarget.executable = attributes().value(QLatin1String("output")).toString();
CMakeTool *tool = CMakeKitInformation::cmakeTool(m_kit);
if (tool)
m_buildTarget.executable = tool->mapAllPaths(m_kit, m_buildTarget.executable);
} else if (attributes().hasAttribute(QLatin1String("type"))) {
const QStringRef value = attributes().value(QLatin1String("type"));
if (value == QLatin1String("2") || value == QLatin1String("3"))
@@ -304,8 +310,13 @@ void CMakeCbpParser::parseMakeCommands()
void CMakeCbpParser::parseBuildTargetBuild()
{
if (attributes().hasAttribute(QLatin1String("command")))
if (attributes().hasAttribute(QLatin1String("command"))) {
m_buildTarget.makeCommand = attributes().value(QLatin1String("command")).toString();
CMakeTool *tool = CMakeKitInformation::cmakeTool(m_kit);
if (tool)
m_buildTarget.makeCommand = tool->mapAllPaths(m_kit, m_buildTarget.makeCommand);
}
while (!atEnd()) {
readNext();
if (isEndElement())
@@ -317,8 +328,13 @@ void CMakeCbpParser::parseBuildTargetBuild()
void CMakeCbpParser::parseBuildTargetClean()
{
if (attributes().hasAttribute(QLatin1String("command")))
if (attributes().hasAttribute(QLatin1String("command"))) {
m_buildTarget.makeCleanCommand = attributes().value(QLatin1String("command")).toString();
CMakeTool *tool = CMakeKitInformation::cmakeTool(m_kit);
if (tool)
m_buildTarget.makeCleanCommand = tool->mapAllPaths(m_kit, m_buildTarget.makeCleanCommand);
}
while (!atEnd()) {
readNext();
if (isEndElement())
@@ -346,7 +362,12 @@ void CMakeCbpParser::parseAdd()
// CMake only supports <Add option=\> and <Add directory=\>
const QXmlStreamAttributes addAttributes = attributes();
const QString includeDirectory = addAttributes.value(QLatin1String("directory")).toString();
QString includeDirectory = addAttributes.value(QLatin1String("directory")).toString();
CMakeTool *tool = CMakeKitInformation::cmakeTool(m_kit);
if (tool)
includeDirectory = tool->mapAllPaths(m_kit, includeDirectory);
// allow adding multiple times because order happens
if (!includeDirectory.isEmpty())
m_buildTarget.includeFiles.append(includeDirectory);
@@ -380,6 +401,13 @@ void CMakeCbpParser::parseUnit()
//qDebug()<<stream.attributes().value("filename");
FileName fileName =
FileName::fromUserInput(attributes().value(QLatin1String("filename")).toString());
CMakeTool *tool = CMakeKitInformation::cmakeTool(m_kit);
if (tool) {
QString mappedFile = tool->mapAllPaths(m_kit, fileName.toString());
fileName = FileName::fromUserInput(mappedFile);
}
m_parsingCmakeUnit = false;
while (!atEnd()) {
readNext();