~gabriel1984sibiu/minitube/qt5.6

« back to all changes in this revision

Viewing changes to qmake/generators/win32/msbuild_objectmodel.cpp

  • Committer: Grevutiu Gabriel
  • Date: 2017-06-13 08:43:17 UTC
  • Revision ID: gabriel1984sibiu@gmail.com-20170613084317-ek0zqe0u9g3ocvi8
OriginalĀ upstreamĀ code

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2016 The Qt Company Ltd.
 
4
** Contact: https://www.qt.io/licensing/
 
5
**
 
6
** This file is part of the qmake application of the Qt Toolkit.
 
7
**
 
8
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
 
9
** Commercial License Usage
 
10
** Licensees holding valid commercial Qt licenses may use this file in
 
11
** accordance with the commercial license agreement provided with the
 
12
** Software or, alternatively, in accordance with the terms contained in
 
13
** a written agreement between you and The Qt Company. For licensing terms
 
14
** and conditions see https://www.qt.io/terms-conditions. For further
 
15
** information use the contact form at https://www.qt.io/contact-us.
 
16
**
 
17
** GNU General Public License Usage
 
18
** Alternatively, this file may be used under the terms of the GNU
 
19
** General Public License version 3 as published by the Free Software
 
20
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
 
21
** included in the packaging of this file. Please review the following
 
22
** information to ensure the GNU General Public License requirements will
 
23
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
 
24
**
 
25
** $QT_END_LICENSE$
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#include "msbuild_objectmodel.h"
 
30
 
 
31
#include "msvc_objectmodel.h"
 
32
#include "msvc_vcproj.h"
 
33
#include "msvc_vcxproj.h"
 
34
#include <qscopedpointer.h>
 
35
#include <qstringlist.h>
 
36
#include <qfileinfo.h>
 
37
 
 
38
QT_BEGIN_NAMESPACE
 
39
 
 
40
// XML Tags ---------------------------------------------------------
 
41
const char _CLCompile[]                         = "ClCompile";
 
42
const char _ItemGroup[]                         = "ItemGroup";
 
43
const char _Link[]                              = "Link";
 
44
const char _Lib[]                               = "Lib";
 
45
const char _ManifestTool[]                      = "ManifestTool";
 
46
const char _Midl[]                              = "Midl";
 
47
const char _ResourceCompile[]                   = "ResourceCompile";
 
48
 
 
49
// XML Properties ---------------------------------------------------
 
50
const char _AddModuleNamesToAssembly[]          = "AddModuleNamesToAssembly";
 
51
const char _AdditionalDependencies[]            = "AdditionalDependencies";
 
52
const char _AdditionalIncludeDirectories[]      = "AdditionalIncludeDirectories";
 
53
const char _AdditionalLibraryDirectories[]      = "AdditionalLibraryDirectories";
 
54
const char _AdditionalManifestDependencies[]    = "AdditionalManifestDependencies";
 
55
const char _AdditionalOptions[]                 = "AdditionalOptions";
 
56
const char _AdditionalUsingDirectories[]        = "AdditionalUsingDirectories";
 
57
const char _AllowIsolation[]                    = "AllowIsolation";
 
58
const char _AlwaysAppend[]                      = "AlwaysAppend";
 
59
const char _ApplicationConfigurationMode[]      = "ApplicationConfigurationMode";
 
60
const char _AssemblerListingLocation[]          = "AssemblerListingLocation";
 
61
const char _AssemblerOutput[]                   = "AssemblerOutput";
 
62
const char _AssemblyDebug[]                     = "AssemblyDebug";
 
63
const char _AssemblyLinkResource[]              = "AssemblyLinkResource";
 
64
const char _ATLMinimizesCRunTimeLibraryUsage[]  = "ATLMinimizesCRunTimeLibraryUsage";
 
65
const char _BaseAddress[]                       = "BaseAddress";
 
66
const char _BasicRuntimeChecks[]                = "BasicRuntimeChecks";
 
67
const char _BrowseInformation[]                 = "BrowseInformation";
 
68
const char _BrowseInformationFile[]             = "BrowseInformationFile";
 
69
const char _BufferSecurityCheck[]               = "BufferSecurityCheck";
 
70
const char _BuildBrowserInformation[]           = "BuildBrowserInformation";
 
71
const char _CallingConvention[]                 = "CallingConvention";
 
72
const char _CharacterSet[]                      = "CharacterSet";
 
73
const char _ClientStubFile[]                    = "ClientStubFile";
 
74
const char _CLRImageType[]                      = "CLRImageType";
 
75
const char _CLRSupportLastError[]               = "CLRSupportLastError";
 
76
const char _CLRThreadAttribute[]                = "CLRThreadAttribute";
 
77
const char _CLRUnmanagedCodeCheck[]             = "CLRUnmanagedCodeCheck";
 
78
const char _Command[]                           = "Command";
 
79
const char _CompileAs[]                         = "CompileAs";
 
80
const char _CompileAsManaged[]                  = "CompileAsManaged";
 
81
const char _CompileAsWinRT[]                    = "CompileAsWinRT";
 
82
const char _ConfigurationType[]                 = "ConfigurationType";
 
83
const char _CPreprocessOptions[]                = "CPreprocessOptions";
 
84
const char _CreateHotpatchableImage[]           = "CreateHotpatchableImage";
 
85
const char _CreateHotPatchableImage[]           = "CreateHotPatchableImage";
 
86
const char _Culture[]                           = "Culture";
 
87
const char _DataExecutionPrevention[]           = "DataExecutionPrevention";
 
88
const char _DebugInformationFormat[]            = "DebugInformationFormat";
 
89
const char _DefaultCharType[]                   = "DefaultCharType";
 
90
const char _DelayLoadDLLs[]                     = "DelayLoadDLLs";
 
91
const char _DelaySign[]                         = "DelaySign";
 
92
const char _DeleteExtensionsOnClean[]           = "DeleteExtensionsOnClean";
 
93
const char _DisableLanguageExtensions[]         = "DisableLanguageExtensions";
 
94
const char _DisableSpecificWarnings[]           = "DisableSpecificWarnings";
 
95
const char _DisplayLibrary[]                    = "DisplayLibrary";
 
96
const char _DLLDataFileName[]                   = "DLLDataFileName";
 
97
const char _EmbedManagedResourceFile[]          = "EmbedManagedResourceFile";
 
98
const char _EmbedManifest[]                     = "EmbedManifest";
 
99
const char _EnableCOMDATFolding[]               = "EnableCOMDATFolding";
 
100
const char _EnableUAC[]                         = "EnableUAC";
 
101
const char _EnableErrorChecks[]                 = "EnableErrorChecks";
 
102
const char _EnableEnhancedInstructionSet[]      = "EnableEnhancedInstructionSet";
 
103
const char _EnableFiberSafeOptimizations[]      = "EnableFiberSafeOptimizations";
 
104
const char _EnablePREfast[]                     = "EnablePREfast";
 
105
const char _EntryPointSymbol[]                  = "EntryPointSymbol";
 
106
const char _ErrorCheckAllocations[]             = "ErrorCheckAllocations";
 
107
const char _ErrorCheckBounds[]                  = "ErrorCheckBounds";
 
108
const char _ErrorCheckEnumRange[]               = "ErrorCheckEnumRange";
 
109
const char _ErrorCheckRefPointers[]             = "ErrorCheckRefPointers";
 
110
const char _ErrorCheckStubData[]                = "ErrorCheckStubData";
 
111
const char _ErrorReporting[]                    = "ErrorReporting";
 
112
const char _ExceptionHandling[]                 = "ExceptionHandling";
 
113
const char _ExpandAttributedSource[]            = "ExpandAttributedSource";
 
114
const char _ExportNamedFunctions[]              = "ExportNamedFunctions";
 
115
const char _FavorSizeOrSpeed[]                  = "FavorSizeOrSpeed";
 
116
const char _FloatingPointModel[]                = "FloatingPointModel";
 
117
const char _FloatingPointExceptions[]           = "FloatingPointExceptions";
 
118
const char _ForceConformanceInForLoopScope[]    = "ForceConformanceInForLoopScope";
 
119
const char _ForceSymbolReferences[]             = "ForceSymbolReferences";
 
120
const char _ForcedIncludeFiles[]                = "ForcedIncludeFiles";
 
121
const char _ForcedUsingFiles[]                  = "ForcedUsingFiles";
 
122
const char _FunctionLevelLinking[]              = "FunctionLevelLinking";
 
123
const char _FunctionOrder[]                     = "FunctionOrder";
 
124
const char _GenerateClientFiles[]               = "GenerateClientFiles";
 
125
const char _GenerateDebugInformation[]          = "GenerateDebugInformation";
 
126
const char _GenerateManifest[]                  = "GenerateManifest";
 
127
const char _GenerateMapFile[]                   = "GenerateMapFile";
 
128
const char _GenerateServerFiles[]               = "GenerateServerFiles";
 
129
const char _GenerateStublessProxies[]           = "GenerateStublessProxies";
 
130
const char _GenerateTypeLibrary[]               = "GenerateTypeLibrary";
 
131
const char _GenerateWindowsMetadata[]           = "GenerateWindowsMetadata";
 
132
const char _GenerateXMLDocumentationFiles[]     = "GenerateXMLDocumentationFiles";
 
133
const char _HeaderFileName[]                    = "HeaderFileName";
 
134
const char _HeapCommitSize[]                    = "HeapCommitSize";
 
135
const char _HeapReserveSize[]                   = "HeapReserveSize";
 
136
const char _IgnoreAllDefaultLibraries[]         = "IgnoreAllDefaultLibraries";
 
137
const char _IgnoreEmbeddedIDL[]                 = "IgnoreEmbeddedIDL";
 
138
const char _IgnoreImportLibrary[]               = "IgnoreImportLibrary";
 
139
const char _ImageHasSafeExceptionHandlers[]     = "ImageHasSafeExceptionHandlers";
 
140
const char _IgnoreSpecificDefaultLibraries[]    = "IgnoreSpecificDefaultLibraries";
 
141
const char _IgnoreStandardIncludePath[]         = "IgnoreStandardIncludePath";
 
142
const char _ImportLibrary[]                     = "ImportLibrary";
 
143
const char _InlineFunctionExpansion[]           = "InlineFunctionExpansion";
 
144
const char _IntrinsicFunctions[]                = "IntrinsicFunctions";
 
145
const char _InterfaceIdentifierFileName[]       = "InterfaceIdentifierFileName";
 
146
const char _IntermediateDirectory[]             = "IntermediateDirectory";
 
147
const char _KeyContainer[]                      = "KeyContainer";
 
148
const char _KeyFile[]                           = "KeyFile";
 
149
const char _LargeAddressAware[]                 = "LargeAddressAware";
 
150
const char _LinkDLL[]                           = "LinkDLL";
 
151
const char _LinkErrorReporting[]                = "LinkErrorReporting";
 
152
const char _LinkIncremental[]                   = "LinkIncremental";
 
153
const char _LinkStatus[]                        = "LinkStatus";
 
154
const char _LinkTimeCodeGeneration[]            = "LinkTimeCodeGeneration";
 
155
const char _LocaleID[]                          = "LocaleID";
 
156
const char _ManifestFile[]                      = "ManifestFile";
 
157
const char _MapExports[]                        = "MapExports";
 
158
const char _MapFileName[]                       = "MapFileName";
 
159
const char _MergedIDLBaseFileName[]             = "MergedIDLBaseFileName";
 
160
const char _MergeSections[]                     = "MergeSections";
 
161
const char _Message[]                           = "Message";
 
162
const char _MidlCommandFile[]                   = "MidlCommandFile";
 
163
const char _MinimalRebuild[]                    = "MinimalRebuild";
 
164
const char _MkTypLibCompatible[]                = "MkTypLibCompatible";
 
165
const char _ModuleDefinitionFile[]              = "ModuleDefinitionFile";
 
166
const char _MultiProcessorCompilation[]         = "MultiProcessorCompilation";
 
167
const char _Name[]                              = "Name";
 
168
const char _NoEntryPoint[]                      = "NoEntryPoint";
 
169
const char _NullTerminateStrings[]              = "NullTerminateStrings";
 
170
const char _ObjectFiles[]                       = "ObjectFiles";
 
171
const char _ObjectFileName[]                    = "ObjectFileName";
 
172
const char _OmitDefaultLibName[]                = "OmitDefaultLibName";
 
173
const char _OmitFramePointers[]                 = "OmitFramePointers";
 
174
const char _OpenMPSupport[]                     = "OpenMPSupport";
 
175
const char _Optimization[]                      = "Optimization";
 
176
const char _OptimizeReferences[]                = "OptimizeReferences";
 
177
const char _OutputDirectory[]                   = "OutputDirectory";
 
178
const char _OutputFile[]                        = "OutputFile";
 
179
const char _PlatformToolSet[]                   = "PlatformToolSet";
 
180
const char _PrecompiledHeader[]                 = "PrecompiledHeader";
 
181
const char _PrecompiledHeaderFile[]             = "PrecompiledHeaderFile";
 
