CppTools: Add target information to ProjectPart

This is important to be able to map sources to actual things that are
going to be built.

Change-Id: I1aef940767d60192642ed79a1703cff8dfdad9e1
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Tobias Hunger
2017-02-27 14:46:45 +01:00
committed by Christian Stenger
parent 831864c56c
commit 802eff3485
9 changed files with 17 additions and 0 deletions

View File

@@ -306,6 +306,7 @@ void ServerModeReader::updateCodeModel(CppTools::RawProjectParts &rpps)
CppTools::RawProjectPart rpp;
rpp.setProjectFileLocation(fg->target->sourceDirectory.toString() + "/CMakeLists.txt");
rpp.setBuildSystemTarget(fg->target->name);
rpp.setDisplayName(fg->target->name + QString::number(counter));
rpp.setDefines(defineArg.toUtf8());
rpp.setIncludePaths(includes);

View File

@@ -358,6 +358,7 @@ void TeaLeafReader::updateCodeModel(CppTools::RawProjectParts &rpps)
includePaths += m_parameters.buildDirectory.toString();
CppTools::RawProjectPart rpp;
rpp.setProjectFileLocation(QString()); // No project file information available!
rpp.setBuildSystemTarget(cbt.title);
rpp.setIncludePaths(includePaths);
CppTools::RawProjectPartFlags cProjectFlags;

View File

@@ -1779,12 +1779,16 @@ void CppCodeModelInspectorDialog::updateProjectPartData(const ProjectPart::Ptr &
}
const QString callGroupId = part->callGroupId.isEmpty() ? QString::fromLatin1("<None>")
: part->callGroupId;
const QString buildSystemTarget
= part->buildSystemTarget.isEmpty() ? QString::fromLatin1("<None>")
: part->buildSystemTarget;
KeyValueModel::Table table = KeyValueModel::Table()
<< qMakePair(QString::fromLatin1("Project Part Name"), part->displayName)
<< qMakePair(QString::fromLatin1("Project Part File"), part->projectFileLocation())
<< qMakePair(QString::fromLatin1("Project Name"), projectName)
<< qMakePair(QString::fromLatin1("Project File"), projectFilePath)
<< qMakePair(QString::fromLatin1("Buildsystem Target"), buildSystemTarget)
<< qMakePair(QString::fromLatin1("Callgroup Id"), callGroupId)
<< qMakePair(QString::fromLatin1("Selected For Building"),
CMI::Utils::toString(part->selectedForBuilding))

View File

@@ -185,6 +185,7 @@ static ProjectPart::Ptr projectPartFromRawProjectPart(const RawProjectPart &rawP
part->projectFileLine = rawProjectPart.projectFileLine;
part->projectFileColumn = rawProjectPart.projectFileColumn;
part->callGroupId = rawProjectPart.callGroupId;
part->buildSystemTarget = rawProjectPart.buildSystemTarget;
part->qtVersion = rawProjectPart.qtVersion;
part->projectDefines = rawProjectPart.projectDefines;
part->headerPaths = rawProjectPart.headerPaths;

View File

@@ -66,6 +66,11 @@ void RawProjectPart::setConfigFileName(const QString &configFileName)
this->projectConfigFile = configFileName;
}
void RawProjectPart::setBuildSystemTarget(const QString &target)
{
buildSystemTarget = target;
}
void RawProjectPart::setCallGroupId(const QString &id)
{
callGroupId = id;

View File

@@ -63,6 +63,7 @@ public:
void setProjectFileLocation(const QString &projectFile, int line = -1, int column = -1);
void setConfigFileName(const QString &configFileName);
void setCallGroupId(const QString &id);
void setBuildSystemTarget(const QString &target);
void setQtVersion(ProjectPart::QtVersion qtVersion);
@@ -84,6 +85,7 @@ public:
int projectFileColumn = -1;
QString projectConfigFile; // currently only used by the Generic Project Manager
QString callGroupId;
QString buildSystemTarget;
QStringList precompiledHeaders;
ProjectPartHeaderPaths headerPaths;
QByteArray projectDefines;

View File

@@ -110,6 +110,7 @@ public:
int projectFileColumn = -1;
QString projectConfigFile; // currently only used by the Generic Project Manager
QString callGroupId;
QString buildSystemTarget;
ProjectFiles files;

View File

@@ -996,6 +996,7 @@ void QbsProject::updateCppCodeModel()
rpp.setDisplayName(grp.name());
rpp.setProjectFileLocation(grp.location().filePath(),
grp.location().line(), grp.location().column());
rpp.setBuildSystemTarget(uniqueProductName(prd));
QHash<QString, qbs::ArtifactData> filePathToSourceArtifact;
bool hasCFiles = false;

View File

@@ -345,6 +345,7 @@ void QmakeProject::updateCppCodeModel()
CppTools::RawProjectPart rpp;
rpp.setDisplayName(pro->displayName());
rpp.setProjectFileLocation(pro->filePath().toString());
rpp.setBuildSystemTarget(pro->targetInformation().target);
// TODO: Handle QMAKE_CFLAGS
rpp.setFlagsForCxx({cxxToolChain, pro->variableValue(Variable::CppFlags)});
rpp.setDefines(pro->cxxDefines());