Initial commit
[yaffs-website] / node_modules / node-gyp / gyp / pylib / gyp / MSVSSettings_test.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2012 Google Inc. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 """Unit tests for the MSVSSettings.py file."""
8
9 import StringIO
10 import unittest
11 import gyp.MSVSSettings as MSVSSettings
12
13
14 class TestSequenceFunctions(unittest.TestCase):
15
16   def setUp(self):
17     self.stderr = StringIO.StringIO()
18
19   def _ExpectedWarnings(self, expected):
20     """Compares recorded lines to expected warnings."""
21     self.stderr.seek(0)
22     actual = self.stderr.read().split('\n')
23     actual = [line for line in actual if line]
24     self.assertEqual(sorted(expected), sorted(actual))
25
26   def testValidateMSVSSettings_tool_names(self):
27     """Tests that only MSVS tool names are allowed."""
28     MSVSSettings.ValidateMSVSSettings(
29         {'VCCLCompilerTool': {},
30          'VCLinkerTool': {},
31          'VCMIDLTool': {},
32          'foo': {},
33          'VCResourceCompilerTool': {},
34          'VCLibrarianTool': {},
35          'VCManifestTool': {},
36          'ClCompile': {}},
37         self.stderr)
38     self._ExpectedWarnings([
39         'Warning: unrecognized tool foo',
40         'Warning: unrecognized tool ClCompile'])
41
42   def testValidateMSVSSettings_settings(self):
43     """Tests that for invalid MSVS settings."""
44     MSVSSettings.ValidateMSVSSettings(
45         {'VCCLCompilerTool': {
46             'AdditionalIncludeDirectories': 'folder1;folder2',
47             'AdditionalOptions': ['string1', 'string2'],
48             'AdditionalUsingDirectories': 'folder1;folder2',
49             'AssemblerListingLocation': 'a_file_name',
50             'AssemblerOutput': '0',
51             'BasicRuntimeChecks': '5',
52             'BrowseInformation': 'fdkslj',
53             'BrowseInformationFile': 'a_file_name',
54             'BufferSecurityCheck': 'true',
55             'CallingConvention': '-1',
56             'CompileAs': '1',
57             'DebugInformationFormat': '2',
58             'DefaultCharIsUnsigned': 'true',
59             'Detect64BitPortabilityProblems': 'true',
60             'DisableLanguageExtensions': 'true',
61             'DisableSpecificWarnings': 'string1;string2',
62             'EnableEnhancedInstructionSet': '1',
63             'EnableFiberSafeOptimizations': 'true',
64             'EnableFunctionLevelLinking': 'true',
65             'EnableIntrinsicFunctions': 'true',
66             'EnablePREfast': 'true',
67             'Enableprefast': 'bogus',
68             'ErrorReporting': '1',
69             'ExceptionHandling': '1',
70             'ExpandAttributedSource': 'true',
71             'FavorSizeOrSpeed': '1',
72             'FloatingPointExceptions': 'true',
73             'FloatingPointModel': '1',
74             'ForceConformanceInForLoopScope': 'true',
75             'ForcedIncludeFiles': 'file1;file2',
76             'ForcedUsingFiles': 'file1;file2',
77             'GeneratePreprocessedFile': '1',
78             'GenerateXMLDocumentationFiles': 'true',
79             'IgnoreStandardIncludePath': 'true',
80             'InlineFunctionExpansion': '1',
81             'KeepComments': 'true',
82             'MinimalRebuild': 'true',
83             'ObjectFile': 'a_file_name',
84             'OmitDefaultLibName': 'true',
85             'OmitFramePointers': 'true',
86             'OpenMP': 'true',
87             'Optimization': '1',
88             'PrecompiledHeaderFile': 'a_file_name',
89             'PrecompiledHeaderThrough': 'a_file_name',
90             'PreprocessorDefinitions': 'string1;string2',
91             'ProgramDataBaseFileName': 'a_file_name',
92             'RuntimeLibrary': '1',
93             'RuntimeTypeInfo': 'true',
94             'ShowIncludes': 'true',
95             'SmallerTypeCheck': 'true',
96             'StringPooling': 'true',
97             'StructMemberAlignment': '1',
98             'SuppressStartupBanner': 'true',
99             'TreatWChar_tAsBuiltInType': 'true',
100             'UndefineAllPreprocessorDefinitions': 'true',
101             'UndefinePreprocessorDefinitions': 'string1;string2',
102             'UseFullPaths': 'true',
103             'UsePrecompiledHeader': '1',
104             'UseUnicodeResponseFiles': 'true',
105             'WarnAsError': 'true',
106             'WarningLevel': '1',
107             'WholeProgramOptimization': 'true',
108             'XMLDocumentationFileName': 'a_file_name',
109             'ZZXYZ': 'bogus'},
110          'VCLinkerTool': {
111              'AdditionalDependencies': 'file1;file2',
112              'AdditionalDependencies_excluded': 'file3',
113              'AdditionalLibraryDirectories': 'folder1;folder2',
114              'AdditionalManifestDependencies': 'file1;file2',
115              'AdditionalOptions': 'a string1',
116              'AddModuleNamesToAssembly': 'file1;file2',
117              'AllowIsolation': 'true',
118              'AssemblyDebug': '2',
119              'AssemblyLinkResource': 'file1;file2',
120              'BaseAddress': 'a string1',
121              'CLRImageType': '2',
122              'CLRThreadAttribute': '2',
123              'CLRUnmanagedCodeCheck': 'true',
124              'DataExecutionPrevention': '2',
125              'DelayLoadDLLs': 'file1;file2',
126              'DelaySign': 'true',
127              'Driver': '2',
128              'EmbedManagedResourceFile': 'file1;file2',
129              'EnableCOMDATFolding': '2',
130              'EnableUAC': 'true',
131              'EntryPointSymbol': 'a string1',
132              'ErrorReporting': '2',
133              'FixedBaseAddress': '2',
134              'ForceSymbolReferences': 'file1;file2',
135              'FunctionOrder': 'a_file_name',
136              'GenerateDebugInformation': 'true',
137              'GenerateManifest': 'true',
138              'GenerateMapFile': 'true',
139              'HeapCommitSize': 'a string1',
140              'HeapReserveSize': 'a string1',
141              'IgnoreAllDefaultLibraries': 'true',
142              'IgnoreDefaultLibraryNames': 'file1;file2',
143              'IgnoreEmbeddedIDL': 'true',
144              'IgnoreImportLibrary': 'true',
145              'ImportLibrary': 'a_file_name',
146              'KeyContainer': 'a_file_name',
147              'KeyFile': 'a_file_name',
148              'LargeAddressAware': '2',
149              'LinkIncremental': '2',
150              'LinkLibraryDependencies': 'true',
151              'LinkTimeCodeGeneration': '2',
152              'ManifestFile': 'a_file_name',
153              'MapExports': 'true',
154              'MapFileName': 'a_file_name',
155              'MergedIDLBaseFileName': 'a_file_name',
156              'MergeSections': 'a string1',
157              'MidlCommandFile': 'a_file_name',
158              'ModuleDefinitionFile': 'a_file_name',
159              'OptimizeForWindows98': '1',
160              'OptimizeReferences': '2',
161              'OutputFile': 'a_file_name',
162              'PerUserRedirection': 'true',
163              'Profile': 'true',
164              'ProfileGuidedDatabase': 'a_file_name',
165              'ProgramDatabaseFile': 'a_file_name',
166              'RandomizedBaseAddress': '2',
167              'RegisterOutput': 'true',
168              'ResourceOnlyDLL': 'true',
169              'SetChecksum': 'true',
170              'ShowProgress': '2',
171              'StackCommitSize': 'a string1',
172              'StackReserveSize': 'a string1',
173              'StripPrivateSymbols': 'a_file_name',
174              'SubSystem': '2',
175              'SupportUnloadOfDelayLoadedDLL': 'true',
176              'SuppressStartupBanner': 'true',
177              'SwapRunFromCD': 'true',
178              'SwapRunFromNet': 'true',
179              'TargetMachine': '2',
180              'TerminalServerAware': '2',
181              'TurnOffAssemblyGeneration': 'true',
182              'TypeLibraryFile': 'a_file_name',
183              'TypeLibraryResourceID': '33',
184              'UACExecutionLevel': '2',
185              'UACUIAccess': 'true',
186              'UseLibraryDependencyInputs': 'true',
187              'UseUnicodeResponseFiles': 'true',
188              'Version': 'a string1'},
189          'VCMIDLTool': {
190              'AdditionalIncludeDirectories': 'folder1;folder2',
191              'AdditionalOptions': 'a string1',
192              'CPreprocessOptions': 'a string1',
193              'DefaultCharType': '1',
194              'DLLDataFileName': 'a_file_name',
195              'EnableErrorChecks': '1',
196              'ErrorCheckAllocations': 'true',
197              'ErrorCheckBounds': 'true',
198              'ErrorCheckEnumRange': 'true',
199              'ErrorCheckRefPointers': 'true',
200              'ErrorCheckStubData': 'true',
201              'GenerateStublessProxies': 'true',
202              'GenerateTypeLibrary': 'true',
203              'HeaderFileName': 'a_file_name',
204              'IgnoreStandardIncludePath': 'true',
205              'InterfaceIdentifierFileName': 'a_file_name',
206              'MkTypLibCompatible': 'true',
207              'notgood': 'bogus',
208              'OutputDirectory': 'a string1',
209              'PreprocessorDefinitions': 'string1;string2',
210              'ProxyFileName': 'a_file_name',
211              'RedirectOutputAndErrors': 'a_file_name',
212              'StructMemberAlignment': '1',
213              'SuppressStartupBanner': 'true',
214              'TargetEnvironment': '1',
215              'TypeLibraryName': 'a_file_name',
216              'UndefinePreprocessorDefinitions': 'string1;string2',
217              'ValidateParameters': 'true',
218              'WarnAsError': 'true',
219              'WarningLevel': '1'},
220          'VCResourceCompilerTool': {
221              'AdditionalOptions': 'a string1',
222              'AdditionalIncludeDirectories': 'folder1;folder2',
223              'Culture': '1003',
224              'IgnoreStandardIncludePath': 'true',
225              'notgood2': 'bogus',
226              'PreprocessorDefinitions': 'string1;string2',
227              'ResourceOutputFileName': 'a string1',
228              'ShowProgress': 'true',
229              'SuppressStartupBanner': 'true',
230              'UndefinePreprocessorDefinitions': 'string1;string2'},
231          'VCLibrarianTool': {
232              'AdditionalDependencies': 'file1;file2',
233              'AdditionalLibraryDirectories': 'folder1;folder2',
234              'AdditionalOptions': 'a string1',
235              'ExportNamedFunctions': 'string1;string2',
236              'ForceSymbolReferences': 'a string1',
237              'IgnoreAllDefaultLibraries': 'true',
238              'IgnoreSpecificDefaultLibraries': 'file1;file2',
239              'LinkLibraryDependencies': 'true',
240              'ModuleDefinitionFile': 'a_file_name',
241              'OutputFile': 'a_file_name',
242              'SuppressStartupBanner': 'true',
243              'UseUnicodeResponseFiles': 'true'},
244          'VCManifestTool': {
245              'AdditionalManifestFiles': 'file1;file2',
246              'AdditionalOptions': 'a string1',
247              'AssemblyIdentity': 'a string1',
248              'ComponentFileName': 'a_file_name',
249              'DependencyInformationFile': 'a_file_name',
250              'GenerateCatalogFiles': 'true',
251              'InputResourceManifests': 'a string1',
252              'ManifestResourceFile': 'a_file_name',
253              'OutputManifestFile': 'a_file_name',
254              'RegistrarScriptFile': 'a_file_name',
255              'ReplacementsFile': 'a_file_name',
256              'SuppressStartupBanner': 'true',
257              'TypeLibraryFile': 'a_file_name',
258              'UpdateFileHashes': 'truel',
259              'UpdateFileHashesSearchPath': 'a_file_name',
260              'UseFAT32Workaround': 'true',
261              'UseUnicodeResponseFiles': 'true',
262              'VerboseOutput': 'true'}},
263         self.stderr)
264     self._ExpectedWarnings([
265         'Warning: for VCCLCompilerTool/BasicRuntimeChecks, '
266         'index value (5) not in expected range [0, 4)',
267         'Warning: for VCCLCompilerTool/BrowseInformation, '
268         "invalid literal for int() with base 10: 'fdkslj'",
269         'Warning: for VCCLCompilerTool/CallingConvention, '
270         'index value (-1) not in expected range [0, 4)',
271         'Warning: for VCCLCompilerTool/DebugInformationFormat, '
272         'converted value for 2 not specified.',
273         'Warning: unrecognized setting VCCLCompilerTool/Enableprefast',
274         'Warning: unrecognized setting VCCLCompilerTool/ZZXYZ',
275         'Warning: for VCLinkerTool/TargetMachine, '
276         'converted value for 2 not specified.',
277         'Warning: unrecognized setting VCMIDLTool/notgood',
278         'Warning: unrecognized setting VCResourceCompilerTool/notgood2',
279         'Warning: for VCManifestTool/UpdateFileHashes, '
280         "expected bool; got 'truel'"
281         ''])
282
283   def testValidateMSBuildSettings_settings(self):
284     """Tests that for invalid MSBuild settings."""
285     MSVSSettings.ValidateMSBuildSettings(
286         {'ClCompile': {
287             'AdditionalIncludeDirectories': 'folder1;folder2',
288             'AdditionalOptions': ['string1', 'string2'],
289             'AdditionalUsingDirectories': 'folder1;folder2',
290             'AssemblerListingLocation': 'a_file_name',
291             'AssemblerOutput': 'NoListing',
292             'BasicRuntimeChecks': 'StackFrameRuntimeCheck',
293             'BrowseInformation': 'false',
294             'BrowseInformationFile': 'a_file_name',
295             'BufferSecurityCheck': 'true',
296             'BuildingInIDE': 'true',
297             'CallingConvention': 'Cdecl',
298             'CompileAs': 'CompileAsC',
299             'CompileAsManaged': 'true',
300             'CreateHotpatchableImage': 'true',
301             'DebugInformationFormat': 'ProgramDatabase',
302             'DisableLanguageExtensions': 'true',
303             'DisableSpecificWarnings': 'string1;string2',
304             'EnableEnhancedInstructionSet': 'StreamingSIMDExtensions',
305             'EnableFiberSafeOptimizations': 'true',
306             'EnablePREfast': 'true',
307             'Enableprefast': 'bogus',
308             'ErrorReporting': 'Prompt',
309             'ExceptionHandling': 'SyncCThrow',
310             'ExpandAttributedSource': 'true',
311             'FavorSizeOrSpeed': 'Neither',
312             'FloatingPointExceptions': 'true',
313             'FloatingPointModel': 'Precise',
314             'ForceConformanceInForLoopScope': 'true',
315             'ForcedIncludeFiles': 'file1;file2',
316             'ForcedUsingFiles': 'file1;file2',
317             'FunctionLevelLinking': 'false',
318             'GenerateXMLDocumentationFiles': 'true',
319             'IgnoreStandardIncludePath': 'true',
320             'InlineFunctionExpansion': 'OnlyExplicitInline',
321             'IntrinsicFunctions': 'false',
322             'MinimalRebuild': 'true',
323             'MultiProcessorCompilation': 'true',
324             'ObjectFileName': 'a_file_name',
325             'OmitDefaultLibName': 'true',
326             'OmitFramePointers': 'true',
327             'OpenMPSupport': 'true',
328             'Optimization': 'Disabled',
329             'PrecompiledHeader': 'NotUsing',
330             'PrecompiledHeaderFile': 'a_file_name',
331             'PrecompiledHeaderOutputFile': 'a_file_name',
332             'PreprocessKeepComments': 'true',
333             'PreprocessorDefinitions': 'string1;string2',
334             'PreprocessOutputPath': 'a string1',
335             'PreprocessSuppressLineNumbers': 'false',
336             'PreprocessToFile': 'false',
337             'ProcessorNumber': '33',
338             'ProgramDataBaseFileName': 'a_file_name',
339             'RuntimeLibrary': 'MultiThreaded',
340             'RuntimeTypeInfo': 'true',
341             'ShowIncludes': 'true',
342             'SmallerTypeCheck': 'true',
343             'StringPooling': 'true',
344             'StructMemberAlignment': '1Byte',
345             'SuppressStartupBanner': 'true',
346             'TrackerLogDirectory': 'a_folder',
347             'TreatSpecificWarningsAsErrors': 'string1;string2',
348             'TreatWarningAsError': 'true',
349             'TreatWChar_tAsBuiltInType': 'true',
350             'UndefineAllPreprocessorDefinitions': 'true',
351             'UndefinePreprocessorDefinitions': 'string1;string2',
352             'UseFullPaths': 'true',
353             'UseUnicodeForAssemblerListing': 'true',
354             'WarningLevel': 'TurnOffAllWarnings',
355             'WholeProgramOptimization': 'true',
356             'XMLDocumentationFileName': 'a_file_name',
357             'ZZXYZ': 'bogus'},
358          'Link': {
359              'AdditionalDependencies': 'file1;file2',
360              'AdditionalLibraryDirectories': 'folder1;folder2',
361              'AdditionalManifestDependencies': 'file1;file2',
362              'AdditionalOptions': 'a string1',
363              'AddModuleNamesToAssembly': 'file1;file2',
364              'AllowIsolation': 'true',
365              'AssemblyDebug': '',
366              'AssemblyLinkResource': 'file1;file2',
367              'BaseAddress': 'a string1',
368              'BuildingInIDE': 'true',
369              'CLRImageType': 'ForceIJWImage',
370              'CLRSupportLastError': 'Enabled',
371              'CLRThreadAttribute': 'MTAThreadingAttribute',
372              'CLRUnmanagedCodeCheck': 'true',
373              'CreateHotPatchableImage': 'X86Image',
374              'DataExecutionPrevention': 'false',
375              'DelayLoadDLLs': 'file1;file2',
376              'DelaySign': 'true',
377              'Driver': 'NotSet',
378              'EmbedManagedResourceFile': 'file1;file2',
379              'EnableCOMDATFolding': 'false',
380              'EnableUAC': 'true',
381              'EntryPointSymbol': 'a string1',
382              'FixedBaseAddress': 'false',
383              'ForceFileOutput': 'Enabled',
384              'ForceSymbolReferences': 'file1;file2',
385              'FunctionOrder': 'a_file_name',
386              'GenerateDebugInformation': 'true',
387              'GenerateMapFile': 'true',
388              'HeapCommitSize': 'a string1',
389              'HeapReserveSize': 'a string1',
390              'IgnoreAllDefaultLibraries': 'true',
391              'IgnoreEmbeddedIDL': 'true',
392              'IgnoreSpecificDefaultLibraries': 'a_file_list',
393              'ImageHasSafeExceptionHandlers': 'true',
394              'ImportLibrary': 'a_file_name',
395              'KeyContainer': 'a_file_name',
396              'KeyFile': 'a_file_name',
397              'LargeAddressAware': 'false',
398              'LinkDLL': 'true',
399              'LinkErrorReporting': 'SendErrorReport',
400              'LinkStatus': 'true',
401              'LinkTimeCodeGeneration': 'UseLinkTimeCodeGeneration',
402              'ManifestFile': 'a_file_name',
403              'MapExports': 'true',
404              'MapFileName': 'a_file_name',
405              'MergedIDLBaseFileName': 'a_file_name',
406              'MergeSections': 'a string1',
407              'MidlCommandFile': 'a_file_name',
408              'MinimumRequiredVersion': 'a string1',
409              'ModuleDefinitionFile': 'a_file_name',
410              'MSDOSStubFileName': 'a_file_name',
411              'NoEntryPoint': 'true',
412              'OptimizeReferences': 'false',
413              'OutputFile': 'a_file_name',
414              'PerUserRedirection': 'true',
415              'PreventDllBinding': 'true',
416              'Profile': 'true',
417              'ProfileGuidedDatabase': 'a_file_name',
418              'ProgramDatabaseFile': 'a_file_name',
419              'RandomizedBaseAddress': 'false',
420              'RegisterOutput': 'true',
421              'SectionAlignment': '33',
422              'SetChecksum': 'true',
423              'ShowProgress': 'LinkVerboseREF',
424              'SpecifySectionAttributes': 'a string1',
425              'StackCommitSize': 'a string1',
426              'StackReserveSize': 'a string1',
427              'StripPrivateSymbols': 'a_file_name',
428              'SubSystem': 'Console',
429              'SupportNobindOfDelayLoadedDLL': 'true',
430              'SupportUnloadOfDelayLoadedDLL': 'true',
431              'SuppressStartupBanner': 'true',
432              'SwapRunFromCD': 'true',
433              'SwapRunFromNET': 'true',
434              'TargetMachine': 'MachineX86',
435              'TerminalServerAware': 'false',
436              'TrackerLogDirectory': 'a_folder',
437              'TreatLinkerWarningAsErrors': 'true',
438              'TurnOffAssemblyGeneration': 'true',
439              'TypeLibraryFile': 'a_file_name',
440              'TypeLibraryResourceID': '33',
441              'UACExecutionLevel': 'AsInvoker',
442              'UACUIAccess': 'true',
443              'Version': 'a string1'},
444          'ResourceCompile': {
445              'AdditionalIncludeDirectories': 'folder1;folder2',
446              'AdditionalOptions': 'a string1',
447              'Culture': '0x236',
448              'IgnoreStandardIncludePath': 'true',
449              'NullTerminateStrings': 'true',
450              'PreprocessorDefinitions': 'string1;string2',
451              'ResourceOutputFileName': 'a string1',
452              'ShowProgress': 'true',
453              'SuppressStartupBanner': 'true',
454              'TrackerLogDirectory': 'a_folder',
455              'UndefinePreprocessorDefinitions': 'string1;string2'},
456          'Midl': {
457              'AdditionalIncludeDirectories': 'folder1;folder2',
458              'AdditionalOptions': 'a string1',
459              'ApplicationConfigurationMode': 'true',
460              'ClientStubFile': 'a_file_name',
461              'CPreprocessOptions': 'a string1',
462              'DefaultCharType': 'Signed',
463              'DllDataFileName': 'a_file_name',
464              'EnableErrorChecks': 'EnableCustom',
465              'ErrorCheckAllocations': 'true',
466              'ErrorCheckBounds': 'true',
467              'ErrorCheckEnumRange': 'true',
468              'ErrorCheckRefPointers': 'true',
469              'ErrorCheckStubData': 'true',
470              'GenerateClientFiles': 'Stub',
471              'GenerateServerFiles': 'None',
472              'GenerateStublessProxies': 'true',
473              'GenerateTypeLibrary': 'true',
474              'HeaderFileName': 'a_file_name',
475              'IgnoreStandardIncludePath': 'true',
476              'InterfaceIdentifierFileName': 'a_file_name',
477              'LocaleID': '33',
478              'MkTypLibCompatible': 'true',
479              'OutputDirectory': 'a string1',
480              'PreprocessorDefinitions': 'string1;string2',
481              'ProxyFileName': 'a_file_name',
482              'RedirectOutputAndErrors': 'a_file_name',
483              'ServerStubFile': 'a_file_name',
484              'StructMemberAlignment': 'NotSet',
485              'SuppressCompilerWarnings': 'true',
486              'SuppressStartupBanner': 'true',
487              'TargetEnvironment': 'Itanium',
488              'TrackerLogDirectory': 'a_folder',
489              'TypeLibFormat': 'NewFormat',
490              'TypeLibraryName': 'a_file_name',
491              'UndefinePreprocessorDefinitions': 'string1;string2',
492              'ValidateAllParameters': 'true',
493              'WarnAsError': 'true',
494              'WarningLevel': '1'},
495          'Lib': {
496              'AdditionalDependencies': 'file1;file2',
497              'AdditionalLibraryDirectories': 'folder1;folder2',
498              'AdditionalOptions': 'a string1',
499              'DisplayLibrary': 'a string1',
500              'ErrorReporting': 'PromptImmediately',
501              'ExportNamedFunctions': 'string1;string2',
502              'ForceSymbolReferences': 'a string1',
503              'IgnoreAllDefaultLibraries': 'true',
504              'IgnoreSpecificDefaultLibraries': 'file1;file2',
505              'LinkTimeCodeGeneration': 'true',
506              'MinimumRequiredVersion': 'a string1',
507              'ModuleDefinitionFile': 'a_file_name',
508              'Name': 'a_file_name',
509              'OutputFile': 'a_file_name',
510              'RemoveObjects': 'file1;file2',
511              'SubSystem': 'Console',
512              'SuppressStartupBanner': 'true',
513              'TargetMachine': 'MachineX86i',
514              'TrackerLogDirectory': 'a_folder',
515              'TreatLibWarningAsErrors': 'true',
516              'UseUnicodeResponseFiles': 'true',
517              'Verbose': 'true'},
518          'Manifest': {
519              'AdditionalManifestFiles': 'file1;file2',
520              'AdditionalOptions': 'a string1',
521              'AssemblyIdentity': 'a string1',
522              'ComponentFileName': 'a_file_name',
523              'EnableDPIAwareness': 'fal',
524              'GenerateCatalogFiles': 'truel',
525              'GenerateCategoryTags': 'true',
526              'InputResourceManifests': 'a string1',
527              'ManifestFromManagedAssembly': 'a_file_name',
528              'notgood3': 'bogus',
529              'OutputManifestFile': 'a_file_name',
530              'OutputResourceManifests': 'a string1',
531              'RegistrarScriptFile': 'a_file_name',
532              'ReplacementsFile': 'a_file_name',
533              'SuppressDependencyElement': 'true',
534              'SuppressStartupBanner': 'true',
535              'TrackerLogDirectory': 'a_folder',
536              'TypeLibraryFile': 'a_file_name',
537              'UpdateFileHashes': 'true',
538              'UpdateFileHashesSearchPath': 'a_file_name',
539              'VerboseOutput': 'true'},
540          'ProjectReference': {
541              'LinkLibraryDependencies': 'true',
542              'UseLibraryDependencyInputs': 'true'},
543          'ManifestResourceCompile': {
544              'ResourceOutputFileName': 'a_file_name'},
545          '': {
546              'EmbedManifest': 'true',
547              'GenerateManifest': 'true',
548              'IgnoreImportLibrary': 'true',
549              'LinkIncremental': 'false'}},
550         self.stderr)
551     self._ExpectedWarnings([
552         'Warning: unrecognized setting ClCompile/Enableprefast',
553         'Warning: unrecognized setting ClCompile/ZZXYZ',
554         'Warning: unrecognized setting Manifest/notgood3',
555         'Warning: for Manifest/GenerateCatalogFiles, '
556         "expected bool; got 'truel'",
557         'Warning: for Lib/TargetMachine, unrecognized enumerated value '
558         'MachineX86i',
559         "Warning: for Manifest/EnableDPIAwareness, expected bool; got 'fal'"])
560
561   def testConvertToMSBuildSettings_empty(self):
562     """Tests an empty conversion."""
563     msvs_settings = {}
564     expected_msbuild_settings = {}
565     actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(
566         msvs_settings,
567         self.stderr)
568     self.assertEqual(expected_msbuild_settings, actual_msbuild_settings)
569     self._ExpectedWarnings([])
570
571   def testConvertToMSBuildSettings_minimal(self):
572     """Tests a minimal conversion."""
573     msvs_settings = {
574         'VCCLCompilerTool': {
575             'AdditionalIncludeDirectories': 'dir1',
576             'AdditionalOptions': '/foo',
577             'BasicRuntimeChecks': '0',
578             },
579         'VCLinkerTool': {
580             'LinkTimeCodeGeneration': '1',
581             'ErrorReporting': '1',
582             'DataExecutionPrevention': '2',
583             },
584         }
585     expected_msbuild_settings = {
586         'ClCompile': {
587             'AdditionalIncludeDirectories': 'dir1',
588             'AdditionalOptions': '/foo',
589             'BasicRuntimeChecks': 'Default',
590             },
591         'Link': {
592             'LinkTimeCodeGeneration': 'UseLinkTimeCodeGeneration',
593             'LinkErrorReporting': 'PromptImmediately',
594             'DataExecutionPrevention': 'true',
595             },
596         }
597     actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(
598         msvs_settings,
599         self.stderr)
600     self.assertEqual(expected_msbuild_settings, actual_msbuild_settings)
601     self._ExpectedWarnings([])
602
603   def testConvertToMSBuildSettings_warnings(self):
604     """Tests conversion that generates warnings."""
605     msvs_settings = {
606         'VCCLCompilerTool': {
607             'AdditionalIncludeDirectories': '1',
608             'AdditionalOptions': '2',
609             # These are incorrect values:
610             'BasicRuntimeChecks': '12',
611             'BrowseInformation': '21',
612             'UsePrecompiledHeader': '13',
613             'GeneratePreprocessedFile': '14'},
614         'VCLinkerTool': {
615             # These are incorrect values:
616             'Driver': '10',
617             'LinkTimeCodeGeneration': '31',
618             'ErrorReporting': '21',
619             'FixedBaseAddress': '6'},
620         'VCResourceCompilerTool': {
621             # Custom
622             'Culture': '1003'}}
623     expected_msbuild_settings = {
624         'ClCompile': {
625             'AdditionalIncludeDirectories': '1',
626             'AdditionalOptions': '2'},
627         'Link': {},
628         'ResourceCompile': {
629             # Custom
630             'Culture': '0x03eb'}}
631     actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(
632         msvs_settings,
633         self.stderr)
634     self.assertEqual(expected_msbuild_settings, actual_msbuild_settings)
635     self._ExpectedWarnings([
636         'Warning: while converting VCCLCompilerTool/BasicRuntimeChecks to '
637         'MSBuild, index value (12) not in expected range [0, 4)',
638         'Warning: while converting VCCLCompilerTool/BrowseInformation to '
639         'MSBuild, index value (21) not in expected range [0, 3)',
640         'Warning: while converting VCCLCompilerTool/UsePrecompiledHeader to '
641         'MSBuild, index value (13) not in expected range [0, 3)',
642         'Warning: while converting VCCLCompilerTool/GeneratePreprocessedFile to '
643         'MSBuild, value must be one of [0, 1, 2]; got 14',
644
645         'Warning: while converting VCLinkerTool/Driver to '
646         'MSBuild, index value (10) not in expected range [0, 4)',
647         'Warning: while converting VCLinkerTool/LinkTimeCodeGeneration to '
648         'MSBuild, index value (31) not in expected range [0, 5)',
649         'Warning: while converting VCLinkerTool/ErrorReporting to '
650         'MSBuild, index value (21) not in expected range [0, 3)',
651         'Warning: while converting VCLinkerTool/FixedBaseAddress to '
652         'MSBuild, index value (6) not in expected range [0, 3)',
653         ])
654
655   def testConvertToMSBuildSettings_full_synthetic(self):
656     """Tests conversion of all the MSBuild settings."""
657     msvs_settings = {
658         'VCCLCompilerTool': {
659             'AdditionalIncludeDirectories': 'folder1;folder2;folder3',
660             'AdditionalOptions': 'a_string',
661             'AdditionalUsingDirectories': 'folder1;folder2;folder3',
662             'AssemblerListingLocation': 'a_file_name',
663             'AssemblerOutput': '0',
664             'BasicRuntimeChecks': '1',
665             'BrowseInformation': '2',
666             'BrowseInformationFile': 'a_file_name',
667             'BufferSecurityCheck': 'true',
668             'CallingConvention': '0',
669             'CompileAs': '1',
670             'DebugInformationFormat': '4',
671             'DefaultCharIsUnsigned': 'true',
672             'Detect64BitPortabilityProblems': 'true',
673             'DisableLanguageExtensions': 'true',
674             'DisableSpecificWarnings': 'd1;d2;d3',
675             'EnableEnhancedInstructionSet': '0',
676             'EnableFiberSafeOptimizations': 'true',
677             'EnableFunctionLevelLinking': 'true',
678             'EnableIntrinsicFunctions': 'true',
679             'EnablePREfast': 'true',
680             'ErrorReporting': '1',
681             'ExceptionHandling': '2',
682             'ExpandAttributedSource': 'true',
683             'FavorSizeOrSpeed': '0',
684             'FloatingPointExceptions': 'true',
685             'FloatingPointModel': '1',
686             'ForceConformanceInForLoopScope': 'true',
687             'ForcedIncludeFiles': 'file1;file2;file3',
688             'ForcedUsingFiles': 'file1;file2;file3',
689             'GeneratePreprocessedFile': '1',
690             'GenerateXMLDocumentationFiles': 'true',
691             'IgnoreStandardIncludePath': 'true',
692             'InlineFunctionExpansion': '2',
693             'KeepComments': 'true',
694             'MinimalRebuild': 'true',
695             'ObjectFile': 'a_file_name',
696             'OmitDefaultLibName': 'true',
697             'OmitFramePointers': 'true',
698             'OpenMP': 'true',
699             'Optimization': '3',
700             'PrecompiledHeaderFile': 'a_file_name',
701             'PrecompiledHeaderThrough': 'a_file_name',
702             'PreprocessorDefinitions': 'd1;d2;d3',
703             'ProgramDataBaseFileName': 'a_file_name',
704             'RuntimeLibrary': '0',
705             'RuntimeTypeInfo': 'true',
706             'ShowIncludes': 'true',
707             'SmallerTypeCheck': 'true',
708             'StringPooling': 'true',
709             'StructMemberAlignment': '1',
710             'SuppressStartupBanner': 'true',
711             'TreatWChar_tAsBuiltInType': 'true',
712             'UndefineAllPreprocessorDefinitions': 'true',
713             'UndefinePreprocessorDefinitions': 'd1;d2;d3',
714             'UseFullPaths': 'true',
715             'UsePrecompiledHeader': '1',
716             'UseUnicodeResponseFiles': 'true',
717             'WarnAsError': 'true',
718             'WarningLevel': '2',
719             'WholeProgramOptimization': 'true',
720             'XMLDocumentationFileName': 'a_file_name'},
721         'VCLinkerTool': {
722             'AdditionalDependencies': 'file1;file2;file3',
723             'AdditionalLibraryDirectories': 'folder1;folder2;folder3',
724             'AdditionalLibraryDirectories_excluded': 'folder1;folder2;folder3',
725             'AdditionalManifestDependencies': 'file1;file2;file3',
726             'AdditionalOptions': 'a_string',
727             'AddModuleNamesToAssembly': 'file1;file2;file3',
728             'AllowIsolation': 'true',
729             'AssemblyDebug': '0',
730             'AssemblyLinkResource': 'file1;file2;file3',
731             'BaseAddress': 'a_string',
732             'CLRImageType': '1',
733             'CLRThreadAttribute': '2',
734             'CLRUnmanagedCodeCheck': 'true',
735             'DataExecutionPrevention': '0',
736             'DelayLoadDLLs': 'file1;file2;file3',
737             'DelaySign': 'true',
738             'Driver': '1',
739             'EmbedManagedResourceFile': 'file1;file2;file3',
740             'EnableCOMDATFolding': '0',
741             'EnableUAC': 'true',
742             'EntryPointSymbol': 'a_string',
743             'ErrorReporting': '0',
744             'FixedBaseAddress': '1',
745             'ForceSymbolReferences': 'file1;file2;file3',
746             'FunctionOrder': 'a_file_name',
747             'GenerateDebugInformation': 'true',
748             'GenerateManifest': 'true',
749             'GenerateMapFile': 'true',
750             'HeapCommitSize': 'a_string',
751             'HeapReserveSize': 'a_string',
752             'IgnoreAllDefaultLibraries': 'true',
753             'IgnoreDefaultLibraryNames': 'file1;file2;file3',
754             'IgnoreEmbeddedIDL': 'true',
755             'IgnoreImportLibrary': 'true',
756             'ImportLibrary': 'a_file_name',
757             'KeyContainer': 'a_file_name',
758             'KeyFile': 'a_file_name',
759             'LargeAddressAware': '2',
760             'LinkIncremental': '1',
761             'LinkLibraryDependencies': 'true',
762             'LinkTimeCodeGeneration': '2',
763             'ManifestFile': 'a_file_name',
764             'MapExports': 'true',
765             'MapFileName': 'a_file_name',
766             'MergedIDLBaseFileName': 'a_file_name',
767             'MergeSections': 'a_string',
768             'MidlCommandFile': 'a_file_name',
769             'ModuleDefinitionFile': 'a_file_name',
770             'OptimizeForWindows98': '1',
771             'OptimizeReferences': '0',
772             'OutputFile': 'a_file_name',
773             'PerUserRedirection': 'true',
774             'Profile': 'true',
775             'ProfileGuidedDatabase': 'a_file_name',
776             'ProgramDatabaseFile': 'a_file_name',
777             'RandomizedBaseAddress': '1',
778             'RegisterOutput': 'true',
779             'ResourceOnlyDLL': 'true',
780             'SetChecksum': 'true',
781             'ShowProgress': '0',
782             'StackCommitSize': 'a_string',
783             'StackReserveSize': 'a_string',
784             'StripPrivateSymbols': 'a_file_name',
785             'SubSystem': '2',
786             'SupportUnloadOfDelayLoadedDLL': 'true',
787             'SuppressStartupBanner': 'true',
788             'SwapRunFromCD': 'true',
789             'SwapRunFromNet': 'true',
790             'TargetMachine': '3',
791             'TerminalServerAware': '2',
792             'TurnOffAssemblyGeneration': 'true',
793             'TypeLibraryFile': 'a_file_name',
794             'TypeLibraryResourceID': '33',
795             'UACExecutionLevel': '1',
796             'UACUIAccess': 'true',
797             'UseLibraryDependencyInputs': 'false',
798             'UseUnicodeResponseFiles': 'true',
799             'Version': 'a_string'},
800         'VCResourceCompilerTool': {
801             'AdditionalIncludeDirectories': 'folder1;folder2;folder3',
802             'AdditionalOptions': 'a_string',
803             'Culture': '1003',
804             'IgnoreStandardIncludePath': 'true',
805             'PreprocessorDefinitions': 'd1;d2;d3',
806             'ResourceOutputFileName': 'a_string',
807             'ShowProgress': 'true',
808             'SuppressStartupBanner': 'true',
809             'UndefinePreprocessorDefinitions': 'd1;d2;d3'},
810         'VCMIDLTool': {
811             'AdditionalIncludeDirectories': 'folder1;folder2;folder3',
812             'AdditionalOptions': 'a_string',
813             'CPreprocessOptions': 'a_string',
814             'DefaultCharType': '0',
815             'DLLDataFileName': 'a_file_name',
816             'EnableErrorChecks': '2',
817             'ErrorCheckAllocations': 'true',
818             'ErrorCheckBounds': 'true',
819             'ErrorCheckEnumRange': 'true',
820             'ErrorCheckRefPointers': 'true',
821             'ErrorCheckStubData': 'true',
822             'GenerateStublessProxies': 'true',
823             'GenerateTypeLibrary': 'true',
824             'HeaderFileName': 'a_file_name',
825             'IgnoreStandardIncludePath': 'true',
826             'InterfaceIdentifierFileName': 'a_file_name',
827             'MkTypLibCompatible': 'true',
828             'OutputDirectory': 'a_string',
829             'PreprocessorDefinitions': 'd1;d2;d3',
830             'ProxyFileName': 'a_file_name',
831             'RedirectOutputAndErrors': 'a_file_name',
832             'StructMemberAlignment': '3',
833             'SuppressStartupBanner': 'true',
834             'TargetEnvironment': '1',
835             'TypeLibraryName': 'a_file_name',
836             'UndefinePreprocessorDefinitions': 'd1;d2;d3',
837             'ValidateParameters': 'true',
838             'WarnAsError': 'true',
839             'WarningLevel': '4'},
840         'VCLibrarianTool': {
841             'AdditionalDependencies': 'file1;file2;file3',
842             'AdditionalLibraryDirectories': 'folder1;folder2;folder3',
843             'AdditionalLibraryDirectories_excluded': 'folder1;folder2;folder3',
844             'AdditionalOptions': 'a_string',
845             'ExportNamedFunctions': 'd1;d2;d3',
846             'ForceSymbolReferences': 'a_string',
847             'IgnoreAllDefaultLibraries': 'true',
848             'IgnoreSpecificDefaultLibraries': 'file1;file2;file3',
849             'LinkLibraryDependencies': 'true',
850             'ModuleDefinitionFile': 'a_file_name',
851             'OutputFile': 'a_file_name',
852             'SuppressStartupBanner': 'true',
853             'UseUnicodeResponseFiles': 'true'},
854         'VCManifestTool': {
855             'AdditionalManifestFiles': 'file1;file2;file3',
856             'AdditionalOptions': 'a_string',
857             'AssemblyIdentity': 'a_string',
858             'ComponentFileName': 'a_file_name',
859             'DependencyInformationFile': 'a_file_name',
860             'EmbedManifest': 'true',
861             'GenerateCatalogFiles': 'true',
862             'InputResourceManifests': 'a_string',
863             'ManifestResourceFile': 'my_name',
864             'OutputManifestFile': 'a_file_name',
865             'RegistrarScriptFile': 'a_file_name',
866             'ReplacementsFile': 'a_file_name',
867             'SuppressStartupBanner': 'true',
868             'TypeLibraryFile': 'a_file_name',
869             'UpdateFileHashes': 'true',
870             'UpdateFileHashesSearchPath': 'a_file_name',
871             'UseFAT32Workaround': 'true',
872             'UseUnicodeResponseFiles': 'true',
873             'VerboseOutput': 'true'}}
874     expected_msbuild_settings = {
875         'ClCompile': {
876             'AdditionalIncludeDirectories': 'folder1;folder2;folder3',
877             'AdditionalOptions': 'a_string /J',
878             'AdditionalUsingDirectories': 'folder1;folder2;folder3',
879             'AssemblerListingLocation': 'a_file_name',
880             'AssemblerOutput': 'NoListing',
881             'BasicRuntimeChecks': 'StackFrameRuntimeCheck',
882             'BrowseInformation': 'true',
883             'BrowseInformationFile': 'a_file_name',
884             'BufferSecurityCheck': 'true',
885             'CallingConvention': 'Cdecl',
886             'CompileAs': 'CompileAsC',
887             'DebugInformationFormat': 'EditAndContinue',
888             'DisableLanguageExtensions': 'true',
889             'DisableSpecificWarnings': 'd1;d2;d3',
890             'EnableEnhancedInstructionSet': 'NotSet',
891             'EnableFiberSafeOptimizations': 'true',
892             'EnablePREfast': 'true',
893             'ErrorReporting': 'Prompt',
894             'ExceptionHandling': 'Async',
895             'ExpandAttributedSource': 'true',
896             'FavorSizeOrSpeed': 'Neither',
897             'FloatingPointExceptions': 'true',
898             'FloatingPointModel': 'Strict',
899             'ForceConformanceInForLoopScope': 'true',
900             'ForcedIncludeFiles': 'file1;file2;file3',
901             'ForcedUsingFiles': 'file1;file2;file3',
902             'FunctionLevelLinking': 'true',
903             'GenerateXMLDocumentationFiles': 'true',
904             'IgnoreStandardIncludePath': 'true',
905             'InlineFunctionExpansion': 'AnySuitable',
906             'IntrinsicFunctions': 'true',
907             'MinimalRebuild': 'true',
908             'ObjectFileName': 'a_file_name',
909             'OmitDefaultLibName': 'true',
910             'OmitFramePointers': 'true',
911             'OpenMPSupport': 'true',
912             'Optimization': 'Full',
913             'PrecompiledHeader': 'Create',
914             'PrecompiledHeaderFile': 'a_file_name',
915             'PrecompiledHeaderOutputFile': 'a_file_name',
916             'PreprocessKeepComments': 'true',
917             'PreprocessorDefinitions': 'd1;d2;d3',
918             'PreprocessSuppressLineNumbers': 'false',
919             'PreprocessToFile': 'true',
920             'ProgramDataBaseFileName': 'a_file_name',
921             'RuntimeLibrary': 'MultiThreaded',
922             'RuntimeTypeInfo': 'true',
923             'ShowIncludes': 'true',
924             'SmallerTypeCheck': 'true',
925             'StringPooling': 'true',
926             'StructMemberAlignment': '1Byte',
927             'SuppressStartupBanner': 'true',
928             'TreatWarningAsError': 'true',
929             'TreatWChar_tAsBuiltInType': 'true',
930             'UndefineAllPreprocessorDefinitions': 'true',
931             'UndefinePreprocessorDefinitions': 'd1;d2;d3',
932             'UseFullPaths': 'true',
933             'WarningLevel': 'Level2',
934             'WholeProgramOptimization': 'true',
935             'XMLDocumentationFileName': 'a_file_name'},
936         'Link': {
937             'AdditionalDependencies': 'file1;file2;file3',
938             'AdditionalLibraryDirectories': 'folder1;folder2;folder3',
939             'AdditionalManifestDependencies': 'file1;file2;file3',
940             'AdditionalOptions': 'a_string',
941             'AddModuleNamesToAssembly': 'file1;file2;file3',
942             'AllowIsolation': 'true',
943             'AssemblyDebug': '',
944             'AssemblyLinkResource': 'file1;file2;file3',
945             'BaseAddress': 'a_string',
946             'CLRImageType': 'ForceIJWImage',
947             'CLRThreadAttribute': 'STAThreadingAttribute',
948             'CLRUnmanagedCodeCheck': 'true',
949             'DataExecutionPrevention': '',
950             'DelayLoadDLLs': 'file1;file2;file3',
951             'DelaySign': 'true',
952             'Driver': 'Driver',
953             'EmbedManagedResourceFile': 'file1;file2;file3',
954             'EnableCOMDATFolding': '',
955             'EnableUAC': 'true',
956             'EntryPointSymbol': 'a_string',
957             'FixedBaseAddress': 'false',
958             'ForceSymbolReferences': 'file1;file2;file3',
959             'FunctionOrder': 'a_file_name',
960             'GenerateDebugInformation': 'true',
961             'GenerateMapFile': 'true',
962             'HeapCommitSize': 'a_string',
963             'HeapReserveSize': 'a_string',
964             'IgnoreAllDefaultLibraries': 'true',
965             'IgnoreEmbeddedIDL': 'true',
966             'IgnoreSpecificDefaultLibraries': 'file1;file2;file3',
967             'ImportLibrary': 'a_file_name',
968             'KeyContainer': 'a_file_name',
969             'KeyFile': 'a_file_name',
970             'LargeAddressAware': 'true',
971             'LinkErrorReporting': 'NoErrorReport',
972             'LinkTimeCodeGeneration': 'PGInstrument',
973             'ManifestFile': 'a_file_name',
974             'MapExports': 'true',
975             'MapFileName': 'a_file_name',
976             'MergedIDLBaseFileName': 'a_file_name',
977             'MergeSections': 'a_string',
978             'MidlCommandFile': 'a_file_name',
979             'ModuleDefinitionFile': 'a_file_name',
980             'NoEntryPoint': 'true',
981             'OptimizeReferences': '',
982             'OutputFile': 'a_file_name',
983             'PerUserRedirection': 'true',
984             'Profile': 'true',
985             'ProfileGuidedDatabase': 'a_file_name',
986             'ProgramDatabaseFile': 'a_file_name',
987             'RandomizedBaseAddress': 'false',
988             'RegisterOutput': 'true',
989             'SetChecksum': 'true',
990             'ShowProgress': 'NotSet',
991             'StackCommitSize': 'a_string',
992             'StackReserveSize': 'a_string',
993             'StripPrivateSymbols': 'a_file_name',
994             'SubSystem': 'Windows',
995             'SupportUnloadOfDelayLoadedDLL': 'true',
996             'SuppressStartupBanner': 'true',
997             'SwapRunFromCD': 'true',
998             'SwapRunFromNET': 'true',
999             'TargetMachine': 'MachineARM',
1000             'TerminalServerAware': 'true',
1001             'TurnOffAssemblyGeneration': 'true',
1002             'TypeLibraryFile': 'a_file_name',
1003             'TypeLibraryResourceID': '33',
1004             'UACExecutionLevel': 'HighestAvailable',
1005             'UACUIAccess': 'true',
1006             'Version': 'a_string'},
1007         'ResourceCompile': {
1008             'AdditionalIncludeDirectories': 'folder1;folder2;folder3',
1009             'AdditionalOptions': 'a_string',
1010             'Culture': '0x03eb',
1011             'IgnoreStandardIncludePath': 'true',
1012             'PreprocessorDefinitions': 'd1;d2;d3',
1013             'ResourceOutputFileName': 'a_string',
1014             'ShowProgress': 'true',
1015             'SuppressStartupBanner': 'true',
1016             'UndefinePreprocessorDefinitions': 'd1;d2;d3'},
1017         'Midl': {
1018             'AdditionalIncludeDirectories': 'folder1;folder2;folder3',
1019             'AdditionalOptions': 'a_string',
1020             'CPreprocessOptions': 'a_string',
1021             'DefaultCharType': 'Unsigned',
1022             'DllDataFileName': 'a_file_name',
1023             'EnableErrorChecks': 'All',
1024             'ErrorCheckAllocations': 'true',
1025             'ErrorCheckBounds': 'true',
1026             'ErrorCheckEnumRange': 'true',
1027             'ErrorCheckRefPointers': 'true',
1028             'ErrorCheckStubData': 'true',
1029             'GenerateStublessProxies': 'true',
1030             'GenerateTypeLibrary': 'true',
1031             'HeaderFileName': 'a_file_name',
1032             'IgnoreStandardIncludePath': 'true',
1033             'InterfaceIdentifierFileName': 'a_file_name',
1034             'MkTypLibCompatible': 'true',
1035             'OutputDirectory': 'a_string',
1036             'PreprocessorDefinitions': 'd1;d2;d3',
1037             'ProxyFileName': 'a_file_name',
1038             'RedirectOutputAndErrors': 'a_file_name',
1039             'StructMemberAlignment': '4',
1040             'SuppressStartupBanner': 'true',
1041             'TargetEnvironment': 'Win32',
1042             'TypeLibraryName': 'a_file_name',
1043             'UndefinePreprocessorDefinitions': 'd1;d2;d3',
1044             'ValidateAllParameters': 'true',
1045             'WarnAsError': 'true',
1046             'WarningLevel': '4'},
1047         'Lib': {
1048             'AdditionalDependencies': 'file1;file2;file3',
1049             'AdditionalLibraryDirectories': 'folder1;folder2;folder3',
1050             'AdditionalOptions': 'a_string',
1051             'ExportNamedFunctions': 'd1;d2;d3',
1052             'ForceSymbolReferences': 'a_string',
1053             'IgnoreAllDefaultLibraries': 'true',
1054             'IgnoreSpecificDefaultLibraries': 'file1;file2;file3',
1055             'ModuleDefinitionFile': 'a_file_name',
1056             'OutputFile': 'a_file_name',
1057             'SuppressStartupBanner': 'true',
1058             'UseUnicodeResponseFiles': 'true'},
1059         'Manifest': {
1060             'AdditionalManifestFiles': 'file1;file2;file3',
1061             'AdditionalOptions': 'a_string',
1062             'AssemblyIdentity': 'a_string',
1063             'ComponentFileName': 'a_file_name',
1064             'GenerateCatalogFiles': 'true',
1065             'InputResourceManifests': 'a_string',
1066             'OutputManifestFile': 'a_file_name',
1067             'RegistrarScriptFile': 'a_file_name',
1068             'ReplacementsFile': 'a_file_name',
1069             'SuppressStartupBanner': 'true',
1070             'TypeLibraryFile': 'a_file_name',
1071             'UpdateFileHashes': 'true',
1072             'UpdateFileHashesSearchPath': 'a_file_name',
1073             'VerboseOutput': 'true'},
1074         'ManifestResourceCompile': {
1075             'ResourceOutputFileName': 'my_name'},
1076         'ProjectReference': {
1077             'LinkLibraryDependencies': 'true',
1078             'UseLibraryDependencyInputs': 'false'},
1079         '': {
1080             'EmbedManifest': 'true',
1081             'GenerateManifest': 'true',
1082             'IgnoreImportLibrary': 'true',
1083             'LinkIncremental': 'false'}}
1084     actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(
1085         msvs_settings,
1086         self.stderr)
1087     self.assertEqual(expected_msbuild_settings, actual_msbuild_settings)
1088     self._ExpectedWarnings([])
1089
1090   def testConvertToMSBuildSettings_actual(self):
1091     """Tests the conversion of an actual project.
1092
1093     A VS2008 project with most of the options defined was created through the
1094     VS2008 IDE.  It was then converted to VS2010.  The tool settings found in
1095     the .vcproj and .vcxproj files were converted to the two dictionaries
1096     msvs_settings and expected_msbuild_settings.
1097
1098     Note that for many settings, the VS2010 converter adds macros like
1099     %(AdditionalIncludeDirectories) to make sure than inherited values are
1100     included.  Since the Gyp projects we generate do not use inheritance,
1101     we removed these macros.  They were:
1102         ClCompile:
1103             AdditionalIncludeDirectories:  ';%(AdditionalIncludeDirectories)'
1104             AdditionalOptions:  ' %(AdditionalOptions)'
1105             AdditionalUsingDirectories:  ';%(AdditionalUsingDirectories)'
1106             DisableSpecificWarnings: ';%(DisableSpecificWarnings)',
1107             ForcedIncludeFiles:  ';%(ForcedIncludeFiles)',
1108             ForcedUsingFiles:  ';%(ForcedUsingFiles)',
1109             PreprocessorDefinitions:  ';%(PreprocessorDefinitions)',
1110             UndefinePreprocessorDefinitions:
1111                 ';%(UndefinePreprocessorDefinitions)',
1112         Link:
1113             AdditionalDependencies:  ';%(AdditionalDependencies)',
1114             AdditionalLibraryDirectories:  ';%(AdditionalLibraryDirectories)',
1115             AdditionalManifestDependencies:
1116                 ';%(AdditionalManifestDependencies)',
1117             AdditionalOptions:  ' %(AdditionalOptions)',
1118             AddModuleNamesToAssembly:  ';%(AddModuleNamesToAssembly)',
1119             AssemblyLinkResource:  ';%(AssemblyLinkResource)',
1120             DelayLoadDLLs:  ';%(DelayLoadDLLs)',
1121             EmbedManagedResourceFile:  ';%(EmbedManagedResourceFile)',
1122             ForceSymbolReferences:  ';%(ForceSymbolReferences)',
1123             IgnoreSpecificDefaultLibraries:
1124                 ';%(IgnoreSpecificDefaultLibraries)',
1125         ResourceCompile:
1126             AdditionalIncludeDirectories:  ';%(AdditionalIncludeDirectories)',
1127             AdditionalOptions:  ' %(AdditionalOptions)',
1128             PreprocessorDefinitions:  ';%(PreprocessorDefinitions)',
1129         Manifest:
1130             AdditionalManifestFiles:  ';%(AdditionalManifestFiles)',
1131             AdditionalOptions:  ' %(AdditionalOptions)',
1132             InputResourceManifests:  ';%(InputResourceManifests)',
1133     """
1134     msvs_settings = {
1135         'VCCLCompilerTool': {
1136             'AdditionalIncludeDirectories': 'dir1',
1137             'AdditionalOptions': '/more',
1138             'AdditionalUsingDirectories': 'test',
1139             'AssemblerListingLocation': '$(IntDir)\\a',
1140             'AssemblerOutput': '1',
1141             'BasicRuntimeChecks': '3',
1142             'BrowseInformation': '1',
1143             'BrowseInformationFile': '$(IntDir)\\e',
1144             'BufferSecurityCheck': 'false',
1145             'CallingConvention': '1',
1146             'CompileAs': '1',
1147             'DebugInformationFormat': '4',
1148             'DefaultCharIsUnsigned': 'true',
1149             'Detect64BitPortabilityProblems': 'true',
1150             'DisableLanguageExtensions': 'true',
1151             'DisableSpecificWarnings': 'abc',
1152             'EnableEnhancedInstructionSet': '1',
1153             'EnableFiberSafeOptimizations': 'true',
1154             'EnableFunctionLevelLinking': 'true',
1155             'EnableIntrinsicFunctions': 'true',
1156             'EnablePREfast': 'true',
1157             'ErrorReporting': '2',
1158             'ExceptionHandling': '2',
1159             'ExpandAttributedSource': 'true',
1160             'FavorSizeOrSpeed': '2',
1161             'FloatingPointExceptions': 'true',
1162             'FloatingPointModel': '1',
1163             'ForceConformanceInForLoopScope': 'false',
1164             'ForcedIncludeFiles': 'def',
1165             'ForcedUsingFiles': 'ge',
1166             'GeneratePreprocessedFile': '2',
1167             'GenerateXMLDocumentationFiles': 'true',
1168             'IgnoreStandardIncludePath': 'true',
1169             'InlineFunctionExpansion': '1',
1170             'KeepComments': 'true',
1171             'MinimalRebuild': 'true',
1172             'ObjectFile': '$(IntDir)\\b',
1173             'OmitDefaultLibName': 'true',
1174             'OmitFramePointers': 'true',
1175             'OpenMP': 'true',
1176             'Optimization': '3',
1177             'PrecompiledHeaderFile': '$(IntDir)\\$(TargetName).pche',
1178             'PrecompiledHeaderThrough': 'StdAfx.hd',
1179             'PreprocessorDefinitions': 'WIN32;_DEBUG;_CONSOLE',
1180             'ProgramDataBaseFileName': '$(IntDir)\\vc90b.pdb',
1181             'RuntimeLibrary': '3',
1182             'RuntimeTypeInfo': 'false',
1183             'ShowIncludes': 'true',
1184             'SmallerTypeCheck': 'true',
1185             'StringPooling': 'true',
1186             'StructMemberAlignment': '3',
1187             'SuppressStartupBanner': 'false',
1188             'TreatWChar_tAsBuiltInType': 'false',
1189             'UndefineAllPreprocessorDefinitions': 'true',
1190             'UndefinePreprocessorDefinitions': 'wer',
1191             'UseFullPaths': 'true',
1192             'UsePrecompiledHeader': '0',
1193             'UseUnicodeResponseFiles': 'false',
1194             'WarnAsError': 'true',
1195             'WarningLevel': '3',
1196             'WholeProgramOptimization': 'true',
1197             'XMLDocumentationFileName': '$(IntDir)\\c'},
1198         'VCLinkerTool': {
1199             'AdditionalDependencies': 'zx',
1200             'AdditionalLibraryDirectories': 'asd',
1201             'AdditionalManifestDependencies': 's2',
1202             'AdditionalOptions': '/mor2',
1203             'AddModuleNamesToAssembly': 'd1',
1204             'AllowIsolation': 'false',
1205             'AssemblyDebug': '1',
1206             'AssemblyLinkResource': 'd5',
1207             'BaseAddress': '23423',
1208             'CLRImageType': '3',
1209             'CLRThreadAttribute': '1',
1210             'CLRUnmanagedCodeCheck': 'true',
1211             'DataExecutionPrevention': '0',
1212             'DelayLoadDLLs': 'd4',
1213             'DelaySign': 'true',
1214             'Driver': '2',
1215             'EmbedManagedResourceFile': 'd2',
1216             'EnableCOMDATFolding': '1',
1217             'EnableUAC': 'false',
1218             'EntryPointSymbol': 'f5',
1219             'ErrorReporting': '2',
1220             'FixedBaseAddress': '1',
1221             'ForceSymbolReferences': 'd3',
1222             'FunctionOrder': 'fssdfsd',
1223             'GenerateDebugInformation': 'true',
1224             'GenerateManifest': 'false',
1225             'GenerateMapFile': 'true',
1226             'HeapCommitSize': '13',
1227             'HeapReserveSize': '12',
1228             'IgnoreAllDefaultLibraries': 'true',
1229             'IgnoreDefaultLibraryNames': 'flob;flok',
1230             'IgnoreEmbeddedIDL': 'true',
1231             'IgnoreImportLibrary': 'true',
1232             'ImportLibrary': 'f4',
1233             'KeyContainer': 'f7',
1234             'KeyFile': 'f6',
1235             'LargeAddressAware': '2',
1236             'LinkIncremental': '0',
1237             'LinkLibraryDependencies': 'false',
1238             'LinkTimeCodeGeneration': '1',
1239             'ManifestFile':
1240             '$(IntDir)\\$(TargetFileName).2intermediate.manifest',
1241             'MapExports': 'true',
1242             'MapFileName': 'd5',
1243             'MergedIDLBaseFileName': 'f2',
1244             'MergeSections': 'f5',
1245             'MidlCommandFile': 'f1',
1246             'ModuleDefinitionFile': 'sdsd',
1247             'OptimizeForWindows98': '2',
1248             'OptimizeReferences': '2',
1249             'OutputFile': '$(OutDir)\\$(ProjectName)2.exe',
1250             'PerUserRedirection': 'true',
1251             'Profile': 'true',
1252             'ProfileGuidedDatabase': '$(TargetDir)$(TargetName).pgdd',
1253             'ProgramDatabaseFile': 'Flob.pdb',
1254             'RandomizedBaseAddress': '1',
1255             'RegisterOutput': 'true',
1256             'ResourceOnlyDLL': 'true',
1257             'SetChecksum': 'false',
1258             'ShowProgress': '1',
1259             'StackCommitSize': '15',
1260             'StackReserveSize': '14',
1261             'StripPrivateSymbols': 'd3',
1262             'SubSystem': '1',
1263             'SupportUnloadOfDelayLoadedDLL': 'true',
1264             'SuppressStartupBanner': 'false',
1265             'SwapRunFromCD': 'true',
1266             'SwapRunFromNet': 'true',
1267             'TargetMachine': '1',
1268             'TerminalServerAware': '1',
1269             'TurnOffAssemblyGeneration': 'true',
1270             'TypeLibraryFile': 'f3',
1271             'TypeLibraryResourceID': '12',
1272             'UACExecutionLevel': '2',
1273             'UACUIAccess': 'true',
1274             'UseLibraryDependencyInputs': 'true',
1275             'UseUnicodeResponseFiles': 'false',
1276             'Version': '333'},
1277         'VCResourceCompilerTool': {
1278             'AdditionalIncludeDirectories': 'f3',
1279             'AdditionalOptions': '/more3',
1280             'Culture': '3084',
1281             'IgnoreStandardIncludePath': 'true',
1282             'PreprocessorDefinitions': '_UNICODE;UNICODE2',
1283             'ResourceOutputFileName': '$(IntDir)/$(InputName)3.res',
1284             'ShowProgress': 'true'},
1285         'VCManifestTool': {
1286             'AdditionalManifestFiles': 'sfsdfsd',
1287             'AdditionalOptions': 'afdsdafsd',
1288             'AssemblyIdentity': 'sddfdsadfsa',
1289             'ComponentFileName': 'fsdfds',
1290             'DependencyInformationFile': '$(IntDir)\\mt.depdfd',
1291             'EmbedManifest': 'false',
1292             'GenerateCatalogFiles': 'true',
1293             'InputResourceManifests': 'asfsfdafs',
1294             'ManifestResourceFile':
1295             '$(IntDir)\\$(TargetFileName).embed.manifest.resfdsf',
1296             'OutputManifestFile': '$(TargetPath).manifestdfs',
1297             'RegistrarScriptFile': 'sdfsfd',
1298             'ReplacementsFile': 'sdffsd',
1299             'SuppressStartupBanner': 'false',
1300             'TypeLibraryFile': 'sfsd',
1301             'UpdateFileHashes': 'true',
1302             'UpdateFileHashesSearchPath': 'sfsd',
1303             'UseFAT32Workaround': 'true',
1304             'UseUnicodeResponseFiles': 'false',
1305             'VerboseOutput': 'true'}}
1306     expected_msbuild_settings = {
1307         'ClCompile': {
1308             'AdditionalIncludeDirectories': 'dir1',
1309             'AdditionalOptions': '/more /J',
1310             'AdditionalUsingDirectories': 'test',
1311             'AssemblerListingLocation': '$(IntDir)a',
1312             'AssemblerOutput': 'AssemblyCode',
1313             'BasicRuntimeChecks': 'EnableFastChecks',
1314             'BrowseInformation': 'true',
1315             'BrowseInformationFile': '$(IntDir)e',
1316             'BufferSecurityCheck': 'false',
1317             'CallingConvention': 'FastCall',
1318             'CompileAs': 'CompileAsC',
1319             'DebugInformationFormat': 'EditAndContinue',
1320             'DisableLanguageExtensions': 'true',
1321             'DisableSpecificWarnings': 'abc',
1322             'EnableEnhancedInstructionSet': 'StreamingSIMDExtensions',
1323             'EnableFiberSafeOptimizations': 'true',
1324             'EnablePREfast': 'true',
1325             'ErrorReporting': 'Queue',
1326             'ExceptionHandling': 'Async',
1327             'ExpandAttributedSource': 'true',
1328             'FavorSizeOrSpeed': 'Size',
1329             'FloatingPointExceptions': 'true',
1330             'FloatingPointModel': 'Strict',
1331             'ForceConformanceInForLoopScope': 'false',
1332             'ForcedIncludeFiles': 'def',
1333             'ForcedUsingFiles': 'ge',
1334             'FunctionLevelLinking': 'true',
1335             'GenerateXMLDocumentationFiles': 'true',
1336             'IgnoreStandardIncludePath': 'true',
1337             'InlineFunctionExpansion': 'OnlyExplicitInline',
1338             'IntrinsicFunctions': 'true',
1339             'MinimalRebuild': 'true',
1340             'ObjectFileName': '$(IntDir)b',
1341             'OmitDefaultLibName': 'true',
1342             'OmitFramePointers': 'true',
1343             'OpenMPSupport': 'true',
1344             'Optimization': 'Full',
1345             'PrecompiledHeader': 'NotUsing',  # Actual conversion gives ''
1346             'PrecompiledHeaderFile': 'StdAfx.hd',
1347             'PrecompiledHeaderOutputFile': '$(IntDir)$(TargetName).pche',
1348             'PreprocessKeepComments': 'true',
1349             'PreprocessorDefinitions': 'WIN32;_DEBUG;_CONSOLE',
1350             'PreprocessSuppressLineNumbers': 'true',
1351             'PreprocessToFile': 'true',
1352             'ProgramDataBaseFileName': '$(IntDir)vc90b.pdb',
1353             'RuntimeLibrary': 'MultiThreadedDebugDLL',
1354             'RuntimeTypeInfo': 'false',
1355             'ShowIncludes': 'true',
1356             'SmallerTypeCheck': 'true',
1357             'StringPooling': 'true',
1358             'StructMemberAlignment': '4Bytes',
1359             'SuppressStartupBanner': 'false',
1360             'TreatWarningAsError': 'true',
1361             'TreatWChar_tAsBuiltInType': 'false',
1362             'UndefineAllPreprocessorDefinitions': 'true',
1363             'UndefinePreprocessorDefinitions': 'wer',
1364             'UseFullPaths': 'true',
1365             'WarningLevel': 'Level3',
1366             'WholeProgramOptimization': 'true',
1367             'XMLDocumentationFileName': '$(IntDir)c'},
1368         'Link': {
1369             'AdditionalDependencies': 'zx',
1370             'AdditionalLibraryDirectories': 'asd',
1371             'AdditionalManifestDependencies': 's2',
1372             'AdditionalOptions': '/mor2',
1373             'AddModuleNamesToAssembly': 'd1',
1374             'AllowIsolation': 'false',
1375             'AssemblyDebug': 'true',
1376             'AssemblyLinkResource': 'd5',
1377             'BaseAddress': '23423',
1378             'CLRImageType': 'ForceSafeILImage',
1379             'CLRThreadAttribute': 'MTAThreadingAttribute',
1380             'CLRUnmanagedCodeCheck': 'true',
1381             'DataExecutionPrevention': '',
1382             'DelayLoadDLLs': 'd4',
1383             'DelaySign': 'true',
1384             'Driver': 'UpOnly',
1385             'EmbedManagedResourceFile': 'd2',
1386             'EnableCOMDATFolding': 'false',
1387             'EnableUAC': 'false',
1388             'EntryPointSymbol': 'f5',
1389             'FixedBaseAddress': 'false',
1390             'ForceSymbolReferences': 'd3',
1391             'FunctionOrder': 'fssdfsd',
1392             'GenerateDebugInformation': 'true',
1393             'GenerateMapFile': 'true',
1394             'HeapCommitSize': '13',
1395             'HeapReserveSize': '12',
1396             'IgnoreAllDefaultLibraries': 'true',
1397             'IgnoreEmbeddedIDL': 'true',
1398             'IgnoreSpecificDefaultLibraries': 'flob;flok',
1399             'ImportLibrary': 'f4',
1400             'KeyContainer': 'f7',
1401             'KeyFile': 'f6',
1402             'LargeAddressAware': 'true',
1403             'LinkErrorReporting': 'QueueForNextLogin',
1404             'LinkTimeCodeGeneration': 'UseLinkTimeCodeGeneration',
1405             'ManifestFile': '$(IntDir)$(TargetFileName).2intermediate.manifest',
1406             'MapExports': 'true',
1407             'MapFileName': 'd5',
1408             'MergedIDLBaseFileName': 'f2',
1409             'MergeSections': 'f5',
1410             'MidlCommandFile': 'f1',
1411             'ModuleDefinitionFile': 'sdsd',
1412             'NoEntryPoint': 'true',
1413             'OptimizeReferences': 'true',
1414             'OutputFile': '$(OutDir)$(ProjectName)2.exe',
1415             'PerUserRedirection': 'true',
1416             'Profile': 'true',
1417             'ProfileGuidedDatabase': '$(TargetDir)$(TargetName).pgdd',
1418             'ProgramDatabaseFile': 'Flob.pdb',
1419             'RandomizedBaseAddress': 'false',
1420             'RegisterOutput': 'true',
1421             'SetChecksum': 'false',
1422             'ShowProgress': 'LinkVerbose',
1423             'StackCommitSize': '15',
1424             'StackReserveSize': '14',
1425             'StripPrivateSymbols': 'd3',
1426             'SubSystem': 'Console',
1427             'SupportUnloadOfDelayLoadedDLL': 'true',
1428             'SuppressStartupBanner': 'false',
1429             'SwapRunFromCD': 'true',
1430             'SwapRunFromNET': 'true',
1431             'TargetMachine': 'MachineX86',
1432             'TerminalServerAware': 'false',
1433             'TurnOffAssemblyGeneration': 'true',
1434             'TypeLibraryFile': 'f3',
1435             'TypeLibraryResourceID': '12',
1436             'UACExecutionLevel': 'RequireAdministrator',
1437             'UACUIAccess': 'true',
1438             'Version': '333'},
1439         'ResourceCompile': {
1440             'AdditionalIncludeDirectories': 'f3',
1441             'AdditionalOptions': '/more3',
1442             'Culture': '0x0c0c',
1443             'IgnoreStandardIncludePath': 'true',
1444             'PreprocessorDefinitions': '_UNICODE;UNICODE2',
1445             'ResourceOutputFileName': '$(IntDir)%(Filename)3.res',
1446             'ShowProgress': 'true'},
1447         'Manifest': {
1448             'AdditionalManifestFiles': 'sfsdfsd',
1449             'AdditionalOptions': 'afdsdafsd',
1450             'AssemblyIdentity': 'sddfdsadfsa',
1451             'ComponentFileName': 'fsdfds',
1452             'GenerateCatalogFiles': 'true',
1453             'InputResourceManifests': 'asfsfdafs',
1454             'OutputManifestFile': '$(TargetPath).manifestdfs',
1455             'RegistrarScriptFile': 'sdfsfd',
1456             'ReplacementsFile': 'sdffsd',
1457             'SuppressStartupBanner': 'false',
1458             'TypeLibraryFile': 'sfsd',
1459             'UpdateFileHashes': 'true',
1460             'UpdateFileHashesSearchPath': 'sfsd',
1461             'VerboseOutput': 'true'},
1462         'ProjectReference': {
1463             'LinkLibraryDependencies': 'false',
1464             'UseLibraryDependencyInputs': 'true'},
1465         '': {
1466             'EmbedManifest': 'false',
1467             'GenerateManifest': 'false',
1468             'IgnoreImportLibrary': 'true',
1469             'LinkIncremental': ''
1470             },
1471         'ManifestResourceCompile': {
1472             'ResourceOutputFileName':
1473             '$(IntDir)$(TargetFileName).embed.manifest.resfdsf'}
1474         }
1475     actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(
1476         msvs_settings,
1477         self.stderr)
1478     self.assertEqual(expected_msbuild_settings, actual_msbuild_settings)
1479     self._ExpectedWarnings([])
1480
1481
1482 if __name__ == '__main__':
1483   unittest.main()