From 990a413a2e3c557edb260a12843a0ea0e1802a2f Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 23 Sep 2014 14:27:05 +0200 Subject: refactor VCXProjectWriter::outputFileConfig Put common code into a function. Subsequent patches will become easier. Change-Id: I0d549886585d90e4701a2430503bc0d2d716e341 Reviewed-by: Oswald Buddenhagen Reviewed-by: Joerg Bornemann --- qmake/generators/win32/msbuild_objectmodel.cpp | 206 ++++++++----------------- qmake/generators/win32/msbuild_objectmodel.h | 1 + 2 files changed, 62 insertions(+), 145 deletions(-) (limited to 'qmake') diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index 07af6e3599..58e600c48e 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -1855,80 +1855,7 @@ void VCXProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, Xml } if ( !fileAdded ) - { - if (filtername.startsWith("Source Files")) { - - xmlFilter << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(info.file)) - << attrTagS("Filter", filtername); - - xml << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - - } else if(filtername.startsWith("Header Files")) { - - xmlFilter << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(info.file)) - << attrTagS("Filter", filtername); - - xml << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - } else if(filtername.startsWith("Generated Files") || filtername.startsWith("Form Files")) { - - if (info.file.endsWith(".h")) { - - xmlFilter << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(info.file)) - << attrTagS("Filter", filtername); - - xml << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - } else if(info.file.endsWith(".cpp")) { - - xmlFilter << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(info.file)) - << attrTagS("Filter", filtername); - - xml << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - } else if(info.file.endsWith(".res")) { - - xmlFilter << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(info.file)) - << attrTagS("Filter", filtername); - - xml << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - } else { - - xmlFilter << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(info.file)) - << attrTagS("Filter", filtername); - - xml << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - } - - } else if(filtername.startsWith("Root Files")) { - - if (info.file.endsWith(".rc")) { - - xmlFilter << tag("ResourceCompile") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - - xml << tag("ResourceCompile") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - } - } else { - - xmlFilter << tag("None") - << attrTag("Include",Option::fixPathToLocalOS(info.file)) - << attrTagS("Filter", filtername); - - xml << tag("None") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - } - } + outputFileConfig(xml, xmlFilter, info.file, filtername, false); xml << closetag(); xmlFilter << closetag(); @@ -2001,77 +1928,7 @@ bool VCXProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, XmlOut if ( !fileAdded && !fileAllreadyAdded ) { fileAdded = true; - - if (filtername.startsWith("Source Files")) { - - xmlFilter << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(filename)) - << attrTagS("Filter", filtername); - - xml << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - - } else if(filtername.startsWith("Header Files")) { - - xmlFilter << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(filename)) - << attrTagS("Filter", filtername); - - xml << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - } else if(filtername.startsWith("Generated Files") || filtername.startsWith("Form Files")) { - - if (filename.endsWith(".h")) { - - xmlFilter << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(filename)) - << attrTagS("Filter", filtername); - - xml << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - } else if(filename.endsWith(".cpp")) { - - xmlFilter << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(filename)) - << attrTagS("Filter", filtername); - - xml << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - } else if(filename.endsWith(".res")) { - - xmlFilter << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(filename)) - << attrTagS("Filter", filtername); - - xml << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - } else { - - xmlFilter << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(filename)) - << attrTagS("Filter", filtername); - - xml << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - } - } else if(filtername.startsWith("Root Files")) { - - if (filename.endsWith(".rc")) { - - xmlFilter << tag("ResourceCompile") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - - xml << tag("ResourceCompile") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - } - } else if (filtername.startsWith("Deployment Files")) { - xmlFilter << tag("None") - << attrTag("Include",Option::fixPathToLocalOS(filename)) - << attrTagS("Filter", filtername); - - xml << tag("None") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - } + outputFileConfig(xml, xmlFilter, filename, filtername, true); } const QString condition = generateCondition(*filter.Config); @@ -2110,6 +1967,65 @@ bool VCXProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, XmlOut return fileAdded; } +void VCXProjectWriter::outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter, + const QString &filePath, const QString &filterName, + bool checkDeploymentFilter) +{ + const QString nativeFilePath = Option::fixPathToLocalOS(filePath); + if (filterName.startsWith("Source Files")) { + xmlFilter << tag("ClCompile") + << attrTag("Include", nativeFilePath) + << attrTagS("Filter", filterName); + xml << tag("ClCompile") + << attrTag("Include", nativeFilePath); + } else if (filterName.startsWith("Header Files")) { + xmlFilter << tag("ClInclude") + << attrTag("Include", nativeFilePath) + << attrTagS("Filter", filterName); + xml << tag("ClInclude") + << attrTag("Include", nativeFilePath); + } else if (filterName.startsWith("Generated Files") || filterName.startsWith("Form Files")) { + if (filePath.endsWith(".h")) { + xmlFilter << tag("ClInclude") + << attrTag("Include", nativeFilePath) + << attrTagS("Filter", filterName); + xml << tag("ClInclude") + << attrTag("Include", nativeFilePath); + } else if (filePath.endsWith(".cpp")) { + xmlFilter << tag("ClCompile") + << attrTag("Include", nativeFilePath) + << attrTagS("Filter", filterName); + xml << tag("ClCompile") + << attrTag("Include", nativeFilePath); + } else if (filePath.endsWith(".res")) { + xmlFilter << tag("CustomBuild") + << attrTag("Include", nativeFilePath) + << attrTagS("Filter", filterName); + xml << tag("CustomBuild") + << attrTag("Include", nativeFilePath); + } else { + xmlFilter << tag("CustomBuild") + << attrTag("Include", nativeFilePath) + << attrTagS("Filter", filterName); + xml << tag("CustomBuild") + << attrTag("Include", nativeFilePath); + } + } else if (filterName.startsWith("Root Files")) { + if (filePath.endsWith(".rc")) { + xmlFilter << tag("ResourceCompile") + << attrTag("Include", nativeFilePath); + xml << tag("ResourceCompile") + << attrTag("Include", nativeFilePath); + } + } else if (!checkDeploymentFilter || filterName.startsWith("Deployment Files")) { + xmlFilter << tag("None") + << attrTag("Include", nativeFilePath) + << attrTagS("Filter", filterName); + xml << tag("None") + << attrTag("Include", nativeFilePath); + } +} + QString VCXProjectWriter::generateCondition(const VCConfiguration &config) { return QStringLiteral("'$(Configuration)|$(Platform)'=='") + config.Name + QLatin1Char('\''); diff --git a/qmake/generators/win32/msbuild_objectmodel.h b/qmake/generators/win32/msbuild_objectmodel.h index cb8443112c..336904d87c 100644 --- a/qmake/generators/win32/msbuild_objectmodel.h +++ b/qmake/generators/win32/msbuild_objectmodel.h @@ -175,6 +175,7 @@ private: 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 bool outputFileConfig(VCFilter &filter, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filename, const QString &filtername, bool fileAllreadyAdded); + static void outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter, const QString &fileName, const QString &filterName, bool checkDeploymentFilter); static QString generateCondition(const VCConfiguration &config); friend class XTreeNode; -- cgit v1.2.3