From b8a162ee97b4b4a225101cf7848e04810766c434 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 12 Feb 2015 10:08:19 +0100 Subject: fix vcxproj generation for CONFIG-=flat Commit 4f21eb03 broke the generation of non-flat vcxprojs. XTreeNode passes filter names to outputFileConfigs that have the source subdirectory suffixed (e.g. "Generated Files\subdir"). Function filterByName must be called with the substring before the backslash. Change-Id: Ic259e6316ab0727828773b13e0d8ad0cc7f0808f Task-number: QTBUG-41746 Reviewed-by: Oswald Buddenhagen Reviewed-by: Joerg Bornemann --- qmake/generators/win32/msbuild_objectmodel.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'qmake') diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index ee92efe42f..e6be3334e4 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -1854,17 +1854,26 @@ void VCXProjectWriter::outputFilter(VCProject &project, XmlOutput &xml, XmlOutpu root->generateXML(xml, xmlFilter, "", project, filtername); // output root tree } +static QString stringBeforeFirstBackslash(const QString &str) +{ + int idx = str.indexOf(QLatin1Char('\\')); + return idx == -1 ? str : str.left(idx); +} + // Output all configurations (by filtername) for a file (by info) // A filters config output is in VCFilter.outputFileConfig() void VCXProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const VCFilterFile &info, const QString &filtername) { + // In non-flat mode the filter names have directory suffixes, e.g. "Generated Files\subdir". + const QString cleanFilterName = stringBeforeFirstBackslash(filtername); + // We need to check if the file has any custom build step. // If there is one then it has to be included with "CustomBuild Include" bool hasCustomBuildStep = false; QVarLengthArray data(project.SingleProjects.count()); for (int i = 0; i < project.SingleProjects.count(); ++i) { - data[i].filter = project.SingleProjects.at(i).filterByName(filtername); + data[i].filter = project.SingleProjects.at(i).filterByName(cleanFilterName); if (!data[i].filter.Config) // only if the filter is not empty continue; VCFilter &filter = data[i].filter; @@ -1886,7 +1895,7 @@ void VCXProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, Xml bool fileAdded = false; for (int i = 0; i < project.SingleProjects.count(); ++i) { - const VCFilter &filter = project.SingleProjects.at(i).filterByName(filtername); + const VCFilter &filter = project.SingleProjects.at(i).filterByName(cleanFilterName); if (!filter.Config) // only if the filter is not empty continue; if (outputFileConfig(&data[i], xml, xmlFilter, info.file, fileAdded, -- cgit v1.2.3