182
const char _PrecompiledHeaderOutputFile[]       = "PrecompiledHeaderOutputFile";
 
183
const char _PreprocessorDefinitions[]           = "PreprocessorDefinitions";
 
184
const char _PreprocessKeepComments[]            = "PreprocessKeepComments";
 
185
const char _PreprocessOutputPath[]              = "PreprocessOutputPath";
 
186
const char _PreprocessSuppressLineNumbers[]     = "PreprocessSuppressLineNumbers";
 
187
const char _PreprocessToFile[]                  = "PreprocessToFile";
 
188
const char _PreventDllBinding[]                 = "PreventDllBinding";
 
189
const char _PrimaryOutput[]                     = "PrimaryOutput";
 
190
const char _ProcessorNumber[]                   = "ProcessorNumber";
 
191
const char _ProgramDatabase[]                   = "ProgramDatabase";
 
192
const char _ProgramDataBaseFileName[]           = "ProgramDataBaseFileName";
 
193
const char _ProgramDatabaseFile[]               = "ProgramDatabaseFile";
 
194
const char _ProxyFileName[]                     = "ProxyFileName";
 
195
const char _RandomizedBaseAddress[]             = "RandomizedBaseAddress";
 
196
const char _RedirectOutputAndErrors[]           = "RedirectOutputAndErrors";
 
197
const char _RegisterOutput[]                    = "RegisterOutput";
 
198
const char _RemoveObjects[]                     = "RemoveObjects";
 
199
const char _ResourceOutputFileName[]            = "ResourceOutputFileName";
 
200
const char _RuntimeLibrary[]                    = "RuntimeLibrary";
 
201
const char _RuntimeTypeInfo[]                   = "RuntimeTypeInfo";
 
202
const char _SectionAlignment[]                  = "SectionAlignment";
 
203
const char _ServerStubFile[]                    = "ServerStubFile";
 
204
const char _SetChecksum[]                       = "SetChecksum";
 
205
const char _ShowIncludes[]                      = "ShowIncludes";
 
206
const char _ShowProgress[]                      = "ShowProgress";
 
207
const char _SmallerTypeCheck[]                  = "SmallerTypeCheck";
 
208
const char _StackCommitSize[]                   = "StackCommitSize";
 
209
const char _StackReserveSize[]                  = "StackReserveSize";
 
210
const char _StringPooling[]                     = "StringPooling";
 
211
const char _StripPrivateSymbols[]               = "StripPrivateSymbols";
 
212
const char _StructMemberAlignment[]             = "StructMemberAlignment";
 
213
const char _SubSystem[]                         = "SubSystem";
 
214
const char _SupportNobindOfDelayLoadedDLL[]     = "SupportNobindOfDelayLoadedDLL";
 
215
const char _SupportUnloadOfDelayLoadedDLL[]     = "SupportUnloadOfDelayLoadedDLL";
 
216
const char _SuppressCompilerWarnings[]          = "SuppressCompilerWarnings";
 
217
const char _SuppressStartupBanner[]             = "SuppressStartupBanner";
 
218
const char _SwapRunFromCD[]                     = "SwapRunFromCD";
 
219
const char _SwapRunFromNet[]                    = "SwapRunFromNet";
 
220
const char _TargetEnvironment[]                 = "TargetEnvironment";
 
221
const char _TargetMachine[]                     = "TargetMachine";
 
222
const char _TerminalServerAware[]               = "TerminalServerAware";
 
223
const char _TrackerLogDirectory[]               = "TrackerLogDirectory";
 
224
const char _TreatLibWarningAsErrors[]           = "TreatLibWarningAsErrors";
 
225
const char _TreatLinkerWarningAsErrors[]        = "TreatLinkerWarningAsErrors";
 
226
const char _TreatSpecificWarningsAsErrors[]     = "TreatSpecificWarningsAsErrors";
 
227
const char _TreatWarningAsError[]               = "TreatWarningAsError";
 
228
const char _TreatWChar_tAsBuiltInType[]         = "TreatWChar_tAsBuiltInType";
 
229
const char _TurnOffAssemblyGeneration[]         = "TurnOffAssemblyGeneration";
 
230
const char _TypeLibFormat[]                     = "TypeLibFormat";
 
231
const char _TypeLibraryFile[]                   = "TypeLibraryFile";
 
232
const char _TypeLibraryName[]                   = "TypeLibraryName";
 
233
const char _TypeLibraryResourceID[]             = "TypeLibraryResourceID";
 
234
const char _UACExecutionLevel[]                 = "UACExecutionLevel";
 
235
const char _UACUIAccess[]                       = "UACUIAccess";
 
236
const char _UndefineAllPreprocessorDefinitions[]= "UndefineAllPreprocessorDefinitions";
 
237
const char _UndefinePreprocessorDefinitions[]   = "UndefinePreprocessorDefinitions";
 
238
const char _UseFullPaths[]                      = "UseFullPaths";
 
239
const char _UseOfATL[]                          = "UseOfATL";
 
240
const char _UseOfMfc[]                          = "UseOfMfc";
 
241
const char _UseUnicodeForAssemblerListing[]     = "UseUnicodeForAssemblerListing";
 
242
const char _ValidateAllParameters[]             = "ValidateAllParameters";
 
243
const char _VCCustomBuildTool[]                 = "VCCustomBuildTool";
 
244
const char _Verbose[]                           = "Verbose";
 
245
const char _Version[]                           = "Version";
 
246
const char _WarnAsError[]                       = "WarnAsError";
 
247
const char _WarningLevel[]                      = "WarningLevel";
 
248
const char _WholeProgramOptimization[]          = "WholeProgramOptimization";
 
249
const char _WindowsMetadataFile[]               = "WindowsMetadataFile";
 
250
const char _XMLDocumentationFileName[]          = "XMLDocumentationFileName";
 
251
 
 
252
 
 
253
// XmlOutput stream functions ------------------------------
 
254
inline XmlOutput::xml_output attrTagT(const char *name, const triState v)
 
255
{
 
256
    if(v == unset)
 
257
        return noxml();
 
258
    return tagValue(name, (v == _True ? "true" : "false"));
 
259
}
 
260
 
 
261
inline XmlOutput::xml_output attrTagL(const char *name, qint64 v)
 
262
{
 
263
    return tagValue(name, QString::number(v));
 
264
}
 
265
 
 
266
/*ifNot version*/
 
267
inline XmlOutput::xml_output attrTagL(const char *name, qint64 v, qint64 ifn)
 
268
{
 
269
    if (v == ifn)
 
270
        return noxml();
 
271
    return tagValue(name, QString::number(v));
 
272
}
 
273
 
 
274
inline XmlOutput::xml_output attrTagS(const char *name, const QString &v)
 
275
{
 
276
    if(v.isEmpty())
 
277
        return noxml();
 
278
    return tagValue(name, v);
 
279
}
 
280
 
 
281
inline XmlOutput::xml_output attrTagX(const char *name, const QStringList &v, const char *s = ",")
 
282
{
 
283
    if(v.isEmpty())
 
284
        return noxml();
 
285
    QStringList temp = v;
 
286
    temp.append(QString("%(%1)").arg(name));
 
287
    return tagValue(name, temp.join(s));
 
288
}
 
289
 
 
290
inline XmlOutput::xml_output valueTagX(const QStringList &v, const char *s = " ")
 
291
{
 
292
    if(v.isEmpty())
 
293
        return noxml();
 
294
    return valueTag(v.join(s));
 
295
}
 
296
 
 
297
inline XmlOutput::xml_output valueTagDefX(const QStringList &v, const QString &tagName, const char *s = " ")
 
298
{
 
299
    if(v.isEmpty())
 
300
        return noxml();
 
301
    QStringList temp = v;
 
302
    temp.append(QString("%(%1)").arg(tagName));
 
303
    return valueTag(temp.join(s));
 
304
}
 
305
 
 
306
inline XmlOutput::xml_output valueTagT( const triState v)
 
307
{
 
308
    if(v == unset)
 
309
        return noxml();
 
310
    return valueTag(v == _True ? "true" : "false");
 
311
}
 
312
 
 
313
static QString vcxCommandSeparator()
 
314
{
 
315
    // MSBuild puts the contents of the custom commands into a batch file and calls it.
 
316
    // As we want every sub-command to be error-checked (as is done by makefile-based
 
317
    // backends), we insert the checks ourselves, using the undocumented jump target.
 
318
    static QString cmdSep =
 
319
    QLatin1String("&#x000D;&#x000A;if errorlevel 1 goto VCEnd&#x000D;&#x000A;");
 
320
    return cmdSep;
 
321
}
 
322
 
 
323
static QString unquote(const QString &value)
 
324
{
 
325
    QString result = value;
 
326
    result.replace(QLatin1String("\\\""), QLatin1String("\""));
 
327
    return result;
 
328
}
 
329
 
 
330
static QStringList unquote(const QStringList &values)
 
331
{
 
332
    QStringList result;
 
333
    result.reserve(values.size());
 
334
    for (int i = 0; i < values.count(); ++i)
 
335
        result << unquote(values.at(i));
 
336
    return result;
 
337
}
 
338
 
 
339
// Tree file generation ---------------------------------------------
 
340
void XTreeNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName,
 
341
                            VCProject &tool, const QString &filter)
 
342
{
 
343
    if (children.size()) {
 
344
        // Filter
 
345
        QString tempFilterName;
 
346
        ChildrenMap::ConstIterator it, end = children.constEnd();
 
347
        if (!tagName.isEmpty()) {
 
348
            tempFilterName.append(filter);
 
349
            tempFilterName.append("\\");
 
350
            tempFilterName.append(tagName);
 
351
            xmlFilter << tag(_ItemGroup);
 
352
            xmlFilter << tag("Filter")
 
353
                      << attrTag("Include", tempFilterName)
 
354
                      << closetag();
 
355
            xmlFilter << closetag();
 
356
        }
 
357
        // First round, do nested filters
 
358
        for (it = children.constBegin(); it != end; ++it)
 
359
            if ((*it)->children.size())
 
360
            {
 
361
                if ( !tempFilterName.isEmpty() )
 
362
                    (*it)->generateXML(xml, xmlFilter, it.key(), tool, tempFilterName);
 
363
                else
 
364
                    (*it)->generateXML(xml, xmlFilter, it.key(), tool, filter);
 
365
            }
 
366
        // Second round, do leafs
 
367
        for (it = children.constBegin(); it != end; ++it)
 
368
            if (!(*it)->children.size())
 
369
            {
 
370
                if ( !tempFilterName.isEmpty() )
 
371
                    (*it)->generateXML(xml, xmlFilter, it.key(), tool, tempFilterName);
 
372
                else
 
373
                    (*it)->generateXML(xml, xmlFilter, it.key(), tool, filter);
 
374
            }
 
375
    } else {
 
376
        // Leaf
 
377
        xml << tag(_ItemGroup);
 
378
        xmlFilter << tag(_ItemGroup);
 
379
        VCXProjectWriter::outputFileConfigs(tool, xml, xmlFilter, info, filter);
 
380
        xmlFilter << closetag();
 
381
        xml << closetag();
 
382
    }
 
383
}
 
384
 
 
385
// Flat file generation ---------------------------------------------
 
386
void XFlatNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &/*tagName*/,
 
387
                            VCProject &tool, const QString &filter)
 
388
{
 
389
    if (children.size()) {
 
390
        ChildrenMapFlat::ConstIterator it = children.constBegin();
 
391
        ChildrenMapFlat::ConstIterator end = children.constEnd();
 
392
        xml << tag(_ItemGroup);
 
393
        xmlFilter << tag(_ItemGroup);
 
394
        for (; it != end; ++it) {
 
395
            VCXProjectWriter::outputFileConfigs(tool, xml, xmlFilter, (*it), filter);
 
396
        }
 
397
        xml << closetag();
 
398
        xmlFilter << closetag();
 
399
    }
 
400
}
 
401
 
 
402
void VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool)
 
