Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

msvc_objectmodel.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** 
00003 **
00004 ** Implementation of VCProject class.
00005 **
00006 ** Copyright (C) 2002-2003 Trolltech AS.  All rights reserved.
00007 **
00008 ** This file is part of qmake.
00009 **
00010 ** This file may be distributed under the terms of the Q Public License
00011 ** as defined by Trolltech AS of Norway and appearing in the file
00012 ** LICENSE.QPL included in the packaging of this file.
00013 **
00014 ** This file may be distributed and/or modified under the terms of the
00015 ** GNU General Public License version 2 as published by the Free Software
00016 ** Foundation and appearing in the file LICENSE.GPL included in the
00017 ** packaging of this file.
00018 **
00019 ** Licensees holding valid Qt Enterprise Edition licenses may use this
00020 ** file in accordance with the Qt Commercial License Agreement provided
00021 ** with the Software.
00022 **
00023 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00024 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00025 **
00026 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00027 **   information about Qt Commercial License Agreements.
00028 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00029 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00030 **
00031 ** Contact info@trolltech.com if any conditions of this licensing are
00032 ** not clear to you.
00033 **
00034 **********************************************************************/
00035 
00036 #include "msvc_objectmodel.h"
00037 #include "msvc_vcproj.h"
00038 #include <qtextstream.h>
00039 #include <qstringlist.h>
00040 #include <qfileinfo.h>
00041 
00042 // XML Tags ---------------------------------------------------------
00043 const char* _xmlInit                            = "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>";
00044 const char* _begConfiguration                   = "\n\t\t<Configuration";
00045 const char* _begConfigurations                  = "\n\t<Configurations>";
00046 const char* _begFile                            = "\n\t\t\t<File";
00047 const char* _begFileConfiguration               = "\n\t\t\t\t<FileConfiguration";
00048 const char* _begFiles                           = "\n\t<Files>";
00049 const char* _begFilter                          = "\n\t\t<Filter";
00050 const char* _begGlobals                         = "\n\t<Globals>";
00051 const char* _begPlatform                        = "\n\t\t<Platform";
00052 const char* _begPlatforms                       = "\n\t<Platforms>";
00053 const char* _begTool3                           = "\n\t\t\t<Tool";
00054 const char* _begTool5                           = "\n\t\t\t\t\t<Tool";
00055 const char* _begVisualStudioProject             = "\n<VisualStudioProject";
00056 const char* _endConfiguration                   = "\n\t\t</Configuration>";
00057 const char* _endConfigurations                  = "\n\t</Configurations>";
00058 const char* _endFile                            = "\n\t\t\t</File>";
00059 const char* _endFileConfiguration               = "\n\t\t\t\t</FileConfiguration>";
00060 const char* _endFiles                           = "\n\t</Files>";
00061 const char* _endFilter                          = "\n\t\t</Filter>";
00062 const char* _endGlobals                         = "\n\t</Globals>";
00063 const char* _endPlatforms                       = "\n\t</Platforms>";
00064 const char* _endVisualStudioProject             = "\n</VisualStudioProject>";
00065 
00066 // XML Properties ---------------------------------------------------
00067 const char* _AddModuleNamesToAssembly           = "\n\t\t\t\tAddModuleNamesToAssembly=\"";
00068 const char* _AdditionalDependencies4            = "\n\t\t\t\tAdditionalDependencies=\"";
00069 const char* _AdditionalDependencies6            = "\n\t\t\t\t\t\tAdditionalDependencies=\"";
00070 const char* _AdditionalIncludeDirectories       = "\n\t\t\t\tAdditionalIncludeDirectories=\"";
00071 const char* _AdditionalLibraryDirectories       = "\n\t\t\t\tAdditionalLibraryDirectories=\"";
00072 const char* _AdditionalOptions                  = "\n\t\t\t\tAdditionalOptions=\"";
00073 const char* _AdditionalUsingDirectories         = "\n\t\t\t\tAdditionalUsingDirectories=\"";
00074 const char* _AssemblerListingLocation           = "\n\t\t\t\tAssemblerListingLocation=\"";
00075 const char* _AssemblerOutput                    = "\n\t\t\t\tAssemblerOutput=\"";
00076 const char* _ATLMinimizesCRunTimeLibraryUsage   = "\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"";
00077 const char* _BaseAddress                        = "\n\t\t\t\tBaseAddress=\"";
00078 const char* _BasicRuntimeChecks                 = "\n\t\t\t\tBasicRuntimeChecks=\"";
00079 const char* _BrowseInformation                  = "\n\t\t\t\tBrowseInformation=\"";
00080 const char* _BrowseInformationFile              = "\n\t\t\t\tBrowseInformationFile=\"";
00081 const char* _BufferSecurityCheck                = "\n\t\t\t\tBufferSecurityCheck=\"";
00082 const char* _BuildBrowserInformation            = "\n\t\t\tBuildBrowserInformation=\"";
00083 const char* _CPreprocessOptions                 = "\n\t\t\t\tCPreprocessOptions=\"";
00084 const char* _CallingConvention                  = "\n\t\t\t\tCallingConvention=\"";
00085 const char* _CharacterSet                       = "\n\t\t\tCharacterSet=\"";
00086 const char* _CommandLine4                       = "\n\t\t\t\tCommandLine=\"";
00087 const char* _CommandLine6                       = "\n\t\t\t\t\t\tCommandLine=\"";
00088 const char* _CompileAs                          = "\n\t\t\t\tCompileAs=\"";
00089 const char* _CompileAsManaged                   = "\n\t\t\t\tCompileAsManaged=\"";
00090 const char* _CompileOnly                        = "\n\t\t\t\tCompileOnly=\"";
00091 const char* _ConfigurationType                  = "\n\t\t\tConfigurationType=\"";
00092 const char* _Culture                            = "\n\t\t\t\tCulture=\"";
00093 const char* _DLLDataFileName                    = "\n\t\t\t\tDLLDataFileName=\"";
00094 const char* _DebugInformationFormat             = "\n\t\t\t\tDebugInformationFormat=\"";
00095 const char* _DefaultCharIsUnsigned              = "\n\t\t\t\tDefaultCharIsUnsigned=\"";
00096 const char* _DefaultCharType                    = "\n\t\t\t\tDefaultCharType=\"";
00097 const char* _DelayLoadDLLs                      = "\n\t\t\t\tDelayLoadDLLs=\"";
00098 const char* _DeleteExtensionsOnClean            = "\n\t\t\tDeleteExtensionsOnClean=\"";
00099 const char* _Description4                       = "\n\t\t\t\tDescription=\"";
00100 const char* _Description6                       = "\n\t\t\t\t\t\tDescription=\"";
00101 const char* _Detect64BitPortabilityProblems     = "\n\t\t\t\tDetect64BitPortabilityProblems=\"";
00102 const char* _DisableLanguageExtensions          = "\n\t\t\t\tDisableLanguageExtensions=\"";
00103 const char* _DisableSpecificWarnings            = "\n\t\t\t\tDisableSpecificWarnings=\"";
00104 const char* _EnableCOMDATFolding                = "\n\t\t\t\tEnableCOMDATFolding=\"";
00105 const char* _EnableErrorChecks                  = "\n\t\t\t\tEnableErrorChecks=\"";
00106 const char* _EnableFiberSafeOptimizations       = "\n\t\t\t\tEnableFiberSafeOptimizations=\"";
00107 const char* _EnableFunctionLevelLinking         = "\n\t\t\t\tEnableFunctionLevelLinking=\"";
00108 const char* _EnableIntrinsicFunctions           = "\n\t\t\t\tEnableIntrinsicFunctions=\"";
00109 const char* _EntryPointSymbol                   = "\n\t\t\t\tEntryPointSymbol=\"";
00110 const char* _ErrorCheckAllocations              = "\n\t\t\t\tErrorCheckAllocations=\"";
00111 const char* _ErrorCheckBounds                   = "\n\t\t\t\tErrorCheckBounds=\"";
00112 const char* _ErrorCheckEnumRange                = "\n\t\t\t\tErrorCheckEnumRange=\"";
00113 const char* _ErrorCheckRefPointers              = "\n\t\t\t\tErrorCheckRefPointers=\"";
00114 const char* _ErrorCheckStubData                 = "\n\t\t\t\tErrorCheckStubData=\"";
00115 const char* _ExceptionHandling                  = "\n\t\t\t\tExceptionHandling=\"";
00116 const char* _ExcludedFromBuild                  = "\n\t\t\t\tExcludedFromBuild=\"";
00117 const char* _ExpandAttributedSource             = "\n\t\t\t\tExpandAttributedSource=\"";
00118 const char* _ExportNamedFunctions               = "\n\t\t\t\tExportNamedFunctions=\"";
00119 const char* _FavorSizeOrSpeed                   = "\n\t\t\t\tFavorSizeOrSpeed=\"";
00120 const char* _Filter                             = "\n\t\t\tFilter=\"";
00121 const char* _ForceConformanceInForLoopScope     = "\n\t\t\t\tForceConformanceInForLoopScope=\"";
00122 const char* _ForceSymbolReferences              = "\n\t\t\t\tForceSymbolReferences=\"";
00123 const char* _ForcedIncludeFiles                 = "\n\t\t\t\tForcedIncludeFiles=\"";
00124 const char* _ForcedUsingFiles                   = "\n\t\t\t\tForcedUsingFiles=\"";
00125 const char* _FullIncludePath                    = "\n\t\t\t\tFullIncludePath=\"";
00126 const char* _FunctionOrder                      = "\n\t\t\t\tFunctionOrder=\"";
00127 const char* _GenerateDebugInformation           = "\n\t\t\t\tGenerateDebugInformation=\"";
00128 const char* _GenerateMapFile                    = "\n\t\t\t\tGenerateMapFile=\"";
00129 const char* _GeneratePreprocessedFile           = "\n\t\t\t\tGeneratePreprocessedFile=\"";
00130 const char* _GenerateStublessProxies            = "\n\t\t\t\tGenerateStublessProxies=\"";
00131 const char* _GenerateTypeLibrary                = "\n\t\t\t\tGenerateTypeLibrary=\"";
00132 const char* _GlobalOptimizations                = "\n\t\t\t\tGlobalOptimizations=\"";
00133 const char* _HeaderFileName                     = "\n\t\t\t\tHeaderFileName=\"";
00134 const char* _HeapCommitSize                     = "\n\t\t\t\tHeapCommitSize=\"";
00135 const char* _HeapReserveSize                    = "\n\t\t\t\tHeapReserveSize=\"";
00136 const char* _IgnoreAllDefaultLibraries          = "\n\t\t\t\tIgnoreAllDefaultLibraries=\"";
00137 const char* _IgnoreDefaultLibraryNames          = "\n\t\t\t\tIgnoreDefaultLibraryNames=\"";
00138 const char* _IgnoreEmbeddedIDL                  = "\n\t\t\t\tIgnoreEmbeddedIDL=\"";
00139 const char* _IgnoreImportLibrary                = "\n\t\t\t\tIgnoreImportLibrary=\"";
00140 const char* _IgnoreStandardIncludePath          = "\n\t\t\t\tIgnoreStandardIncludePath=\"";
00141 const char* _ImportLibrary                      = "\n\t\t\t\tImportLibrary=\"";
00142 const char* _ImproveFloatingPointConsistency    = "\n\t\t\t\tImproveFloatingPointConsistency=\"";
00143 const char* _InlineFunctionExpansion            = "\n\t\t\t\tInlineFunctionExpansion=\"";
00144 const char* _InterfaceIdentifierFileName        = "\n\t\t\t\tInterfaceIdentifierFileName=\"";
00145 const char* _IntermediateDirectory              = "\n\t\t\tIntermediateDirectory=\"";
00146 const char* _KeepComments                       = "\n\t\t\t\tKeepComments=\"";
00147 const char* _LargeAddressAware                  = "\n\t\t\t\tLargeAddressAware=\"";
00148 const char* _LinkDLL                            = "\n\t\t\t\tLinkDLL=\"";
00149 const char* _LinkIncremental                    = "\n\t\t\t\tLinkIncremental=\"";
00150 const char* _LinkTimeCodeGeneration             = "\n\t\t\t\tLinkTimeCodeGeneration=\"";
00151 const char* _LinkToManagedResourceFile          = "\n\t\t\t\tLinkToManagedResourceFile=\"";
00152 const char* _MapExports                         = "\n\t\t\t\tMapExports=\"";
00153 const char* _MapFileName                        = "\n\t\t\t\tMapFileName=\"";
00154 const char* _MapLines                           = "\n\t\t\t\tMapLines =\"";
00155 const char* _MergeSections                      = "\n\t\t\t\tMergeSections=\"";
00156 const char* _MergedIDLBaseFileName              = "\n\t\t\t\tMergedIDLBaseFileName=\"";
00157 const char* _MidlCommandFile                    = "\n\t\t\t\tMidlCommandFile=\"";
00158 const char* _MinimalRebuild                     = "\n\t\t\t\tMinimalRebuild=\"";
00159 const char* _MkTypLibCompatible                 = "\n\t\t\t\tMkTypLibCompatible=\"";
00160 const char* _ModuleDefinitionFile               = "\n\t\t\t\tModuleDefinitionFile=\"";
00161 const char* _Name1                              = "\n\tName=\"";
00162 const char* _Name2                              = "\n\t\tName=\"";
00163 const char* _Name3                              = "\n\t\t\tName=\"";
00164 const char* _Name4                              = "\n\t\t\t\tName=\"";
00165 const char* _Name5                              = "\n\t\t\t\t\tName=\"";
00166 const char* _ObjectFile                         = "\n\t\t\t\tObjectFile=\"";
00167 const char* _OmitFramePointers                  = "\n\t\t\t\tOmitFramePointers=\"";
00168 const char* _Optimization                       = "\n\t\t\t\tOptimization =\"";
00169 const char* _OptimizeForProcessor               = "\n\t\t\t\tOptimizeForProcessor=\"";
00170 const char* _OptimizeForWindows98               = "\n\t\t\t\tOptimizeForWindows98=\"";
00171 const char* _OptimizeForWindowsApplication      = "\n\t\t\t\tOptimizeForWindowsApplication=\"";
00172 const char* _OptimizeReferences                 = "\n\t\t\t\tOptimizeReferences=\"";
00173 const char* _OutputDirectory3                   = "\n\t\t\tOutputDirectory=\"";
00174 const char* _OutputDirectory4                   = "\n\t\t\t\tOutputDirectory=\"";
00175 const char* _OutputFile                         = "\n\t\t\t\tOutputFile=\"";
00176 const char* _Outputs4                           = "\n\t\t\t\tOutputs=\"";
00177 const char* _Outputs6                           = "\n\t\t\t\t\t\tOutputs=\"";
00178 const char* _ParseFiles                         = "\n\t\t\tParseFiles=\"";
00179 const char* _PrecompiledHeaderFile              = "\n\t\t\t\tPrecompiledHeaderFile=\"";
00180 const char* _PrecompiledHeaderThrough           = "\n\t\t\t\tPrecompiledHeaderThrough=\"";
00181 const char* _PreprocessorDefinitions            = "\n\t\t\t\tPreprocessorDefinitions=\"";
00182 const char* _PrimaryOutput                      = "\n\t\t\tPrimaryOutput=\"";
00183 const char* _ProjectGUID                        = "\n\tProjectGUID=\"";
00184 const char* _ProjectType                        = "\n\tProjectType=\"Visual C++\"";
00185 const char* _ProgramDatabase                    = "\n\t\t\tProgramDatabase=\"";
00186 const char* _ProgramDataBaseFileName            = "\n\t\t\t\tProgramDataBaseFileName=\"";
00187 const char* _ProgramDatabaseFile                = "\n\t\t\t\tProgramDatabaseFile=\"";
00188 const char* _ProxyFileName                      = "\n\t\t\t\tProxyFileName=\"";
00189 const char* _RedirectOutputAndErrors            = "\n\t\t\t\tRedirectOutputAndErrors=\"";
00190 const char* _RegisterOutput                     = "\n\t\t\t\tRegisterOutput=\"";
00191 const char* _RelativePath                       = "\n\t\t\t\tRelativePath=\"";
00192 const char* _ResourceOnlyDLL                    = "\n\t\t\t\tResourceOnlyDLL=\"";
00193 const char* _ResourceOutputFileName             = "\n\t\t\t\tResourceOutputFileName=\"";
00194 const char* _RuntimeLibrary                     = "\n\t\t\t\tRuntimeLibrary=\"";
00195 const char* _RuntimeTypeInfo                    = "\n\t\t\t\tRuntimeTypeInfo=\"";
00196 const char* _SccProjectName                     = "\n\tSccProjectName=\"";
00197 const char* _SccLocalPath                       = "\n\tSccLocalPath=\"";
00198 const char* _SetChecksum                        = "\n\t\t\t\tSetChecksum=\"";
00199 const char* _ShowIncludes                       = "\n\t\t\t\tShowIncludes=\"";
00200 const char* _ShowProgress                       = "\n\t\t\t\tShowProgress=\"";
00201 const char* _SmallerTypeCheck                   = "\n\t\t\t\tSmallerTypeCheck=\"";
00202 const char* _StackCommitSize                    = "\n\t\t\t\tStackCommitSize=\"";
00203 const char* _StackReserveSize                   = "\n\t\t\t\tStackReserveSize=\"";
00204 const char* _StringPooling                      = "\n\t\t\t\tStringPooling=\"";
00205 const char* _StripPrivateSymbols                = "\n\t\t\t\tStripPrivateSymbols=\"";
00206 const char* _StructMemberAlignment              = "\n\t\t\t\tStructMemberAlignment=\"";
00207 const char* _SubSystem                          = "\n\t\t\t\tSubSystem=\"";
00208 const char* _SupportUnloadOfDelayLoadedDLL      = "\n\t\t\t\tSupportUnloadOfDelayLoadedDLL=\"";
00209 const char* _SuppressStartupBanner              = "\n\t\t\t\tSuppressStartupBanner=\"";
00210 const char* _SwapRunFromCD                      = "\n\t\t\t\tSwapRunFromCD=\"";
00211 const char* _SwapRunFromNet                     = "\n\t\t\t\tSwapRunFromNet=\"";
00212 const char* _TargetEnvironment                  = "\n\t\t\t\tTargetEnvironment=\"";
00213 const char* _TargetMachine                      = "\n\t\t\t\tTargetMachine=\"";
00214 const char* _TerminalServerAware                = "\n\t\t\t\tTerminalServerAware=\"";
00215 const char* _ToolName                           = "\n\t\t\t\tName=\"";
00216 const char* _ToolPath                           = "\n\t\t\t\tPath=\"";
00217 const char* _TreatWChar_tAsBuiltInType          = "\n\t\t\t\tTreatWChar_tAsBuiltInType=\"";
00218 const char* _TurnOffAssemblyGeneration          = "\n\t\t\t\tTurnOffAssemblyGeneration=\"";
00219 const char* _TypeLibraryFile                    = "\n\t\t\t\tTypeLibraryFile=\"";
00220 const char* _TypeLibraryName                    = "\n\t\t\t\tTypeLibraryName=\"";
00221 const char* _TypeLibraryResourceID              = "\n\t\t\t\tTypeLibraryResourceID=\"";
00222 const char* _UndefineAllPreprocessorDefinitions = "\n\t\t\t\tUndefineAllPreprocessorDefinitions=\"";
00223 const char* _UndefinePreprocessorDefinitions    = "\n\t\t\t\tUndefinePreprocessorDefinitions=\"";
00224 const char* _UseOfATL                           = "\n\t\t\tUseOfATL=\"";
00225 const char* _UseOfMfc                           = "\n\t\t\tUseOfMfc=\"";
00226 const char* _UsePrecompiledHeader               = "\n\t\t\t\tUsePrecompiledHeader=\"";
00227 const char* _ValidateParameters                 = "\n\t\t\t\tValidateParameters=\"";
00228 const char* _VCCLCompilerToolName               = "\n\t\t\t\tName=\"VCCLCompilerTool\"";
00229 const char* _VCCustomBuildTool                  = "\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"";
00230 const char* _VCLinkerToolName                   = "\n\t\t\t\tName=\"VCLinkerTool\"";
00231 const char* _VCResourceCompilerToolName         = "\n\t\t\t\tName=\"VCResourceCompilerTool\"";
00232 const char* _VCMIDLToolName                     = "\n\t\t\t\tName=\"VCMIDLTool\"";
00233 const char* _Version1                           = "\n\tVersion=\"";
00234 const char* _Version4                           = "\n\t\t\t\tVersion=\"";
00235 const char* _WarnAsError                        = "\n\t\t\t\tWarnAsError=\"";
00236 const char* _WarnLevel                          = "\n\t\t\t\tWarnLevel=\"";
00237 const char* _WarningLevel                       = "\n\t\t\t\tWarningLevel=\"";
00238 const char* _WholeProgramOptimization           = "\n\t\t\t\tWholeProgramOptimization=\"";
00239 
00240 // Property name and value as Pairs ---------------------------------
00241 struct TPair {
00242     TPair( const char* n, const triState v ) : name(n), value(v) {};
00243     const char* name;
00244     const triState value;
00245 };
00246 struct EPair {
00247     EPair( const char* n, const int v ) : name(n), value(v) {};
00248     const char* name;
00249     const int value;
00250 };
00251 struct LPair {
00252     LPair( const char* n, const long v ) : name(n), value(v) {};
00253     const char* name;
00254     const long value;
00255 };
00256 struct SPair {
00257     SPair( const char* n, const QString& v ) : name(n), value(v) {};
00258     const char* name;
00259     const QString& value;
00260 };
00261 struct XPair {
00262     XPair( const char* n, const QStringList& v, const char* s = "," ) : name(n), value(v), sep(s) {};
00263     const char* name;
00264     const QStringList& value;
00265     const char* sep;
00266 };
00267 
00268 // void streamSPair( QTextStream &strm, const char *n, const QString &s )
00269 
00270 // Streaming operators for property Pairs ---------------------------
00271 QTextStream &operator<<( QTextStream &strm, const TPair &prop )
00272 {
00273     switch( prop.value ) {
00274     case _False:
00275         strm << prop.name << "FALSE\"";
00276         break;
00277     case _True:
00278         strm << prop.name << "TRUE\"";
00279         break;
00280     case unset:
00281     default:
00282         break;
00283     }
00284     return strm;
00285 }
00286 
00287 /* Be sure to check that each enum is not set to
00288    default before streaming it out. Defaults seem
00289    to not be in the XML file.
00290 */
00291 QTextStream &operator<<( QTextStream &strm, const EPair &prop )
00292 {
00293     strm << prop.name << prop.value << "\"";
00294     return strm;
00295 }
00296 
00297 QTextStream &operator<<( QTextStream &strm, const LPair &prop )
00298 {
00299     strm << prop.name << prop.value << "\"";
00300     return strm;
00301 }
00302 
00303 QTextStream &operator<<( QTextStream &strm, const SPair &prop )
00304 {
00305     if ( !prop.value.isEmpty() )
00306         strm << prop.name << QString(prop.value).remove("\"") << "\"";
00307     return strm;
00308 }
00309 
00310 QTextStream &operator<<( QTextStream &strm, const XPair &prop )
00311 {
00312     if ( !prop.value.isEmpty() )
00313         strm << prop.name << prop.value.join(prop.sep).latin1() << "\"";
00314     return strm;
00315 }
00316 
00317 // VCCLCompilerTool -------------------------------------------------
00318 VCCLCompilerTool::VCCLCompilerTool()
00319     :   AssemblerOutput( asmListingNone ),
00320         BasicRuntimeChecks( runtimeBasicCheckNone ),
00321         BrowseInformation( brInfoNone ),
00322         BufferSecurityCheck( _False ),
00323         CallingConvention( callConventionDefault ),
00324         CompileAs( compileAsDefault ),
00325         CompileAsManaged( managedDefault ),
00326         CompileOnly( unset ),
00327         DebugInformationFormat( debugDisabled ),
00328         DefaultCharIsUnsigned( unset ),
00329         Detect64BitPortabilityProblems( unset ),
00330         DisableLanguageExtensions( unset ),
00331         EnableFiberSafeOptimizations( unset ),
00332         EnableFunctionLevelLinking( unset ),
00333         EnableIntrinsicFunctions( unset ),
00334         ExceptionHandling( _False ),
00335         ExpandAttributedSource( unset ),
00336         FavorSizeOrSpeed( favorNone ),
00337         ForceConformanceInForLoopScope( unset ),
00338         GeneratePreprocessedFile( preprocessNo ),
00339         GlobalOptimizations( unset ),
00340         IgnoreStandardIncludePath( unset ),
00341         ImproveFloatingPointConsistency( unset ),
00342         InlineFunctionExpansion( expandDefault ),
00343         KeepComments( unset ),
00344         MinimalRebuild( unset ),
00345         OmitFramePointers( unset ),
00346         Optimization( optimizeCustom ),
00347         OptimizeForProcessor( procOptimizeBlended ),
00348         OptimizeForWindowsApplication( unset ),
00349         ProgramDataBaseFileName( "" ),
00350         RuntimeLibrary( rtMultiThreaded ),
00351         RuntimeTypeInfo( unset ),
00352         ShowIncludes( unset ),
00353         SmallerTypeCheck( unset ),
00354         StringPooling( unset ),
00355         StructMemberAlignment( alignNotSet ),
00356         SuppressStartupBanner( unset ),
00357         TreatWChar_tAsBuiltInType( unset ),
00358         TurnOffAssemblyGeneration( unset ),
00359         UndefineAllPreprocessorDefinitions( unset ),
00360         UsePrecompiledHeader( pchNone ),
00361         WarnAsError( unset ),
00362         WarningLevel( warningLevel_0 ),
00363         WholeProgramOptimization( unset )
00364 {
00365 }
00366 
00367 QTextStream &operator<<( QTextStream &strm, const VCCLCompilerTool &tool )
00368 {
00369     strm << _begTool3;
00370     strm << _VCCLCompilerToolName;
00371     strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories );
00372     strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " );
00373     strm << XPair( _AdditionalUsingDirectories, tool.AdditionalUsingDirectories );
00374     strm << SPair( _AssemblerListingLocation, tool.AssemblerListingLocation );
00375     if ( tool.AssemblerOutput != asmListingNone )           strm << EPair( _AssemblerOutput, tool.AssemblerOutput );
00376     if ( tool.BasicRuntimeChecks != runtimeBasicCheckNone ) strm << EPair( _BasicRuntimeChecks, tool.BasicRuntimeChecks );
00377     if ( tool.BrowseInformation != brInfoNone )             strm << EPair( _BrowseInformation, tool.BrowseInformation );
00378     strm << SPair( _BrowseInformationFile, tool.BrowseInformationFile );
00379     strm << TPair( _BufferSecurityCheck, tool.BufferSecurityCheck );
00380     if ( tool.CallingConvention != callConventionDefault )  strm << EPair( _CallingConvention, tool.CallingConvention );
00381     if ( tool.CompileAs != compileAsDefault )               strm << EPair( _CompileAs, tool.CompileAs );
00382     if ( tool.CompileAsManaged != managedDefault )          strm << EPair( _CompileAsManaged, tool.CompileAsManaged );
00383     strm << TPair( _CompileOnly, tool.CompileOnly );
00384     if ( tool.DebugInformationFormat != debugUnknown )      strm << EPair( _DebugInformationFormat, tool.DebugInformationFormat );
00385     strm << TPair( _DefaultCharIsUnsigned, tool.DefaultCharIsUnsigned );
00386     strm << TPair( _Detect64BitPortabilityProblems, tool.Detect64BitPortabilityProblems );
00387     strm << TPair( _DisableLanguageExtensions, tool.DisableLanguageExtensions );
00388     strm << XPair( _DisableSpecificWarnings, tool.DisableSpecificWarnings );
00389     strm << TPair( _EnableFiberSafeOptimizations, tool.EnableFiberSafeOptimizations );
00390     strm << TPair( _EnableFunctionLevelLinking, tool.EnableFunctionLevelLinking );
00391     strm << TPair( _EnableIntrinsicFunctions, tool.EnableIntrinsicFunctions );
00392     strm << TPair( _ExceptionHandling, tool.ExceptionHandling );
00393     strm << TPair( _ExpandAttributedSource, tool.ExpandAttributedSource );
00394     if ( tool.FavorSizeOrSpeed != favorNone )               strm << EPair( _FavorSizeOrSpeed, tool.FavorSizeOrSpeed );
00395     strm << TPair( _ForceConformanceInForLoopScope, tool.ForceConformanceInForLoopScope );
00396     strm << XPair( _ForcedIncludeFiles, tool.ForcedIncludeFiles );
00397     strm << XPair( _ForcedUsingFiles, tool.ForcedUsingFiles );
00398     if ( tool.GeneratePreprocessedFile != preprocessUnknown)strm << EPair( _GeneratePreprocessedFile, tool.GeneratePreprocessedFile );
00399     strm << TPair( _GlobalOptimizations, tool.GlobalOptimizations );
00400     strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath );
00401     strm << TPair( _ImproveFloatingPointConsistency, tool.ImproveFloatingPointConsistency );
00402     if ( tool.InlineFunctionExpansion != expandDefault ) strm << EPair( _InlineFunctionExpansion, tool.InlineFunctionExpansion );
00403     strm << TPair( _KeepComments, tool.KeepComments );
00404     strm << TPair( _MinimalRebuild, tool.MinimalRebuild );
00405     strm << SPair( _ObjectFile, tool.ObjectFile );
00406     strm << TPair( _OmitFramePointers, tool.OmitFramePointers );
00407     if ( tool.Optimization != optimizeDefault ) strm << EPair( _Optimization, tool.Optimization );
00408     if ( tool.OptimizeForProcessor != procOptimizeBlended ) strm << EPair( _OptimizeForProcessor, tool.OptimizeForProcessor );
00409     strm << TPair( _OptimizeForWindowsApplication, tool.OptimizeForWindowsApplication );
00410     strm << SPair( _OutputFile, tool.OutputFile );
00411     strm << SPair( _PrecompiledHeaderFile, tool.PrecompiledHeaderFile );
00412     strm << SPair( _PrecompiledHeaderThrough, tool.PrecompiledHeaderThrough );
00413     strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions );
00414     if ( !tool.ProgramDataBaseFileName.isNull() ) strm << _ProgramDataBaseFileName << tool.ProgramDataBaseFileName.latin1() << "\"";
00415     if ( tool.RuntimeLibrary != rtUnknown ) strm << EPair( _RuntimeLibrary, tool.RuntimeLibrary );
00416     strm << TPair( _RuntimeTypeInfo, tool.RuntimeTypeInfo );
00417     strm << TPair( _ShowIncludes, tool.ShowIncludes );
00418     strm << TPair( _SmallerTypeCheck, tool.SmallerTypeCheck );
00419     strm << TPair( _StringPooling, tool.StringPooling );
00420     if ( tool.StructMemberAlignment != alignNotSet )        strm << EPair( _StructMemberAlignment, tool.StructMemberAlignment );
00421     strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
00422     strm << TPair( _TreatWChar_tAsBuiltInType, tool.TreatWChar_tAsBuiltInType );
00423     strm << TPair( _TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration );
00424     strm << TPair( _UndefineAllPreprocessorDefinitions, tool.UndefineAllPreprocessorDefinitions );
00425     strm << XPair( _UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions );
00426     if ( !tool.PrecompiledHeaderFile.isEmpty() ||
00427          !tool.PrecompiledHeaderThrough.isEmpty() )
00428         strm << EPair( _UsePrecompiledHeader, tool.UsePrecompiledHeader );
00429     strm << TPair( _WarnAsError, tool.WarnAsError );
00430     if ( tool.WarningLevel != warningLevelUnknown ) strm << EPair( _WarningLevel, tool.WarningLevel );
00431     strm << TPair( _WholeProgramOptimization, tool.WholeProgramOptimization );
00432     strm << "/>";
00433 return strm;
00434 }
00435 
00436 bool VCCLCompilerTool::parseOption( const char* option )
00437 {
00438     // skip index 0 ('/' or '-')
00439     char first  = option[1];
00440     char second = option[2];
00441     char third  = option[3];
00442     char fourth = option[4];
00443     bool found = TRUE;
00444 
00445     switch ( first ) {
00446     case '?':
00447     case 'h':
00448         qWarning( "Generator: Option '/?', '/help': MSVC.NET projects do not support outputting help info" );
00449         found = FALSE;
00450         break;
00451     case '@':
00452         qWarning( "Generator: Option '/@': MSVC.NET projects do not support the use of a response file" );
00453         found = FALSE;
00454         break;
00455     case 'l':
00456         qWarning( "Generator: Option '/link': qmake generator does not support passing link options through the compiler tool" );
00457         found = FALSE;
00458         break;
00459     case 'A':
00460         if ( second != 'I' ) {
00461             found = FALSE; break;
00462         }
00463         AdditionalUsingDirectories += option+3;
00464         break;
00465     case 'C':
00466         KeepComments = _True;
00467         break;
00468     case 'D':
00469         PreprocessorDefinitions += option+2;
00470         break;
00471     case 'E':
00472         if ( second == 'H' ) {
00473             if ( third == 'a'
00474                 || (third == 'c' && fourth != 's')
00475                 || (third == 's' && fourth != 'c') ) {
00476                 // ExceptionHandling must be false, or it will override
00477                 // with an /EHsc option
00478                 ExceptionHandling = _False;
00479                 AdditionalOptions += option;
00480                 break;
00481             } else if ( (third == 'c' && fourth == 's')
00482                      || (third == 's' && fourth == 'c') ) {
00483                 ExceptionHandling = _True;
00484                 AdditionalOptions += option;
00485                 break;
00486             }
00487             found = FALSE; break;
00488         }
00489         GeneratePreprocessedFile = preprocessYes;
00490         break;
00491     case 'F':
00492         if ( second <= '9' && second >= '0' ) {
00493             AdditionalOptions += option;
00494             break;
00495         } else {
00496             switch ( second ) {
00497             case 'A':
00498                 if ( third == 'c' ) {
00499                     AssemblerOutput = asmListingAsmMachine;
00500                     if ( fourth == 's' )
00501                         AssemblerOutput = asmListingAsmMachineSrc;
00502                 } else if ( third == 's' ) {
00503                     AssemblerOutput = asmListingAsmSrc;
00504                 } else {
00505                     AssemblerOutput = asmListingAssemblyOnly;
00506                 }
00507                 break;
00508             case 'a':
00509                 AssemblerListingLocation = option+3;
00510                 break;
00511             case 'I':
00512                 ForcedIncludeFiles += option+3;
00513                 break;
00514             case 'R':
00515                 BrowseInformation = brAllInfo;
00516                 BrowseInformationFile = option+3;
00517                 break;
00518             case 'r':
00519                 BrowseInformation = brNoLocalSymbols;
00520                 BrowseInformationFile = option+3;
00521                 break;
00522             case 'U':
00523                 ForcedUsingFiles += option+3;
00524                 break;
00525             case 'd':
00526                 ProgramDataBaseFileName = option+3;
00527                 break;
00528             case 'e':
00529                 OutputFile = option+3;
00530                 break;
00531             case 'm':
00532                 AdditionalOptions += option;
00533                 break;
00534             case 'o':
00535                 ObjectFile = option+3;
00536                 break;
00537             case 'p':
00538                 PrecompiledHeaderFile = option+3;
00539                 break;
00540             case 'x':
00541                 ExpandAttributedSource = _True;
00542                 break;
00543             default:
00544                 found = FALSE; break;
00545             }
00546         }
00547         break;
00548     case 'G':
00549         switch ( second ) {
00550         case '3':
00551         case '4':
00552             qWarning( "Option '/G3' and '/G4' were phased out in Visual C++ 5.0" );
00553             found = FALSE; break;
00554         case '5':
00555             OptimizeForProcessor = procOptimizePentium;
00556             break;
00557         case '6':
00558         case 'B':
00559             OptimizeForProcessor = procOptimizePentiumProAndAbove;
00560             break;
00561         case 'A':
00562             OptimizeForWindowsApplication = _True;
00563             break;
00564         case 'F':
00565             StringPooling = _True;
00566             break;
00567         case 'H':
00568             AdditionalOptions += option;
00569             break;
00570         case 'L':
00571             WholeProgramOptimization = _True;
00572             if ( third == '-' )
00573                 WholeProgramOptimization = _False;
00574             break;
00575         case 'R':
00576             RuntimeTypeInfo = _True;
00577             if ( third == '-' )
00578                 RuntimeTypeInfo = _False;
00579             break;
00580         case 'S':
00581             BufferSecurityCheck = _True;
00582             break;
00583         case 'T':
00584             EnableFiberSafeOptimizations = _True;
00585             break;
00586         case 'X':
00587             // ExceptionHandling == true will override with
00588             // an /EHsc option, which is correct with /GX
00589             ExceptionHandling = _True; // Fall-through
00590         case 'Z':
00591         case 'e':
00592         case 'h':
00593             AdditionalOptions += option;
00594             break;
00595         case 'd':
00596             CallingConvention = callConventionCDecl;
00597             break;
00598         case 'f':
00599             StringPooling = _True;
00600             AdditionalOptions += option;
00601             break;
00602         case 'm':
00603             MinimalRebuild = _True;
00604             if ( third == '-' )
00605                 MinimalRebuild = _False;
00606             break;
00607         case 'r':
00608             CallingConvention = callConventionFastCall;
00609             break;
00610         case 's':
00611             // Warning: following [num] is not used,
00612             // were should we put it?
00613             BufferSecurityCheck = _True;
00614             break;
00615         case 'y':
00616             EnableFunctionLevelLinking = _True;
00617             break;
00618         case 'z':
00619             CallingConvention = callConventionStdCall;
00620             break;
00621         default:
00622             found = FALSE; break;
00623         }
00624         break;
00625     case 'H':
00626         AdditionalOptions += option;
00627         break;
00628     case 'I':
00629         AdditionalIncludeDirectories += option+2;
00630         break;
00631     case 'L':
00632         if ( second == 'D' ) {
00633             AdditionalOptions += option;
00634             break;
00635         }
00636         found = FALSE; break;
00637     case 'M':
00638         if ( second == 'D' ) {
00639             RuntimeLibrary = rtMultiThreadedDLL;
00640             if ( third == 'd' )
00641                 RuntimeLibrary = rtMultiThreadedDebugDLL;
00642             break;
00643         } else if ( second == 'L' ) {
00644             RuntimeLibrary = rtSingleThreaded;
00645             if ( third == 'd' )
00646                 RuntimeLibrary = rtSingleThreadedDebug;
00647             break;
00648         } else if ( second == 'T' ) {
00649             RuntimeLibrary = rtMultiThreaded;
00650             if ( third == 'd' )
00651                 RuntimeLibrary = rtMultiThreadedDebug;
00652             break;
00653         }
00654         found = FALSE; break;
00655     case 'O':
00656         switch ( second ) {
00657         case '1':
00658             Optimization = optimizeMinSpace;
00659             break;
00660         case '2':
00661             Optimization = optimizeMaxSpeed;
00662             break;
00663         case 'a':
00664             AdditionalOptions += option;
00665             break;
00666         case 'b':
00667             if ( third == '0' )
00668                 InlineFunctionExpansion = expandDisable;
00669             else if ( third == '1' )
00670                 InlineFunctionExpansion = expandOnlyInline;
00671             else if ( third == '2' )
00672                 InlineFunctionExpansion = expandAnySuitable;
00673             else
00674                 found = FALSE;
00675             break;
00676         case 'd':
00677             Optimization = optimizeDisabled;
00678             break;
00679         case 'g':
00680             GlobalOptimizations = _True;
00681             break;
00682         case 'i':
00683             EnableIntrinsicFunctions = _True;
00684             break;
00685         case 'p':
00686             ImproveFloatingPointConsistency = _True;
00687             if ( third == '-' )
00688                 ImproveFloatingPointConsistency = _False;
00689             break;
00690         case 's':
00691             FavorSizeOrSpeed = favorSize;
00692             break;
00693         case 't':
00694             FavorSizeOrSpeed = favorSpeed;
00695             break;
00696         case 'w':
00697             AdditionalOptions += option;
00698             break;
00699         case 'x':
00700             Optimization = optimizeFull;
00701             break;
00702         case 'y':
00703             OmitFramePointers = _True;
00704             if ( third == '-' )
00705                 OmitFramePointers = _False;
00706             break;
00707         default:
00708             found = FALSE; break;
00709         }
00710         break;
00711     case 'P':
00712         GeneratePreprocessedFile = preprocessYes;
00713         break;
00714     case 'Q':
00715         if ( second == 'I' ) {
00716             AdditionalOptions += option;
00717             break;
00718         }
00719         found = FALSE; break;
00720     case 'R':
00721         if ( second == 'T' && third == 'C' ) {
00722             if ( fourth == '1' )
00723                 BasicRuntimeChecks = runtimeBasicCheckAll;
00724             else if ( fourth == 'c' )
00725                 SmallerTypeCheck = _True;
00726             else if ( fourth == 's' )
00727                 BasicRuntimeChecks = runtimeCheckStackFrame;
00728             else if ( fourth == 'u' )
00729                 BasicRuntimeChecks = runtimeCheckUninitVariables;
00730             else
00731                 found = FALSE; break;
00732         }
00733         break;
00734     case 'T':
00735         if ( second == 'C' ) {
00736             CompileAs = compileAsC;
00737         } else if ( second == 'P' ) {
00738             CompileAs = compileAsCPlusPlus;
00739         } else {
00740             qWarning( "Generator: Options '/Tp<filename>' and '/Tc<filename>' are not supported by qmake" );
00741             found = FALSE; break;
00742         }
00743         break;
00744     case 'U':
00745         UndefinePreprocessorDefinitions += option+2;
00746         break;
00747     case 'V':
00748         AdditionalOptions += option;
00749         break;
00750     case 'W':
00751         switch ( second ) {
00752         case 'a':
00753         case '4':
00754             WarningLevel = warningLevel_4;
00755             break;
00756         case '3':
00757             WarningLevel = warningLevel_3;
00758             break;
00759         case '2':
00760             WarningLevel = warningLevel_2;
00761             break;
00762         case '1':
00763             WarningLevel = warningLevel_1;
00764             break;
00765         case '0':
00766             WarningLevel = warningLevel_0;
00767             break;
00768         case 'L':
00769             AdditionalOptions += option;
00770             break;
00771         case 'X':
00772             WarnAsError = _True;
00773             break;
00774         case 'p':
00775             if ( third == '6' && fourth == '4' ) {
00776                 Detect64BitPortabilityProblems = _True;
00777                 break;
00778             }
00779             // Fallthrough
00780         default:
00781             found = FALSE; break;
00782         }
00783         break;
00784     case 'X':
00785         IgnoreStandardIncludePath = _True;
00786         break;
00787     case 'Y':
00788         switch ( second ) {
00789         case '\0':
00790         case '-':
00791             AdditionalOptions += option;
00792             break;
00793         case 'X':
00794             UsePrecompiledHeader = pchGenerateAuto;
00795             PrecompiledHeaderFile = option+3;
00796             break;
00797         case 'c':
00798             UsePrecompiledHeader = pchCreateUsingSpecific;
00799             PrecompiledHeaderFile = option+3;
00800             break;
00801         case 'd':
00802         case 'l':
00803             AdditionalOptions =+ option;
00804             break;
00805         case 'u':
00806             UsePrecompiledHeader = pchUseUsingSpecific;
00807             PrecompiledHeaderFile = option+3;
00808             break;
00809         default:
00810             found = FALSE; break;
00811         }
00812         break;
00813     case 'Z':
00814         switch ( second ) {
00815         case '7':
00816             DebugInformationFormat = debugOldStyleInfo;
00817             break;
00818         case 'I':
00819             DebugInformationFormat = debugEditAndContinue;
00820             break;
00821         case 'd':
00822             DebugInformationFormat = debugLineInfoOnly;
00823             break;
00824         case 'i':
00825             DebugInformationFormat = debugEnabled;
00826             break;
00827         case 'l':
00828             DebugInformationFormat = debugEditAndContinue;
00829             break;
00830         case 'a':
00831             DisableLanguageExtensions = _True;
00832             break;
00833         case 'e':
00834             DisableLanguageExtensions = _False;
00835             break;
00836         case 'c':
00837             if ( third == ':' ) {
00838                 if ( fourth == 'f' )
00839                     ForceConformanceInForLoopScope = _True;
00840                 else if ( fourth == 'w' )
00841                     TreatWChar_tAsBuiltInType = _True;
00842                 else
00843                     found = FALSE;
00844             } else {
00845                 found = FALSE; break;
00846             }
00847             break;
00848         case 'g':
00849         case 'm':
00850         case 's':
00851             AdditionalOptions += option;
00852             break;
00853         case 'p':
00854             switch ( third )
00855             {
00856             case '\0':
00857             case '1':
00858                 StructMemberAlignment = alignSingleByte;
00859                 if ( fourth == '6' )
00860                     StructMemberAlignment = alignSixteenBytes;
00861                 break;
00862             case '2':
00863                 StructMemberAlignment = alignTwoBytes;
00864                 break;
00865             case '4':
00866                 StructMemberAlignment = alignFourBytes;
00867                 break;
00868             case '8':
00869                 StructMemberAlignment = alignEightBytes;
00870                 break;
00871             default:
00872                 found = FALSE; break;
00873             }
00874             break;
00875         default:
00876             found = FALSE; break;
00877         }
00878         break;
00879     case 'c':
00880         if ( second == '\0' ) {
00881             CompileOnly = _True;
00882         } else if ( second == 'l' ) {
00883             if ( *(option+5) == 'n' ) {
00884                 CompileAsManaged = managedAssembly;
00885                 TurnOffAssemblyGeneration = _True;
00886             } else {
00887                 CompileAsManaged = managedAssembly;
00888             }
00889         } else {
00890             found = FALSE; break;
00891         }
00892         break;
00893     case 'd':
00894         if ( second != 'r' ) {
00895             found = FALSE; break;
00896         }
00897         CompileAsManaged = managedAssembly;
00898         break;
00899     case 'n':
00900         if ( second == 'o' && third == 'B' && fourth == 'o' ) {
00901             AdditionalOptions += "/noBool";
00902             break;
00903         }
00904         if ( second == 'o' && third == 'l' && fourth == 'o' ) {
00905             SuppressStartupBanner = _True;
00906             break;
00907         }
00908         found = FALSE; break;
00909     case 's':
00910         if ( second == 'h' && third == 'o' && fourth == 'w' ) {
00911             ShowIncludes = _True;
00912             break;
00913         }
00914         found = FALSE; break;
00915     case 'u':
00916         UndefineAllPreprocessorDefinitions = _True;
00917         break;
00918     case 'v':
00919         if ( second == 'd' || second == 'm' ) {
00920             AdditionalOptions += option;
00921             break;
00922         }
00923         found = FALSE; break;
00924     case 'w':
00925         switch ( second ) {
00926         case '\0':
00927             WarningLevel = warningLevel_0;
00928             break;
00929         case 'd':
00930             DisableSpecificWarnings += option+3;
00931             break;
00932         default:
00933             AdditionalOptions += option;
00934         }
00935         break;
00936     default:
00937         found = FALSE; break;
00938     }
00939     if( !found )
00940         warn_msg( WarnLogic, "Could not parse Compiler option: %s", option );
00941     return TRUE;
00942 }
00943 
00944 // VCLinkerTool -----------------------------------------------------
00945 VCLinkerTool::VCLinkerTool()
00946     :   EnableCOMDATFolding( optFoldingDefault ),
00947         GenerateDebugInformation( unset ),
00948         GenerateMapFile( unset ),
00949         HeapCommitSize( -1 ),
00950         HeapReserveSize( -1 ),
00951         IgnoreAllDefaultLibraries( unset ),
00952         IgnoreEmbeddedIDL( unset ),
00953         IgnoreImportLibrary( _True ),
00954         LargeAddressAware( addrAwareDefault ),
00955         LinkDLL( unset ),
00956         LinkIncremental( linkIncrementalDefault ),
00957         LinkTimeCodeGeneration( unset ),
00958         MapExports( unset ),
00959         MapLines( unset ),
00960         OptimizeForWindows98( optWin98Default ),
00961         OptimizeReferences( optReferencesDefault ),
00962         RegisterOutput( unset ),
00963         ResourceOnlyDLL( unset ),
00964         SetChecksum( unset ),
00965         ShowProgress( linkProgressNotSet ),
00966         StackCommitSize( -1 ),
00967         StackReserveSize( -1 ),
00968         SubSystem( subSystemNotSet ),
00969         SupportUnloadOfDelayLoadedDLL( unset ),
00970         SuppressStartupBanner( unset ),
00971         SwapRunFromCD( unset ),
00972         SwapRunFromNet( unset ),
00973         TargetMachine( machineNotSet ),
00974         TerminalServerAware( termSvrAwareDefault ),
00975         TurnOffAssemblyGeneration( unset ),
00976         TypeLibraryResourceID( 0 )
00977 {
00978 }
00979 
00980 QTextStream &operator<<( QTextStream &strm, const VCLinkerTool &tool )
00981 {
00982     strm << _begTool3;
00983     strm << _VCLinkerToolName;
00984     strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, " " );
00985     strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories );
00986     strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " );
00987     strm << XPair( _AddModuleNamesToAssembly, tool.AddModuleNamesToAssembly );
00988     strm << SPair( _BaseAddress, tool.BaseAddress );
00989     strm << XPair( _DelayLoadDLLs, tool.DelayLoadDLLs );
00990     if ( tool.EnableCOMDATFolding != optFoldingDefault )    strm << EPair( _EnableCOMDATFolding, tool.EnableCOMDATFolding );
00991     strm << SPair( _EntryPointSymbol, tool.EntryPointSymbol );
00992     strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences );
00993     strm << SPair( _FunctionOrder, tool.FunctionOrder );
00994     strm << TPair( _GenerateDebugInformation, tool.GenerateDebugInformation );
00995     strm << TPair( _GenerateMapFile, tool.GenerateMapFile );
00996     if ( tool.HeapCommitSize != -1 )                        strm << LPair( _HeapCommitSize, tool.HeapCommitSize );
00997     if ( tool.HeapReserveSize != -1 )                       strm << LPair( _HeapReserveSize, tool.HeapReserveSize );
00998     strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries );
00999     strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames );
01000     strm << TPair( _IgnoreEmbeddedIDL, tool.IgnoreEmbeddedIDL );
01001     strm << TPair( _IgnoreImportLibrary, tool.IgnoreImportLibrary );
01002     strm << SPair( _ImportLibrary, tool.ImportLibrary );
01003     if ( tool.LargeAddressAware != addrAwareDefault )       strm << EPair( _LargeAddressAware, tool.LargeAddressAware );
01004     strm << TPair( _LinkDLL, tool.LinkDLL );
01005     if ( tool.LinkIncremental != linkIncrementalDefault )   strm << EPair( _LinkIncremental, tool.LinkIncremental );
01006     strm << TPair( _LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration );
01007     strm << SPair( _LinkToManagedResourceFile, tool.LinkToManagedResourceFile );
01008     strm << TPair( _MapExports, tool.MapExports );
01009     strm << SPair( _MapFileName, tool.MapFileName );
01010     strm << TPair( _MapLines, tool.MapLines );
01011     strm << SPair( _MergedIDLBaseFileName, tool.MergedIDLBaseFileName );
01012     strm << SPair( _MergeSections, tool.MergeSections );
01013     strm << SPair( _MidlCommandFile, tool.MidlCommandFile );
01014     strm << SPair( _ModuleDefinitionFile, tool.ModuleDefinitionFile );
01015     if ( tool.OptimizeForWindows98 != optWin98Default )     strm << EPair( _OptimizeForWindows98, tool.OptimizeForWindows98 );
01016     if ( tool.OptimizeReferences != optReferencesDefault )  strm << EPair( _OptimizeReferences, tool.OptimizeReferences );
01017     strm << SPair( _OutputFile, tool.OutputFile );
01018     strm << _ProgramDatabaseFile << tool.ProgramDatabaseFile << "\"";
01019     strm << TPair( _RegisterOutput, tool.RegisterOutput );
01020     strm << TPair( _ResourceOnlyDLL, tool.ResourceOnlyDLL );
01021     strm << TPair( _SetChecksum, tool.SetChecksum );
01022     if ( tool.ShowProgress != linkProgressNotSet )          strm << EPair( _ShowProgress, tool.ShowProgress );
01023     if ( tool.StackCommitSize != -1 )                       strm << LPair( _StackCommitSize, tool.StackCommitSize );
01024     if ( tool.StackReserveSize != -1 )                      strm << LPair( _StackReserveSize, tool.StackReserveSize );
01025     strm << SPair( _StripPrivateSymbols, tool.StripPrivateSymbols );
01026     strm << EPair( _SubSystem, tool.SubSystem );
01027     strm << TPair( _SupportUnloadOfDelayLoadedDLL, tool.SupportUnloadOfDelayLoadedDLL );
01028     strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
01029     strm << TPair( _SwapRunFromCD, tool.SwapRunFromCD );
01030     strm << TPair( _SwapRunFromNet, tool.SwapRunFromNet );
01031     if ( tool.TargetMachine != machineNotSet )              strm << EPair( _TargetMachine, tool.TargetMachine );
01032     if ( tool.TerminalServerAware != termSvrAwareDefault )  strm << EPair( _TerminalServerAware, tool.TerminalServerAware );
01033     strm << TPair( _TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration );
01034     strm << SPair( _TypeLibraryFile, tool.TypeLibraryFile );
01035     if ( tool.TypeLibraryResourceID != rcUseDefault ) strm << LPair( _TypeLibraryResourceID, tool.TypeLibraryResourceID );
01036     strm << SPair( _Version4, tool.Version );
01037     strm << "/>";
01038     return strm;
01039 }
01040 
01041 // Hashing routine to do fast option lookups ----
01042 // Slightly rewritten to stop on ':' ',' and '\0'
01043 // Original routine in qtranslator.cpp ----------
01044 static uint elfHash( const char* name )
01045 {
01046     const uchar *k;
01047     uint h = 0;
01048     uint g;
01049 
01050     if ( name ) {
01051         k = (const uchar *) name;
01052         while ( (*k) &&
01053                 (*k)!= ':' &&
01054                 (*k)!=',' &&
01055                 (*k)!=' ' ) {
01056             h = ( h << 4 ) + *k++;
01057             if ( (g = (h & 0xf0000000)) != 0 )
01058                 h ^= g >> 24;
01059             h &= ~g;
01060         }
01061     }
01062     if ( !h )
01063         h = 1;
01064     return h;
01065 }
01066 
01067 //#define USE_DISPLAY_HASH
01068 #ifdef USE_DISPLAY_HASH
01069 static void displayHash( const char* str )
01070 {
01071     printf( "case 0x%07x: // %s\n    break;\n", elfHash(str), str );
01072 }
01073 #endif
01074 
01075 bool VCLinkerTool::parseOption( const char* option )
01076 {
01077 #ifdef USE_DISPLAY_HASH
01078     // Main options
01079     displayHash( "/ALIGN" ); displayHash( "/ALLOWBIND" ); displayHash( "/ASSEMBLYMODULE" );
01080     displayHash( "/ASSEMBLYRESOURCE" ); displayHash( "/BASE" ); displayHash( "/DEBUG" );
01081     displayHash( "/DEF" ); displayHash( "/DEFAULTLIB" ); displayHash( "/DELAY" );
01082     displayHash( "/DELAYLOAD" ); displayHash( "/DLL" ); displayHash( "/DRIVER" );
01083     displayHash( "/ENTRY" ); displayHash( "/EXETYPE" ); displayHash( "/EXPORT" );
01084     displayHash( "/FIXED" ); displayHash( "/FORCE" ); displayHash( "/HEAP" );
01085     displayHash( "/IDLOUT" ); displayHash( "/IGNOREIDL" ); displayHash( "/IMPLIB" );
01086     displayHash( "/INCLUDE" ); displayHash( "/INCREMENTAL" ); displayHash( "/LARGEADDRESSAWARE" );
01087     displayHash( "/LIBPATH" ); displayHash( "/LTCG" ); displayHash( "/MACHINE" );
01088     displayHash( "/MAP" ); displayHash( "/MAPINFO" ); displayHash( "/MERGE" );
01089     displayHash( "/MIDL" ); displayHash( "/NOASSEMBLY" ); displayHash( "/NODEFAULTLIB" );
01090     displayHash( "/NOENTRY" ); displayHash( "/NOLOGO" ); displayHash( "/OPT" );
01091     displayHash( "/ORDER" ); displayHash( "/OUT" ); displayHash( "/PDB" );
01092     displayHash( "/PDBSTRIPPED" ); displayHash( "/RELEASE" ); displayHash( "/SECTION" );
01093     displayHash( "/STACK" ); displayHash( "/STUB" ); displayHash( "/SUBSYSTEM" );
01094     displayHash( "/SWAPRUN" ); displayHash( "/TLBID" ); displayHash( "/TLBOUT" );
01095     displayHash( "/TSAWARE" ); displayHash( "/VERBOSE" ); displayHash( "/VERSION" );
01096     displayHash( "/VXD" ); displayHash( "/WS " );
01097 #endif
01098 #ifdef USE_DISPLAY_HASH
01099     // Sub options
01100     displayHash( "UNLOAD" ); displayHash( "NOBIND" ); displayHash( "no" ); displayHash( "NOSTATUS" ); displayHash( "STATUS" );
01101     displayHash( "AM33" ); displayHash( "ARM" ); displayHash( "CEE" ); displayHash( "IA64" ); displayHash( "X86" ); displayHash( "M32R" );
01102     displayHash( "MIPS" ); displayHash( "MIPS16" ); displayHash( "MIPSFPU" ); displayHash( "MIPSFPU16" ); displayHash( "MIPSR41XX" ); displayHash( "PPC" );
01103     displayHash( "SH3" ); displayHash( "SH4" ); displayHash( "SH5" ); displayHash( "THUMB" ); displayHash( "TRICORE" ); displayHash( "EXPORTS" );
01104     displayHash( "LINES" ); displayHash( "REF" ); displayHash( "NOREF" ); displayHash( "ICF" ); displayHash( "WIN98" ); displayHash( "NOWIN98" );
01105     displayHash( "CONSOLE" ); displayHash( "EFI_APPLICATION" ); displayHash( "EFI_BOOT_SERVICE_DRIVER" ); displayHash( "EFI_ROM" ); displayHash( "EFI_RUNTIME_DRIVER" ); displayHash( "NATIVE" );
01106     displayHash( "POSIX" ); displayHash( "WINDOWS" ); displayHash( "WINDOWSCE" ); displayHash( "NET" ); displayHash( "CD" ); displayHash( "NO" );
01107 #endif
01108     bool found = TRUE;
01109     switch ( elfHash(option) ) {
01110     case 0x3360dbe: // /ALIGN[:number]
01111     case 0x1485c34: // /ALLOWBIND[:NO]
01112     case 0x6b21972: // /DEFAULTLIB:library
01113     case 0x396ea92: // /DRIVER[:UPONLY | :WDM]
01114     case 0xaca9d75: // /EXETYPE[:DYNAMIC | :DEV386]
01115     case 0x3ad5444: // /EXPORT:entryname[,@ordinal[,NONAME]][,DATA]
01116     case 0x33aec94: // /FIXED[:NO]
01117     case 0x33b4675: // /FORCE:[MULTIPLE|UNRESOLVED]
01118     case 0x7988f7e: // /SECTION:name,[E][R][W][S][D][K][L][P][X][,ALIGN=#]
01119     case 0x0348992: // /STUB:filename
01120     case 0x0034bc4: // /VXD
01121     case 0x0034c50: // /WS
01122         AdditionalOptions += option;
01123         break;
01124     case 0x679c075: // /ASSEMBLYMODULE:filename
01125         AddModuleNamesToAssembly += option+15;
01126         break;
01127     case 0x062d065: // /ASSEMBLYRESOURCE:filename
01128         LinkToManagedResourceFile = option+18;
01129         break;
01130     case 0x0336675: // /BASE:{address | @filename,key}
01131         // Do we need to do a manual lookup when '@filename,key'?
01132         // Seems BaseAddress only can contain the location...
01133         // We don't use it in Qt, so keep it simple for now
01134         BaseAddress = option+6;
01135         break;
01136     case 0x3389797: // /DEBUG
01137         GenerateDebugInformation = _True;
01138         break;
01139     case 0x0033896: // /DEF:filename
01140         ModuleDefinitionFile = option+5;
01141         break;
01142     case 0x338a069: // /DELAY:{UNLOAD | NOBIND}
01143         // MS documentation does not specify what to do with
01144         // this option, so we'll put it in AdditionalOptions
01145         AdditionalOptions += option;
01146         break;
01147     case 0x06f4bf4: // /DELAYLOAD:dllname
01148         DelayLoadDLLs += option+11;
01149         break;
01150     // case 0x003390c: // /DLL
01151     // This option is not used for vcproj files
01152     //  break;
01153     case 0x33a3979: // /ENTRY:function
01154         EntryPointSymbol = option+7;
01155         break;
01156     case 0x033c960: // /HEAP:reserve[,commit]
01157         {
01158             QStringList both = QStringList::split( ",", option+6 );
01159             HeapReserveSize = both[0].toLong();
01160             if ( both.count() == 2 )
01161                 HeapCommitSize = both[1].toLong();
01162         }
01163         break;
01164     case 0x3d91494: // /IDLOUT:[path\]filename
01165         MergedIDLBaseFileName = option+8;
01166         break;
01167     case 0x345a04c: // /IGNOREIDL
01168         IgnoreEmbeddedIDL = _True;
01169         break;
01170     case 0x3e250e2: // /IMPLIB:filename
01171         ImportLibrary = option+8;
01172         break;
01173     case 0xe281ab5: // /INCLUDE:symbol
01174         ForceSymbolReferences += option+9;
01175         break;
01176     case 0xb28103c: // /INCREMENTAL[:no]
01177         if ( *(option+12) == ':' &&
01178              *(option+13) == 'n' )
01179             LinkIncremental = linkIncrementalNo;
01180         else
01181             LinkIncremental = linkIncrementalYes;
01182         break;
01183     case 0x26e4675: // /LARGEADDRESSAWARE[:no]
01184         if ( *(option+18) == ':' &&
01185              *(option+19) == 'n' )
01186             LargeAddressAware = addrAwareNoLarge;
01187         else
01188             LargeAddressAware = addrAwareLarge;
01189         break;
01190     case 0x0d745c8: // /LIBPATH:dir
01191         AdditionalLibraryDirectories += option+9;
01192         break;
01193     case 0x0341877: // /LTCG[:NOSTATUS|:STATUS]
01194         config->WholeProgramOptimization = _True;
01195         LinkTimeCodeGeneration = _True;
01196         if ( *(option+5) == ':' &&
01197              *(option+6) == 'S' )
01198              ShowProgress = linkProgressAll;
01199         break;
01200     case 0x157cf65: // /MACHINE:{AM33|ARM|CEE|IA64|X86|M32R|MIPS|MIPS16|MIPSFPU|MIPSFPU16|MIPSR41XX|PPC|SH3|SH4|SH5|THUMB|TRICORE}
01201         switch ( elfHash(option+9) ) {
01202             // Very limited documentation on all options but X86,
01203             // so we put the others in AdditionalOptions...
01204         case 0x0046063: // AM33
01205         case 0x000466d: // ARM
01206         case 0x0004795: // CEE
01207         case 0x004d494: // IA64
01208         case 0x0050672: // M32R
01209         case 0x0051e53: // MIPS
01210         case 0x51e5646: // MIPS16
01211         case 0x1e57b05: // MIPSFPU
01212         case 0x57b09a6: // MIPSFPU16
01213         case 0x5852738: // MIPSR41XX
01214         case 0x0005543: // PPC
01215         case 0x00057b3: // SH3
01216         case 0x00057b4: // SH4
01217         case 0x00057b5: // SH5
01218         case 0x058da12: // THUMB
01219         case 0x96d8435: // TRICORE
01220             AdditionalOptions += option;
01221             break;
01222         case 0x0005bb6: // X86
01223             TargetMachine = machineX86;
01224             break;
01225         default:
01226             found = FALSE;
01227         }
01228         break;
01229     case 0x0034160: // /MAP[:filename]
01230         GenerateMapFile = _True;
01231         MapFileName = option+5;
01232         break;
01233     case 0x164e1ef: // /MAPINFO:{EXPORTS|LINES}
01234         if ( *(option+9) == 'E' )
01235             MapExports = _True;
01236         else if ( *(option+9) == 'L' )
01237             MapLines = _True;
01238         break;
01239     case 0x341a6b5: // /MERGE:from=to
01240         MergeSections = option+7;
01241         break;
01242     case 0x0341d8c: // /MIDL:@file
01243         MidlCommandFile = option+7;
01244         break;
01245     case 0x84e2679: // /NOASSEMBLY
01246         TurnOffAssemblyGeneration = _True;
01247         break;
01248     case 0x2b21942: // /NODEFAULTLIB[:library]
01249         if ( *(option+13) == '\0' )
01250             IgnoreAllDefaultLibraries = _True;
01251         else
01252             IgnoreDefaultLibraryNames += option+14;
01253         break;
01254     case 0x33a3a39: // /NOENTRY
01255         ResourceOnlyDLL = _True;
01256         break;
01257     case 0x434138f: // /NOLOGO
01258         SuppressStartupBanner = _True;
01259         break;
01260     case 0x0034454: // /OPT:{REF | NOREF | ICF[=iterations] | NOICF | WIN98 | NOWIN98}
01261         {
01262             char third = *(option+7);
01263             switch ( third ) {
01264             case 'F': // REF
01265                 if ( *(option+5) == 'R' ) {
01266                     OptimizeReferences = optReferences;
01267                 } else { // ICF[=iterations]
01268                     EnableCOMDATFolding = optFolding;
01269                     // [=iterations] case is not documented
01270                 }
01271                 break;
01272             case 'R': // NOREF
01273                 OptimizeReferences = optNoReferences;
01274                 break;
01275             case 'I': // NOICF
01276                 EnableCOMDATFolding = optNoFolding;
01277                 break;
01278             case 'N': // WIN98
01279                 OptimizeForWindows98 = optWin98Yes;
01280                 break;
01281             case 'W': // NOWIN98
01282                 OptimizeForWindows98 = optWin98No;
01283                 break;
01284             default:
01285                 found = FALSE;
01286             }
01287         }
01288         break;
01289     case 0x34468a2: // /ORDER:@filename
01290         FunctionOrder = option+8;
01291         break;
01292     case 0x00344a4: // /OUT:filename
01293         OutputFile = option+5;
01294         break;
01295     case 0x0034482: // /PDB:filename
01296         ProgramDatabaseFile = option+5;
01297         break;
01298     case 0xa2ad314: // /PDBSTRIPPED:pdb_file_name
01299         StripPrivateSymbols = option+13;
01300         break;
01301     case 0x6a09535: // /RELEASE
01302         SetChecksum = _True;
01303         break;
01304     case 0x348857b: // /STACK:reserve[,commit]
01305         {
01306             QStringList both = QStringList::split( ",", option+7 );
01307             StackReserveSize = both[0].toLong();
01308             if ( both.count() == 2 )
01309                 StackCommitSize = both[1].toLong();
01310         }
01311         break;
01312     case 0x78dc00d: // /SUBSYSTEM:{CONSOLE|EFI_APPLICATION|EFI_BOOT_SERVICE_DRIVER|EFI_ROM|EFI_RUNTIME_DRIVER|NATIVE|POSIX|WINDOWS|WINDOWSCE}[,major[.minor]]
01313         {
01314             // Split up in subsystem, and version number
01315             QStringList both = QStringList::split( ",", option+11 );
01316             switch ( elfHash(both[0].latin1()) ) {
01317             case 0x8438445: // CONSOLE
01318                 SubSystem = subSystemConsole;
01319                 break;
01320             case 0xbe29493: // WINDOWS
01321                 SubSystem = subSystemWindows;
01322                 break;
01323             // The following are undocumented, so add them to AdditionalOptions
01324             case 0x240949e: // EFI_APPLICATION
01325             case 0xe617652: // EFI_BOOT_SERVICE_DRIVER
01326             case 0x9af477d: // EFI_ROM
01327             case 0xd34df42: // EFI_RUNTIME_DRIVER
01328             case 0x5268ea5: // NATIVE
01329             case 0x05547e8: // POSIX
01330             case 0x2949c95: // WINDOWSCE
01331                 AdditionalOptions += option;
01332                 break;
01333             default:
01334                 found = FALSE;
01335             }
01336         }
01337         break;
01338     case 0x8b654de: // /SWAPRUN:{NET | CD}
01339         if ( *(option+9) == 'N' )
01340             SwapRunFromNet = _True;
01341         else if ( *(option+9) == 'C' )
01342             SwapRunFromCD = _True;
01343         else
01344             found = FALSE;
01345         break;
01346     case 0x34906d4: // /TLBID:id
01347         TypeLibraryResourceID = QString( option+7 ).toLong();
01348         break;
01349     case 0x4907494: // /TLBOUT:[path\]filename
01350         TypeLibraryFile = option+8;
01351         break;
01352     case 0x976b525: // /TSAWARE[:NO]
01353         if ( *(option+8) == ':' )
01354             TerminalServerAware = termSvrAwareNo;
01355         else
01356             TerminalServerAware = termSvrAwareYes;
01357         break;
01358     case 0xaa67735: // /VERBOSE[:lib]
01359         if ( *(option+9) == ':' ) {
01360             ShowProgress = linkProgressLibs;
01361             AdditionalOptions += option;
01362         } else {
01363             ShowProgress = linkProgressAll;
01364         }
01365         break;
01366     case 0xaa77f7e: // /VERSION:major[.minor]
01367         Version = option+9;
01368         break;
01369     default:
01370         found = FALSE;
01371     }
01372     if( !found )
01373         warn_msg( WarnLogic, "Could not parse Linker options: %s", option );
01374     return found;
01375 }
01376 
01377 // VCMIDLTool -------------------------------------------------------
01378 VCMIDLTool::VCMIDLTool()
01379     :   DefaultCharType( midlCharUnsigned ),
01380         EnableErrorChecks( midlDisableAll ),
01381         ErrorCheckAllocations( unset ),
01382         ErrorCheckBounds( unset ),
01383         ErrorCheckEnumRange( unset ),
01384         ErrorCheckRefPointers( unset ),
01385         ErrorCheckStubData( unset ),
01386         GenerateStublessProxies( unset ),
01387         GenerateTypeLibrary( unset ),
01388         IgnoreStandardIncludePath( unset ),
01389         MkTypLibCompatible( unset ),
01390         StructMemberAlignment( midlAlignNotSet ),
01391         SuppressStartupBanner( unset ),
01392         TargetEnvironment( midlTargetNotSet ),
01393         ValidateParameters( unset ),
01394         WarnAsError( unset ),
01395         WarningLevel( midlWarningLevel_0 )
01396 {
01397 }
01398 
01399 QTextStream &operator<<( QTextStream &strm, const VCMIDLTool &tool )
01400 {
01401     strm << _begTool3;
01402     strm << _VCMIDLToolName;
01403     strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories );
01404     strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " );
01405     strm << XPair( _CPreprocessOptions, tool.CPreprocessOptions );
01406     strm << EPair( _DefaultCharType, tool.DefaultCharType );
01407     strm << SPair( _DLLDataFileName, tool.DLLDataFileName );
01408     strm << EPair( _EnableErrorChecks, tool.EnableErrorChecks );
01409     strm << TPair( _ErrorCheckAllocations, tool.ErrorCheckAllocations );
01410     strm << TPair( _ErrorCheckBounds, tool.ErrorCheckBounds );
01411     strm << TPair( _ErrorCheckEnumRange, tool.ErrorCheckEnumRange );
01412     strm << TPair( _ErrorCheckRefPointers, tool.ErrorCheckRefPointers );
01413     strm << TPair( _ErrorCheckStubData, tool.ErrorCheckStubData );
01414     strm << XPair( _FullIncludePath, tool.FullIncludePath );
01415     strm << TPair( _GenerateStublessProxies, tool.GenerateStublessProxies );
01416     strm << TPair( _GenerateTypeLibrary, tool.GenerateTypeLibrary );
01417     strm << SPair( _HeaderFileName, tool.HeaderFileName );
01418     strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath );
01419     strm << SPair( _InterfaceIdentifierFileName, tool.InterfaceIdentifierFileName );
01420     strm << TPair( _MkTypLibCompatible, tool.MkTypLibCompatible );
01421     strm << SPair( _OutputDirectory4, tool.OutputDirectory );
01422     strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions );
01423     strm << SPair( _ProxyFileName, tool.ProxyFileName );
01424     strm << SPair( _RedirectOutputAndErrors, tool.RedirectOutputAndErrors );
01425     if ( tool.StructMemberAlignment != midlAlignNotSet)     strm << EPair( _StructMemberAlignment, tool.StructMemberAlignment );
01426     strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
01427     if ( tool.TargetEnvironment != midlTargetNotSet )       strm << EPair( _TargetEnvironment, tool.TargetEnvironment );
01428     strm << SPair( _TypeLibraryName, tool.TypeLibraryName );
01429     strm << XPair( _UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions );
01430     strm << TPair( _ValidateParameters, tool.ValidateParameters );
01431     strm << TPair( _WarnAsError, tool.WarnAsError );
01432     strm << EPair( _WarningLevel, tool.WarningLevel );
01433     strm << "/>";
01434     return strm;
01435 }
01436 
01437 bool VCMIDLTool::parseOption( const char* option )
01438 {
01439 #ifdef USE_DISPLAY_HASH
01440     displayHash( "/D name[=def]" ); displayHash( "/I directory-list" ); displayHash( "/Oi" );
01441     displayHash( "/Oic" ); displayHash( "/Oicf" ); displayHash( "/Oif" ); displayHash( "/Os" );
01442     displayHash( "/U name" ); displayHash( "/WX" ); displayHash( "/W{0|1|2|3|4}" );
01443     displayHash( "/Zp {N}" ); displayHash( "/Zs" ); displayHash( "/acf filename" );
01444     displayHash( "/align {N}" ); displayHash( "/app_config" ); displayHash( "/c_ext" );
01445     displayHash( "/char ascii7" ); displayHash( "/char signed" ); displayHash( "/char unsigned" );
01446     displayHash( "/client none" ); displayHash( "/client stub" ); displayHash( "/confirm" );
01447     displayHash( "/cpp_cmd cmd_line" ); displayHash( "/cpp_opt options" );
01448     displayHash( "/cstub filename" ); displayHash( "/dlldata filename" ); displayHash( "/env win32" );
01449     displayHash( "/env win64" ); displayHash( "/error all" ); displayHash( "/error allocation" );
01450     displayHash( "/error bounds_check" ); displayHash( "/error enum" ); displayHash( "/error none" );
01451     displayHash( "/error ref" ); displayHash( "/error stub_data" ); displayHash( "/h filename" );
01452     displayHash( "/header filename" ); displayHash( "/iid filename" ); displayHash( "/lcid" );
01453     displayHash( "/mktyplib203" ); displayHash( "/ms_ext" ); displayHash( "/ms_union" );
01454     displayHash( "/msc_ver <nnnn>" ); displayHash( "/newtlb" ); displayHash( "/no_cpp" );
01455     displayHash( "/no_def_idir" ); displayHash( "/no_default_epv" ); displayHash( "/no_format_opt" );
01456     displayHash( "/no_warn" ); displayHash( "/nocpp" ); displayHash( "/nologo" ); displayHash( "/notlb" );
01457     displayHash( "/o filename" ); displayHash( "/oldnames" ); displayHash( "/oldtlb" );
01458     displayHash( "/osf" ); displayHash( "/out directory" ); displayHash( "/pack {N}" );
01459     displayHash( "/prefix all" ); displayHash( "/prefix client" ); displayHash( "/prefix server" );
01460     displayHash( "/prefix switch" ); displayHash( "/protocol all" ); displayHash( "/protocol dce" );
01461     displayHash( "/protocol ndr64" ); displayHash( "/proxy filename" ); displayHash( "/robust" );
01462     displayHash( "/rpcss" ); displayHash( "/savePP" ); displayHash( "/server none" );
01463     displayHash( "/server stub" ); displayHash( "/sstub filename" ); displayHash( "/syntax_check" );
01464     displayHash( "/target {system}" ); displayHash( "/tlb filename" ); displayHash( "/use_epv" );
01465     displayHash( "/win32" ); displayHash( "/win64" );
01466 #endif
01467     bool found = TRUE;
01468     int offset = 0;
01469     switch( elfHash(option) ) {
01470     case 0x0000334: // /D name[=def]
01471         PreprocessorDefinitions += option+3;
01472         break;
01473     case 0x0000339: // /I directory-list
01474         AdditionalIncludeDirectories += option+3;
01475         break;
01476     case 0x0345f96: // /Oicf
01477     case 0x00345f6: // /Oif
01478         GenerateStublessProxies = _True;
01479         break;
01480     case 0x0000345: // /U name
01481         UndefinePreprocessorDefinitions += option+3;
01482         break;
01483     case 0x00034c8: // /WX
01484         WarnAsError = _True;
01485         break;
01486     case 0x3582fde: // /align {N}
01487         offset = 3;  // Fallthrough
01488     case 0x0003510: // /Zp {N}
01489         switch ( *(option+offset+4) ) {
01490         case '1':
01491             StructMemberAlignment = ( *(option+offset+5) == '\0' ) ? midlAlignSingleByte : midlAlignSixteenBytes;
01492             break;
01493         case '2':
01494             StructMemberAlignment = midlAlignTwoBytes;
01495             break;
01496         case '4':
01497             StructMemberAlignment = midlAlignFourBytes;
01498             break;
01499         case '8':
01500             StructMemberAlignment = midlAlignEightBytes;
01501             break;
01502         default:
01503             found = FALSE;
01504         }
01505         break;
01506     case 0x0359e82: // /char {ascii7|signed|unsigned}
01507         switch( *(option+6) ) {
01508         case 'a':
01509             DefaultCharType = midlCharAscii7;
01510             break;
01511         case 's':
01512             DefaultCharType = midlCharSigned;
01513             break;
01514         case 'u':
01515             DefaultCharType = midlCharUnsigned;
01516             break;
01517         default:
01518             found = FALSE;
01519         }
01520         break;
01521     case 0xa766524: // /cpp_opt options
01522         CPreprocessOptions += option+9;
01523         break;
01524     case 0xb32abf1: // /dlldata filename
01525         DLLDataFileName = option + 9;
01526         break;
01527     case 0x0035c56: // /env {win32|win64}
01528         TargetEnvironment = ( *(option+8) == '6' ) ? midlTargetWin64 : midlTargetWin32;
01529         break;
01530     case 0x35c9962: // /error {all|allocation|bounds_check|enum|none|ref|stub_data}
01531         EnableErrorChecks = midlEnableCustom;
01532         switch ( *(option+7) ) {
01533         case 'a':
01534             if ( *(option+10) == '\0' )
01535                 EnableErrorChecks = midlEnableAll;
01536             else
01537                 ErrorCheckAllocations = _True;
01538             break;
01539         case 'b':
01540             ErrorCheckBounds = _True;
01541             break;
01542         case 'e':
01543             ErrorCheckEnumRange = _True;
01544             break;
01545         case 'n':
01546             EnableErrorChecks = midlDisableAll;
01547             break;
01548         case 'r':
01549             ErrorCheckRefPointers = _True;
01550             break;
01551         case 's':
01552             ErrorCheckStubData = _True;
01553             break;
01554         default:
01555             found = FALSE;
01556         }
01557         break;
01558     case 0x5eb7af2: // /header filename
01559         offset = 5;
01560     case 0x0000358: // /h filename
01561         HeaderFileName = option + offset + 3;
01562         break;
01563     case 0x0035ff4: // /iid filename
01564         InterfaceIdentifierFileName = option+5;
01565         break;
01566     case 0x64b7933: // /mktyplib203
01567         MkTypLibCompatible = _True;
01568         break;
01569     case 0x8e0b0a2: // /no_def_idir
01570         IgnoreStandardIncludePath = _True;
01571         break;
01572     case 0x65635ef: // /nologo
01573         SuppressStartupBanner = _True;
01574         break;
01575     case 0x3656b22: // /notlb
01576         GenerateTypeLibrary = _True;
01577         break;
01578     case 0x000035f: // /o filename
01579         RedirectOutputAndErrors = option+3;
01580         break;
01581     case 0x00366c4: // /out directory
01582         OutputDirectory = option+5;
01583         break;
01584     case 0x36796f9: // /proxy filename
01585         ProxyFileName = option+7;
01586         break;
01587     case 0x6959c94: // /robust
01588         ValidateParameters = _True;
01589         break;
01590     case 0x6a88df4: // /target {system}
01591         if ( *(option+11) == '6' )
01592             TargetEnvironment = midlTargetWin64;
01593         else
01594             TargetEnvironment = midlTargetWin32;
01595         break;
01596     case 0x0036b22: // /tlb filename
01597         TypeLibraryName = option+5;
01598         break;
01599     case 0x36e0162: // /win32
01600         TargetEnvironment = midlTargetWin32;
01601         break;
01602     case 0x36e0194: // /win64
01603         TargetEnvironment = midlTargetWin64;
01604         break;
01605     case 0x0003459: // /Oi
01606     case 0x00345f3: // /Oic
01607     case 0x0003463: // /Os
01608     case 0x0003513: // /Zs
01609     case 0x0035796: // /acf filename
01610     case 0x5b1cb97: // /app_config
01611     case 0x3595cf4: // /c_ext
01612     case 0x5a2fc64: // /client {none|stub}
01613     case 0xa64d3dd: // /confirm
01614     case 0xa765b64: // /cpp_cmd cmd_line
01615     case 0x35aabb2: // /cstub filename
01616     case 0x03629f4: // /lcid
01617     case 0x6495cc4: // /ms_ext
01618     case 0x96c7a1e: // /ms_union
01619     case 0x4996fa2: // /msc_ver <nnnn>
01620     case 0x64ceb12: // /newtlb
01621     case 0x6555a40: // /no_cpp
01622     case 0xf64d6a6: // /no_default_epv
01623     case 0x6dd9384: // /no_format_opt
01624     case 0x556dbee: // /no_warn
01625     case 0x3655a70: // /nocpp
01626     case 0x2b455a3: // /oldnames
01627     case 0x662bb12: // /oldtlb
01628     case 0x0036696: // /osf
01629     case 0x036679b: // /pack {N}
01630     case 0x678bd38: // /prefix {all|client|server|switch}
01631     case 0x96b702c: // /protocol {all|dce|ndr64}
01632     case 0x3696aa3: // /rpcss
01633     case 0x698ca60: // /savePP
01634     case 0x69c9cf2: // /server {none|stub}
01635     case 0x36aabb2: // /sstub filename
01636     case 0xce9b12b: // /syntax_check
01637     case 0xc9b5f16: // /use_epv
01638         AdditionalOptions += option;
01639         break;
01640     default:
01641         // /W{0|1|2|3|4} case
01642         if ( *(option+1) == 'W' ) {
01643             switch ( *(option+2) ) {
01644             case '0':
01645                 WarningLevel = midlWarningLevel_0;
01646                 break;
01647             case '1':
01648                 WarningLevel = midlWarningLevel_1;
01649                 break;
01650             case '2':
01651                 WarningLevel = midlWarningLevel_2;
01652                 break;
01653             case '3':
01654                 WarningLevel = midlWarningLevel_3;
01655                 break;
01656             case '4':
01657                 WarningLevel = midlWarningLevel_4;
01658                 break;
01659             default:
01660                 found = FALSE;
01661             }
01662         }
01663         break;
01664     }
01665     if( !found )
01666         warn_msg( WarnLogic, "Could not parse MIDL option: %s", option );
01667     return TRUE;
01668 }
01669 
01670 // VCLibrarianTool --------------------------------------------------
01671 VCLibrarianTool::VCLibrarianTool()
01672     :   IgnoreAllDefaultLibraries( unset ),
01673         SuppressStartupBanner( _True )
01674 {
01675 }
01676 
01677 QTextStream &operator<<( QTextStream &strm, const VCLibrarianTool &tool )
01678 {
01679     strm << _begTool3;
01680     strm << SPair( _ToolName, QString( "VCLibrarianTool" ) );
01681     strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies );
01682     strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories );
01683     strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " );
01684     strm << XPair( _ExportNamedFunctions, tool.ExportNamedFunctions );
01685     strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences );
01686     strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries );
01687     strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames );
01688     strm << SPair( _ModuleDefinitionFile, tool.ModuleDefinitionFile );
01689     strm << SPair( _OutputFile, tool.OutputFile );
01690     strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
01691     strm << "/>";
01692     return strm;
01693 }
01694 
01695 // VCCustomBuildTool ------------------------------------------------
01696 VCCustomBuildTool::VCCustomBuildTool()
01697 {
01698     ToolName = "VCCustomBuildTool";
01699 }
01700 
01701 QTextStream &operator<<( QTextStream &strm, const VCCustomBuildTool &tool )
01702 {
01703     strm << _begTool3;
01704     strm << SPair( _ToolName, tool.ToolName );
01705     strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, ";" );
01706     strm << XPair( _CommandLine4, tool.CommandLine, "\n" );
01707     strm << SPair( _Description4, tool.Description );
01708     strm << XPair( _Outputs4, tool.Outputs, ";" );
01709     strm << SPair( _ToolPath, tool.ToolPath );
01710     strm << "/>";
01711    return strm;
01712 }
01713 
01714 // VCResourceCompilerTool -------------------------------------------
01715 VCResourceCompilerTool::VCResourceCompilerTool()
01716     :   Culture( rcUseDefault ),
01717         IgnoreStandardIncludePath( unset ),
01718         ShowProgress( linkProgressNotSet )
01719 {
01720     PreprocessorDefinitions = "NDEBUG";
01721 }
01722 
01723 QTextStream &operator<<( QTextStream &strm, const VCResourceCompilerTool &tool )
01724 {
01725     strm << _begTool3;
01726     strm << _VCResourceCompilerToolName;
01727     strm << SPair( _ToolPath, tool.ToolPath );
01728     strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories );
01729     strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " );
01730     if ( tool.Culture != rcUseDefault )                     strm << EPair( _Culture, tool.Culture );
01731     strm << XPair( _FullIncludePath, tool.FullIncludePath );
01732     strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath );
01733     strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions );
01734     strm << SPair( _ResourceOutputFileName, tool.ResourceOutputFileName );
01735     if ( tool.ShowProgress != linkProgressNotSet )          strm << EPair( _ShowProgress, tool.ShowProgress );
01736     strm << "/>";
01737     return strm;
01738 }
01739 
01740 // VCEventTool -------------------------------------------------
01741 QTextStream &operator<<( QTextStream &strm, const VCEventTool &tool )
01742 {
01743     strm << _begTool3;
01744     strm << SPair( _ToolName, tool.ToolName );
01745     strm << SPair( _ToolPath, tool.ToolPath );
01746     strm << SPair( _CommandLine4, tool.CommandLine );
01747     strm << SPair( _Description4, tool.Description );
01748     strm << TPair( _ExcludedFromBuild, tool.ExcludedFromBuild );
01749     strm << "/>";
01750     return strm;
01751 }
01752 
01753 // VCPostBuildEventTool ---------------------------------------------
01754 VCPostBuildEventTool::VCPostBuildEventTool()
01755 {
01756     ToolName = "VCPostBuildEventTool";
01757 }
01758 
01759 // VCPreBuildEventTool ----------------------------------------------
01760 VCPreBuildEventTool::VCPreBuildEventTool()
01761 {
01762     ToolName = "VCPreBuildEventTool";
01763 }
01764 
01765 // VCPreLinkEventTool -----------------------------------------------
01766 VCPreLinkEventTool::VCPreLinkEventTool()
01767 {
01768     ToolName = "VCPreLinkEventTool";
01769 }
01770 
01771 // VCConfiguration --------------------------------------------------
01772 
01773 VCConfiguration::VCConfiguration()
01774     :   ATLMinimizesCRunTimeLibraryUsage( unset ),
01775         BuildBrowserInformation( unset ),
01776         CharacterSet( charSetNotSet ),
01777         ConfigurationType( typeApplication ),
01778         RegisterOutput( unset ),
01779         UseOfATL( useATLNotSet ),
01780         UseOfMfc( useMfcStdWin ),
01781         WholeProgramOptimization( unset )
01782 {
01783     compiler.config = this;
01784     linker.config = this;
01785     idl.config = this;
01786 }
01787 
01788 QTextStream &operator<<( QTextStream &strm, const VCConfiguration &tool )
01789 {
01790     strm << _begConfiguration;
01791     strm << SPair( _Name3, tool.Name );
01792     strm << SPair( _OutputDirectory3, tool.OutputDirectory );
01793     strm << TPair( _ATLMinimizesCRunTimeLibraryUsage, tool.ATLMinimizesCRunTimeLibraryUsage );
01794     strm << TPair( _BuildBrowserInformation, tool.BuildBrowserInformation );
01795     if ( tool.CharacterSet != charSetNotSet)    strm << EPair( _CharacterSet, tool.CharacterSet );
01796     strm << EPair( _ConfigurationType, tool.ConfigurationType );
01797     strm << SPair( _DeleteExtensionsOnClean, tool.DeleteExtensionsOnClean );
01798     strm << SPair( _ImportLibrary, tool.ImportLibrary );
01799     strm << SPair( _IntermediateDirectory, tool.IntermediateDirectory );
01800     strm << SPair( _PrimaryOutput, tool.PrimaryOutput );
01801     strm << SPair( _ProgramDatabase, tool.ProgramDatabase );
01802     strm << TPair( _RegisterOutput, tool.RegisterOutput );
01803     if ( tool.UseOfATL != useATLNotSet)         strm << EPair( _UseOfATL, tool.UseOfATL );
01804     strm << EPair( _UseOfMfc, tool.UseOfMfc );
01805     strm << TPair( _WholeProgramOptimization, tool.WholeProgramOptimization );
01806     strm << ">";
01807     strm << tool.compiler;
01808     strm << tool.custom;
01809     if ( tool.ConfigurationType == typeStaticLibrary )
01810         strm << tool.librarian;
01811     else
01812         strm << tool.linker;
01813     strm << tool.idl;
01814     strm << tool.postBuild;
01815     strm << tool.preBuild;
01816     strm << tool.preLink;
01817     strm << tool.resource;
01818     strm << _endConfiguration;
01819     return strm;
01820 }
01821 // VCFilter ---------------------------------------------------------
01822 VCFilter::VCFilter()
01823     :   ParseFiles( unset )
01824 {
01825     useCustomBuildTool = FALSE;
01826     useCompilerTool = FALSE;
01827 }
01828 
01829 void VCFilter::addMOCstage( QTextStream &strm, QString filename )
01830 {
01831     QString mocOutput = Project->findMocDestination( filename );
01832     QString mocApp = Project->var( "QMAKE_MOC" );
01833 
01834     if( mocOutput.isEmpty() && filename.endsWith(".moc") ) {
01835         // In specialcases we DO moc .cpp files
01836         // when the result is an .moc file
01837         mocOutput = filename;
01838         filename = Project->findMocSource( mocOutput );
01839     }
01840 
01841     if (mocOutput.isEmpty())
01842         return;
01843 
01844     CustomBuildTool = VCCustomBuildTool();
01845     useCustomBuildTool = TRUE;
01846     CustomBuildTool.Description = "Moc&apos;ing " + filename + "...";
01847     CustomBuildTool.CommandLine += (mocApp + " "
01848                                 + filename + " -o " + mocOutput);
01849     CustomBuildTool.AdditionalDependencies = mocApp;
01850     CustomBuildTool.Outputs += mocOutput;
01851 }
01852 
01853 void VCFilter::addUICstage( QTextStream &strm, QString str )
01854 {
01855     CustomBuildTool = VCCustomBuildTool();
01856     useCustomBuildTool = TRUE;
01857 
01858     QString uicApp = Project->var("QMAKE_UIC");
01859     QString mocApp = Project->var( "QMAKE_MOC" );
01860     QString fname = str.section( '\\', -1 );
01861     QString mocDir = Project->var( "MOC_DIR" );
01862     QString uiDir = Project->var( "UI_DIR" );
01863     QString uiHeaders;
01864     QString uiSources;
01865 
01866     // Determining the paths for the output files.
01867     int slash = str.findRev( '\\' );
01868     QString pname = ( slash != -1 ) ? str.left( slash+1 ) : QString( ".\\" );
01869     if( !uiDir.isEmpty() ) {
01870         uiHeaders = uiDir;
01871         uiSources = uiDir;
01872     } else {
01873         uiHeaders = Project->var( "UI_HEADERS_DIR" );
01874         uiSources = Project->var( "UI_SOURCES_DIR" );
01875         if( uiHeaders.isEmpty() )
01876             uiHeaders = pname;
01877         if( uiSources.isEmpty() )
01878             uiSources = pname;
01879     }
01880     if( !uiHeaders.endsWith( "\\" ) )
01881         uiHeaders += "\\";
01882     if( !uiSources.endsWith( "\\" ) )
01883         uiSources += "\\";
01884 
01885     // Determine the file name.
01886     int dot = fname.findRev( '.' );
01887     if( dot != -1 )
01888         fname.truncate( dot );
01889 
01890     if ( mocDir.isEmpty() )
01891         mocDir = pname;
01892 
01893     CustomBuildTool.Description = ("Uic'ing " + str + "...\"");
01894     CustomBuildTool.CommandLine += // Create .h from .ui file
01895         uicApp + " " + str + " -o " + uiHeaders + fname + ".h";
01896     CustomBuildTool.CommandLine += // Create .cpp from .ui file
01897         uicApp + " " + str + " -i " + fname + ".h -o " + uiSources + fname + ".cpp";
01898     CustomBuildTool.CommandLine += // Moc the headerfile
01899         mocApp + " " + uiHeaders + fname + ".h -o " + mocDir + Option::h_moc_mod + fname + Option::h_moc_ext;
01900 
01901     CustomBuildTool.AdditionalDependencies += mocApp;
01902     CustomBuildTool.AdditionalDependencies += uicApp;
01903     CustomBuildTool.Outputs +=
01904         uiHeaders + fname + ".h;" + uiSources + fname + ".cpp;" + mocDir + Option::h_moc_mod + fname + Option::h_moc_ext;
01905 }
01906 
01907 void VCFilter::modifyPCHstage( QTextStream &strm, QString str )
01908 {
01909     bool isCFile = str.endsWith(".c");
01910     bool isHFile = (str.endsWith(".h") && str == Project->precompH);
01911 
01912     if (!isCFile && !isHFile)
01913         return;
01914 
01915     CompilerTool = VCCLCompilerTool();
01916     useCompilerTool = TRUE;
01917 
01918     // Unset some default options
01919     CompilerTool.BufferSecurityCheck = unset;
01920     CompilerTool.DebugInformationFormat = debugUnknown;
01921     CompilerTool.ExceptionHandling = unset;
01922     CompilerTool.GeneratePreprocessedFile = preprocessUnknown;
01923     CompilerTool.Optimization = optimizeDefault;
01924     CompilerTool.ProgramDataBaseFileName = QString::null;
01925     CompilerTool.RuntimeLibrary = rtUnknown;
01926     CompilerTool.WarningLevel = warningLevelUnknown;
01927 
01928     // Setup PCH options
01929     CompilerTool.UsePrecompiledHeader     = (isCFile ? pchNone : pchCreateUsingSpecific);
01930     CompilerTool.PrecompiledHeaderThrough = "$(NOINHERIT)";
01931     CompilerTool.ForcedIncludeFiles       = "$(NOINHERIT)";
01932 }
01933 
01934 bool VCFilter::addIMGstage( QTextStream &strm, QString str )
01935 {
01936     bool isCorH = FALSE;
01937     if (str.endsWith(".c") || str.endsWith(".rc"))
01938         isCorH = TRUE;
01939     QStringList::Iterator it;
01940     for(it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it)
01941         if(str.endsWith(*it))
01942             isCorH = TRUE;
01943     for(it = Option::h_ext.begin(); it != Option::h_ext.end(); ++it)
01944         if(str.endsWith(*it))
01945             isCorH = TRUE;
01946 
01947     QString collectionName = Project->project->first("QMAKE_IMAGE_COLLECTION");
01948     if (str.isEmpty() || isCorH || collectionName.isEmpty())
01949         return FALSE;
01950 
01951     CustomBuildTool = VCCustomBuildTool();
01952     useCustomBuildTool = TRUE;
01953 
01954     // Some projects (like designer core) may have too many images to
01955     // call uic directly. Therefor we have to create a temporary
01956     // file, with the image list, and call uic with the -f option.
01957     QString tmpFileCmd = "echo ";
01958     QString tmpImageFilename = ".imgcol";
01959     QStringList& list = Project->project->variables()["IMAGES"];
01960     bool firstOutput = TRUE;
01961     it = list.begin();
01962     while( it!=list.end() ) {
01963         tmpFileCmd += (*it) + " ";
01964         ++it;
01965         if (tmpFileCmd.length()>250 || it==list.end()) {
01966             CustomBuildTool.CommandLine += tmpFileCmd
01967                                           + (firstOutput?"> ":">> ")
01968                                           + tmpImageFilename;
01969             tmpFileCmd = "echo ";
01970             firstOutput = FALSE;
01971         }
01972     }
01973 
01974     QString uicApp = Project->var("QMAKE_UIC");
01975     CustomBuildTool.Description = ("Generate imagecollection");
01976     CustomBuildTool.CommandLine +=
01977         uicApp + " -embed " + Project->project->first("QMAKE_ORIG_TARGET")
01978         + " -f .imgcol -o " + collectionName;
01979     CustomBuildTool.AdditionalDependencies += uicApp;
01980     CustomBuildTool.AdditionalDependencies += list;
01981     CustomBuildTool.Outputs = collectionName;
01982     CustomBuildTool.Outputs += tmpImageFilename;
01983     return TRUE;
01984 }
01985 
01986 QTextStream &operator<<( QTextStream &strm, VCFilter &tool )
01987 {
01988     if ( tool.Files.count() == 0 )
01989         return strm;
01990 
01991     strm << _begFilter;
01992     strm << SPair( _Name3, tool.Name );
01993     strm << TPair( _ParseFiles, tool.ParseFiles );
01994     strm << SPair( _Filter, tool.Filter );
01995     strm << ">";
01996 
01997     bool resourceBuild = FALSE;
01998     int currentLevels = 0;
01999     QStringList currentDirs;
02000     for ( QStringList::ConstIterator it = tool.Files.begin(); it != tool.Files.end(); ++it ) {
02001         if ( !tool.flat_files ) {
02002             QStringList newDirs = QStringList::split('\\',(*it));
02003             newDirs.pop_back(); // Skip the filename
02004 
02005             int newLevels = int(newDirs.count());
02006             int equalLevels = 0;
02007             for (int i = 0; i<currentLevels; i++, equalLevels++ )
02008                 if (currentDirs[i] != newDirs[i])
02009                     break;
02010             int closeFilters = currentLevels - equalLevels;
02011             int openFilters  = newLevels - equalLevels;
02012 
02013             // close previous non-equal filter
02014             while ( closeFilters-- )
02015                 strm << _endFilter;
02016 
02017             // open new non-equal filters
02018             newLevels = 0;
02019             while ( openFilters-- ) {
02020                 strm << _begFilter;
02021                 strm << SPair( _Name3, newDirs[equalLevels + newLevels] );
02022                 strm << _Filter << "\">"; // Blank filter
02023                 ++newLevels;
02024             }
02025             currentDirs = newDirs;
02026             currentLevels = int(newDirs.count());
02027         }
02028 
02029         tool.useCustomBuildTool = FALSE;
02030         tool.useCompilerTool = FALSE;
02031         // Add UIC, MOC and PCH stages to file
02032         if ( tool.CustomBuild == moc )
02033             tool.addMOCstage( strm, *it );
02034         else if ( tool.CustomBuild == uic )
02035             tool.addUICstage( strm, *it );
02036         else if ( tool.CustomBuild == resource ) {
02037             if (!resourceBuild)
02038                 resourceBuild = tool.addIMGstage(strm, *it);
02039         }
02040         if (tool.Project->usePCH)
02041             tool.modifyPCHstage( strm, *it );
02042 
02043         strm << _begFile;
02044         strm << SPair( _RelativePath, *it );
02045         strm << ">";
02046         // Output custom build and compiler options
02047         // for all configurations
02048         if (tool.useCustomBuildTool || tool.useCompilerTool) {
02049             for ( uint i = 0; i < tool.Config->count(); i++ ) {
02050                 strm << _begFileConfiguration;
02051                 strm << _Name5;
02052                 strm << (*tool.Config)[i].Name;
02053                 strm << "\">";
02054                 if (tool.useCustomBuildTool)
02055                     strm <<  tool.CustomBuildTool;
02056                 if (tool.useCompilerTool)
02057                     strm <<  tool.CompilerTool;
02058                 strm << _endFileConfiguration;
02059             }
02060         }
02061         strm << _endFile;
02062     }
02063     // close remaining open filters, in non-flat mode
02064     while ( !tool.flat_files && currentLevels-- ) {
02065         strm << _endFilter;
02066     }
02067     strm << _endFilter;
02068     return strm;
02069 }
02070 
02071 // VCProject --------------------------------------------------------
02072 VCProject::VCProject()
02073 {
02074     VCConfiguration conf;
02075     Configuration += conf ; // Release
02076     //Configuration += conf ; // Debug added later, after Release init
02077 }
02078 
02079 QTextStream &operator<<( QTextStream &strm, const VCProject &tool )
02080 {
02081     strm << _xmlInit;
02082     strm << _begVisualStudioProject;
02083     strm << _ProjectType;
02084     strm << SPair( _Version1, tool.Version );
02085     strm << SPair( _Name1, tool.Name );
02086     strm << SPair( _ProjectGUID, tool.ProjectGUID );
02087     strm << SPair( _SccProjectName, tool.SccProjectName );
02088     strm << SPair( _SccLocalPath, tool.SccLocalPath );
02089     strm << ">";
02090     strm << _begPlatforms;
02091     strm << _begPlatform;
02092     strm << SPair( _Name3, tool.PlatformName );
02093     strm << "/>";
02094     strm << _endPlatforms;
02095     strm << _begConfigurations;
02096     for ( uint i = 0; i < tool.Configuration.count(); i++ )
02097         strm << tool.Configuration[i];
02098     strm << _endConfigurations;
02099     strm << _begFiles;
02100     strm << (VCFilter&)tool.SourceFiles;
02101     strm << (VCFilter&)tool.HeaderFiles;
02102     strm << (VCFilter&)tool.MOCFiles;
02103     strm << (VCFilter&)tool.UICFiles;
02104     strm << (VCFilter&)tool.FormFiles;
02105     strm << (VCFilter&)tool.TranslationFiles;
02106     strm << (VCFilter&)tool.LexYaccFiles;
02107     strm << (VCFilter&)tool.ResourceFiles;
02108     strm << _endFiles;
02109     strm << _begGlobals;
02110     strm << _endGlobals;
02111     strm << _endVisualStudioProject;
02112     return strm;
02113 }

Generated on Sat Nov 5 16:18:22 2005 for OPIE by  doxygen 1.4.2