From e5a8134765cdc69ba916416166f4d416137e2ffc Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 7 Oct 2014 16:20:58 +0200 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"). That's why the original code tested the filter names with QString::startsWith. I've changed the signature of outputFileConfigs to take a filterId parameter which contains the unaltered filter name (e.g. "Generated Files") that will determine the correct filter. Task-number: QTBUG-41746 Change-Id: If33428526a098f433cd6ceb8ab6608bd9f94ef17 Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/msbuild_objectmodel.cpp | 28 +++++++++++++++----------- qmake/generators/win32/msbuild_objectmodel.h | 11 ++++++---- 2 files changed, 23 insertions(+), 16 deletions(-) (limited to 'qmake/generators') diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index 64a927fb77..6751dc0f6b 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -341,7 +341,8 @@ static QStringList unquote(const QStringList &values) } // Tree file generation --------------------------------------------- -void XTreeNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCProject &tool, const QString &filter) { +void XTreeNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, + VCProject &tool, const QString &filter, const QString &filterId) { if (children.size()) { // Filter @@ -362,38 +363,39 @@ void XTreeNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString if ((*it)->children.size()) { if ( !tempFilterName.isEmpty() ) - (*it)->generateXML(xml, xmlFilter, it.key(), tool, tempFilterName); + (*it)->generateXML(xml, xmlFilter, it.key(), tool, tempFilterName, filterId); else - (*it)->generateXML(xml, xmlFilter, it.key(), tool, filter); + (*it)->generateXML(xml, xmlFilter, it.key(), tool, filter, filterId); } // Second round, do leafs for (it = children.constBegin(); it != end; ++it) if (!(*it)->children.size()) { if ( !tempFilterName.isEmpty() ) - (*it)->generateXML(xml, xmlFilter, it.key(), tool, tempFilterName); + (*it)->generateXML(xml, xmlFilter, it.key(), tool, tempFilterName, filterId); else - (*it)->generateXML(xml, xmlFilter, it.key(), tool, filter); + (*it)->generateXML(xml, xmlFilter, it.key(), tool, filter, filterId); } } else { // Leaf xml << tag(_ItemGroup); xmlFilter << tag(_ItemGroup); - VCXProjectWriter::outputFileConfigs(tool, xml, xmlFilter, info, filter); + VCXProjectWriter::outputFileConfigs(tool, xml, xmlFilter, info, filter, filterId); xmlFilter << closetag(); xml << closetag(); } } // Flat file generation --------------------------------------------- -void XFlatNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &/*tagName*/, VCProject &tool, const QString &filter) { +void XFlatNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &/*tagName*/, + VCProject &tool, const QString &filter, const QString &filterId) { if (children.size()) { ChildrenMapFlat::ConstIterator it = children.constBegin(); ChildrenMapFlat::ConstIterator end = children.constEnd(); xml << tag(_ItemGroup); xmlFilter << tag(_ItemGroup); for (; it != end; ++it) { - VCXProjectWriter::outputFileConfigs(tool, xml, xmlFilter, (*it), filter); + VCXProjectWriter::outputFileConfigs(tool, xml, xmlFilter, (*it), filter, filterId); } xml << closetag(); xmlFilter << closetag(); @@ -1836,19 +1838,21 @@ void VCXProjectWriter::outputFilter(VCProject &project, XmlOutput &xml, XmlOutpu if (!root->hasElements()) return; - root->generateXML(xml, xmlFilter, "", project, filtername); // output root tree + root->generateXML(xml, xmlFilter, "", project, filtername, filtername); // output root tree } // 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) +void VCXProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter, + const VCFilterFile &info, const QString &filtername, + const QString &filterId) { // 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(filterId); if (!data[i].filter.Config) // only if the filter is not empty continue; VCFilter &filter = data[i].filter; @@ -1869,7 +1873,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(filterId); if (!filter.Config) // only if the filter is not empty continue; if (outputFileConfig(&data[i], xml, xmlFilter, info.file, fileAdded, diff --git a/qmake/generators/win32/msbuild_objectmodel.h b/qmake/generators/win32/msbuild_objectmodel.h index 6ed82233a3..a562cc364b 100644 --- a/qmake/generators/win32/msbuild_objectmodel.h +++ b/qmake/generators/win32/msbuild_objectmodel.h @@ -56,7 +56,8 @@ public: } virtual void addElement(const QString &filepath, const VCFilterFile &allInfo) = 0; virtual void removeElements()= 0; - virtual void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCProject &tool, const QString &filter) = 0; + virtual void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, + VCProject &tool, const QString &filter, const QString &filterId) = 0; virtual bool hasElements() = 0; }; @@ -106,7 +107,8 @@ public: children.clear(); } - void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCProject &tool, const QString &filter); + void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCProject &tool, + const QString &filter, const QString &filterId); bool hasElements() { return children.size() != 0; } @@ -146,7 +148,8 @@ public: children.clear(); } - void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCProject &proj, const QString &filter); + void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCProject &proj, + const QString &filter, const QString &filterId); bool hasElements() { return children.size() != 0; } @@ -180,7 +183,7 @@ private: static void addFilters(VCProject &project, XmlOutput &xmlFilter, const QString &filterName); static void outputFilter(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filtername); - static void outputFileConfigs(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const VCFilterFile &info, const QString &filtername); + static void outputFileConfigs(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const VCFilterFile &info, const QString &filtername, const QString &filterId); static bool outputFileConfig(OutputFilterData *d, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filename, bool fileAdded, bool hasCustomBuildStep); static void outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter, const QString &fileName, const QString &filterName); static QString generateCondition(const VCConfiguration &config); -- cgit v1.2.3