403
{
 
404
    xml.setIndentString("  ");
 
405
 
 
406
    xml << decl("1.0", "utf-8")
 
407
        << tag("Project")
 
408
        << attrTag("DefaultTargets","Build")
 
409
        << attrTag("ToolsVersion", "4.0")
 
410
        << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003")
 
411
        << tag("ItemGroup")
 
412
        << attrTag("Label", "ProjectConfigurations");
 
413
 
 
414
    xml << tag("ProjectConfiguration")
 
415
        << attrTag("Include" , tool.Configuration.Name)
 
416
        << tagValue("Configuration", tool.Configuration.ConfigurationName)
 
417
        << tagValue("Platform", tool.PlatformName)
 
418
        << closetag();
 
419
 
 
420
    xml << closetag()
 
421
        << tag("PropertyGroup")
 
422
        << attrTag("Label", "Globals")
 
423
        << tagValue("ProjectGuid", tool.ProjectGUID)
 
424
        << tagValue("RootNamespace", tool.Name)
 
425
        << tagValue("Keyword", tool.Keyword)
 
426
        << closetag();
 
427
 
 
428
    // config part.
 
429
    xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props");
 
430
 
 
431
    write(xml, tool.Configuration);
 
432
    const QString condition = generateCondition(tool.Configuration);
 
433
 
 
434
    xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.props");
 
435
 
 
436
    // Extension settings
 
437
    xml << tag("ImportGroup")
 
438
        << attrTag("Label", "ExtensionSettings")
 
439
        << closetag();
 
440
 
 
441
    // PropertySheets
 
442
    xml << tag("ImportGroup")
 
443
        << attrTag("Condition", condition)
 
444
        << attrTag("Label", "PropertySheets");
 
445
 
 
446
    xml << tag("Import")
 
447
        << attrTag("Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props")
 
448
        << attrTag("Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')")
 
449
        << closetag()
 
450
        << closetag();
 
451
 
 
452
    // UserMacros
 
453
    xml << tag("PropertyGroup")
 
454
        << attrTag("Label", "UserMacros")
 
455
        << closetag();
 
456
 
 
457
    xml << tag("PropertyGroup");
 
458
 
 
459
    if ( !tool.Configuration.OutputDirectory.isEmpty() ) {
 
460
        xml<< tag("OutDir")
 
461
            << attrTag("Condition", condition)
 
462
            << valueTag(tool.Configuration.OutputDirectory);
 
463
    }
 
464
    if ( !tool.Configuration.IntermediateDirectory.isEmpty() ) {
 
465
        xml<< tag("IntDir")
 
466
            << attrTag("Condition", condition)
 
467
            << valueTag(tool.Configuration.IntermediateDirectory);
 
468
    }
 
469
    if ( !tool.Configuration.PrimaryOutput.isEmpty() ) {
 
470
        xml<< tag("TargetName")
 
471
            << attrTag("Condition", condition)
 
472
            << valueTag(tool.Configuration.PrimaryOutput);
 
473
    }
 
474
    if (!tool.Configuration.PrimaryOutputExtension.isEmpty()) {
 
475
        xml<< tag("TargetExt")
 
476
            << attrTag("Condition", condition)
 
477
            << valueTag(tool.Configuration.PrimaryOutputExtension);
 
478
    }
 
479
    if ( tool.Configuration.linker.IgnoreImportLibrary != unset) {
 
480
        xml<< tag("IgnoreImportLibrary")
 
481
            << attrTag("Condition", condition)
 
482
            << valueTagT(tool.Configuration.linker.IgnoreImportLibrary);
 
483
    }
 
484
 
 
485
    if ( tool.Configuration.linker.LinkIncremental != linkIncrementalDefault) {
 
486
        const triState ts = (tool.Configuration.linker.LinkIncremental == linkIncrementalYes ? _True : _False);
 
487
        xml<< tag("LinkIncremental")
 
488
            << attrTag("Condition", condition)
 
489
            << valueTagT(ts);
 
490
    }
 
491
 
 
492
    if ( tool.Configuration.preBuild.ExcludedFromBuild != unset )
 
493
    {
 
494
        xml<< tag("PreBuildEventUseInBuild")
 
495
            << attrTag("Condition", condition)
 
496
            << valueTagT(!tool.Configuration.preBuild.ExcludedFromBuild);
 
497
    }
 
498
 
 
499
    if ( tool.Configuration.preLink.ExcludedFromBuild != unset )
 
500
    {
 
501
        xml<< tag("PreLinkEventUseInBuild")
 
502
            << attrTag("Condition", condition)
 
503
            << valueTagT(!tool.Configuration.preLink.ExcludedFromBuild);
 
504
    }
 
505
 
 
506
    if ( tool.Configuration.postBuild.ExcludedFromBuild != unset )
 
507
    {
 
508
        xml<< tag("PostBuildEventUseInBuild")
 
509
            << attrTag("Condition", condition)
 
510
            << valueTagT(!tool.Configuration.postBuild.ExcludedFromBuild);
 
511
    }
 
512
    xml << closetag();
 
513
 
 
514
    xml << tag("ItemDefinitionGroup")
 
515
        << attrTag("Condition", condition);
 
516
 
 
517
    // ClCompile
 
518
    write(xml, tool.Configuration.compiler);
 
519
 
 
520
    // Link
 
521
    write(xml, tool.Configuration.linker);
 
522
 
 
523
    // Midl
 
524
    write(xml, tool.Configuration.idl);
 
525
 
 
526
    // ResourceCompiler
 
527
    write(xml, tool.Configuration.resource);
 
528
 
 
529
    // Post build event
 
530
    if ( tool.Configuration.postBuild.ExcludedFromBuild != unset )
 
531
        write(xml, tool.Configuration.postBuild);
 
532
 
 
533
    // Pre build event
 
534
    if ( tool.Configuration.preBuild.ExcludedFromBuild != unset )
 
535
        write(xml, tool.Configuration.preBuild);
 
536
 
 
537
    // Pre link event
 
538
    if ( tool.Configuration.preLink.ExcludedFromBuild != unset )
 
539
        write(xml, tool.Configuration.preLink);
 
540
 
 
541
    xml << closetag();
 
542
 
 
543
    QFile filterFile;
 
544
    filterFile.setFileName(Option::output.fileName().append(".filters"));
 
545
    filterFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate);
 
546
    QTextStream ts(&filterFile);
 
547
    XmlOutput xmlFilter(ts, XmlOutput::NoConversion);
 
548
 
 
549
    xmlFilter.setIndentString("  ");
 
550
 
 
551
    xmlFilter << decl("1.0", "utf-8")
 
552
              << tag("Project")
 
553
              << attrTag("ToolsVersion", "4.0")
 
554
              << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");
 
555
 
 
556
    xmlFilter << tag("ItemGroup");
 
557
 
 
558
    VCProject tempProj;
 
559
    tempProj.SingleProjects += tool;
 
560
 
 
561
    addFilters(tempProj, xmlFilter, "Form Files");
 
562
    addFilters(tempProj, xmlFilter, "Generated Files");
 
563
    addFilters(tempProj, xmlFilter, "Header Files");
 
564
    addFilters(tempProj, xmlFilter, "LexYacc Files");
 
565
    addFilters(tempProj, xmlFilter, "Resource Files");
 
566
    addFilters(tempProj, xmlFilter, "Source Files");
 
567
    addFilters(tempProj, xmlFilter, "Translation Files");
 
568
    addFilters(tempProj, xmlFilter, "Deployment Files");
 
569
    addFilters(tempProj, xmlFilter, "Distribution Files");
 
570
 
 
571
    for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x)
 
572
        addFilters(tempProj, xmlFilter, tempProj.ExtraCompilers.at(x));
 
573
 
 
574
    xmlFilter << closetag();
 
575
 
 
576
    outputFilter(tempProj, xml, xmlFilter, "Source Files");
 
577
    outputFilter(tempProj, xml, xmlFilter, "Header Files");
 
578
    outputFilter(tempProj, xml, xmlFilter, "Generated Files");
 
579
    outputFilter(tempProj, xml, xmlFilter, "LexYacc Files");
 
580
    outputFilter(tempProj, xml, xmlFilter, "Translation Files");
 
581
    outputFilter(tempProj, xml, xmlFilter, "Form Files");
 
582
    outputFilter(tempProj, xml, xmlFilter, "Resource Files");
 
583
    outputFilter(tempProj, xml, xmlFilter, "Deployment Files");
 
584
    outputFilter(tempProj, xml, xmlFilter, "Distribution Files");
 
585
 
 
586
    for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) {
 
587
        outputFilter(tempProj, xml, xmlFilter, tempProj.ExtraCompilers.at(x));
 
588
    }
 
589
 
 
590
    xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets");
 
591
 
 
592
    xml << tag("ImportGroup")
 
593
        << attrTag("Label", "ExtensionTargets")
 
594
        << closetag();
 
595
}
 
596
 
 
597
void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool)
 
598
{
 
599
    if (tool.SingleProjects.count() == 0) {
 
600
        warn_msg(WarnLogic, "Generator: .NET: no single project in merge project, no output");
 
601
        return;
 
602
    }
 
603
 
 
604
    xml.setIndentString("  ");
 
605
 
 
606
    const QString toolsVersion = (tool.SdkVersion == QLatin1String("10.0")) ? QStringLiteral("14.0")
 
607
                                                                            : QStringLiteral("4.0");
 
608
 
 
609
    xml << decl("1.0", "utf-8")
 
610
        << tag("Project")
 
611
        << attrTag("DefaultTargets","Build")
 
612
        << attrTag("ToolsVersion", toolsVersion)
 
613
        << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003")
 
614
        << tag("ItemGroup")
 
615
        << attrTag("Label", "ProjectConfigurations");
 
616
 
 
617
    bool isWinRT = false;
 
618
    bool isWinPhone = false;
 
619
    for (int i = 0; i < tool.SingleProjects.count(); ++i) {
 
620
        xml << tag("ProjectConfiguration")
 
621
            << attrTag("Include" , tool.SingleProjects.at(i).Configuration.Name)
 
622
            << tagValue("Configuration", tool.SingleProjects.at(i).Configuration.ConfigurationName)
 
623
            << tagValue("Platform", tool.SingleProjects.at(i).PlatformName)
 
624
            << closetag();
 
625
        isWinRT = isWinRT || tool.SingleProjects.at(i).Configuration.WinRT;
 
626
        isWinPhone = isWinPhone || tool.SingleProjects.at(i).Configuration.WinPhone;
 
627
    }
 
628
 
 
629
    xml << closetag()
 
630
        << tag("PropertyGroup")
 
631
        << attrTag("Label", "Globals")
 
632
        << tagValue("ProjectGuid", tool.ProjectGUID)
 
633
        << tagValue("RootNamespace", tool.Name)
 
634
        << tagValue("Keyword", tool.Keyword);
 
635
 
 
636
    if (isWinRT) {
 
637
        xml << tagValue("MinimumVisualStudioVersion", tool.Version)
 
638
            << tagValue("DefaultLanguage", "en")
 
639
            << tagValue("AppContainerApplication", "true")
 
640
            << tagValue("ApplicationType", isWinPhone ? "Windows Phone" : "Windows Store")
 
641
            << tagValue("ApplicationTypeRevision", tool.SdkVersion);
 
642
        if (tool.SdkVersion == "10.0") {
 
643
            const QString ucrtVersion = qgetenv("UCRTVERSION");
 
644
            xml << tagValue("WindowsTargetPlatformVersion", ucrtVersion)
 
645
                << tagValue("WindowsTargetPlatformMinVersion", ucrtVersion);
 
646
        }
 
647
    }
 
648
 
 
649
    xml << closetag();
 
650
 
 
651
    // config part.
 
652
    xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props");
 
653
    for (int i = 0; i < tool.SingleProjects.count(); ++i)
 
654
        write(xml, tool.SingleProjects.at(i).Configuration);
 
655
    xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.props");
 
656
 
 
657
    // Extension settings
 
658
    xml << tag("ImportGroup")
 
659
        << attrTag("Label", "ExtensionSettings")
 
660
        << closetag();
 
661
 
 
662
    // PropertySheets
 
663
    for (int i = 0; i < tool.SingleProjects.count(); ++i) {
 
664
        xml << tag("ImportGroup")
 
665
            << attrTag("Condition", generateCondition(tool.SingleProjects.at(i).Configuration))
 
666
            << attrTag("Label", "PropertySheets");
 
667
 
 
668
        xml << tag("Import")
 
669
            << attrTag("Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props")
 
670
            << attrTag("Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')")
 
671
            << closetag()
 
672
            << closetag();
 
673
    }
 
674
 
 
675
    // UserMacros
 
676
    xml << tag("PropertyGroup")
 
677
        << attrTag("Label", "UserMacros")
 
678
        << closetag();
 
679
 
 
680
    xml << tag("PropertyGroup");
 
681
    for (int i = 0; i < tool.SingleProjects.count(); ++i) {
 
682
        const VCConfiguration &config = tool.SingleProjects.at(i).Configuration;
 
683
        const QString condition = generateCondition(config);
 
684
 
 
685
        if (!config.OutputDirectory.isEmpty()) {
 
686
            xml << tag("OutDir")
 
687
                << attrTag("Condition", condition)
 
688
                << valueTag(config.OutputDirectory);
 
689
        }
 
690
        if (!config.IntermediateDirectory.isEmpty()) {
 
691
            xml << tag("IntDir")
 
692
                << attrTag("Condition", condition)
 
693
                << valueTag(config.IntermediateDirectory);
 
694
        }
 
695
        if (!config.PrimaryOutput.isEmpty()) {
 
696
            xml << tag("TargetName")
 
697
                << attrTag("Condition", condition)
 
698
                << valueTag(config.PrimaryOutput);
 
699
        }
 
700
        if (!config.PrimaryOutputExtension.isEmpty()) {
 
701
            xml << tag("TargetExt")
 
702
                << attrTag("Condition", condition)
 
703
                << valueTag(config.PrimaryOutputExtension);
 
704
        }
 
705
        if (config.linker.IgnoreImportLibrary != unset) {
 
706
            xml << tag("IgnoreImportLibrary")
 
707
                << attrTag("Condition", condition)
 
708
                << valueTagT(config.linker.IgnoreImportLibrary);
 
709
        }
 
710
 
 
711
        if (config.linker.LinkIncremental != linkIncrementalDefault) {
 
712
            const triState ts = (config.linker.LinkIncremental == linkIncrementalYes ? _True : _False);
 
713
            xml << tag("LinkIncremental")
 
714
                << attrTag("Condition", condition)
 
715
                << valueTagT(ts);
 
716
        }
 
717
 
 
718
        const triState generateManifest = config.linker.GenerateManifest;
 
719
        if (generateManifest != unset) {
 
720
            xml << tag("GenerateManifest")
 
721
                << attrTag("Condition", condition)
 
722
                << valueTagT(generateManifest);
 
723
        }
 
724
 
 
725
        if (config.preBuild.ExcludedFromBuild != unset)
 
726
        {
 
727
            xml << tag("PreBuildEventUseInBuild")
 
728
                << attrTag("Condition", condition)
 
729
                << valueTagT(!config.preBuild.ExcludedFromBuild);
 
730
        }
 
731
 
 
732
        if (config.preLink.ExcludedFromBuild != unset)
 
733
        {
 
734
            xml << tag("PreLinkEventUseInBuild")
 
735
                << attrTag("Condition", condition)
 
736
                << valueTagT(!config.preLink.ExcludedFromBuild);
 
737
        }
 
738
 
 
739
        if (config.postBuild.ExcludedFromBuild != unset)
 
740
        {
 
741
            xml << tag("PostBuildEventUseInBuild")
 
742
                << attrTag("Condition", condition)
 
743
                << valueTagT(!config.postBuild.ExcludedFromBuild);
 
744
        }
 
745
    }
 
746
    xml << closetag();
 
747
 
 
748
    for (int i = 0; i < tool.SingleProjects.count(); ++i) {
 
749
        const VCConfiguration &config = tool.SingleProjects.at(i).Configuration;
 
750
 
 
751
        xml << tag("ItemDefinitionGroup")
 
752
            << attrTag("Condition", generateCondition(config));
 
753
 
 
754
        // ClCompile
 
755
        write(xml, config.compiler);
 
756
 
 
757
        // Librarian / Linker
 
758
        if (config.ConfigurationType == typeStaticLibrary)
 
759
            write(xml, config.librarian);
 
760
        else
 
761
            write(xml, config.linker);
 
762
 
 
763
        // Midl
 
764
        write(xml, config.idl);
 
765
 
 
766
        // ResourceCompiler
 
767
        write(xml, config.resource);
 
768
 
 
769
        // Post build event
 
770
        if (config.postBuild.ExcludedFromBuild != unset)
 
771
            write(xml, config.postBuild);
 
772
 
 
773
        // Pre build event
 
774
        if (config.preBuild.ExcludedFromBuild != unset)
 
775
            write(xml, config.preBuild);
 
776
 
 
777
        // Pre link event
 
778
        if (config.preLink.ExcludedFromBuild != unset)
 
779
            write(xml, config.preLink);
 
780
 
 
781
        xml << closetag();
 
782
 
 
783
        // windeployqt
 
784
        if (!config.windeployqt.ExcludedFromBuild)
 
785
            write(xml, config.windeployqt);
 
786
    }
 
787
 
 
788
    // The file filters are added in a separate file for MSBUILD.
 
789
    QFile filterFile;
 
790
    filterFile.setFileName(Option::output.fileName().append(".filters"));
 
791
    filterFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate);
 
