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