forked from qt-creator/qt-creator
CodeBlocks: Take into account file target when explicitly specified
Change-Id: I37556ef6c2c7a651709012daa9a84c66cf3af505 Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
committed by
Daniel Teske
parent
c621768b29
commit
34b92b7574
@@ -137,6 +137,14 @@ auto equal(R (S::*function)() const, T value)
|
|||||||
return std::bind<bool>(std::equal_to<T>(), value, std::bind(function, std::placeholders::_1));
|
return std::bind<bool>(std::equal_to<T>(), value, std::bind(function, std::placeholders::_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename R, typename S, typename T>
|
||||||
|
auto equal(R S::*member, T value)
|
||||||
|
-> decltype(std::bind<bool>(std::equal_to<T>(), value, std::bind(member, std::placeholders::_1)))
|
||||||
|
{
|
||||||
|
return std::bind<bool>(std::equal_to<T>(), value, std::bind(member, std::placeholders::_1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// transform
|
// transform
|
||||||
/////////////////
|
/////////////////
|
||||||
|
@@ -104,10 +104,19 @@ void CMakeCbpParser::sortFiles()
|
|||||||
|
|
||||||
foreach (const FileName &fileName, fileNames) {
|
foreach (const FileName &fileName, fileNames) {
|
||||||
qCDebug(log) << fileName;
|
qCDebug(log) << fileName;
|
||||||
|
const QString unitTarget = m_unitTargetMap[fileName];
|
||||||
|
if (!unitTarget.isEmpty()) { // target was explicitly specified for that file
|
||||||
|
int index = Utils::indexOf(m_buildTargets, Utils::equal(&CMakeBuildTarget::title, unitTarget));
|
||||||
|
if (index != -1) {
|
||||||
|
m_buildTargets[index].files.append(fileName.toString());
|
||||||
|
qCDebug(log) << " into" << m_buildTargets[index].title << "(target attribute)";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (fileName.parentDir() == parentDirectory && last) {
|
if (fileName.parentDir() == parentDirectory && last) {
|
||||||
// easy case, same parent directory as last file
|
// easy case, same parent directory as last file
|
||||||
last->files.append(fileName.toString());
|
last->files.append(fileName.toString());
|
||||||
qCDebug(log) << " into" << last->title;
|
qCDebug(log) << " into" << last->title << "(same parent)";
|
||||||
} else {
|
} else {
|
||||||
int bestDistance = std::numeric_limits<int>::max();
|
int bestDistance = std::numeric_limits<int>::max();
|
||||||
int bestIndex = -1;
|
int bestIndex = -1;
|
||||||
@@ -228,8 +237,7 @@ void CMakeCbpParser::parseBuildTarget()
|
|||||||
readNext();
|
readNext();
|
||||||
if (isEndElement()) {
|
if (isEndElement()) {
|
||||||
if (!m_buildTarget.title.endsWith(QLatin1String("/fast"))
|
if (!m_buildTarget.title.endsWith(QLatin1String("/fast"))
|
||||||
&& !m_buildTarget.title.endsWith(QLatin1String("_automoc"))
|
&& !m_buildTarget.title.endsWith(QLatin1String("_automoc")))
|
||||||
&& !m_buildTarget.title.endsWith(QLatin1String("_unittest")))
|
|
||||||
m_buildTargets.append(m_buildTarget);
|
m_buildTargets.append(m_buildTarget);
|
||||||
return;
|
return;
|
||||||
} else if (name() == QLatin1String("Compiler")) {
|
} else if (name() == QLatin1String("Compiler")) {
|
||||||
@@ -409,6 +417,7 @@ void CMakeCbpParser::parseUnit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_parsingCmakeUnit = false;
|
m_parsingCmakeUnit = false;
|
||||||
|
m_unitTarget.clear();
|
||||||
while (!atEnd()) {
|
while (!atEnd()) {
|
||||||
readNext();
|
readNext();
|
||||||
if (isEndElement()) {
|
if (isEndElement()) {
|
||||||
@@ -429,6 +438,8 @@ void CMakeCbpParser::parseUnit()
|
|||||||
else
|
else
|
||||||
m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::SourceType, generated));
|
m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::SourceType, generated));
|
||||||
}
|
}
|
||||||
|
if (!m_unitTarget.isEmpty())
|
||||||
|
m_unitTargetMap.insert(fileName, m_unitTarget);
|
||||||
m_processedUnits.insert(fileName);
|
m_processedUnits.insert(fileName);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -442,8 +453,9 @@ void CMakeCbpParser::parseUnit()
|
|||||||
|
|
||||||
void CMakeCbpParser::parseUnitOption()
|
void CMakeCbpParser::parseUnitOption()
|
||||||
{
|
{
|
||||||
if (attributes().hasAttribute(QLatin1String("virtualFolder")))
|
const QXmlStreamAttributes optionAttributes = attributes();
|
||||||
m_parsingCmakeUnit = true;
|
m_parsingCmakeUnit = optionAttributes.hasAttribute(QLatin1String("virtualFolder"));
|
||||||
|
m_unitTarget = optionAttributes.value(QLatin1String("target")).toString();
|
||||||
|
|
||||||
while (!atEnd()) {
|
while (!atEnd()) {
|
||||||
readNext();
|
readNext();
|
||||||
|
@@ -72,6 +72,7 @@ private:
|
|||||||
void parseUnknownElement();
|
void parseUnknownElement();
|
||||||
void sortFiles();
|
void sortFiles();
|
||||||
|
|
||||||
|
QMap<Utils::FileName, QString> m_unitTargetMap;
|
||||||
ProjectExplorer::Kit *m_kit;
|
ProjectExplorer::Kit *m_kit;
|
||||||
QList<ProjectExplorer::FileNode *> m_fileList;
|
QList<ProjectExplorer::FileNode *> m_fileList;
|
||||||
QList<ProjectExplorer::FileNode *> m_cmakeFileList;
|
QList<ProjectExplorer::FileNode *> m_cmakeFileList;
|
||||||
@@ -84,6 +85,7 @@ private:
|
|||||||
QString m_compiler;
|
QString m_compiler;
|
||||||
QString m_sourceDirectory;
|
QString m_sourceDirectory;
|
||||||
QString m_buildDirectory;
|
QString m_buildDirectory;
|
||||||
|
QString m_unitTarget;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user