792
    QTextStream ts(&filterFile);
 
793
    XmlOutput xmlFilter(ts, XmlOutput::NoConversion);
 
794
 
 
795
    xmlFilter.setIndentString("  ");
 
796
 
 
797
    xmlFilter << decl("1.0", "utf-8")
 
798
              << tag("Project")
 
799
              << attrTag("ToolsVersion", "4.0")
 
800
              << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");
 
801
 
 
802
    xmlFilter << tag("ItemGroup");
 
803
 
 
804
    addFilters(tool, xmlFilter, "Form Files");
 
805
    addFilters(tool, xmlFilter, "Generated Files");
 
806
    addFilters(tool, xmlFilter, "Header Files");
 
807
    addFilters(tool, xmlFilter, "LexYacc Files");
 
808
    addFilters(tool, xmlFilter, "Resource Files");
 
809
    addFilters(tool, xmlFilter, "Source Files");
 
810
    addFilters(tool, xmlFilter, "Translation Files");
 
811
    addFilters(tool, xmlFilter, "Deployment Files");
 
812
    addFilters(tool, xmlFilter, "Distribution Files");
 
813
 
 
814
    for (int x = 0; x < tool.ExtraCompilers.count(); ++x)
 
815
        addFilters(tool, xmlFilter, tool.ExtraCompilers.at(x));
 
816
 
 
817
    xmlFilter << closetag();
 
818
 
 
819
    outputFilter(tool, xml, xmlFilter, "Source Files");
 
820
    outputFilter(tool, xml, xmlFilter, "Header Files");
 
821
    outputFilter(tool, xml, xmlFilter, "Generated Files");
 
822
    outputFilter(tool, xml, xmlFilter, "LexYacc Files");
 
823
    outputFilter(tool, xml, xmlFilter, "Translation Files");
 
824
    outputFilter(tool, xml, xmlFilter, "Form Files");
 
825
    outputFilter(tool, xml, xmlFilter, "Resource Files");
 
826
    outputFilter(tool, xml, xmlFilter, "Deployment Files");
 
827
    outputFilter(tool, xml, xmlFilter, "Distribution Files");
 
828
    for (int x = 0; x < tool.ExtraCompilers.count(); ++x) {
 
829
        outputFilter(tool, xml, xmlFilter, tool.ExtraCompilers.at(x));
 
830
    }
 
831
    outputFilter(tool, xml, xmlFilter, "Root Files");
 
832
 
 
833
    // App manifest
 
834
    if (isWinRT) {
 
835
        const QString manifest = QStringLiteral("Package.appxmanifest");
 
836
 
 
837
        // Find all icons referenced in the manifest
 
838
        QSet<QString> icons;
 
839
        QFile manifestFile(Option::output_dir + QLatin1Char('/') + manifest);
 
840
        if (manifestFile.open(QFile::ReadOnly)) {
 
841
            const QString contents = manifestFile.readAll();
 
842
            QRegExp regexp("[\\\\/a-zA-Z0-9_\\-\\!]*\\.(png|jpg|jpeg)");
 
843
            int pos = 0;
 
844
            while (pos > -1) {
 
845
                pos = regexp.indexIn(contents, pos);
 
846
                if (pos >= 0) {
 
847
                    const QString match = regexp.cap(0);
 
848
                    icons.insert(match);
 
849
                    pos += match.length();
 
850
                }
 
851
            }
 
852
        }
 
853
 
 
854
        // Write out manifest + icons as content items
 
855
        xml << tag(_ItemGroup)
 
856
            << tag("AppxManifest")
 
857
            << attrTag("Include", manifest)
 
858
            << closetag();
 
859
        for (const QString &icon : qAsConst(icons)) {
 
860
            xml << tag("Image")
 
861
                << attrTag("Include", icon)
 
862
                << closetag();
 
863
        }
 
864
        xml << closetag();
 
865
    }
 
866
 
 
867
    xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets")
 
868
        << tag("ImportGroup")
 
869
        << attrTag("Label", "ExtensionTargets")
 
870
        << closetag();
 
871
}
 
872
 
 
873
static inline QString toString(asmListingOption option)
 
874
{
 
875
    switch (option) {
 
876
    case asmListingNone:
 
877
        break;
 
878
    case asmListingAsmMachine:
 
879
        return "AssemblyAndMachineCode";
 
880
    case asmListingAsmMachineSrc:
 
881
        return "All";
 
882
    case asmListingAsmSrc:
 
883
        return "AssemblyAndSourceCode";
 
884
    case asmListingAssemblyOnly:
 
885
        return "AssemblyCode";
 
886
    }
 
887
    return QString();
 
888
}
 
889
 
 
890
static inline QString toString(basicRuntimeCheckOption option)
 
891
{
 
892
    switch (option) {
 
893
    case runtimeBasicCheckNone:
 
894
        return "";
 
895
    case runtimeCheckStackFrame:
 
896
        return "StackFrameRuntimeCheck";
 
897
    case runtimeCheckUninitVariables:
 
898
        return "UninitializedLocalUsageCheck";
 
899
    case runtimeBasicCheckAll:
 
900
        return "EnableFastChecks";
 
901
    }
 
902
    return QString();
 
903
}
 
904
 
 
905
static inline QString toString(callingConventionOption option)
 
906
{
 
907
    switch (option) {
 
908
    case callConventionDefault:
 
909
        break;
 
910
    case callConventionCDecl:
 
911
        return "Cdecl";
 
912
    case callConventionFastCall:
 
913
        return "FastCall";
 
914
    case callConventionStdCall:
 
915
        return "StdCall";
 
916
    }
 
917
    return QString();
 
918
}
 
919
 
 
920
static inline QString toString(CompileAsOptions option)
 
921
{
 
922
    switch (option) {
 
923
    case compileAsDefault:
 
924
        break;
 
925
    case compileAsC:
 
926
        return "CompileAsC";
 
927
    case compileAsCPlusPlus:
 
928
        return "CompileAsCpp";
 
929
    }
 
930
    return QString();
 
931
}
 
932
 
 
933
static inline QString toString(compileAsManagedOptions option)
 
934
{
 
935
    switch (option) {
 
936
    case managedDefault:
 
937
    case managedAssemblySafe:
 
938
        break;
 
939
    case managedAssembly:
 
940
        return "true";
 
941
    case managedAssemblyPure:
 
942
        return "Safe";
 
943
    case managedAssemblyOldSyntax:
 
944
        return "OldSyntax";
 
945
    }
 
946
    return QString();
 
947
}
 
948
 
 
949
static inline QString toString(debugOption option, DotNET compilerVersion)
 
950
{
 
951
    switch (option) {
 
952
    case debugUnknown:
 
953
    case debugLineInfoOnly:
 
954
        break;
 
955
    case debugDisabled:
 
956
        if (compilerVersion <= NET2010)
 
957
            break;
 
958
        return "None";
 
959
    case debugOldStyleInfo:
 
960
        return "OldStyle";
 
961
    case debugEditAndContinue:
 
962
        return "EditAndContinue";
 
963
    case debugEnabled:
 
964
        return "ProgramDatabase";
 
965
    }
 
966
    return QString();
 
967
}
 
968
 
 
969
static inline QString toString(enhancedInstructionSetOption option)
 
970
{
 
971
    switch (option) {
 
972
    case archNotSet:
 
973
        break;
 
974
    case archSSE:
 
975
        return "StreamingSIMDExtensions";
 
976
    case archSSE2:
 
977
        return "StreamingSIMDExtensions2";
 
978
    }
 
979
    return QString();
 
980
}
 
981
 
 
982
static inline QString toString(exceptionHandling option)
 
983
{
 
984
    switch (option) {
 
985
    case ehDefault:
 
986
        break;
 
987
    case ehNone:
 
988
        return "false";
 
989
    case ehNoSEH:
 
990
        return "Sync";
 
991
    case ehSEH:
 
992
        return "Async";
 
993
    }
 
994
    return QString();
 
995
}
 
996
 
 
997
static inline QString toString(favorSizeOrSpeedOption option)
 
998
{
 
999
    switch (option) {
 
1000
    case favorNone:
 
1001
        break;
 
1002
    case favorSize:
 
1003
        return "Size";
 
1004
    case favorSpeed:
 
1005
        return "Speed";
 
1006
    }
 
1007
    return QString();
 
1008
}
 
1009
 
 
1010
static inline QString toString(floatingPointModel option)
 
1011
{
 
1012
    switch (option) {
 
1013
    case floatingPointNotSet:
 
1014
        break;
 
1015
    case floatingPointFast:
 
1016
        return "Fast";
 
1017
    case floatingPointPrecise:
 
1018
        return "Precise";
 
1019
    case floatingPointStrict:
 
1020
        return "Strict";
 
1021
    }
 
1022
    return QString();
 
1023
}
 
1024
 
 
1025
static inline QString toString(inlineExpansionOption option)
 
1026
{
 
1027
    switch (option) {
 
1028
    case expandDefault:
 
1029
        break;
 
1030
    case expandDisable:
 
1031
        return "Disabled";
 
1032
    case expandOnlyInline:
 
1033
        return "OnlyExplicitInline";
 
1034
    case expandAnySuitable:
 
1035
        return "AnySuitable";
 
1036
    }
 
1037
    return QString();
 
1038
}
 
1039
 
 
1040
static inline QString toString(optimizeOption option)
 
1041
{
 
1042
    switch (option) {
 
1043
    case optimizeCustom:
 
1044
    case optimizeDefault:
 
1045
        break;
 
1046
    case optimizeDisabled:
 
1047
        return "Disabled";
 
1048
    case optimizeMinSpace:
 
1049
        return "MinSpace";
 
1050
    case optimizeMaxSpeed:
 
1051
        return "MaxSpeed";
 
1052
    case optimizeFull:
 
1053
        return "Full";
 
1054
    }
 
1055
    return QString();
 
1056
}
 
