summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@digia.com>2014-09-23 18:44:12 +0200
committerJoerg Bornemann <joerg.bornemann@digia.com>2014-09-29 16:08:57 +0200
commit04d3a89e20d49a3b5015b071bfdedc81973b090c (patch)
treead528c2e0ae3fe6966657cf6dd602d568d0172ef
parent55027c23df76444a128411cfb3ef011f65b40a64 (diff)
downloadqtbase-04d3a89e20d49a3b5015b071bfdedc81973b090c.tar.gz
qtbase-04d3a89e20d49a3b5015b071bfdedc81973b090c.tar.bz2
qtbase-04d3a89e20d49a3b5015b071bfdedc81973b090c.zip
vcxproj: fix custom build steps in different build variants
There's a comment in VCXProjectWriter::outputFileConfigs that states: "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'". This patch adds the code to the comment... Task-number: QTBUG-30373 Change-Id: Ibfef3c80630e08c743bfadce299a8b6a0c58411f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
-rw-r--r--qmake/generators/win32/msbuild_objectmodel.cpp66
-rw-r--r--qmake/generators/win32/msbuild_objectmodel.h9
2 files changed, 47 insertions, 28 deletions
diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp
index 035da5059f..64a927fb77 100644
--- a/qmake/generators/win32/msbuild_objectmodel.cpp
+++ b/qmake/generators/win32/msbuild_objectmodel.cpp
@@ -1845,13 +1845,36 @@ void VCXProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, Xml
{
// 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 fileAdded = false;
+ bool hasCustomBuildStep = false;
+ QVarLengthArray<OutputFilterData> data(project.SingleProjects.count());
+ for (int i = 0; i < project.SingleProjects.count(); ++i) {
+ data[i].filter = project.SingleProjects.at(i).filterByName(filtername);
+ if (!data[i].filter.Config) // only if the filter is not empty
+ continue;
+ VCFilter &filter = data[i].filter;
+
+ // Clearing each filter tool
+ filter.useCustomBuildTool = false;
+ filter.useCompilerTool = false;
+ filter.CustomBuildTool = VCCustomBuildTool();
+ filter.CustomBuildTool.config = filter.Config;
+ filter.CompilerTool = VCCLCompilerTool();
+ filter.CompilerTool.config = filter.Config;
+
+ VCFilterFile fileInFilter = filter.findFile(info.file, &data[i].inBuild);
+ data[i].inBuild &= !fileInFilter.excludeFromBuild;
+ if (data[i].inBuild && filter.addExtraCompiler(fileInFilter))
+ hasCustomBuildStep = true;
+ }
+ bool fileAdded = false;
for (int i = 0; i < project.SingleProjects.count(); ++i) {
const VCFilter &filter = project.SingleProjects.at(i).filterByName(filtername);
- if (filter.Config) // only if the filter is not empty
- if (outputFileConfig(filter, xml, xmlFilter, info.file, fileAdded)) // only add it once.
- fileAdded = true;
+ if (!filter.Config) // only if the filter is not empty
+ continue;
+ if (outputFileConfig(&data[i], xml, xmlFilter, info.file, fileAdded,
+ hasCustomBuildStep))
+ fileAdded = true;
}
if ( !fileAdded )
@@ -1861,36 +1884,25 @@ void VCXProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, Xml
xmlFilter << closetag();
}
-bool VCXProjectWriter::outputFileConfig(VCFilter filter, XmlOutput &xml, XmlOutput &xmlFilter,
- const QString &filename, bool fileAdded)
+bool VCXProjectWriter::outputFileConfig(OutputFilterData *d, XmlOutput &xml, XmlOutput &xmlFilter,
+ const QString &filename, bool fileAdded,
+ bool hasCustomBuildStep)
{
- // Clearing each filter tool
- filter.useCustomBuildTool = false;
- filter.useCompilerTool = false;
- filter.CustomBuildTool = VCCustomBuildTool();
- filter.CustomBuildTool.config = filter.Config;
- filter.CompilerTool = VCCLCompilerTool();
- filter.CompilerTool.config = filter.Config;
-
- bool inBuild;
- VCFilterFile info = filter.findFile(filename, &inBuild);
- inBuild &= !info.excludeFromBuild;
-
- if (inBuild) {
- filter.addExtraCompiler(info);
+ VCFilter &filter = d->filter;
+ if (d->inBuild) {
if (filter.Project->usePCH)
- filter.modifyPCHstage(info.file);
+ filter.modifyPCHstage(filename);
} else {
// Excluded files uses an empty compiler stage
- if(info.excludeFromBuild)
+ if (d->info.excludeFromBuild)
filter.useCompilerTool = true;
}
// Actual XML output ----------------------------------
- if (filter.useCustomBuildTool || filter.useCompilerTool
- || !inBuild || filter.Name.startsWith("Deployment Files")) {
+ if (hasCustomBuildStep || filter.useCompilerTool
+ || !d->inBuild || filter.Name.startsWith("Deployment Files")) {
- if (filter.useCustomBuildTool)
+ if (hasCustomBuildStep)
{
if (!fileAdded) {
fileAdded = true;
@@ -1919,13 +1931,13 @@ bool VCXProjectWriter::outputFileConfig(VCFilter filter, XmlOutput &xml, XmlOutp
}
const QString condition = generateCondition(*filter.Config);
- if(!inBuild) {
+ if (!d->inBuild) {
xml << tag("ExcludedFromBuild")
<< attrTag("Condition", condition)
<< valueTag("true");
}
- if (filter.Name.startsWith("Deployment Files") && inBuild) {
+ if (filter.Name.startsWith("Deployment Files") && d->inBuild) {
xml << tag("DeploymentContent")
<< attrTag("Condition", condition)
<< valueTag("true");
diff --git a/qmake/generators/win32/msbuild_objectmodel.h b/qmake/generators/win32/msbuild_objectmodel.h
index c44897c96a..6ed82233a3 100644
--- a/qmake/generators/win32/msbuild_objectmodel.h
+++ b/qmake/generators/win32/msbuild_objectmodel.h
@@ -171,10 +171,17 @@ public:
void write(XmlOutput &, VCFilter &);
private:
+ struct OutputFilterData
+ {
+ VCFilter filter;
+ VCFilterFile info;
+ bool inBuild;
+ };
+
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 bool outputFileConfig(VCFilter filter, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filename, bool fileAdded);
+ 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);