1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the qmake application of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
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 http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file.  Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef MSVC_OBJECTMODEL_H
43 #define MSVC_OBJECTMODEL_H
44 
45 #include "project.h"
46 #include "xmloutput.h"
47 #include <qatomic.h>
48 #include <qlist.h>
49 #include <qstring.h>
50 #include <qstringlist.h>
51 #include <qmap.h>
52 #include <qdebug.h>
53 
54 QT_BEGIN_NAMESPACE
55 
56 enum DotNET {
57     NETUnknown = 0,
58     NET2002 = 0x70,
59     NET2003 = 0x71,
60     NET2005 = 0x80,
61     NET2008 = 0x90,
62     NET2010 = 0xa0,
63     NET2012 = 0xb0,
64     NET2013 = 0xc0,
65     NET2015 = 0xd0
66 };
67 
68 /*
69     This Object model is of course VERY simplyfied,
70     and does not actually follow the original MSVC
71     object model. However, it fulfilles the basic
72     needs for qmake
73 */
74 
75 /*
76     If a triState value is 'unset' then the
77     corresponding property is not in the output,
78     forcing the tool to utilize default values.
79     False/True values will be in the output...
80 */
81 enum customBuildCheck {
82     none,
83     mocSrc,
84     mocHdr,
85     lexyacc
86 };
87 enum triState {
88     unset = -1,
89     _False = 0,
90     _True = 1
91 };
92 
93 triState operator!(const triState &rhs);
94 
95 enum addressAwarenessType {
96     addrAwareDefault,
97     addrAwareNoLarge,
98     addrAwareLarge
99 };
100 enum asmListingOption {
101     asmListingNone,
102     asmListingAssemblyOnly,
103     asmListingAsmMachineSrc,
104     asmListingAsmMachine,
105     asmListingAsmSrc
106 };
107 enum basicRuntimeCheckOption {
108     runtimeBasicCheckNone = 0,
109     runtimeCheckStackFrame = 1,
110     runtimeCheckUninitVariables = 2,
111     runtimeBasicCheckAll = runtimeCheckStackFrame | runtimeCheckUninitVariables
112 };
113 enum browseInfoOption {
114     brInfoNone,
115     brAllInfo,
116     brNoLocalSymbols
117 };
118 enum callingConventionOption {
119     callConventionDefault = -1,
120     callConventionCDecl,
121     callConventionFastCall,
122     callConventionStdCall
123 };
124 enum charSet {
125     charSetNotSet,
126     charSetUnicode,
127     charSetMBCS
128 };
129 enum compileAsManagedOptions {
130     managedDefault           = -1, // Was: noAssembly
131     managedAssembly          = 1,
132     managedAssemblyPure      = 2,  // Old was: Assembly
133     managedAssemblySafe      = 3,
134     managedAssemblyOldSyntax = 4
135 };
136 enum CompileAsOptions{
137     compileAsDefault,
138     compileAsC,
139     compileAsCPlusPlus
140 };
141 enum ConfigurationTypes {
142     typeUnknown        = 0,
143     typeApplication    = 1,
144     typeDynamicLibrary = 2,
145     typeStaticLibrary  = 4,
146     typeGeneric        = 10
147 };
148 enum debugOption {
149     debugUnknown = -1,
150     debugDisabled,
151     debugOldStyleInfo,
152     debugLineInfoOnly,
153     debugEnabled,
154     debugEditAndContinue
155 };
156 enum eAppProtectionOption {
157     eAppProtectUnchanged,
158     eAppProtectLow,
159     eAppProtectMedium,
160     eAppProtectHigh
161 };
162 enum enhancedInstructionSetOption {
163     archNotSet = 0,
164     archSSE = 1,
165     archSSE2 = 2
166 };
167 enum exceptionHandling {
168     ehDefault = -1,
169     ehNone    = 0,
170     ehNoSEH   = 1,
171     ehSEH     = 2
172 };
173 enum enumResourceLangID {
174     rcUseDefault                 = 0,
175     rcAfrikaans                  = 1078,
176     rcAlbanian                   = 1052,
177     rcArabicAlgeria              = 5121,
178     rcArabicBahrain              = 15361,
179     rcArabicEgypt                = 3073,
180     rcArabicIraq                 = 2049,
181     rcArabicJordan               = 11265,
182     rcArabicKuwait               = 13313,
183     rcArabicLebanon              = 12289,
184     rcArabicLibya                = 4097,
185     rcArabicMorocco              = 6145,
186     rcArabicOman                 = 8193,
187     rcArabicQatar                = 16385,
188     rcArabicSaudi                = 1025,
189     rcArabicSyria                = 10241,
190     rcArabicTunisia              = 7169,
191     rcArabicUnitedArabEmirates   = 14337,
192     rcArabicYemen                = 9217,
193     rcBasque                     = 1069,
194     rcBulgarian                  = 1026,
195     rcByelorussian               = 1059,
196     rcCatalan                    = 1027,
197     rcChineseHongKong            = 3076,
198     rcChinesePRC                 = 2052,
199     rcChineseSingapore           = 4100,
200     rcChineseTaiwan              = 1028,
201     rcCroatian                   = 1050,
202     rcCzech                      = 1029,
203     rcDanish                     = 1030,
204     rcDutchBelgium               = 2067,
205     rcDutchStandard              = 1043,
206     rcEnglishAustralia           = 3081,
207     rcEnglishBritain             = 2057,
208     rcEnglishCanada              = 4105,
209     RcEnglishCaribbean           = 9225,
210     rcEnglishIreland             = 6153,
211     rcEnglishJamaica             = 8201,
212     rcEnglishNewZealand          = 5129,
213     rcEnglishSouthAfrica         = 7177,
214     rcEnglishUS                  = 1033,
215     rcEstonian                   = 1061,
216     rcFarsi                      = 1065,
217     rcFinnish                    = 1035,
218     rcFrenchBelgium              = 2060,
219     rcFrenchCanada               = 3084,
220     rcFrenchLuxembourg           = 5132,
221     rcFrenchStandard             = 1036,
222     rcFrenchSwitzerland          = 4108,
223     rcGermanAustria              = 3079,
224     rcGermanLichtenstein         = 5127,
225     rcGermanLuxembourg           = 4103,
226     rcGermanStandard             = 1031,
227     rcGermanSwitzerland          = 2055,
228     rcGreek                      = 1032,
229     rcHebrew                     = 1037,
230     rcHungarian                  = 1038,
231     rcIcelandic                  = 1039,
232     rcIndonesian                 = 1057,
233     rcItalianStandard            = 1040,
234     rcItalianSwitzerland         = 2064,
235     rcJapanese                   = 1041,
236     rcKorean                     = 1042,
237     rcKoreanJohab                = 2066,
238     rcLatvian                    = 1062,
239     rcLithuanian                 = 1063,
240     rcNorwegianBokmal            = 1044,
241     rcNorwegianNynorsk           = 2068,
242     rcPolish                     = 1045,
243     rcPortugueseBrazilian        = 1046,
244     rcPortugueseStandard         = 2070,
245     rcRomanian                   = 1048,
246     rcRussian                    = 1049,
247     rcSerbian                    = 2074,
248     rcSlovak                     = 1051,
249     rcSpanishArgentina           = 11274,
250     rcSpanishBolivia             = 16394,
251     rcSpanishChile               = 13322,
252     rcSpanishColombia            = 9226,
253     rcSpanishCostaRica           = 5130,
254     rcSpanishDominicanRepublic   = 7178,
255     rcSpanishEcuador             = 12298,
256     rcSpanishGuatemala           = 4106,
257     rcSpanishMexico              = 2058,
258     rcSpanishModern              = 3082,
259     rcSpanishPanama              = 6154,
260     rcSpanishParaguay            = 15370,
261     rcSpanishPeru                = 10250,
262     rcSpanishTraditional         = 1034,
263     rcSpanishUruguay             = 14346,
264     rcSpanishVenezuela           = 8202,
265     rcSwedish                    = 1053,
266     rcThai                       = 1054,
267     rcTurkish                    = 1055,
268     rcUkrainian                  = 1058,
269     rcUrdu                       = 1056
270 };
271 enum enumSccEvent {
272     eProjectInScc,
273     ePreDirtyNotification
274 };
275 enum favorSizeOrSpeedOption {
276     favorNone,
277     favorSpeed,
278     favorSize
279 };
280 enum floatingPointModel {
281     floatingPointNotSet = -1,
282     floatingPointPrecise,
283     floatingPointStrict,
284     floatingPointFast
285 };
286 enum genProxyLanguage {
287     genProxyNative,
288     genProxyManaged
289 };
290 enum inlineExpansionOption {
291     expandDisable,
292     expandOnlyInline,
293     expandAnySuitable,
294     expandDefault // Not useful number, but stops the output
295 };
296 enum linkIncrementalType {
297     linkIncrementalDefault,
298     linkIncrementalNo,
299     linkIncrementalYes
300 };
301 enum linkProgressOption {
302     linkProgressNotSet,
303     linkProgressAll,
304     linkProgressLibs
305 };
306 enum machineTypeOption {
307     machineNotSet,
308     machineX86,
309     machineX64 = 17
310 };
311 enum midlCharOption {
312     midlCharUnsigned,
313     midlCharSigned,
314     midlCharAscii7
315 };
316 enum midlErrorCheckOption {
317     midlEnableCustom,
318     midlDisableAll,
319     midlEnableAll
320 };
321 enum midlStructMemberAlignOption {
322     midlAlignNotSet,
323     midlAlignSingleByte,
324     midlAlignTwoBytes,
325     midlAlignFourBytes,
326     midlAlignEightBytes,
327     midlAlignSixteenBytes
328 };
329 enum midlTargetEnvironment {
330     midlTargetNotSet,
331     midlTargetWin32,
332     midlTargetWin64
333 };
334 enum midlWarningLevelOption {
335     midlWarningLevel_0,
336     midlWarningLevel_1,
337     midlWarningLevel_2,
338     midlWarningLevel_3,
339     midlWarningLevel_4
340 };
341 enum optFoldingType {
342     optFoldingDefault,
343     optNoFolding,
344     optFolding
345 };
346 enum optimizeOption {
347     optimizeDisabled,
348     optimizeMinSpace,
349     optimizeMaxSpeed,
350     optimizeFull,
351     optimizeCustom,
352     optimizeDefault // Not useful number, but stops the output
353 };
354 enum optRefType {
355     optReferencesDefault,
356     optNoReferences,
357     optReferences
358 };
359 enum optWin98Type {
360     optWin98Default,
361     optWin98No,
362     optWin98Yes
363 };
364 enum optLinkTimeCodeGenType {
365     optLTCGDefault,
366     optLTCGEnabled,
367     optLTCGInstrument,
368     optLTCGOptimize,
369     optLTCGUpdate
370 };
371 enum pchOption {
372     pchUnset = -1,
373     pchNone,
374     pchCreateUsingSpecific,
375     pchGenerateAuto,
376     pchUseUsingSpecific
377 };
378 enum preprocessOption {
379     preprocessUnknown = -1,
380     preprocessNo,
381     preprocessYes,
382     preprocessNoLineNumbers
383 };
384 enum ProcessorOptimizeOption {
385     procOptimizeBlended,                //GB
386     procOptimizePentium,                //G5
387     procOptimizePentiumProAndAbove,     //G6
388     procOptimizePentium4AndAbove        //G7
389 };
390 enum RegisterDeployOption {
391     registerNo = 0,
392     registerYes
393 };
394 enum RemoteDebuggerType {
395     DbgLocal,
396     DbgRemote,
397     DbgRemoteTCPIP
398 };
399 enum runtimeLibraryOption {
400     rtUnknown = -1,
401     rtMultiThreaded,
402     rtMultiThreadedDebug,
403     rtMultiThreadedDLL,
404     rtMultiThreadedDebugDLL,
405     rtSingleThreaded,
406     rtSingleThreadedDebug
407 };
408 enum structMemberAlignOption {
409     alignNotSet,
410     alignSingleByte,
411     alignTwoBytes,
412     alignFourBytes,
413     alignEightBytes,
414     alignSixteenBytes
415 };
416 enum subSystemOption {
417     subSystemNotSet,
418     subSystemConsole,
419     subSystemWindows
420 };
421 enum termSvrAwarenessType {
422     termSvrAwareDefault,
423     termSvrAwareNo,
424     termSvrAwareYes
425 };
426 enum toolSetType {
427     toolSetUtility,
428     toolSetMakefile,
429     toolSetLinker,
430     toolSetLibrarian,
431     toolSetAll
432 };
433 enum TypeOfDebugger {
434     DbgNativeOnly,
435     DbgManagedOnly,
436     DbgMixed,
437     DbgAuto
438 };
439 enum useOfATL {
440     useATLNotSet,
441     useATLStatic,
442     useATLDynamic
443 };
444 enum useOfMfc {
445     useMfcStdWin,
446     useMfcStatic,
447     useMfcDynamic
448 };
449 enum useOfArchitecture {
450     archUnknown = -1,
451     archArmv4,
452     archArmv5,
453     archArmv4T,
454     archArmv5T,
455     archMips1 = 0,
456     archMips2 = 1,
457     archMips3 = 2,
458     archMips4 = 3,
459     archMips5 = 4,
460     archMips16 = 5,
461     archMips32 = 6,
462     archMips64 = 7
463 };
464 enum warningLevelOption {
465     warningLevelUnknown = -1,
466     warningLevel_0,
467     warningLevel_1,
468     warningLevel_2,
469     warningLevel_3,
470     warningLevel_4
471 };
472 
473 
474 class VCToolBase {
475 protected:
476     // Functions
VCToolBase()477     VCToolBase(){}
~VCToolBase()478     virtual ~VCToolBase(){}
479     virtual bool parseOption(const char* option) = 0;
480 public:
parseOptions(QStringList & options)481     void parseOptions(QStringList& options) {
482         for (QStringList::ConstIterator it=options.begin(); (it!=options.end()); it++)
483             parseOption((*it).toLatin1());
484     }
485     static QStringList fixCommandLine(const QString &input);
486 };
487 
488 class VCConfiguration;
489 class VCProject;
490 
491 class VCCLCompilerTool : public VCToolBase
492 {
493 public:
494     // Functions
495     VCCLCompilerTool();
~VCCLCompilerTool()496     virtual ~VCCLCompilerTool(){}
497     bool parseOption(const char* option);
498 
499     // Variables
500     QStringList             AdditionalIncludeDirectories;
501     QStringList             AdditionalOptions;
502     QStringList             AdditionalUsingDirectories;
503     QString                 AssemblerListingLocation;
504     asmListingOption        AssemblerOutput;
505     basicRuntimeCheckOption BasicRuntimeChecks;
506     browseInfoOption        BrowseInformation;
507     QString                 BrowseInformationFile;
508     triState                BufferSecurityCheck;
509     callingConventionOption CallingConvention;
510     CompileAsOptions        CompileAs;
511     compileAsManagedOptions CompileAsManaged;
512     triState                CompileOnly;
513     debugOption             DebugInformationFormat;
514     triState                DefaultCharIsUnsigned;
515     triState                Detect64BitPortabilityProblems;
516     triState                DisableLanguageExtensions;
517     QStringList             DisableSpecificWarnings;
518     enhancedInstructionSetOption  EnableEnhancedInstructionSet;
519     triState                EnableFiberSafeOptimizations;
520     triState                EnableFunctionLevelLinking;
521     triState                EnableIntrinsicFunctions;
522     exceptionHandling       ExceptionHandling;
523     triState                ExpandAttributedSource;
524     favorSizeOrSpeedOption  FavorSizeOrSpeed;
525     floatingPointModel      FloatingPointModel;
526     triState                FloatingPointExceptions;
527     triState                ForceConformanceInForLoopScope;
528     QStringList             ForcedIncludeFiles;
529     QStringList             ForcedUsingFiles;
530     preprocessOption        GeneratePreprocessedFile;
531     triState                PreprocessSuppressLineNumbers;
532     triState                GlobalOptimizations;
533     triState                IgnoreStandardIncludePath;
534     triState                ImproveFloatingPointConsistency;
535     inlineExpansionOption   InlineFunctionExpansion;
536     triState                KeepComments;
537     triState                MinimalRebuild;
538     QString                 ObjectFile;
539     triState                OmitDefaultLibName;
540     triState                OmitFramePointers;
541     triState                OpenMP;
542     optimizeOption          Optimization;
543     ProcessorOptimizeOption OptimizeForProcessor;
544     triState                OptimizeForWindowsApplication;
545     QString                 OutputFile;
546     QString                 PrecompiledHeaderFile;
547     QString                 PrecompiledHeaderThrough;
548     QStringList             PreprocessorDefinitions;
549     QString                 ProgramDataBaseFileName;
550     runtimeLibraryOption    RuntimeLibrary;
551     triState                RuntimeTypeInfo;
552     triState                ShowIncludes;
553     triState                SmallerTypeCheck;
554     triState                StringPooling;
555     structMemberAlignOption StructMemberAlignment;
556     triState                SuppressStartupBanner;
557     triState                TreatWChar_tAsBuiltInType;
558     triState                TurnOffAssemblyGeneration;
559     triState                UndefineAllPreprocessorDefinitions;
560     QStringList             UndefinePreprocessorDefinitions;
561     pchOption               UsePrecompiledHeader;
562     triState                UseUnicodeForAssemblerListing;
563     QStringList             TreatSpecificWarningsAsErrors;
564     triState                WarnAsError;
565     warningLevelOption      WarningLevel;
566     triState                WholeProgramOptimization;
567     useOfArchitecture       CompileForArchitecture;
568     triState                InterworkCalls;
569 
570     // VS2010
571     triState                EnablePREfast;
572     triState                DisplayFullPaths;
573     triState                MultiProcessorCompilation;
574     QString                 MultiProcessorCompilationProcessorCount;
575     triState                GenerateXMLDocumentationFiles;
576     QString                 XMLDocumentationFileName;
577     QString                 ErrorReporting;
578     triState                CreateHotpatchableImage;
579     QString                 PreprocessOutputPath;
580 
581     VCConfiguration*        config;
582 
583 private:
584     bool parseRuntimeCheckOption(char c, int *rtc);
585 };
586 
587 class VCLinkerTool : public VCToolBase
588 {
589 public:
590     // Functions
591     VCLinkerTool();
~VCLinkerTool()592     virtual ~VCLinkerTool(){}
593     bool parseOption(const char* option);
594 
595     // Variables
596     QStringList             AdditionalDependencies;
597     QStringList             AdditionalLibraryDirectories;
598     QStringList             AdditionalOptions;
599     QStringList             AddModuleNamesToAssembly;
600     QString                 BaseAddress;
601     triState                DataExecutionPrevention;
602     QStringList             DelayLoadDLLs;
603     optFoldingType          EnableCOMDATFolding;
604     QString                 EntryPointSymbol;
605     QStringList             ForceSymbolReferences;
606     QString                 FunctionOrder;
607     triState                GenerateDebugInformation;
608     triState                GenerateMapFile;
609     qlonglong               HeapCommitSize;
610     qlonglong               HeapReserveSize;
611     triState                IgnoreAllDefaultLibraries;
612     QStringList             IgnoreDefaultLibraryNames;
613     triState                IgnoreEmbeddedIDL;
614     triState                IgnoreImportLibrary;
615     QString                 ImportLibrary;
616     addressAwarenessType    LargeAddressAware;
617     triState                LinkDLL;
618     linkIncrementalType     LinkIncremental;
619     optLinkTimeCodeGenType  LinkTimeCodeGeneration;
620     QString                 LinkToManagedResourceFile;
621     triState                MapExports;
622     QString                 MapFileName;
623     triState                MapLines;
624     QString                 MergedIDLBaseFileName;
625     QString                 MergeSections;          // Should be list?
626     QString                 MidlCommandFile;
627     QString                 ModuleDefinitionFile;   // Should be list?
628     optWin98Type            OptimizeForWindows98;
629     optRefType              OptimizeReferences;
630     QString                 OutputFile;
631     QString                 ProgramDatabaseFile;
632     triState                RandomizedBaseAddress;
633     triState                RegisterOutput;
634     triState                ResourceOnlyDLL;
635     triState                SetChecksum;
636     linkProgressOption      ShowProgress;
637     qlonglong               StackCommitSize;
638     qlonglong               StackReserveSize;
639     QString                 StripPrivateSymbols;    // Should be list?
640     subSystemOption         SubSystem;
641     triState                SupportUnloadOfDelayLoadedDLL;
642     triState                SuppressStartupBanner;
643     triState                SwapRunFromCD;
644     triState                SwapRunFromNet;
645     machineTypeOption       TargetMachine;
646     termSvrAwarenessType    TerminalServerAware;
647     triState                TreatWarningsAsErrors;
648     triState                TurnOffAssemblyGeneration;
649     QString                 TypeLibraryFile;
650     qlonglong               TypeLibraryResourceID;
651     QString                 Version;
652 
653     // VS2010
654     triState                GenerateManifest;
655     QStringList             AdditionalManifestDependencies;
656     QString                 ManifestFile;
657     triState                EnableUAC;
658     QString                 UACExecutionLevel;
659     triState                UACUIAccess;
660     qlonglong               SectionAlignment;
661     triState                PreventDllBinding;
662     triState                AllowIsolation;
663     triState                AssemblyDebug;
664     QStringList             AssemblyLinkResource;
665     QString                 CLRImageType;
666     QString                 CLRSupportLastError;
667     QString                 CLRThreadAttribute;
668     triState                CLRUnmanagedCodeCheck;
669     triState                DelaySign;
670     QString                 KeyContainer;
671     QString                 KeyFile;
672     QString                 LinkErrorReporting;
673 
674     VCConfiguration*        config;
675 };
676 
677 class VCMIDLTool : public VCToolBase
678 {
679 public:
680     // Functions
681     VCMIDLTool();
~VCMIDLTool()682     virtual ~VCMIDLTool(){}
683     bool parseOption(const char* option);
684 
685     // Variables
686     QStringList             AdditionalIncludeDirectories;
687     QStringList             AdditionalOptions;
688     QStringList             CPreprocessOptions;
689     midlCharOption          DefaultCharType;
690     QString                 DLLDataFileName;    // Should be list?
691     midlErrorCheckOption    EnableErrorChecks;
692     triState                ErrorCheckAllocations;
693     triState                ErrorCheckBounds;
694     triState                ErrorCheckEnumRange;
695     triState                ErrorCheckRefPointers;
696     triState                ErrorCheckStubData;
697     QStringList             FullIncludePath;
698     triState                GenerateStublessProxies;
699     triState                GenerateTypeLibrary;
700     QString                 HeaderFileName;
701     triState                IgnoreStandardIncludePath;
702     QString                 InterfaceIdentifierFileName;
703     triState                MkTypLibCompatible;
704     QString                 OutputDirectory;
705     QStringList             PreprocessorDefinitions;
706     QString                 ProxyFileName;
707     QString                 RedirectOutputAndErrors;
708     midlStructMemberAlignOption StructMemberAlignment;
709     triState                SuppressStartupBanner;
710     midlTargetEnvironment   TargetEnvironment;
711     QString                 TypeLibraryName;
712     QStringList             UndefinePreprocessorDefinitions;
713     triState                ValidateParameters;
714     triState                WarnAsError;
715     midlWarningLevelOption  WarningLevel;
716 
717     // VS 2010
718     triState                ApplicationConfigurationMode;
719     QString                 GenerateClientFiles;
720     QString                 ClientStubFile;
721     QString                 TypeLibFormat;
722     triState                ValidateAllParameters;
723     triState                SuppressCompilerWarnings;
724     QString                 GenerateServerFiles;
725     QString                 ServerStubFile;
726     qlonglong               LocaleID;
727 
728     VCConfiguration*        config;
729 };
730 
731 class VCLibrarianTool : public VCToolBase
732 {
733 public:
734     // Functions
735     VCLibrarianTool();
~VCLibrarianTool()736     virtual ~VCLibrarianTool(){}
parseOption(const char *)737     bool parseOption(const char*){ return false; }
738 
739     // Variables
740     QStringList             AdditionalDependencies;
741     QStringList             AdditionalLibraryDirectories;
742     QStringList             AdditionalOptions;
743     QStringList             ExportNamedFunctions;
744     QStringList             ForceSymbolReferences;
745     triState                IgnoreAllDefaultLibraries;
746     QStringList             IgnoreDefaultLibraryNames;
747     QString                 ModuleDefinitionFile;
748     QString                 OutputFile;
749     triState                SuppressStartupBanner;
750 };
751 
752 class VCCustomBuildTool : public VCToolBase
753 {
754 public:
755     // Functions
756     VCCustomBuildTool();
~VCCustomBuildTool()757     virtual ~VCCustomBuildTool(){}
parseOption(const char *)758     bool parseOption(const char*){ return false; }
759 
760     // Variables
761     QStringList             AdditionalDependencies;
762     QStringList             CommandLine;
763     QString                 Description;
764     QStringList             Outputs;
765     QString                 ToolName;
766     QString                 ToolPath;
767 
768     VCConfiguration*        config;
769 };
770 
771 class VCResourceCompilerTool : public VCToolBase
772 {
773 public:
774     // Functions
775     VCResourceCompilerTool();
~VCResourceCompilerTool()776     virtual ~VCResourceCompilerTool(){}
parseOption(const char *)777     bool parseOption(const char*){ return false; }
778 
779     // Variables
780     QStringList             AdditionalIncludeDirectories;
781     QStringList             AdditionalOptions;
782     enumResourceLangID      Culture;
783     QStringList             FullIncludePath;
784     triState                IgnoreStandardIncludePath;
785     QStringList             PreprocessorDefinitions;
786     QString                 ResourceOutputFileName;
787     linkProgressOption      ShowProgress;
788     QString                 ToolPath;
789     triState                SuppressStartupBanner;
790 };
791 
792 class VCDeploymentTool
793 {
794 public:
795     // Functions
796     VCDeploymentTool();
~VCDeploymentTool()797     virtual ~VCDeploymentTool() {}
798 
799     // Variables
800     QString                 DeploymentTag;
801     QString                 RemoteDirectory;
802     RegisterDeployOption    RegisterOutput;
803     QString                 AdditionalFiles;
804 };
805 
806 class VCEventTool : public VCToolBase
807 {
808 protected:
809     // Functions
810     VCEventTool(const QString &eventName);
~VCEventTool()811     virtual ~VCEventTool(){}
parseOption(const char *)812     bool parseOption(const char*){ return false; }
813 
814 public:
815     // Variables
816     QStringList             CommandLine;
817     QString                 Description;
818     triState                ExcludedFromBuild;
819     QString                 EventName;
820     QString                 ToolName;
821     QString                 ToolPath;
822 };
823 
824 class VCPostBuildEventTool : public VCEventTool
825 {
826 public:
827     VCPostBuildEventTool();
~VCPostBuildEventTool()828     ~VCPostBuildEventTool(){}
829 };
830 
831 class VCPreBuildEventTool : public VCEventTool
832 {
833 public:
834     VCPreBuildEventTool();
~VCPreBuildEventTool()835     ~VCPreBuildEventTool(){}
836 };
837 
838 class VCPreLinkEventTool : public VCEventTool
839 {
840 public:
841     VCPreLinkEventTool();
~VCPreLinkEventTool()842     ~VCPreLinkEventTool(){}
843 };
844 
845 class VCConfiguration
846 {
847 public:
848     // Functions
849     VCConfiguration();
~VCConfiguration()850     ~VCConfiguration(){}
851 
852     DotNET                  CompilerVersion;
853 
854     // Variables
855     triState                ATLMinimizesCRunTimeLibraryUsage;
856     triState                BuildBrowserInformation;
857     charSet                 CharacterSet;
858     ConfigurationTypes      ConfigurationType;
859     QString                 DeleteExtensionsOnClean;
860     QString                 ImportLibrary;
861     QString                 IntermediateDirectory;
862     QString                 Name;   // "ConfigurationName|PlatformName"
863     QString                 ConfigurationName;
864     QString                 OutputDirectory;
865     QString                 PrimaryOutput;
866     QString                 PrimaryOutputExtension;
867     QString                 ProgramDatabase;
868     triState                RegisterOutput;
869     useOfATL                UseOfATL;
870     useOfMfc                UseOfMfc;
871     triState                WholeProgramOptimization;
872 
873     // XML sub-parts
874     VCCLCompilerTool        compiler;
875     VCLinkerTool            linker;
876     VCLibrarianTool         librarian;
877     VCCustomBuildTool       custom;
878     VCMIDLTool              idl;
879     VCPostBuildEventTool    postBuild;
880     VCPreBuildEventTool     preBuild;
881     VCDeploymentTool        deployment;
882     VCPreLinkEventTool      preLink;
883     VCResourceCompilerTool  resource;
884 };
885 
886 struct VCFilterFile
887 {
VCFilterFileVCFilterFile888     VCFilterFile()
889     { excludeFromBuild = false; }
890     VCFilterFile(const QString &filename, bool exclude = false )
891     { file = filename; excludeFromBuild = exclude; }
892     VCFilterFile(const QString &filename, const QString &additional, bool exclude = false )
893     { file = filename; excludeFromBuild = exclude; additionalFile = additional; }
894     bool operator==(const VCFilterFile &other){
895         return file == other.file
896                && additionalFile == other.additionalFile
897                && excludeFromBuild == other.excludeFromBuild;
898     }
899 
900     bool                    excludeFromBuild;
901     QString                 file;
902     QString                 additionalFile; // For tools like MOC
903 };
904 
905 #ifndef QT_NO_DEBUG_OUTPUT
906 inline QDebug operator<<(QDebug dbg, const VCFilterFile &p)
907 {
908     dbg.nospace() << "VCFilterFile(file(" << p.file
909                   << ") additionalFile(" << p.additionalFile
910                   << ") excludeFromBuild(" << p.excludeFromBuild << "))" << endl;
911     return dbg.space();
912 }
913 #endif
914 
915 class VcprojGenerator;
916 class VCFilter
917 {
918 public:
919     // Functions
920     VCFilter();
~VCFilter()921     ~VCFilter(){}
922 
923     void addFile(const QString& filename);
924     void addFile(const VCFilterFile& fileInfo);
925     void addFiles(const QStringList& fileList);
926     bool addExtraCompiler(const VCFilterFile &info);
927     void modifyPCHstage(QString str);
928 
929     // Variables
930     QString                 Name;
931     QString                 Filter;
932     QString                 Guid;
933     triState                ParseFiles;
934     VcprojGenerator*        Project;
935     VCConfiguration*        Config;
936     QList<VCFilterFile>     Files;
937 
938     customBuildCheck	    CustomBuild;
939 
940     bool                    useCustomBuildTool;
941     VCCustomBuildTool       CustomBuildTool;
942 
943     bool                    useCompilerTool;
944     VCCLCompilerTool        CompilerTool;
945 };
946 
947 typedef QList<VCFilter> VCFilterList;
948 class VCProjectSingleConfig
949 {
950 public:
951     enum FilterTypes {
952         None,
953         Source,
954         Header,
955         Generated,
956         LexYacc,
957         Translation,
958         Resources,
959         Extras
960     };
961     // Functions
VCProjectSingleConfig()962     VCProjectSingleConfig(){}
~VCProjectSingleConfig()963     ~VCProjectSingleConfig(){}
964 
965     // Variables
966     QString                 Name;
967     QString                 Version;
968     QString                 ProjectGUID;
969     QString                 Keyword;
970     QString                 SccProjectName;
971     QString                 SccLocalPath;
972     QString                 PlatformName;
973 
974     // XML sub-parts
975     VCConfiguration         Configuration;
976     VCFilter                RootFiles;
977     VCFilter                SourceFiles;
978     VCFilter                HeaderFiles;
979     VCFilter                GeneratedFiles;
980     VCFilter                LexYaccFiles;
981     VCFilter                TranslationFiles;
982     VCFilter                FormFiles;
983     VCFilter                ResourceFiles;
984     VCFilterList            ExtraCompilersFiles;
985 
986     bool                    flat_files;
987 
988     // Accessor for extracompilers
989     VCFilter               &filterForExtraCompiler(const QString &compilerName);
990 };
991 
992 // Tree & Flat view of files --------------------------------------------------
993 class VCFilter;
994 class Node
995 {
996 public:
~Node()997     virtual ~Node() { }
addElement(const VCFilterFile & file)998     void addElement(const VCFilterFile &file) {
999         addElement(file.file, file);
1000     }
1001     virtual void addElement(const QString &filepath, const VCFilterFile &allInfo) = 0;
1002     virtual void removeElements()= 0;
1003     virtual void generateXML(XmlOutput &xml, const QString &tagName, VCProject &tool, const QString &filter) = 0;
1004     virtual bool hasElements() = 0;
1005 };
1006 
1007 class TreeNode : public Node
1008 {
1009     typedef QMap<QString, TreeNode*> ChildrenMap;
1010     VCFilterFile info;
1011     ChildrenMap children;
1012 
1013 public:
~TreeNode()1014     virtual ~TreeNode() { removeElements(); }
1015 
pathIndex(const QString & filepath)1016     int pathIndex(const QString &filepath) {
1017         int Windex = filepath.indexOf("\\");
1018         int Uindex = filepath.indexOf("/");
1019         if (Windex != -1 && Uindex != -1)
1020             return qMin(Windex, Uindex);
1021         else if (Windex != -1)
1022             return Windex;
1023         return Uindex;
1024     }
1025 
addElement(const QString & filepath,const VCFilterFile & allInfo)1026     void addElement(const QString &filepath, const VCFilterFile &allInfo){
1027         QString newNodeName(filepath);
1028 
1029         int index = pathIndex(filepath);
1030         if (index != -1)
1031             newNodeName = filepath.left(index);
1032 
1033         TreeNode *n = children.value(newNodeName);
1034         if (!n) {
1035             n = new TreeNode;
1036             n->info = allInfo;
1037             children.insert(newNodeName, n);
1038         }
1039         if (index != -1)
1040             n->addElement(filepath.mid(index+1), allInfo);
1041     }
1042 
removeElements()1043     void removeElements() {
1044         ChildrenMap::ConstIterator it = children.constBegin();
1045         ChildrenMap::ConstIterator end = children.constEnd();
1046         for( ; it != end; it++) {
1047             (*it)->removeElements();
1048             delete it.value();
1049         }
1050         children.clear();
1051     }
1052 
1053     void generateXML(XmlOutput &xml, const QString &tagName, VCProject &tool, const QString &filter);
hasElements()1054     bool hasElements() {
1055         return children.size() != 0;
1056     }
1057 };
1058 
1059 class FlatNode : public Node
1060 {
1061     typedef QMap<QString, VCFilterFile> ChildrenMapFlat;
1062     ChildrenMapFlat children;
1063 
1064 public:
~FlatNode()1065     virtual ~FlatNode() { removeElements(); }
1066 
pathIndex(const QString & filepath)1067     int pathIndex(const QString &filepath) {
1068         int Windex = filepath.lastIndexOf("\\");
1069         int Uindex = filepath.lastIndexOf("/");
1070         if (Windex != -1 && Uindex != -1)
1071             return qMax(Windex, Uindex);
1072         else if (Windex != -1)
1073             return Windex;
1074         return Uindex;
1075     }
1076 
addElement(const QString & filepath,const VCFilterFile & allInfo)1077     void addElement(const QString &filepath, const VCFilterFile &allInfo){
1078         QString newKey(filepath);
1079 
1080         int index = pathIndex(filepath);
1081         if (index != -1)
1082             newKey = filepath.mid(index+1);
1083 
1084         // Key designed to sort files with same
1085         // name in different paths correctly
1086         children.insert(newKey + "\0" + allInfo.file, allInfo);
1087     }
1088 
removeElements()1089     void removeElements() {
1090         children.clear();
1091     }
1092 
1093     void generateXML(XmlOutput &xml, const QString &tagName, VCProject &proj, const QString &filter);
hasElements()1094     bool hasElements() {
1095         return children.size() != 0;
1096     }
1097 };
1098 // ----------------------------------------------------------------------------
1099 
1100 class VCProject
1101 {
1102 public:
1103     // Variables
1104     QString                 Name;
1105     QString                 Version;
1106     QString                 ProjectGUID;
1107     QString                 Keyword;
1108     QString                 SccProjectName;
1109     QString                 SccLocalPath;
1110     QString                 PlatformName;
1111 
1112     // Single projects
1113     QList<VCProjectSingleConfig>  SingleProjects;
1114 
1115     // List of all extracompilers
1116     QStringList             ExtraCompilers;
1117 };
1118 
1119 class VCProjectWriter
1120 {
1121 public:
~VCProjectWriter()1122     virtual ~VCProjectWriter() {}
1123 
1124     virtual void write(XmlOutput &, VCProjectSingleConfig &);
1125     virtual void write(XmlOutput &, VCProject &);
1126 
1127     virtual void write(XmlOutput &, const VCCLCompilerTool &);
1128     virtual void write(XmlOutput &, const VCLinkerTool &);
1129     virtual void write(XmlOutput &, const VCMIDLTool &);
1130     virtual void write(XmlOutput &, const VCCustomBuildTool &);
1131     virtual void write(XmlOutput &, const VCLibrarianTool &);
1132     virtual void write(XmlOutput &, const VCResourceCompilerTool &);
1133     virtual void write(XmlOutput &, const VCEventTool &);
1134     virtual void write(XmlOutput &, const VCDeploymentTool &);
1135     virtual void write(XmlOutput &, const VCConfiguration &);
1136     virtual void write(XmlOutput &, VCFilter &);
1137 
1138 private:
1139     static void outputFilter(VCProject &project, XmlOutput &xml, const QString &filtername);
1140     static void outputFileConfigs(VCProject &project, XmlOutput &xml, const VCFilterFile &info, const QString &filtername);
1141     static void outputFileConfig(VCFilter &filter, XmlOutput &xml, const QString &filename);
1142 
1143     friend class TreeNode;
1144     friend class FlatNode;
1145 };
1146 
1147 QT_END_NAMESPACE
1148 
1149 #endif // MSVC_OBJECTMODEL_H
1150