1057
 
 
1058
static inline QString toString(pchOption option)
 
1059
{
 
1060
    switch (option) {
 
1061
    case pchUnset:
 
1062
    case pchGenerateAuto:
 
1063
        break;
 
1064
    case pchNone:
 
1065
         return "NotUsing";
 
1066
    case pchCreateUsingSpecific:
 
1067
        return "Create";
 
1068
    case pchUseUsingSpecific:
 
1069
        return "Use";
 
1070
    }
 
1071
    return QString();
 
1072
}
 
1073
 
 
1074
static inline QString toString(runtimeLibraryOption option)
 
1075
{
 
1076
    switch (option) {
 
1077
    case rtUnknown:
 
1078
    case rtSingleThreaded:
 
1079
    case rtSingleThreadedDebug:
 
1080
        break;
 
1081
    case rtMultiThreaded:
 
1082
        return "MultiThreaded";
 
1083
    case rtMultiThreadedDLL:
 
1084
        return "MultiThreadedDLL";
 
1085
    case rtMultiThreadedDebug:
 
1086
        return "MultiThreadedDebug";
 
1087
    case rtMultiThreadedDebugDLL:
 
1088
        return "MultiThreadedDebugDLL";
 
1089
    }
 
1090
    return QString();
 
1091
}
 
1092
 
 
1093
static inline QString toString(structMemberAlignOption option)
 
1094
{
 
1095
    switch (option) {
 
1096
    case alignNotSet:
 
1097
        break;
 
1098
    case alignSingleByte:
 
1099
        return "1Byte";
 
1100
    case alignTwoBytes:
 
1101
        return "2Bytes";
 
1102
    case alignFourBytes:
 
1103
        return "4Bytes";
 
1104
    case alignEightBytes:
 
1105
        return "8Bytes";
 
1106
    case alignSixteenBytes:
 
1107
        return "16Bytes";
 
1108
    }
 
1109
    return QString();
 
1110
}
 
1111
 
 
1112
static inline QString toString(warningLevelOption option)
 
1113
{
 
1114
    switch (option) {
 
1115
    case warningLevelUnknown:
 
1116
        break;
 
1117
    case warningLevel_0:
 
1118
        return "TurnOffAllWarnings";
 
1119
    case warningLevel_1:
 
1120
        return "Level1";
 
1121
    case warningLevel_2:
 
1122
        return "Level2";
 
1123
    case warningLevel_3:
 
1124
        return "Level3";
 
1125
    case warningLevel_4:
 
1126
        return "Level4";
 
1127
    }
 
1128
    return QString();
 
1129
}
 
1130
 
 
1131
static inline QString toString(optLinkTimeCodeGenType option)
 
1132
{
 
1133
    switch (option) {
 
1134
    case optLTCGDefault:
 
1135
        break;
 
1136
    case optLTCGEnabled:
 
1137
        return "UseLinkTimeCodeGeneration";
 
1138
    case optLTCGInstrument:
 
1139
        return "PGInstrument";
 
1140
    case optLTCGOptimize:
 
1141
        return "PGOptimization";
 
1142
    case optLTCGUpdate:
 
1143
        return "PGUpdate";
 
1144
    }
 
1145
    return QString();
 
1146
}
 
1147
 
 
1148
static inline QString toString(subSystemOption option)
 
1149
{
 
1150
    switch (option) {
 
1151
    case subSystemNotSet:
 
1152
        break;
 
1153
    case subSystemConsole:
 
1154
        return "Console";
 
1155
    case subSystemWindows:
 
1156
        return "Windows";
 
1157
    }
 
1158
    return QString();
 
1159
}
 
1160
 
 
1161
static inline QString toString(machineTypeOption option)
 
1162
{
 
1163
    switch (option) {
 
1164
    case machineNotSet:
 
1165
        break;
 
1166
    case machineX86:
 
1167
        return "MachineX86";
 
1168
    case machineX64:
 
1169
        return "MachineX64";
 
1170
    }
 
1171
    return QString();
 
1172
}
 
1173
 
 
1174
static inline QString toString(midlCharOption option)
 
1175
{
 
1176
    switch (option) {
 
1177
    case midlCharUnsigned:
 
1178
        return "Unsigned";
 
1179
    case midlCharSigned:
 
1180
        return "Signed";
 
1181
    case midlCharAscii7:
 
1182
        return "Ascii";
 
1183
    }
 
1184
    return QString();
 
1185
}
 
1186
 
 
1187
static inline QString toString(midlErrorCheckOption option)
 
1188
{
 
1189
    switch (option) {
 
1190
    case midlAlignNotSet:
 
1191
        break;
 
1192
    case midlDisableAll:
 
1193
        return "None";
 
1194
    case midlEnableAll:
 
1195
        return "All";
 
1196
    }
 
1197
    return QString();
 
1198
}
 
1199
 
 
1200
static inline QString toString(midlStructMemberAlignOption option)
 
1201
{
 
1202
    switch (option) {
 
1203
    case midlAlignNotSet:
 
1204
        break;
 
1205
    case midlAlignSingleByte:
 
1206
        return "1";
 
1207
    case midlAlignTwoBytes:
 
1208
        return "2";
 
1209
    case midlAlignFourBytes:
 
1210
        return "4";
 
1211
    case midlAlignEightBytes:
 
1212
        return "8";
 
1213
    case midlAlignSixteenBytes:
 
1214
        return "16";
 
1215
    }
 
1216
    return QString();
 
1217
}
 
1218
 
 
1219
static inline QString toString(midlTargetEnvironment option)
 
1220
{
 
1221
    switch (option) {
 
1222
    case midlTargetNotSet:
 
1223
        break;
 
1224
    case midlTargetWin32:
 
1225
        return "Win32";
 
1226
    case midlTargetWin64:
 
1227
        return "X64";
 
1228
    }
 
1229
    return QString();
 
1230
}
 
1231
 
 
1232
static inline QString toString(midlWarningLevelOption option)
 
1233
{
 
1234
    switch (option) {
 
1235
    case midlWarningLevel_0:
 
1236
        return "0";
 
1237
    case midlWarningLevel_1:
 
1238
        return "1";
 
1239
    case midlWarningLevel_2:
 
1240
        return "2";
 
1241
    case midlWarningLevel_3:
 
1242
        return "3";
 
1243
    case midlWarningLevel_4:
 
1244
        return "4";
 
1245
    }
 
1246
    return QString();
 
1247
}
 
1248
 
 
1249
static inline QString toString(enumResourceLangID option)
 
1250
{
 
1251
    if (option == 0)
 
1252
        return QString();
 
1253
    else
 
1254
        return QString::number(qlonglong(option));
 
1255
}
 
1256
 
 
1257
static inline QString toString(charSet option)
 
1258
{
 
1259
    switch (option) {
 
1260
    case charSetNotSet:
 
1261
        return "NotSet";
 
1262
    case charSetUnicode:
 
1263
        return "Unicode";
 
1264
    case charSetMBCS:
 
1265
        return "MultiByte";
 
1266
    }
 
1267
    return QString();
 
1268
}
 
1269
 
 
1270
static inline QString toString(ConfigurationTypes option)
 
1271
{
 
1272
    switch (option) {
 
1273
    case typeUnknown:
 
1274
    case typeGeneric:
 
1275
        break;
 
1276
    case typeApplication:
 
1277
        return "Application";
 
1278
    case typeDynamicLibrary:
 
1279
        return "DynamicLibrary";
 
1280
    case typeStaticLibrary:
 
1281
        return "StaticLibrary";
 
1282
    }
 
1283
    return QString();
 
1284
}
 
1285
 
 
1286
static inline QString toString(useOfATL option)
 
1287
{
 
1288
    switch (option) {
 
1289
    case useATLNotSet:
 
1290
        break;
 
1291
    case useATLStatic:
 
1292
        return "Static";
 
1293
    case useATLDynamic:
 
1294
        return "Dynamic";
 
1295
    }
 
1296
    return QString();
 
1297
}
 
1298
 
 
1299
static inline QString toString(useOfMfc option)
 
1300
{
 
1301
    switch (option) {
 
1302
    case useMfcStdWin:
 
1303
        break;
 
1304
    case useMfcStatic:
 
1305
        return "Static";
 
1306
    case useMfcDynamic:
 
1307
        return "Dynamic";
 
1308
    }
 
1309
    return QString();
 
1310
}
 
1311
 
 
1312
static inline triState toTriState(browseInfoOption option)
 
1313
{
 
1314
    switch (option)
 
1315
    {
 
1316
    case brInfoNone:
 
1317
        return _False;
 
1318
    case brAllInfo:
 
1319
    case brNoLocalSymbols:
 
1320
        return _True;
 
1321
    }
 
1322
    return unset;
 
1323
}
 
1324
 
 
1325
static inline triState toTriState(preprocessOption option)
 
1326
{
 
1327
    switch (option)
 
1328
    {
 
1329
    case preprocessUnknown:
 
1330
        break;
 
1331
    case preprocessNo:
 
1332
        return _False;
 
1333
    case preprocessNoLineNumbers:
 
1334
    case preprocessYes:
 
1335
        return _True;
 
1336
    }
 
1337
    return unset;
 
1338
}
 
1339
 
 
1340
static inline triState toTriState(optFoldingType option)
 
1341
{
 
1342
    switch (option)
 
1343
    {
 
1344
    case optFoldingDefault:
 
1345
        break;
 
1346
    case optNoFolding:
 
1347
        return _False;
 
1348
    case optFolding:
 
1349
        return _True;
 
1350
    }
 
1351
    return unset;
 
1352
}
 
1353
 
 
1354
static inline triState toTriState(addressAwarenessType option)
 
1355
{
 
1356
    switch (option)
 
1357
    {
 
1358
    case addrAwareDefault:
 
1359
        return unset;
 
1360
    case addrAwareNoLarge:
 
1361
        return _False;
 
1362
    case addrAwareLarge:
 
1363
        return _True;
 
1364
    }
 
1365
    return unset;
 
1366
}
 
1367
 
 
1368
static inline triState toTriState(linkIncrementalType option)
 
1369
{
 
1370
    switch (option)
 
1371
    {
 
1372
    case linkIncrementalDefault:
 
1373
        return unset;
 
1374
    case linkIncrementalNo:
 
1375
        return _False;
 
1376
    case linkIncrementalYes:
 
1377
        return _True;
 
1378
    }
 
1379
    return unset;
 
1380
}
 
1381
 
 
1382
static inline triState toTriState(linkProgressOption option)
 
1383
{
 
1384
    switch (option)
 
1385
    {
 
1386
    case linkProgressNotSet:
 
1387
        return unset;
 
1388
    case linkProgressAll:
 
1389
    case linkProgressLibs:
 
1390
        return _True;
 
1391
    }
 
1392
    return unset;
 
1393
}
 
1394
 
 
1395
static inline triState toTriState(optRefType option)
 
1396
{
 
1397
    switch (option)
 
1398
    {
 
1399
    case optReferencesDefault:
 
1400
        return unset;
 
1401
    case optNoReferences:
 
1402
        return _False;
 
1403
    case optReferences:
 
1404
        return _True;
 
1405
    }
 
1406
    return unset;
 
1407
}
 
1408
 
 
1409
static inline triState toTriState(termSvrAwarenessType option)
 
1410
{
 
1411
    switch (option)
 
1412
    {
 
1413
    case termSvrAwareDefault:
 
1414
        return unset;
 
1415
    case termSvrAwareNo:
 
1416
        return _False;
 
1417
    case termSvrAwareYes:
 
1418
        return _True;
 
1419
    }
 
1420
    return unset;
 
1421
}
 
1422
 
 
1423
static XmlOutput::xml_output fixedProgramDataBaseFileNameOutput(const VCCLCompilerTool &tool)
 
1424
{
 
1425
    if (tool.config->CompilerVersion >= NET2012
 
1426
            && tool.DebugInformationFormat == debugDisabled
 
1427
            && tool.ProgramDataBaseFileName.isEmpty()) {
 
1428
        // Force the creation of an empty tag to work-around Visual Studio bug. See QTBUG-35570.
 
1429
        return tagValue(_ProgramDataBaseFileName, tool.ProgramDataBaseFileName);
 
1430
    }
 
1431
    return attrTagS(_ProgramDataBaseFileName, tool.ProgramDataBaseFileName);
 
1432
}
 
1433
 
 
1434
void VCXProjectWriter::write(XmlOutput &xml, const VCCLCompilerTool &tool)
 
1435
{
 
1436
    xml
 
1437
        << tag(_CLCompile)
 
1438
            << attrTagX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories, ";")
 
1439
            << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ")
 
1440
            << attrTagX(_AdditionalUsingDirectories, tool.AdditionalUsingDirectories, ";")
 
1441
//unused    << attrTagS(_AlwaysAppend, tool.AlwaysAppend)
 
