refactor VCXProjectWriter::outputFileConfig

Put common code into a function.
Subsequent patches will become easier.

Change-Id: I0d549886585d90e4701a2430503bc0d2d716e341
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
Joerg Bornemann 2014-09-23 14:27:05 +02:00
parent 4f21eb0387
commit 990a413a2e
2 changed files with 62 additions and 145 deletions

View File

@ -1855,80 +1855,7 @@ void VCXProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, Xml
} }
if ( !fileAdded ) if ( !fileAdded )
{ outputFileConfig(xml, xmlFilter, info.file, filtername, false);
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));
}
}
xml << closetag(); xml << closetag();
xmlFilter << closetag(); xmlFilter << closetag();
@ -2001,77 +1928,7 @@ bool VCXProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, XmlOut
if ( !fileAdded && !fileAllreadyAdded ) if ( !fileAdded && !fileAllreadyAdded )
{ {
fileAdded = true; fileAdded = true;
outputFileConfig(xml, xmlFilter, filename, filtername, 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));
}
} }
const QString condition = generateCondition(*filter.Config); const QString condition = generateCondition(*filter.Config);
@ -2110,6 +1967,65 @@ bool VCXProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, XmlOut
return fileAdded; 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) QString VCXProjectWriter::generateCondition(const VCConfiguration &config)
{ {
return QStringLiteral("'$(Configuration)|$(Platform)'=='") + config.Name + QLatin1Char('\''); return QStringLiteral("'$(Configuration)|$(Platform)'=='") + config.Name + QLatin1Char('\'');

View File

@ -175,6 +175,7 @@ private:
static void outputFilter(VCProject &project, XmlOutput &xml, 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);
static bool outputFileConfig(VCFilter &filter, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filename, const QString &filtername, bool fileAllreadyAdded); 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); static QString generateCondition(const VCConfiguration &config);
friend class XTreeNode; friend class XTreeNode;