1442
            << attrTagS(_AssemblerListingLocation, tool.AssemblerListingLocation)
 
1443
            << attrTagS(_AssemblerOutput, toString(tool.AssemblerOutput))
 
1444
            << attrTagS(_BasicRuntimeChecks, toString(tool.BasicRuntimeChecks))
 
1445
            << attrTagT(_BrowseInformation, toTriState(tool.BrowseInformation))
 
1446
            << attrTagS(_BrowseInformationFile, tool.BrowseInformationFile)
 
1447
            << attrTagT(_BufferSecurityCheck, tool.BufferSecurityCheck)
 
1448
            << attrTagS(_CallingConvention, toString(tool.CallingConvention))
 
1449
            << attrTagS(_CompileAs, toString(tool.CompileAs))
 
1450
            << attrTagS(_CompileAsManaged, toString(tool.CompileAsManaged))
 
1451
            << attrTagT(_CompileAsWinRT, tool.CompileAsWinRT)
 
1452
            << attrTagT(_CreateHotpatchableImage, tool.CreateHotpatchableImage)
 
1453
            << attrTagS(_DebugInformationFormat, toString(tool.DebugInformationFormat,
 
1454
                                                          tool.config->CompilerVersion))
 
1455
            << attrTagT(_DisableLanguageExtensions, tool.DisableLanguageExtensions)
 
1456
            << attrTagX(_DisableSpecificWarnings, tool.DisableSpecificWarnings, ";")
 
1457
            << attrTagS(_EnableEnhancedInstructionSet, toString(tool.EnableEnhancedInstructionSet))
 
1458
            << attrTagT(_EnableFiberSafeOptimizations, tool.EnableFiberSafeOptimizations)
 
1459
            << attrTagT(_EnablePREfast, tool.EnablePREfast)
 
1460
            << attrTagS(_ErrorReporting, tool.ErrorReporting)
 
1461
            << attrTagS(_ExceptionHandling, toString(tool.ExceptionHandling))
 
1462
            << attrTagT(_ExpandAttributedSource, tool.ExpandAttributedSource)
 
1463
            << attrTagS(_FavorSizeOrSpeed, toString(tool.FavorSizeOrSpeed))
 
1464
            << attrTagT(_FloatingPointExceptions, tool.FloatingPointExceptions)
 
1465
            << attrTagS(_FloatingPointModel, toString(tool.FloatingPointModel))
 
1466
            << attrTagT(_ForceConformanceInForLoopScope, tool.ForceConformanceInForLoopScope)
 
1467
            << attrTagX(_ForcedIncludeFiles, tool.ForcedIncludeFiles, ";")
 
1468
            << attrTagX(_ForcedUsingFiles, tool.ForcedUsingFiles, ";")
 
1469
            << attrTagT(_FunctionLevelLinking, tool.EnableFunctionLevelLinking)
 
1470
            << attrTagT(_GenerateXMLDocumentationFiles, tool.GenerateXMLDocumentationFiles)
 
1471
            << attrTagT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath)
 
1472
            << attrTagS(_InlineFunctionExpansion, toString(tool.InlineFunctionExpansion))
 
1473
            << attrTagT(_IntrinsicFunctions, tool.EnableIntrinsicFunctions)
 
1474
            << attrTagT(_MinimalRebuild, tool.MinimalRebuild)
 
1475
            << attrTagT(_MultiProcessorCompilation, tool.MultiProcessorCompilation)
 
1476
            << attrTagS(_ObjectFileName, tool.ObjectFile)
 
1477
//unused    << attrTagX(_ObjectFiles, tool.ObjectFiles, ";")
 
1478
            << attrTagT(_OmitDefaultLibName, tool.OmitDefaultLibName)
 
1479
            << attrTagT(_OmitFramePointers, tool.OmitFramePointers)
 
1480
            << attrTagT(_OpenMPSupport, tool.OpenMP)
 
1481
            << attrTagS(_Optimization, toString(tool.Optimization))
 
1482
            << attrTagS(_PrecompiledHeader, toString(tool.UsePrecompiledHeader))
 
1483
            << attrTagS(_PrecompiledHeaderFile, tool.PrecompiledHeaderThrough)
 
1484
            << attrTagS(_PrecompiledHeaderOutputFile, tool.PrecompiledHeaderFile)
 
1485
            << attrTagT(_PreprocessKeepComments, tool.KeepComments)
 
1486
            << attrTagX(_PreprocessorDefinitions, unquote(tool.PreprocessorDefinitions), ";")
 
1487
            << attrTagS(_PreprocessOutputPath, tool.PreprocessOutputPath)
 
1488
            << attrTagT(_PreprocessSuppressLineNumbers, tool.PreprocessSuppressLineNumbers)
 
1489
            << attrTagT(_PreprocessToFile, toTriState(tool.GeneratePreprocessedFile))
 
1490
            << fixedProgramDataBaseFileNameOutput(tool)
 
1491
            << attrTagS(_ProcessorNumber, tool.MultiProcessorCompilationProcessorCount)
 
1492
            << attrTagS(_RuntimeLibrary, toString(tool.RuntimeLibrary))
 
1493
            << attrTagT(_RuntimeTypeInfo, tool.RuntimeTypeInfo)
 
1494
            << attrTagT(_ShowIncludes, tool.ShowIncludes)
 
1495
            << attrTagT(_SmallerTypeCheck, tool.SmallerTypeCheck)
 
1496
            << attrTagT(_StringPooling, tool.StringPooling)
 
1497
            << attrTagS(_StructMemberAlignment, toString(tool.StructMemberAlignment))
 
1498
            << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner)
 
1499
            << attrTagX(_TreatSpecificWarningsAsErrors, tool.TreatSpecificWarningsAsErrors, ";")
 
1500
            << attrTagT(_TreatWarningAsError, tool.WarnAsError)
 
1501
            << attrTagT(_TreatWChar_tAsBuiltInType, tool.TreatWChar_tAsBuiltInType)
 
1502
            << attrTagT(_UndefineAllPreprocessorDefinitions, tool.UndefineAllPreprocessorDefinitions)
 
1503
            << attrTagX(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions, ";")
 
1504
            << attrTagT(_UseFullPaths, tool.DisplayFullPaths)
 
1505
            << attrTagT(_UseUnicodeForAssemblerListing, tool.UseUnicodeForAssemblerListing)
 
1506
            << attrTagS(_WarningLevel, toString(tool.WarningLevel))
 
1507
            << attrTagT(_WholeProgramOptimization, tool.WholeProgramOptimization)
 
1508
            << attrTagS(_XMLDocumentationFileName, tool.XMLDocumentationFileName)
 
1509
        << closetag(_CLCompile);
 
1510
}
 
1511
 
 
1512
void VCXProjectWriter::write(XmlOutput &xml, const VCLinkerTool &tool)
 
1513
{
 
1514
    xml
 
1515
        << tag(_Link)
 
1516
            << attrTagX(_AdditionalDependencies, tool.AdditionalDependencies, ";")
 
1517
            << attrTagX(_AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories, ";")
 
1518
            << attrTagX(_AdditionalManifestDependencies, tool.AdditionalManifestDependencies, ";")
 
1519
            << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ")
 
1520
            << attrTagX(_AddModuleNamesToAssembly, tool.AddModuleNamesToAssembly, ";")
 
1521
            << attrTagT(_AllowIsolation, tool.AllowIsolation)
 
1522
            << attrTagT(_AssemblyDebug, tool.AssemblyDebug)
 
1523
            << attrTagX(_AssemblyLinkResource, tool.AssemblyLinkResource, ";")
 
1524
            << attrTagS(_BaseAddress, tool.BaseAddress)
 
1525
            << attrTagS(_CLRImageType, tool.CLRImageType)
 
1526
            << attrTagS(_CLRSupportLastError, tool.CLRSupportLastError)
 
1527
            << attrTagS(_CLRThreadAttribute, tool.CLRThreadAttribute)
 
1528
            << attrTagT(_CLRUnmanagedCodeCheck, tool.CLRUnmanagedCodeCheck)
 
1529
//unused    << attrTagS(_CreateHotPatchableImage, tool.CreateHotPatchableImage)
 
1530
            << attrTagT(_DataExecutionPrevention, tool.DataExecutionPrevention)
 
1531
            << attrTagX(_DelayLoadDLLs, tool.DelayLoadDLLs, ";")
 
1532
            << attrTagT(_DelaySign, tool.DelaySign)
 
1533
            << attrTagS(_EmbedManagedResourceFile, tool.LinkToManagedResourceFile)
 
1534
            << attrTagT(_EnableCOMDATFolding, toTriState(tool.EnableCOMDATFolding))
 
1535
            << attrTagT(_EnableUAC, tool.EnableUAC)
 
1536
            << attrTagS(_EntryPointSymbol, tool.EntryPointSymbol)
 
1537
            << attrTagX(_ForceSymbolReferences, tool.ForceSymbolReferences, ";")
 
1538
            << attrTagS(_FunctionOrder, tool.FunctionOrder)
 
1539
            << attrTagT(_GenerateDebugInformation, tool.GenerateDebugInformation)
 
1540
            << attrTagT(_GenerateManifest, tool.GenerateManifest)
 
1541
            << attrTagT(_GenerateWindowsMetadata, tool.GenerateWindowsMetadata)
 
1542
            << attrTagS(_WindowsMetadataFile, tool.GenerateWindowsMetadata == _True ? tool.WindowsMetadataFile : QString())
 
1543
            << attrTagT(_GenerateMapFile, tool.GenerateMapFile)
 
1544
            << attrTagL(_HeapCommitSize, tool.HeapCommitSize, /*ifNot*/ -1)
 
1545
            << attrTagL(_HeapReserveSize, tool.HeapReserveSize, /*ifNot*/ -1)
 
1546
            << attrTagT(_IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries)
 
1547
            << attrTagT(_IgnoreEmbeddedIDL, tool.IgnoreEmbeddedIDL)
 
1548
            << attrTagT(_IgnoreImportLibrary, tool.IgnoreImportLibrary)
 
1549
            << attrTagT(_ImageHasSafeExceptionHandlers, tool.ImageHasSafeExceptionHandlers)
 
1550
            << attrTagX(_IgnoreSpecificDefaultLibraries, tool.IgnoreDefaultLibraryNames, ";")
 
1551
            << attrTagS(_ImportLibrary, tool.ImportLibrary)
 
1552
            << attrTagS(_KeyContainer, tool.KeyContainer)
 
1553
            << attrTagS(_KeyFile, tool.KeyFile)
 
1554
            << attrTagT(_LargeAddressAware, toTriState(tool.LargeAddressAware))
 
1555
            << attrTagT(_LinkDLL, (tool.config->ConfigurationType == typeDynamicLibrary ? _True : unset))
 
1556
            << attrTagS(_LinkErrorReporting, tool.LinkErrorReporting)
 
1557
            << attrTagT(_LinkIncremental, toTriState(tool.LinkIncremental))
 
1558
            << attrTagT(_LinkStatus, toTriState(tool.ShowProgress))
 
1559
            << attrTagS(_LinkTimeCodeGeneration, toString(tool.LinkTimeCodeGeneration))
 
1560
            << attrTagS(_ManifestFile, tool.ManifestFile)
 
1561
            << attrTagT(_MapExports, tool.MapExports)
 
1562
            << attrTagS(_MapFileName, tool.MapFileName)
 
1563
            << attrTagS(_MergedIDLBaseFileName, tool.MergedIDLBaseFileName)
 
1564
            << attrTagS(_MergeSections, tool.MergeSections)
 
1565
            << attrTagS(_MidlCommandFile, tool.MidlCommandFile)
 
1566
            << attrTagS(_ModuleDefinitionFile, tool.ModuleDefinitionFile)
 
1567
            << attrTagT(_NoEntryPoint, tool.ResourceOnlyDLL)
 
1568
            << attrTagT(_OptimizeReferences, toTriState(tool.OptimizeReferences))
 
1569
            << attrTagS(_OutputFile, tool.OutputFile)
 
1570
            << attrTagT(_PreventDllBinding, tool.PreventDllBinding)
 
1571
            << attrTagS(_ProgramDatabaseFile, tool.ProgramDatabaseFile)
 
1572
            << attrTagT(_RandomizedBaseAddress, tool.RandomizedBaseAddress)
 
1573
            << attrTagT(_RegisterOutput, tool.RegisterOutput)
 
1574
            << attrTagL(_SectionAlignment, tool.SectionAlignment, /*ifNot*/ -1)
 
1575
            << attrTagT(_SetChecksum, tool.SetChecksum)
 
1576
            << attrTagL(_StackCommitSize, tool.StackCommitSize, /*ifNot*/ -1)
 
1577
            << attrTagL(_StackReserveSize, tool.StackReserveSize, /*ifNot*/ -1)
 
1578
            << attrTagS(_StripPrivateSymbols, tool.StripPrivateSymbols)
 
1579
            << attrTagS(_SubSystem, toString(tool.SubSystem))
 
1580
//            << attrTagT(_SupportNobindOfDelayLoadedDLL, tool.SupportNobindOfDelayLoadedDLL)
 
1581
            << attrTagT(_SupportUnloadOfDelayLoadedDLL, tool.SupportUnloadOfDelayLoadedDLL)
 
1582
            << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner)
 
1583
            << attrTagT(_SwapRunFromCD, tool.SwapRunFromCD)
 
1584
            << attrTagT(_SwapRunFromNet, tool.SwapRunFromNet)
 
1585
            << attrTagS(_TargetMachine, toString(tool.TargetMachine))
 
1586
            << attrTagT(_TerminalServerAware, toTriState(tool.TerminalServerAware))
 
1587
            << attrTagT(_TreatLinkerWarningAsErrors, tool.TreatWarningsAsErrors)
 
1588
            << attrTagT(_TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration)
 
1589
            << attrTagS(_TypeLibraryFile, tool.TypeLibraryFile)
 
1590
            << attrTagL(_TypeLibraryResourceID, tool.TypeLibraryResourceID, /*ifNot*/ 0)
 
1591
            << attrTagS(_UACExecutionLevel, tool.UACExecutionLevel)
 
1592
            << attrTagT(_UACUIAccess, tool.UACUIAccess)
 
1593
            << attrTagS(_Version, tool.Version)
 
1594
        << closetag(_Link);
 
1595
}
 
1596
 
 
1597
void VCXProjectWriter::write(XmlOutput &xml, const VCMIDLTool &tool)
 
1598
{
 
1599
    xml
 
1600
        << tag(_Midl)
 
1601
            << attrTagX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories, ";")
 
1602
            << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ")
 
1603
            << attrTagT(_ApplicationConfigurationMode, tool.ApplicationConfigurationMode)
 
1604
            << attrTagS(_ClientStubFile, tool.ClientStubFile)
 
1605
            << attrTagX(_CPreprocessOptions, tool.CPreprocessOptions, " ")
 
1606
            << attrTagS(_DefaultCharType, toString(tool.DefaultCharType))
 
1607
            << attrTagS(_DLLDataFileName, tool.DLLDataFileName)
 
1608
            << attrTagS(_EnableErrorChecks, toString(tool.EnableErrorChecks))
 
1609
            << attrTagT(_ErrorCheckAllocations, tool.ErrorCheckAllocations)
 
1610
            << attrTagT(_ErrorCheckBounds, tool.ErrorCheckBounds)
 
1611
            << attrTagT(_ErrorCheckEnumRange, tool.ErrorCheckEnumRange)
 
1612
            << attrTagT(_ErrorCheckRefPointers, tool.ErrorCheckRefPointers)
 
1613
            << attrTagT(_ErrorCheckStubData, tool.ErrorCheckStubData)
 
1614
            << attrTagS(_GenerateClientFiles, tool.GenerateClientFiles)
 
1615
            << attrTagS(_GenerateServerFiles, tool.GenerateServerFiles)
 
1616
            << attrTagT(_GenerateStublessProxies, tool.GenerateStublessProxies)
 
1617
            << attrTagT(_GenerateTypeLibrary, tool.GenerateTypeLibrary)
 
1618
            << attrTagS(_HeaderFileName, tool.HeaderFileName)
 
1619
            << attrTagT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath)
 
1620
            << attrTagS(_InterfaceIdentifierFileName, tool.InterfaceIdentifierFileName)
 
1621
            << attrTagL(_LocaleID, tool.LocaleID, /*ifNot*/ -1)
 
1622
            << attrTagT(_MkTypLibCompatible, tool.MkTypLibCompatible)
 
1623
            << attrTagS(_OutputDirectory, tool.OutputDirectory)
 
1624
            << attrTagX(_PreprocessorDefinitions, tool.PreprocessorDefinitions, ";")
 
1625
            << attrTagS(_ProxyFileName, tool.ProxyFileName)
 
1626
            << attrTagS(_RedirectOutputAndErrors, tool.RedirectOutputAndErrors)
 
1627
            << attrTagS(_ServerStubFile, tool.ServerStubFile)
 
1628
            << attrTagS(_StructMemberAlignment, toString(tool.StructMemberAlignment))
 
1629
            << attrTagT(_SuppressCompilerWarnings, tool.SuppressCompilerWarnings)
 
1630
            << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner)
 
1631
            << attrTagS(_TargetEnvironment, toString(tool.TargetEnvironment))
 
1632
            << attrTagS(_TypeLibFormat, tool.TypeLibFormat)
 
1633
            << attrTagS(_TypeLibraryName, tool.TypeLibraryName)
 
1634
            << attrTagX(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions, ";")
 
1635
            << attrTagT(_ValidateAllParameters, tool.ValidateAllParameters)
 
1636
            << attrTagT(_WarnAsError, tool.WarnAsError)
 
1637
            << attrTagS(_WarningLevel, toString(tool.WarningLevel))
 
1638
        << closetag(_Midl);
 
1639
}
 
1640
 
 
1641
void VCXProjectWriter::write(XmlOutput &xml, const VCCustomBuildTool &tool)
 
1642
{
 
1643
    const QString condition = generateCondition(*tool.config);
 
1644
 
 
1645
    if ( !tool.AdditionalDependencies.isEmpty() )
 
1646
    {
 
1647
        xml << tag("AdditionalInputs")
 
1648
            << attrTag("Condition", condition)
 
1649
            << valueTagDefX(tool.AdditionalDependencies, "AdditionalInputs", ";");
 
1650
    }
 
1651
 
 
1652
    if( !tool.CommandLine.isEmpty() )
 
1653
    {
 
1654
        xml << tag("Command")
 
1655
            << attrTag("Condition", condition)
 
1656
            << valueTag(tool.CommandLine.join(vcxCommandSeparator()));
 
1657
    }
 
1658
 
 
1659
    if ( !tool.Description.isEmpty() )
 
1660
    {
 
1661
        xml << tag("Message")
 
1662
            << attrTag("Condition", condition)
 
1663
            << valueTag(tool.Description);
 
1664
    }
 
1665
 
 
1666
    if ( !tool.Outputs.isEmpty() )
 
1667
    {
 
1668
        xml << tag("Outputs")
 
1669
            << attrTag("Condition", condition)
 
1670
            << valueTagDefX(tool.Outputs, "Outputs", ";");
 
1671
    }
 
1672
}
 
1673
 
 
1674
void VCXProjectWriter::write(XmlOutput &xml, const VCLibrarianTool &tool)
 
1675
{
 
1676
    xml
 
1677
        << tag(_Lib)
 
1678
            << attrTagX(_AdditionalDependencies, tool.AdditionalDependencies, ";")
 
1679
            << attrTagX(_AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories, ";")
 
1680
            << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ")
 
1681
//unused    << attrTagS(_DisplayLibrary, tool.DisplayLibrary)
 
1682
//unused    << attrTagS(_ErrorReporting, tool.ErrorReporting)
 
1683
            << attrTagX(_ExportNamedFunctions, tool.ExportNamedFunctions, ";")
 
1684
            << attrTagX(_ForceSymbolReferences, tool.ForceSymbolReferences, ";")
 
1685
            << attrTagT(_IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries)
 
1686
            << attrTagX(_IgnoreSpecificDefaultLibraries, tool.IgnoreDefaultLibraryNames, ";")
 
1687
//unused    << attrTagT(_LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration)
 
1688
            << attrTagS(_ModuleDefinitionFile, tool.ModuleDefinitionFile)
 
1689
//unused    << attrTagS(_Name, tool.Name)
 
1690
            << attrTagS(_OutputFile, tool.OutputFile)
 
1691
//unused    << attrTagX(_RemoveObjects, tool.RemoveObjects, ";")
 
1692
//unused    << attrTagS(_SubSystem, tool.SubSystem)
 
1693
            << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner)
 
1694
//unused    << attrTagS(_TargetMachine, tool.TargetMachine)
 
1695
//unused    << attrTagT(_TreatLibWarningAsErrors, tool.TreatLibWarningAsErrors)
 
1696
//unused    << attrTagT(_Verbose, tool.Verbose)
 
1697
        << closetag(_Lib);
 
1698
}
 
1699
 
 
1700
void VCXProjectWriter::write(XmlOutput &xml, const VCResourceCompilerTool &tool)
 
1701
{
 
1702
    xml
 
1703
        << tag(_ResourceCompile)
 
1704
            << attrTagX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories, ";")
 
1705
            << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ")
 
1706
            << attrTagS(_Culture, toString(tool.Culture))
 
1707
            << attrTagT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath)
 
1708
//unused    << attrTagT(_NullTerminateStrings, tool.NullTerminateStrings)
 
1709
            << attrTagX(_PreprocessorDefinitions, tool.PreprocessorDefinitions, ";")
 
1710
            << attrTagS(_ResourceOutputFileName, tool.ResourceOutputFileName)
 
1711
            << attrTagT(_ShowProgress, toTriState(tool.ShowProgress))
 
1712
            << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner)
 
1713
//unused    << attrTagS(_TrackerLogDirectory, tool.TrackerLogDirectory)
 
1714
//unused    << attrTagS(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions)
 
1715
        << closetag(_ResourceCompile);
 
1716
}
 
1717
 
 
1718
void VCXProjectWriter::write(XmlOutput &xml, const VCEventTool &tool)
 
1719
{
 
1720
    xml
 
1721
        << tag(tool.EventName)
 
1722
            << tag(_Command) << valueTag(tool.CommandLine.join(vcxCommandSeparator()))
 
1723
            << tag(_Message) << valueTag(tool.Description)
 
1724
        << closetag(tool.EventName);
 
1725
}
 
1726
 
 
1727
void VCXProjectWriter::write(XmlOutput &xml, const VCDeploymentTool &tool)
 
1728
{
 
1729
    Q_UNUSED(xml);
 
1730
    Q_UNUSED(tool);
 
1731
    // SmartDevice deployment not supported in VS 2010
 
1732
}
 
1733
 
 
1734
void VCXProjectWriter::write(XmlOutput &xml, const VCWinDeployQtTool &tool)
 
1735
{
 
1736
    const QString name = QStringLiteral("WinDeployQt_") + tool.config->Name;
 
1737
    xml << tag("Target")
 
1738
           << attrTag(_Name, name)
 
1739
           << attrTag("Condition", generateCondition(*tool.config))
 
1740
           << attrTag("Inputs", "$(OutDir)\\$(TargetName).exe")
 
1741
           << attrTag("Outputs", tool.Record)
 
1742
           << tag(_Message)
 
1743
              << attrTag("Text", tool.CommandLine)
 
1744
           << closetag()
 
1745
           << tag("Exec")
 
1746
             << attrTag("Command", tool.CommandLine)
 
1747
           << closetag()
 
1748
        << closetag()
 
1749
        << tag("Target")
 
1750
           << attrTag(_Name, QStringLiteral("PopulateWinDeployQtItems_") + tool.config->Name)
 
1751
           << attrTag("Condition", generateCondition(*tool.config))
 
1752
           << attrTag("AfterTargets", "Link")
 
1753
           << attrTag("DependsOnTargets", name)
 
1754
           << tag("ReadLinesFromFile")
 
1755
              << attrTag("File", tool.Record)
 
1756
              << tag("Output")
 
1757
                 << attrTag("TaskParameter", "Lines")
 
1758
                 << attrTag("ItemName", "DeploymentItems")
 
1759
              << closetag()
 
1760
           << closetag()
 
1761
           << tag(_ItemGroup)
 
1762
              << tag("None")
 
1763
                 << attrTag("Include", "@(DeploymentItems)")
 
1764
                 << attrTagT("DeploymentContent", _True)
 
1765
              << closetag()
 
1766
           << closetag()
 
1767
        << closetag();
 
1768
}
 
1769
 
 
1770
void VCXProjectWriter::write(XmlOutput &xml, const VCConfiguration &tool)
 
1771
{
 
1772
        xml << tag("PropertyGroup")
 
1773
            << attrTag("Condition", generateCondition(tool))
 
1774
            << attrTag("Label", "Configuration")
 
1775
            << attrTagS(_PlatformToolSet, tool.PlatformToolSet)
 
1776
            << attrTagS(_OutputDirectory, tool.OutputDirectory)
 
1777
            << attrTagT(_ATLMinimizesCRunTimeLibraryUsage, tool.ATLMinimizesCRunTimeLibraryUsage)
 
1778
            << attrTagT(_BuildBrowserInformation, tool.BuildBrowserInformation)
 
1779
            << attrTagS(_CharacterSet, toString(tool.CharacterSet))
 
1780
            << attrTagS(_ConfigurationType, toString(tool.ConfigurationType))
 
1781
            << attrTagS(_DeleteExtensionsOnClean, tool.DeleteExtensionsOnClean)
 
1782
            << attrTagS(_ImportLibrary, tool.ImportLibrary)
 
1783
            << attrTagS(_IntermediateDirectory, tool.IntermediateDirectory)
 
1784
            << attrTagS(_PrimaryOutput, tool.PrimaryOutput)
 
1785
            << attrTagS(_ProgramDatabase, tool.ProgramDatabase)
 
1786
            << attrTagT(_RegisterOutput, tool.RegisterOutput)
 
1787
            << attrTagS(_UseOfATL, toString(tool.UseOfATL))
 
1788
            << attrTagS(_UseOfMfc, toString(tool.UseOfMfc))
 
1789
            << attrTagT(_WholeProgramOptimization, tool.WholeProgramOptimization)
 
1790
            << attrTagT(_EmbedManifest, tool.manifestTool.EmbedManifest)
 
1791
        << closetag();
 
1792
}
 
1793
 
 
1794
void VCXProjectWriter::write(XmlOutput &xml, VCFilter &tool)
 
1795
{
 
1796
    Q_UNUSED(xml);
 
1797
    Q_UNUSED(tool);
 
1798
    // unused in this generator
 
1799
}
 
1800
 
 
1801
void VCXProjectWriter::addFilters(VCProject &project, XmlOutput &xmlFilter, const QString &filtername)
 
1802
{
 
1803
    bool added = false;
 
1804
 
 
1805
    for (int i = 0; i < project.SingleProjects.count(); ++i) {
 
1806
        const VCFilter filter = project.SingleProjects.at(i).filterByName(filtername);
 
1807
        if(!filter.Files.isEmpty() && !added) {
 
1808
            xmlFilter << tag("Filter")
 
1809
                      << attrTag("Include", filtername)
 
1810
                      << attrTagS("UniqueIdentifier", filter.Guid)
 
1811
                      << attrTagS("Extensions", filter.Filter)
 
1812
                      << attrTagT("ParseFiles", filter.ParseFiles)
 
1813
                      << closetag();
 
1814
        }
 
1815
    }
 
1816
}
 
1817
 
 
1818
// outputs a given filter for all existing configurations of a project
 
1819
void VCXProjectWriter::outputFilter(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filtername)
 
1820
{
 
1821
    QScopedPointer<XNode> root;
 
1822
    if (project.SingleProjects.at(0).flat_files)
 
1823
        root.reset(new XFlatNode);
 
1824
    else
 
1825
        root.reset(new XTreeNode);
 
1826
 
 
1827
    for (int i = 0; i < project.SingleProjects.count(); ++i) {
 
1828
        const VCFilter filter = project.SingleProjects.at(i).filterByName(filtername);
 
1829
        // Merge all files in this filter to root tree
 
1830
        for (int x = 0; x < filter.Files.count(); ++x)
 
1831
            root->addElement(filter.Files.at(x));
 
1832
    }
 
1833
 
 
1834
    if (!root->hasElements())
 
1835
        return;
 
1836
 
 
1837
    root->generateXML(xml, xmlFilter, "", project, filtername); // output root tree
 
1838
}
 
1839
 
 
1840
static QString stringBeforeFirstBackslash(const QString &str)
 
1841
{
 
1842
    int idx = str.indexOf(QLatin1Char('\\'));
 
1843
    return idx == -1 ? str : str.left(idx);
 
1844
}
 
1845
 
 
1846
// Output all configurations (by filtername) for a file (by info)
 
1847
// A filters config output is in VCFilter.outputFileConfig()
 
1848
void VCXProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter,
 
1849
                                         const VCFilterFile &info, const QString &filtername)
 
1850
{
 
1851
    // In non-flat mode the filter names have directory suffixes, e.g. "Generated Files\subdir".
 
1852
    const QString cleanFilterName = stringBeforeFirstBackslash(filtername);
 
1853
 
 
1854
    // We need to check if the file has any custom build step.
 
1855
    // If there is one then it has to be included with "CustomBuild Include"
 
1856
    bool hasCustomBuildStep = false;
 
1857
    QVarLengthArray<OutputFilterData> data(project.SingleProjects.count());
 
1858
    for (int i = 0; i < project.SingleProjects.count(); ++i) {
 
1859
        data[i].filter = project.SingleProjects.at(i).filterByName(cleanFilterName);
 
1860
        if (!data[i].filter.Config) // only if the filter is not empty
 
1861
            continue;
 
1862
        VCFilter &filter = data[i].filter;
 
1863
 
 
1864
        // Clearing each filter tool
 
1865
        filter.useCustomBuildTool = false;
 
1866
        filter.useCompilerTool = false;
 
1867
        filter.CustomBuildTool = VCCustomBuildTool();
 
1868
        filter.CustomBuildTool.config = filter.Config;
 
1869
        filter.CompilerTool = VCCLCompilerTool();
 
1870
        filter.CompilerTool.config = filter.Config;
 
1871
 
 
1872
        VCFilterFile fileInFilter = filter.findFile(info.file, &data[i].inBuild);
 
1873
        data[i].info = fileInFilter;
 
1874
        data[i].inBuild &= !fileInFilter.excludeFromBuild;
 
1875
        if (data[i].inBuild && filter.addExtraCompiler(fileInFilter))
 
1876
            hasCustomBuildStep = true;
 
1877
    }
 
1878
 
 
1879
    bool fileAdded = false;
 
1880
    for (int i = 0; i < project.SingleProjects.count(); ++i) {
 
1881
        OutputFilterData *d = &data[i];
 
1882
        if (!d->filter.Config) // only if the filter is not empty
 
1883
            continue;
 
1884
        if (outputFileConfig(d, xml, xmlFilter, info.file, filtername, fileAdded,
 
1885
                             hasCustomBuildStep)) {
 
1886
            fileAdded = true;
 
1887
        }
 
1888
    }
 
1889
 
 
1890
    if ( !fileAdded )
 
1891
        outputFileConfig(xml, xmlFilter, info.file, filtername);
 
1892
 
 
1893
    xml << closetag();
 
1894
    xmlFilter << closetag();
 
1895
}
 
1896
 
 
1897
bool VCXProjectWriter::outputFileConfig(OutputFilterData *d, XmlOutput &xml, XmlOutput &xmlFilter,
 
1898
                                        const QString &filename, const QString &fullFilterName,
 
1899
                                        bool fileAdded, bool hasCustomBuildStep)
 
1900
{
 
1901
    VCFilter &filter = d->filter;
 
1902
    if (d->inBuild) {
 
1903
        if (filter.Project->usePCH)
 
1904
            filter.modifyPCHstage(filename);
 
1905
    } else {
 
1906
        // Excluded files uses an empty compiler stage
 
1907
        if (d->info.excludeFromBuild)
 
1908
            filter.useCompilerTool = true;
 
1909
    }
 
1910
 
 
1911
    // Actual XML output ----------------------------------
 
1912
    if (hasCustomBuildStep || filter.useCustomBuildTool || filter.useCompilerTool
 
1913
            || !d->inBuild || filter.Name.startsWith("Deployment Files")) {
 
1914
 
 
1915
        if (hasCustomBuildStep || filter.useCustomBuildTool)
 
1916
        {
 
1917
            if (!fileAdded) {
 
1918
                fileAdded = true;
 
1919
 
 
1920
                xmlFilter << tag("CustomBuild")
 
1921
                    << attrTag("Include", Option::fixPathToTargetOS(filename))
 
1922
                    << attrTagS("Filter", fullFilterName);
 
1923
 
 
1924
                xml << tag("CustomBuild")
 
1925
                    << attrTag("Include", Option::fixPathToTargetOS(filename));
 
1926
 
 
1927
                if (filter.Name.startsWith("Form Files")
 
1928
                        || filter.Name.startsWith("Generated Files")
 
1929
                        || filter.Name.startsWith("Resource Files")
 
1930
                        || filter.Name.startsWith("Deployment Files"))
 
1931
                    xml << attrTagS("FileType", "Document");
 
1932
            }
 
1933
 
 
1934
            filter.Project->projectWriter->write(xml, filter.CustomBuildTool);
 
1935
        }
 
1936
 
 
1937
        if (!fileAdded)
 
1938
        {
 
1939
            fileAdded = true;
 
1940
            outputFileConfig(xml, xmlFilter, filename, fullFilterName);
 
1941
        }
 
1942
 
 
1943
        const QString condition = generateCondition(*filter.Config);
 
1944
        if (!d->inBuild) {
 
1945
            xml << tag("ExcludedFromBuild")
 
1946
                << attrTag("Condition", condition)
 
1947
                << valueTag("true");
 
1948
        }
 
1949
 
 
1950
        if (filter.Name.startsWith("Deployment Files") && d->inBuild) {
 
1951
            xml << tag("DeploymentContent")
 
1952
                << attrTag("Condition", condition)
 
1953
                << valueTag("true");
 
1954
        }
 
1955
 
 
1956
        if (filter.useCompilerTool) {
 
1957
 
 
1958
            if ( !filter.CompilerTool.ForcedIncludeFiles.isEmpty() ) {
 
1959
                xml << tag("ForcedIncludeFiles")
 
1960
                    << attrTag("Condition", condition)
 
1961
                    << valueTagX(filter.CompilerTool.ForcedIncludeFiles);
 
1962
            }
 
1963
 
 
1964
            if ( !filter.CompilerTool.PrecompiledHeaderThrough.isEmpty() ) {
 
1965
                xml << tag("PrecompiledHeaderFile")
 
1966
                    << attrTag("Condition", condition)
 
1967
                    << valueTag(filter.CompilerTool.PrecompiledHeaderThrough);
 
1968
            }
 
1969
 
 
1970
            if (filter.CompilerTool.UsePrecompiledHeader != pchUnset) {
 
1971
                xml << tag("PrecompiledHeader")
 
1972
                    << attrTag("Condition", condition)
 
1973
                    << valueTag(toString(filter.CompilerTool.UsePrecompiledHeader));
 
1974
            }
 
1975
        }
 
1976
    }
 
1977
 
 
1978
    return fileAdded;
 
1979
}
 
1980
 
 
1981
void VCXProjectWriter::outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter,
 
1982
                                        const QString &filePath, const QString &filterName)
 
1983
{
 
1984
    const QString nativeFilePath = Option::fixPathToTargetOS(filePath);
 
1985
    if (filterName.startsWith("Source Files")) {
 
1986
        xmlFilter << tag("ClCompile")
 
1987
                  << attrTag("Include", nativeFilePath)
 
1988
                  << attrTagS("Filter", filterName);
 
1989
        xml << tag("ClCompile")
 
1990
            << attrTag("Include", nativeFilePath);
 
1991
    } else if (filterName.startsWith("Header Files")) {
 
1992
        xmlFilter << tag("ClInclude")
 
1993
                  << attrTag("Include", nativeFilePath)
 
1994
                  << attrTagS("Filter", filterName);
 
1995
        xml << tag("ClInclude")
 
1996
            << attrTag("Include", nativeFilePath);
 
1997
    } else if (filterName.startsWith("Generated Files") || filterName.startsWith("Form Files")) {
 
1998
        if (filePath.endsWith(".h")) {
 
1999
            xmlFilter << tag("ClInclude")
 
2000
                      << attrTag("Include", nativeFilePath)
 
2001
                      << attrTagS("Filter", filterName);
 
2002
            xml << tag("ClInclude")
 
2003
                << attrTag("Include", nativeFilePath);
 
2004
        } else if (filePath.endsWith(".cpp")) {
 
2005
            xmlFilter << tag("ClCompile")
 
2006
                      << attrTag("Include", nativeFilePath)
 
2007
                      << attrTagS("Filter", filterName);
 
2008
            xml << tag("ClCompile")
 
2009
                << attrTag("Include", nativeFilePath);
 
2010
        } else if (filePath.endsWith(".res")) {
 
2011
            xmlFilter << tag("CustomBuild")
 
2012
                      << attrTag("Include", nativeFilePath)
 
2013
                      << attrTagS("Filter", filterName);
 
2014
            xml << tag("CustomBuild")
 
2015
                << attrTag("Include", nativeFilePath);
 
2016
        } else {
 
2017
            xmlFilter << tag("CustomBuild")
 
2018
                      << attrTag("Include", nativeFilePath)
 
2019
                      << attrTagS("Filter", filterName);
 
2020
            xml << tag("CustomBuild")
 
2021
                << attrTag("Include", nativeFilePath);
 
2022
        }
 
2023
    } else if (filterName.startsWith("Root Files")) {
 
2024
        if (filePath.endsWith(".rc")) {
 
2025
            xmlFilter << tag("ResourceCompile")
 
2026
                      << attrTag("Include", nativeFilePath);
 
2027
            xml << tag("ResourceCompile")
 
2028
                << attrTag("Include", nativeFilePath);
 
2029
        }
 
2030
    } else {
 
2031
        xmlFilter << tag("None")
 
2032
                  << attrTag("Include", nativeFilePath)
 
2033
                  << attrTagS("Filter", filterName);
 
2034
        xml << tag("None")
 
2035
            << attrTag("Include", nativeFilePath);
 
2036
    }
 
2037
}
 
2038
 
 
2039
QString VCXProjectWriter::generateCondition(const VCConfiguration &config)
 
2040
{
 
2041
    return QStringLiteral("'$(Configuration)|$(Platform)'=='") + config.Name + QLatin1Char('\'');
 
2042
}
 
2043
 
 
2044
QT_END_NAMESPACE