1# Copyright (c) 2012 Google Inc. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5r"""Code to validate and convert settings of the Microsoft build tools.
6
7This file contains code to validate and convert settings of the Microsoft
8build tools.  The function ConvertToMSBuildSettings(), ValidateMSVSSettings(),
9and ValidateMSBuildSettings() are the entry points.
10
11This file was created by comparing the projects created by Visual Studio 2008
12and Visual Studio 2010 for all available settings through the user interface.
13The MSBuild schemas were also considered.  They are typically found in the
14MSBuild install directory, e.g. c:\Program Files (x86)\MSBuild
15"""
16
17from __future__ import print_function
18
19import sys
20import re
21
22try:
23  # basestring was removed in python3.
24  basestring
25except NameError:
26  basestring = str
27
28# Dictionaries of settings validators. The key is the tool name, the value is
29# a dictionary mapping setting names to validation functions.
30_msvs_validators = {}
31_msbuild_validators = {}
32
33
34# A dictionary of settings converters. The key is the tool name, the value is
35# a dictionary mapping setting names to conversion functions.
36_msvs_to_msbuild_converters = {}
37
38
39# Tool name mapping from MSVS to MSBuild.
40_msbuild_name_of_tool = {}
41
42
43class _Tool(object):
44  """Represents a tool used by MSVS or MSBuild.
45
46  Attributes:
47      msvs_name: The name of the tool in MSVS.
48      msbuild_name: The name of the tool in MSBuild.
49  """
50
51  def __init__(self, msvs_name, msbuild_name):
52    self.msvs_name = msvs_name
53    self.msbuild_name = msbuild_name
54
55
56def _AddTool(tool):
57  """Adds a tool to the four dictionaries used to process settings.
58
59  This only defines the tool.  Each setting also needs to be added.
60
61  Args:
62    tool: The _Tool object to be added.
63  """
64  _msvs_validators[tool.msvs_name] = {}
65  _msbuild_validators[tool.msbuild_name] = {}
66  _msvs_to_msbuild_converters[tool.msvs_name] = {}
67  _msbuild_name_of_tool[tool.msvs_name] = tool.msbuild_name
68
69
70def _GetMSBuildToolSettings(msbuild_settings, tool):
71  """Returns an MSBuild tool dictionary.  Creates it if needed."""
72  return msbuild_settings.setdefault(tool.msbuild_name, {})
73
74
75class _Type(object):
76  """Type of settings (Base class)."""
77
78  def ValidateMSVS(self, value):
79    """Verifies that the value is legal for MSVS.
80
81    Args:
82      value: the value to check for this type.
83
84    Raises:
85      ValueError if value is not valid for MSVS.
86    """
87
88  def ValidateMSBuild(self, value):
89    """Verifies that the value is legal for MSBuild.
90
91    Args:
92      value: the value to check for this type.
93
94    Raises:
95      ValueError if value is not valid for MSBuild.
96    """
97
98  def ConvertToMSBuild(self, value):
99    """Returns the MSBuild equivalent of the MSVS value given.
100
101    Args:
102      value: the MSVS value to convert.
103
104    Returns:
105      the MSBuild equivalent.
106
107    Raises:
108      ValueError if value is not valid.
109    """
110    return value
111
112
113class _String(_Type):
114  """A setting that's just a string."""
115
116  def ValidateMSVS(self, value):
117    if not isinstance(value, basestring):
118      raise ValueError('expected string; got %r' % value)
119
120  def ValidateMSBuild(self, value):
121    if not isinstance(value, basestring):
122      raise ValueError('expected string; got %r' % value)
123
124  def ConvertToMSBuild(self, value):
125    # Convert the macros
126    return ConvertVCMacrosToMSBuild(value)
127
128
129class _StringList(_Type):
130  """A settings that's a list of strings."""
131
132  def ValidateMSVS(self, value):
133    if not isinstance(value, basestring) and not isinstance(value, list):
134      raise ValueError('expected string list; got %r' % value)
135
136  def ValidateMSBuild(self, value):
137    if not isinstance(value, basestring) and not isinstance(value, list):
138      raise ValueError('expected string list; got %r' % value)
139
140  def ConvertToMSBuild(self, value):
141    # Convert the macros
142    if isinstance(value, list):
143      return [ConvertVCMacrosToMSBuild(i) for i in value]
144    else:
145      return ConvertVCMacrosToMSBuild(value)
146
147
148class _Boolean(_Type):
149  """Boolean settings, can have the values 'false' or 'true'."""
150
151  def _Validate(self, value):
152    if value != 'true' and value != 'false':
153      raise ValueError('expected bool; got %r' % value)
154
155  def ValidateMSVS(self, value):
156    self._Validate(value)
157
158  def ValidateMSBuild(self, value):
159    self._Validate(value)
160
161  def ConvertToMSBuild(self, value):
162    self._Validate(value)
163    return value
164
165
166class _Integer(_Type):
167  """Integer settings."""
168
169  def __init__(self, msbuild_base=10):
170    _Type.__init__(self)
171    self._msbuild_base = msbuild_base
172
173  def ValidateMSVS(self, value):
174    # Try to convert, this will raise ValueError if invalid.
175    self.ConvertToMSBuild(value)
176
177  def ValidateMSBuild(self, value):
178    # Try to convert, this will raise ValueError if invalid.
179    int(value, self._msbuild_base)
180
181  def ConvertToMSBuild(self, value):
182    msbuild_format = (self._msbuild_base == 10) and '%d' or '0x%04x'
183    return msbuild_format % int(value)
184
185
186class _Enumeration(_Type):
187  """Type of settings that is an enumeration.
188
189  In MSVS, the values are indexes like '0', '1', and '2'.
190  MSBuild uses text labels that are more representative, like 'Win32'.
191
192  Constructor args:
193    label_list: an array of MSBuild labels that correspond to the MSVS index.
194        In the rare cases where MSVS has skipped an index value, None is
195        used in the array to indicate the unused spot.
196    new: an array of labels that are new to MSBuild.
197  """
198
199  def __init__(self, label_list, new=None):
200    _Type.__init__(self)
201    self._label_list = label_list
202    self._msbuild_values = set(value for value in label_list
203                               if value is not None)
204    if new is not None:
205      self._msbuild_values.update(new)
206
207  def ValidateMSVS(self, value):
208    # Try to convert.  It will raise an exception if not valid.
209    self.ConvertToMSBuild(value)
210
211  def ValidateMSBuild(self, value):
212    if value not in self._msbuild_values:
213      raise ValueError('unrecognized enumerated value %s' % value)
214
215  def ConvertToMSBuild(self, value):
216    index = int(value)
217    if index < 0 or index >= len(self._label_list):
218      raise ValueError('index value (%d) not in expected range [0, %d)' %
219                       (index, len(self._label_list)))
220    label = self._label_list[index]
221    if label is None:
222      raise ValueError('converted value for %s not specified.' % value)
223    return label
224
225
226# Instantiate the various generic types.
227_boolean = _Boolean()
228_integer = _Integer()
229# For now, we don't do any special validation on these types:
230_string = _String()
231_file_name = _String()
232_folder_name = _String()
233_file_list = _StringList()
234_folder_list = _StringList()
235_string_list = _StringList()
236# Some boolean settings went from numerical values to boolean.  The
237# mapping is 0: default, 1: false, 2: true.
238_newly_boolean = _Enumeration(['', 'false', 'true'])
239
240
241def _Same(tool, name, setting_type):
242  """Defines a setting that has the same name in MSVS and MSBuild.
243
244  Args:
245    tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
246    name: the name of the setting.
247    setting_type: the type of this setting.
248  """
249  _Renamed(tool, name, name, setting_type)
250
251
252def _Renamed(tool, msvs_name, msbuild_name, setting_type):
253  """Defines a setting for which the name has changed.
254
255  Args:
256    tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
257    msvs_name: the name of the MSVS setting.
258    msbuild_name: the name of the MSBuild setting.
259    setting_type: the type of this setting.
260  """
261
262  def _Translate(value, msbuild_settings):
263    msbuild_tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool)
264    msbuild_tool_settings[msbuild_name] = setting_type.ConvertToMSBuild(value)
265
266  _msvs_validators[tool.msvs_name][msvs_name] = setting_type.ValidateMSVS
267  _msbuild_validators[tool.msbuild_name][msbuild_name] = (
268      setting_type.ValidateMSBuild)
269  _msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate
270
271
272def _Moved(tool, settings_name, msbuild_tool_name, setting_type):
273  _MovedAndRenamed(tool, settings_name, msbuild_tool_name, settings_name,
274                   setting_type)
275
276
277def _MovedAndRenamed(tool, msvs_settings_name, msbuild_tool_name,
278                     msbuild_settings_name, setting_type):
279  """Defines a setting that may have moved to a new section.
280
281  Args:
282    tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
283    msvs_settings_name: the MSVS name of the setting.
284    msbuild_tool_name: the name of the MSBuild tool to place the setting under.
285    msbuild_settings_name: the MSBuild name of the setting.
286    setting_type: the type of this setting.
287  """
288
289  def _Translate(value, msbuild_settings):
290    tool_settings = msbuild_settings.setdefault(msbuild_tool_name, {})
291    tool_settings[msbuild_settings_name] = setting_type.ConvertToMSBuild(value)
292
293  _msvs_validators[tool.msvs_name][msvs_settings_name] = (
294      setting_type.ValidateMSVS)
295  validator = setting_type.ValidateMSBuild
296  _msbuild_validators[msbuild_tool_name][msbuild_settings_name] = validator
297  _msvs_to_msbuild_converters[tool.msvs_name][msvs_settings_name] = _Translate
298
299
300def _MSVSOnly(tool, name, setting_type):
301  """Defines a setting that is only found in MSVS.
302
303  Args:
304    tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
305    name: the name of the setting.
306    setting_type: the type of this setting.
307  """
308
309  def _Translate(unused_value, unused_msbuild_settings):
310    # Since this is for MSVS only settings, no translation will happen.
311    pass
312
313  _msvs_validators[tool.msvs_name][name] = setting_type.ValidateMSVS
314  _msvs_to_msbuild_converters[tool.msvs_name][name] = _Translate
315
316
317def _MSBuildOnly(tool, name, setting_type):
318  """Defines a setting that is only found in MSBuild.
319
320  Args:
321    tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
322    name: the name of the setting.
323    setting_type: the type of this setting.
324  """
325
326  def _Translate(value, msbuild_settings):
327    # Let msbuild-only properties get translated as-is from msvs_settings.
328    tool_settings = msbuild_settings.setdefault(tool.msbuild_name, {})
329    tool_settings[name] = value
330
331  _msbuild_validators[tool.msbuild_name][name] = setting_type.ValidateMSBuild
332  _msvs_to_msbuild_converters[tool.msvs_name][name] = _Translate
333
334
335def _ConvertedToAdditionalOption(tool, msvs_name, flag):
336  """Defines a setting that's handled via a command line option in MSBuild.
337
338  Args:
339    tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
340    msvs_name: the name of the MSVS setting that if 'true' becomes a flag
341    flag: the flag to insert at the end of the AdditionalOptions
342  """
343
344  def _Translate(value, msbuild_settings):
345    if value == 'true':
346      tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool)
347      if 'AdditionalOptions' in tool_settings:
348        new_flags = '%s %s' % (tool_settings['AdditionalOptions'], flag)
349      else:
350        new_flags = flag
351      tool_settings['AdditionalOptions'] = new_flags
352  _msvs_validators[tool.msvs_name][msvs_name] = _boolean.ValidateMSVS
353  _msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate
354
355
356def _CustomGeneratePreprocessedFile(tool, msvs_name):
357  def _Translate(value, msbuild_settings):
358    tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool)
359    if value == '0':
360      tool_settings['PreprocessToFile'] = 'false'
361      tool_settings['PreprocessSuppressLineNumbers'] = 'false'
362    elif value == '1':  # /P
363      tool_settings['PreprocessToFile'] = 'true'
364      tool_settings['PreprocessSuppressLineNumbers'] = 'false'
365    elif value == '2':  # /EP /P
366      tool_settings['PreprocessToFile'] = 'true'
367      tool_settings['PreprocessSuppressLineNumbers'] = 'true'
368    else:
369      raise ValueError('value must be one of [0, 1, 2]; got %s' % value)
370  # Create a bogus validator that looks for '0', '1', or '2'
371  msvs_validator = _Enumeration(['a', 'b', 'c']).ValidateMSVS
372  _msvs_validators[tool.msvs_name][msvs_name] = msvs_validator
373  msbuild_validator = _boolean.ValidateMSBuild
374  msbuild_tool_validators = _msbuild_validators[tool.msbuild_name]
375  msbuild_tool_validators['PreprocessToFile'] = msbuild_validator
376  msbuild_tool_validators['PreprocessSuppressLineNumbers'] = msbuild_validator
377  _msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate
378
379
380fix_vc_macro_slashes_regex_list = ('IntDir', 'OutDir')
381fix_vc_macro_slashes_regex = re.compile(
382  r'(\$\((?:%s)\))(?:[\\/]+)' % "|".join(fix_vc_macro_slashes_regex_list)
383)
384
385# Regular expression to detect keys that were generated by exclusion lists
386_EXCLUDED_SUFFIX_RE = re.compile('^(.*)_excluded$')
387
388
389def _ValidateExclusionSetting(setting, settings, error_msg, stderr=sys.stderr):
390  """Verify that 'setting' is valid if it is generated from an exclusion list.
391
392  If the setting appears to be generated from an exclusion list, the root name
393  is checked.
394
395  Args:
396      setting:   A string that is the setting name to validate
397      settings:  A dictionary where the keys are valid settings
398      error_msg: The message to emit in the event of error
399      stderr:    The stream receiving the error messages.
400  """
401  # This may be unrecognized because it's an exclusion list. If the
402  # setting name has the _excluded suffix, then check the root name.
403  unrecognized = True
404  m = re.match(_EXCLUDED_SUFFIX_RE, setting)
405  if m:
406    root_setting = m.group(1)
407    unrecognized = root_setting not in settings
408
409  if unrecognized:
410    # We don't know this setting. Give a warning.
411    print(error_msg, file=stderr)
412
413
414def FixVCMacroSlashes(s):
415  """Replace macros which have excessive following slashes.
416
417  These macros are known to have a built-in trailing slash. Furthermore, many
418  scripts hiccup on processing paths with extra slashes in the middle.
419
420  This list is probably not exhaustive.  Add as needed.
421  """
422  if '$' in s:
423    s = fix_vc_macro_slashes_regex.sub(r'\1', s)
424  return s
425
426
427def ConvertVCMacrosToMSBuild(s):
428  """Convert the the MSVS macros found in the string to the MSBuild equivalent.
429
430  This list is probably not exhaustive.  Add as needed.
431  """
432  if '$' in s:
433    replace_map = {
434        '$(ConfigurationName)': '$(Configuration)',
435        '$(InputDir)': '%(RelativeDir)',
436        '$(InputExt)': '%(Extension)',
437        '$(InputFileName)': '%(Filename)%(Extension)',
438        '$(InputName)': '%(Filename)',
439        '$(InputPath)': '%(Identity)',
440        '$(ParentName)': '$(ProjectFileName)',
441        '$(PlatformName)': '$(Platform)',
442        '$(SafeInputName)': '%(Filename)',
443    }
444    for old, new in replace_map.items():
445      s = s.replace(old, new)
446    s = FixVCMacroSlashes(s)
447  return s
448
449
450def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
451  """Converts MSVS settings (VS2008 and earlier) to MSBuild settings (VS2010+).
452
453  Args:
454      msvs_settings: A dictionary.  The key is the tool name.  The values are
455          themselves dictionaries of settings and their values.
456      stderr: The stream receiving the error messages.
457
458  Returns:
459      A dictionary of MSBuild settings.  The key is either the MSBuild tool name
460      or the empty string (for the global settings).  The values are themselves
461      dictionaries of settings and their values.
462  """
463  msbuild_settings = {}
464  for msvs_tool_name, msvs_tool_settings in msvs_settings.items():
465    if msvs_tool_name in _msvs_to_msbuild_converters:
466      msvs_tool = _msvs_to_msbuild_converters[msvs_tool_name]
467      for msvs_setting, msvs_value in msvs_tool_settings.items():
468        if msvs_setting in msvs_tool:
469          # Invoke the translation function.
470          try:
471            msvs_tool[msvs_setting](msvs_value, msbuild_settings)
472          except ValueError as e:
473            print(('Warning: while converting %s/%s to MSBuild, '
474                              '%s' % (msvs_tool_name, msvs_setting, e)),
475                              file=stderr)
476        else:
477          _ValidateExclusionSetting(msvs_setting,
478                                    msvs_tool,
479                                    ('Warning: unrecognized setting %s/%s '
480                                     'while converting to MSBuild.' %
481                                     (msvs_tool_name, msvs_setting)),
482                                    stderr)
483    else:
484      print(('Warning: unrecognized tool %s while converting to '
485                        'MSBuild.' % msvs_tool_name), file=stderr)
486  return msbuild_settings
487
488
489def ValidateMSVSSettings(settings, stderr=sys.stderr):
490  """Validates that the names of the settings are valid for MSVS.
491
492  Args:
493      settings: A dictionary.  The key is the tool name.  The values are
494          themselves dictionaries of settings and their values.
495      stderr: The stream receiving the error messages.
496  """
497  _ValidateSettings(_msvs_validators, settings, stderr)
498
499
500def ValidateMSBuildSettings(settings, stderr=sys.stderr):
501  """Validates that the names of the settings are valid for MSBuild.
502
503  Args:
504      settings: A dictionary.  The key is the tool name.  The values are
505          themselves dictionaries of settings and their values.
506      stderr: The stream receiving the error messages.
507  """
508  _ValidateSettings(_msbuild_validators, settings, stderr)
509
510
511def _ValidateSettings(validators, settings, stderr):
512  """Validates that the settings are valid for MSBuild or MSVS.
513
514  We currently only validate the names of the settings, not their values.
515
516  Args:
517      validators: A dictionary of tools and their validators.
518      settings: A dictionary.  The key is the tool name.  The values are
519          themselves dictionaries of settings and their values.
520      stderr: The stream receiving the error messages.
521  """
522  for tool_name in settings:
523    if tool_name in validators:
524      tool_validators = validators[tool_name]
525      for setting, value in settings[tool_name].items():
526        if setting in tool_validators:
527          try:
528            tool_validators[setting](value)
529          except ValueError as e:
530            print(('Warning: for %s/%s, %s' %
531                              (tool_name, setting, e)), file=stderr)
532        else:
533          _ValidateExclusionSetting(setting,
534                                    tool_validators,
535                                    ('Warning: unrecognized setting %s/%s' %
536                                     (tool_name, setting)),
537                                    stderr)
538
539    else:
540      print(('Warning: unrecognized tool %s' % tool_name), file=stderr)
541
542
543# MSVS and MBuild names of the tools.
544_compile = _Tool('VCCLCompilerTool', 'ClCompile')
545_link = _Tool('VCLinkerTool', 'Link')
546_midl = _Tool('VCMIDLTool', 'Midl')
547_rc = _Tool('VCResourceCompilerTool', 'ResourceCompile')
548_lib = _Tool('VCLibrarianTool', 'Lib')
549_manifest = _Tool('VCManifestTool', 'Manifest')
550_masm = _Tool('MASM', 'MASM')
551
552
553_AddTool(_compile)
554_AddTool(_link)
555_AddTool(_midl)
556_AddTool(_rc)
557_AddTool(_lib)
558_AddTool(_manifest)
559_AddTool(_masm)
560# Add sections only found in the MSBuild settings.
561_msbuild_validators[''] = {}
562_msbuild_validators['ProjectReference'] = {}
563_msbuild_validators['ManifestResourceCompile'] = {}
564
565# Descriptions of the compiler options, i.e. VCCLCompilerTool in MSVS and
566# ClCompile in MSBuild.
567# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\cl.xml" for
568# the schema of the MSBuild ClCompile settings.
569
570# Options that have the same name in MSVS and MSBuild
571_Same(_compile, 'AdditionalIncludeDirectories', _folder_list)  # /I
572_Same(_compile, 'AdditionalOptions', _string_list)
573_Same(_compile, 'AdditionalUsingDirectories', _folder_list)  # /AI
574_Same(_compile, 'AssemblerListingLocation', _file_name)  # /Fa
575_Same(_compile, 'BrowseInformationFile', _file_name)
576_Same(_compile, 'BufferSecurityCheck', _boolean)  # /GS
577_Same(_compile, 'DisableLanguageExtensions', _boolean)  # /Za
578_Same(_compile, 'DisableSpecificWarnings', _string_list)  # /wd
579_Same(_compile, 'EnableFiberSafeOptimizations', _boolean)  # /GT
580_Same(_compile, 'EnablePREfast', _boolean)  # /analyze Visible='false'
581_Same(_compile, 'ExpandAttributedSource', _boolean)  # /Fx
582_Same(_compile, 'FloatingPointExceptions', _boolean)  # /fp:except
583_Same(_compile, 'ForceConformanceInForLoopScope', _boolean)  # /Zc:forScope
584_Same(_compile, 'ForcedIncludeFiles', _file_list)  # /FI
585_Same(_compile, 'ForcedUsingFiles', _file_list)  # /FU
586_Same(_compile, 'GenerateXMLDocumentationFiles', _boolean)  # /doc
587_Same(_compile, 'IgnoreStandardIncludePath', _boolean)  # /X
588_Same(_compile, 'MinimalRebuild', _boolean)  # /Gm
589_Same(_compile, 'OmitDefaultLibName', _boolean)  # /Zl
590_Same(_compile, 'OmitFramePointers', _boolean)  # /Oy
591_Same(_compile, 'PreprocessorDefinitions', _string_list)  # /D
592_Same(_compile, 'ProgramDataBaseFileName', _file_name)  # /Fd
593_Same(_compile, 'RuntimeTypeInfo', _boolean)  # /GR
594_Same(_compile, 'ShowIncludes', _boolean)  # /showIncludes
595_Same(_compile, 'SmallerTypeCheck', _boolean)  # /RTCc
596_Same(_compile, 'StringPooling', _boolean)  # /GF
597_Same(_compile, 'SuppressStartupBanner', _boolean)  # /nologo
598_Same(_compile, 'TreatWChar_tAsBuiltInType', _boolean)  # /Zc:wchar_t
599_Same(_compile, 'UndefineAllPreprocessorDefinitions', _boolean)  # /u
600_Same(_compile, 'UndefinePreprocessorDefinitions', _string_list)  # /U
601_Same(_compile, 'UseFullPaths', _boolean)  # /FC
602_Same(_compile, 'WholeProgramOptimization', _boolean)  # /GL
603_Same(_compile, 'XMLDocumentationFileName', _file_name)
604_Same(_compile, 'CompileAsWinRT', _boolean)  # /ZW
605
606_Same(_compile, 'AssemblerOutput',
607      _Enumeration(['NoListing',
608                    'AssemblyCode',  # /FA
609                    'All',  # /FAcs
610                    'AssemblyAndMachineCode',  # /FAc
611                    'AssemblyAndSourceCode']))  # /FAs
612_Same(_compile, 'BasicRuntimeChecks',
613      _Enumeration(['Default',
614                    'StackFrameRuntimeCheck',  # /RTCs
615                    'UninitializedLocalUsageCheck',  # /RTCu
616                    'EnableFastChecks']))  # /RTC1
617_Same(_compile, 'BrowseInformation',
618      _Enumeration(['false',
619                    'true',  # /FR
620                    'true']))  # /Fr
621_Same(_compile, 'CallingConvention',
622      _Enumeration(['Cdecl',  # /Gd
623                    'FastCall',  # /Gr
624                    'StdCall',  # /Gz
625                    'VectorCall']))  # /Gv
626_Same(_compile, 'CompileAs',
627      _Enumeration(['Default',
628                    'CompileAsC',  # /TC
629                    'CompileAsCpp']))  # /TP
630_Same(_compile, 'DebugInformationFormat',
631      _Enumeration(['',  # Disabled
632                    'OldStyle',  # /Z7
633                    None,
634                    'ProgramDatabase',  # /Zi
635                    'EditAndContinue']))  # /ZI
636_Same(_compile, 'EnableEnhancedInstructionSet',
637      _Enumeration(['NotSet',
638                    'StreamingSIMDExtensions',  # /arch:SSE
639                    'StreamingSIMDExtensions2',  # /arch:SSE2
640                    'AdvancedVectorExtensions',  # /arch:AVX (vs2012+)
641                    'NoExtensions',  # /arch:IA32 (vs2012+)
642                    # This one only exists in the new msbuild format.
643                    'AdvancedVectorExtensions2',  # /arch:AVX2 (vs2013r2+)
644                    ]))
645_Same(_compile, 'ErrorReporting',
646      _Enumeration(['None',  # /errorReport:none
647                    'Prompt',  # /errorReport:prompt
648                    'Queue'],  # /errorReport:queue
649                   new=['Send']))  # /errorReport:send"
650_Same(_compile, 'ExceptionHandling',
651      _Enumeration(['false',
652                    'Sync',  # /EHsc
653                    'Async'],  # /EHa
654                   new=['SyncCThrow']))  # /EHs
655_Same(_compile, 'FavorSizeOrSpeed',
656      _Enumeration(['Neither',
657                    'Speed',  # /Ot
658                    'Size']))  # /Os
659_Same(_compile, 'FloatingPointModel',
660      _Enumeration(['Precise',  # /fp:precise
661                    'Strict',  # /fp:strict
662                    'Fast']))  # /fp:fast
663_Same(_compile, 'InlineFunctionExpansion',
664      _Enumeration(['Default',
665                    'OnlyExplicitInline',  # /Ob1
666                    'AnySuitable'],  # /Ob2
667                   new=['Disabled']))  # /Ob0
668_Same(_compile, 'Optimization',
669      _Enumeration(['Disabled',  # /Od
670                    'MinSpace',  # /O1
671                    'MaxSpeed',  # /O2
672                    'Full']))  # /Ox
673_Same(_compile, 'RuntimeLibrary',
674      _Enumeration(['MultiThreaded',  # /MT
675                    'MultiThreadedDebug',  # /MTd
676                    'MultiThreadedDLL',  # /MD
677                    'MultiThreadedDebugDLL']))  # /MDd
678_Same(_compile, 'StructMemberAlignment',
679      _Enumeration(['Default',
680                    '1Byte',  # /Zp1
681                    '2Bytes',  # /Zp2
682                    '4Bytes',  # /Zp4
683                    '8Bytes',  # /Zp8
684                    '16Bytes']))  # /Zp16
685_Same(_compile, 'WarningLevel',
686      _Enumeration(['TurnOffAllWarnings',  # /W0
687                    'Level1',  # /W1
688                    'Level2',  # /W2
689                    'Level3',  # /W3
690                    'Level4'],  # /W4
691                   new=['EnableAllWarnings']))  # /Wall
692
693# Options found in MSVS that have been renamed in MSBuild.
694_Renamed(_compile, 'EnableFunctionLevelLinking', 'FunctionLevelLinking',
695         _boolean)  # /Gy
696_Renamed(_compile, 'EnableIntrinsicFunctions', 'IntrinsicFunctions',
697         _boolean)  # /Oi
698_Renamed(_compile, 'KeepComments', 'PreprocessKeepComments', _boolean)  # /C
699_Renamed(_compile, 'ObjectFile', 'ObjectFileName', _file_name)  # /Fo
700_Renamed(_compile, 'OpenMP', 'OpenMPSupport', _boolean)  # /openmp
701_Renamed(_compile, 'PrecompiledHeaderThrough', 'PrecompiledHeaderFile',
702         _file_name)  # Used with /Yc and /Yu
703_Renamed(_compile, 'PrecompiledHeaderFile', 'PrecompiledHeaderOutputFile',
704         _file_name)  # /Fp
705_Renamed(_compile, 'UsePrecompiledHeader', 'PrecompiledHeader',
706         _Enumeration(['NotUsing',  # VS recognized '' for this value too.
707                       'Create',   # /Yc
708                       'Use']))  # /Yu
709_Renamed(_compile, 'WarnAsError', 'TreatWarningAsError', _boolean)  # /WX
710
711_ConvertedToAdditionalOption(_compile, 'DefaultCharIsUnsigned', '/J')
712
713# MSVS options not found in MSBuild.
714_MSVSOnly(_compile, 'Detect64BitPortabilityProblems', _boolean)
715_MSVSOnly(_compile, 'UseUnicodeResponseFiles', _boolean)
716
717# MSBuild options not found in MSVS.
718_MSBuildOnly(_compile, 'BuildingInIDE', _boolean)
719_MSBuildOnly(_compile, 'CompileAsManaged',
720             _Enumeration([], new=['false',
721                                   'true']))  # /clr
722_MSBuildOnly(_compile, 'CreateHotpatchableImage', _boolean)  # /hotpatch
723_MSBuildOnly(_compile, 'MultiProcessorCompilation', _boolean)  # /MP
724_MSBuildOnly(_compile, 'PreprocessOutputPath', _string)  # /Fi
725_MSBuildOnly(_compile, 'ProcessorNumber', _integer)  # the number of processors
726_MSBuildOnly(_compile, 'TrackerLogDirectory', _folder_name)
727_MSBuildOnly(_compile, 'TreatSpecificWarningsAsErrors', _string_list)  # /we
728_MSBuildOnly(_compile, 'UseUnicodeForAssemblerListing', _boolean)  # /FAu
729
730# Defines a setting that needs very customized processing
731_CustomGeneratePreprocessedFile(_compile, 'GeneratePreprocessedFile')
732
733
734# Directives for converting MSVS VCLinkerTool to MSBuild Link.
735# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\link.xml" for
736# the schema of the MSBuild Link settings.
737
738# Options that have the same name in MSVS and MSBuild
739_Same(_link, 'AdditionalDependencies', _file_list)
740_Same(_link, 'AdditionalLibraryDirectories', _folder_list)  # /LIBPATH
741#  /MANIFESTDEPENDENCY:
742_Same(_link, 'AdditionalManifestDependencies', _file_list)
743_Same(_link, 'AdditionalOptions', _string_list)
744_Same(_link, 'AddModuleNamesToAssembly', _file_list)  # /ASSEMBLYMODULE
745_Same(_link, 'AllowIsolation', _boolean)  # /ALLOWISOLATION
746_Same(_link, 'AssemblyLinkResource', _file_list)  # /ASSEMBLYLINKRESOURCE
747_Same(_link, 'BaseAddress', _string)  # /BASE
748_Same(_link, 'CLRUnmanagedCodeCheck', _boolean)  # /CLRUNMANAGEDCODECHECK
749_Same(_link, 'DelayLoadDLLs', _file_list)  # /DELAYLOAD
750_Same(_link, 'DelaySign', _boolean)  # /DELAYSIGN
751_Same(_link, 'EmbedManagedResourceFile', _file_list)  # /ASSEMBLYRESOURCE
752_Same(_link, 'EnableUAC', _boolean)  # /MANIFESTUAC
753_Same(_link, 'EntryPointSymbol', _string)  # /ENTRY
754_Same(_link, 'ForceSymbolReferences', _file_list)  # /INCLUDE
755_Same(_link, 'FunctionOrder', _file_name)  # /ORDER
756_Same(_link, 'GenerateDebugInformation', _boolean)  # /DEBUG
757_Same(_link, 'GenerateMapFile', _boolean)  # /MAP
758_Same(_link, 'HeapCommitSize', _string)
759_Same(_link, 'HeapReserveSize', _string)  # /HEAP
760_Same(_link, 'IgnoreAllDefaultLibraries', _boolean)  # /NODEFAULTLIB
761_Same(_link, 'IgnoreEmbeddedIDL', _boolean)  # /IGNOREIDL
762_Same(_link, 'ImportLibrary', _file_name)  # /IMPLIB
763_Same(_link, 'KeyContainer', _file_name)  # /KEYCONTAINER
764_Same(_link, 'KeyFile', _file_name)  # /KEYFILE
765_Same(_link, 'ManifestFile', _file_name)  # /ManifestFile
766_Same(_link, 'MapExports', _boolean)  # /MAPINFO:EXPORTS
767_Same(_link, 'MapFileName', _file_name)
768_Same(_link, 'MergedIDLBaseFileName', _file_name)  # /IDLOUT
769_Same(_link, 'MergeSections', _string)  # /MERGE
770_Same(_link, 'MidlCommandFile', _file_name)  # /MIDL
771_Same(_link, 'ModuleDefinitionFile', _file_name)  # /DEF
772_Same(_link, 'OutputFile', _file_name)  # /OUT
773_Same(_link, 'PerUserRedirection', _boolean)
774_Same(_link, 'Profile', _boolean)  # /PROFILE
775_Same(_link, 'ProfileGuidedDatabase', _file_name)  # /PGD
776_Same(_link, 'ProgramDatabaseFile', _file_name)  # /PDB
777_Same(_link, 'RegisterOutput', _boolean)
778_Same(_link, 'SetChecksum', _boolean)  # /RELEASE
779_Same(_link, 'StackCommitSize', _string)
780_Same(_link, 'StackReserveSize', _string)  # /STACK
781_Same(_link, 'StripPrivateSymbols', _file_name)  # /PDBSTRIPPED
782_Same(_link, 'SupportUnloadOfDelayLoadedDLL', _boolean)  # /DELAY:UNLOAD
783_Same(_link, 'SuppressStartupBanner', _boolean)  # /NOLOGO
784_Same(_link, 'SwapRunFromCD', _boolean)  # /SWAPRUN:CD
785_Same(_link, 'TurnOffAssemblyGeneration', _boolean)  # /NOASSEMBLY
786_Same(_link, 'TypeLibraryFile', _file_name)  # /TLBOUT
787_Same(_link, 'TypeLibraryResourceID', _integer)  # /TLBID
788_Same(_link, 'UACUIAccess', _boolean)  # /uiAccess='true'
789_Same(_link, 'Version', _string)  # /VERSION
790
791_Same(_link, 'EnableCOMDATFolding', _newly_boolean)  # /OPT:ICF
792_Same(_link, 'FixedBaseAddress', _newly_boolean)  # /FIXED
793_Same(_link, 'LargeAddressAware', _newly_boolean)  # /LARGEADDRESSAWARE
794_Same(_link, 'OptimizeReferences', _newly_boolean)  # /OPT:REF
795_Same(_link, 'RandomizedBaseAddress', _newly_boolean)  # /DYNAMICBASE
796_Same(_link, 'TerminalServerAware', _newly_boolean)  # /TSAWARE
797
798_subsystem_enumeration = _Enumeration(
799    ['NotSet',
800     'Console',  # /SUBSYSTEM:CONSOLE
801     'Windows',  # /SUBSYSTEM:WINDOWS
802     'Native',  # /SUBSYSTEM:NATIVE
803     'EFI Application',  # /SUBSYSTEM:EFI_APPLICATION
804     'EFI Boot Service Driver',  # /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER
805     'EFI ROM',  # /SUBSYSTEM:EFI_ROM
806     'EFI Runtime',  # /SUBSYSTEM:EFI_RUNTIME_DRIVER
807     'WindowsCE'],  # /SUBSYSTEM:WINDOWSCE
808    new=['POSIX'])  # /SUBSYSTEM:POSIX
809
810_target_machine_enumeration = _Enumeration(
811    ['NotSet',
812     'MachineX86',  # /MACHINE:X86
813     None,
814     'MachineARM',  # /MACHINE:ARM
815     'MachineEBC',  # /MACHINE:EBC
816     'MachineIA64',  # /MACHINE:IA64
817     None,
818     'MachineMIPS',  # /MACHINE:MIPS
819     'MachineMIPS16',  # /MACHINE:MIPS16
820     'MachineMIPSFPU',  # /MACHINE:MIPSFPU
821     'MachineMIPSFPU16',  # /MACHINE:MIPSFPU16
822     None,
823     None,
824     None,
825     'MachineSH4',  # /MACHINE:SH4
826     None,
827     'MachineTHUMB',  # /MACHINE:THUMB
828     'MachineX64'])  # /MACHINE:X64
829
830_Same(_link, 'AssemblyDebug',
831      _Enumeration(['',
832                    'true',  # /ASSEMBLYDEBUG
833                    'false']))  # /ASSEMBLYDEBUG:DISABLE
834_Same(_link, 'CLRImageType',
835      _Enumeration(['Default',
836                    'ForceIJWImage',  # /CLRIMAGETYPE:IJW
837                    'ForcePureILImage',  # /Switch="CLRIMAGETYPE:PURE
838                    'ForceSafeILImage']))  # /Switch="CLRIMAGETYPE:SAFE
839_Same(_link, 'CLRThreadAttribute',
840      _Enumeration(['DefaultThreadingAttribute',  # /CLRTHREADATTRIBUTE:NONE
841                    'MTAThreadingAttribute',  # /CLRTHREADATTRIBUTE:MTA
842                    'STAThreadingAttribute']))  # /CLRTHREADATTRIBUTE:STA
843_Same(_link, 'DataExecutionPrevention',
844      _Enumeration(['',
845                    'false',  # /NXCOMPAT:NO
846                    'true']))  # /NXCOMPAT
847_Same(_link, 'Driver',
848      _Enumeration(['NotSet',
849                    'Driver',  # /Driver
850                    'UpOnly',  # /DRIVER:UPONLY
851                    'WDM']))  # /DRIVER:WDM
852_Same(_link, 'LinkTimeCodeGeneration',
853      _Enumeration(['Default',
854                    'UseLinkTimeCodeGeneration',  # /LTCG
855                    'PGInstrument',  # /LTCG:PGInstrument
856                    'PGOptimization',  # /LTCG:PGOptimize
857                    'PGUpdate']))  # /LTCG:PGUpdate
858_Same(_link, 'ShowProgress',
859      _Enumeration(['NotSet',
860                    'LinkVerbose',  # /VERBOSE
861                    'LinkVerboseLib'],  # /VERBOSE:Lib
862                   new=['LinkVerboseICF',  # /VERBOSE:ICF
863                        'LinkVerboseREF',  # /VERBOSE:REF
864                        'LinkVerboseSAFESEH',  # /VERBOSE:SAFESEH
865                        'LinkVerboseCLR']))  # /VERBOSE:CLR
866_Same(_link, 'SubSystem', _subsystem_enumeration)
867_Same(_link, 'TargetMachine', _target_machine_enumeration)
868_Same(_link, 'UACExecutionLevel',
869      _Enumeration(['AsInvoker',  # /level='asInvoker'
870                    'HighestAvailable',  # /level='highestAvailable'
871                    'RequireAdministrator']))  # /level='requireAdministrator'
872_Same(_link, 'MinimumRequiredVersion', _string)
873_Same(_link, 'TreatLinkerWarningAsErrors', _boolean)  # /WX
874
875
876# Options found in MSVS that have been renamed in MSBuild.
877_Renamed(_link, 'ErrorReporting', 'LinkErrorReporting',
878         _Enumeration(['NoErrorReport',  # /ERRORREPORT:NONE
879                       'PromptImmediately',  # /ERRORREPORT:PROMPT
880                       'QueueForNextLogin'],  # /ERRORREPORT:QUEUE
881                      new=['SendErrorReport']))  # /ERRORREPORT:SEND
882_Renamed(_link, 'IgnoreDefaultLibraryNames', 'IgnoreSpecificDefaultLibraries',
883         _file_list)  # /NODEFAULTLIB
884_Renamed(_link, 'ResourceOnlyDLL', 'NoEntryPoint', _boolean)  # /NOENTRY
885_Renamed(_link, 'SwapRunFromNet', 'SwapRunFromNET', _boolean)  # /SWAPRUN:NET
886
887_Moved(_link, 'GenerateManifest', '', _boolean)
888_Moved(_link, 'IgnoreImportLibrary', '', _boolean)
889_Moved(_link, 'LinkIncremental', '', _newly_boolean)
890_Moved(_link, 'LinkLibraryDependencies', 'ProjectReference', _boolean)
891_Moved(_link, 'UseLibraryDependencyInputs', 'ProjectReference', _boolean)
892
893# MSVS options not found in MSBuild.
894_MSVSOnly(_link, 'OptimizeForWindows98', _newly_boolean)
895_MSVSOnly(_link, 'UseUnicodeResponseFiles', _boolean)
896
897# MSBuild options not found in MSVS.
898_MSBuildOnly(_link, 'BuildingInIDE', _boolean)
899_MSBuildOnly(_link, 'ImageHasSafeExceptionHandlers', _boolean)  # /SAFESEH
900_MSBuildOnly(_link, 'LinkDLL', _boolean)  # /DLL Visible='false'
901_MSBuildOnly(_link, 'LinkStatus', _boolean)  # /LTCG:STATUS
902_MSBuildOnly(_link, 'PreventDllBinding', _boolean)  # /ALLOWBIND
903_MSBuildOnly(_link, 'SupportNobindOfDelayLoadedDLL', _boolean)  # /DELAY:NOBIND
904_MSBuildOnly(_link, 'TrackerLogDirectory', _folder_name)
905_MSBuildOnly(_link, 'MSDOSStubFileName', _file_name)  # /STUB Visible='false'
906_MSBuildOnly(_link, 'SectionAlignment', _integer)  # /ALIGN
907_MSBuildOnly(_link, 'SpecifySectionAttributes', _string)  # /SECTION
908_MSBuildOnly(_link, 'ForceFileOutput',
909             _Enumeration([], new=['Enabled',  # /FORCE
910                                   # /FORCE:MULTIPLE
911                                   'MultiplyDefinedSymbolOnly',
912                                   'UndefinedSymbolOnly']))  # /FORCE:UNRESOLVED
913_MSBuildOnly(_link, 'CreateHotPatchableImage',
914             _Enumeration([], new=['Enabled',  # /FUNCTIONPADMIN
915                                   'X86Image',  # /FUNCTIONPADMIN:5
916                                   'X64Image',  # /FUNCTIONPADMIN:6
917                                   'ItaniumImage']))  # /FUNCTIONPADMIN:16
918_MSBuildOnly(_link, 'CLRSupportLastError',
919             _Enumeration([], new=['Enabled',  # /CLRSupportLastError
920                                   'Disabled',  # /CLRSupportLastError:NO
921                                   # /CLRSupportLastError:SYSTEMDLL
922                                   'SystemDlls']))
923
924
925# Directives for converting VCResourceCompilerTool to ResourceCompile.
926# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\rc.xml" for
927# the schema of the MSBuild ResourceCompile settings.
928
929_Same(_rc, 'AdditionalOptions', _string_list)
930_Same(_rc, 'AdditionalIncludeDirectories', _folder_list)  # /I
931_Same(_rc, 'Culture', _Integer(msbuild_base=16))
932_Same(_rc, 'IgnoreStandardIncludePath', _boolean)  # /X
933_Same(_rc, 'PreprocessorDefinitions', _string_list)  # /D
934_Same(_rc, 'ResourceOutputFileName', _string)  # /fo
935_Same(_rc, 'ShowProgress', _boolean)  # /v
936# There is no UI in VisualStudio 2008 to set the following properties.
937# However they are found in CL and other tools.  Include them here for
938# completeness, as they are very likely to have the same usage pattern.
939_Same(_rc, 'SuppressStartupBanner', _boolean)  # /nologo
940_Same(_rc, 'UndefinePreprocessorDefinitions', _string_list)  # /u
941
942# MSBuild options not found in MSVS.
943_MSBuildOnly(_rc, 'NullTerminateStrings', _boolean)  # /n
944_MSBuildOnly(_rc, 'TrackerLogDirectory', _folder_name)
945
946
947# Directives for converting VCMIDLTool to Midl.
948# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\midl.xml" for
949# the schema of the MSBuild Midl settings.
950
951_Same(_midl, 'AdditionalIncludeDirectories', _folder_list)  # /I
952_Same(_midl, 'AdditionalOptions', _string_list)
953_Same(_midl, 'CPreprocessOptions', _string)  # /cpp_opt
954_Same(_midl, 'ErrorCheckAllocations', _boolean)  # /error allocation
955_Same(_midl, 'ErrorCheckBounds', _boolean)  # /error bounds_check
956_Same(_midl, 'ErrorCheckEnumRange', _boolean)  # /error enum
957_Same(_midl, 'ErrorCheckRefPointers', _boolean)  # /error ref
958_Same(_midl, 'ErrorCheckStubData', _boolean)  # /error stub_data
959_Same(_midl, 'GenerateStublessProxies', _boolean)  # /Oicf
960_Same(_midl, 'GenerateTypeLibrary', _boolean)
961_Same(_midl, 'HeaderFileName', _file_name)  # /h
962_Same(_midl, 'IgnoreStandardIncludePath', _boolean)  # /no_def_idir
963_Same(_midl, 'InterfaceIdentifierFileName', _file_name)  # /iid
964_Same(_midl, 'MkTypLibCompatible', _boolean)  # /mktyplib203
965_Same(_midl, 'OutputDirectory', _string)  # /out
966_Same(_midl, 'PreprocessorDefinitions', _string_list)  # /D
967_Same(_midl, 'ProxyFileName', _file_name)  # /proxy
968_Same(_midl, 'RedirectOutputAndErrors', _file_name)  # /o
969_Same(_midl, 'SuppressStartupBanner', _boolean)  # /nologo
970_Same(_midl, 'TypeLibraryName', _file_name)  # /tlb
971_Same(_midl, 'UndefinePreprocessorDefinitions', _string_list)  # /U
972_Same(_midl, 'WarnAsError', _boolean)  # /WX
973
974_Same(_midl, 'DefaultCharType',
975      _Enumeration(['Unsigned',  # /char unsigned
976                    'Signed',  # /char signed
977                    'Ascii']))  # /char ascii7
978_Same(_midl, 'TargetEnvironment',
979      _Enumeration(['NotSet',
980                    'Win32',  # /env win32
981                    'Itanium',  # /env ia64
982                    'X64']))  # /env x64
983_Same(_midl, 'EnableErrorChecks',
984      _Enumeration(['EnableCustom',
985                    'None',  # /error none
986                    'All']))  # /error all
987_Same(_midl, 'StructMemberAlignment',
988      _Enumeration(['NotSet',
989                    '1',  # Zp1
990                    '2',  # Zp2
991                    '4',  # Zp4
992                    '8']))  # Zp8
993_Same(_midl, 'WarningLevel',
994      _Enumeration(['0',  # /W0
995                    '1',  # /W1
996                    '2',  # /W2
997                    '3',  # /W3
998                    '4']))  # /W4
999
1000_Renamed(_midl, 'DLLDataFileName', 'DllDataFileName', _file_name)  # /dlldata
1001_Renamed(_midl, 'ValidateParameters', 'ValidateAllParameters',
1002         _boolean)  # /robust
1003
1004# MSBuild options not found in MSVS.
1005_MSBuildOnly(_midl, 'ApplicationConfigurationMode', _boolean)  # /app_config
1006_MSBuildOnly(_midl, 'ClientStubFile', _file_name)  # /cstub
1007_MSBuildOnly(_midl, 'GenerateClientFiles',
1008             _Enumeration([], new=['Stub',  # /client stub
1009                                   'None']))  # /client none
1010_MSBuildOnly(_midl, 'GenerateServerFiles',
1011             _Enumeration([], new=['Stub',  # /client stub
1012                                   'None']))  # /client none
1013_MSBuildOnly(_midl, 'LocaleID', _integer)  # /lcid DECIMAL
1014_MSBuildOnly(_midl, 'ServerStubFile', _file_name)  # /sstub
1015_MSBuildOnly(_midl, 'SuppressCompilerWarnings', _boolean)  # /no_warn
1016_MSBuildOnly(_midl, 'TrackerLogDirectory', _folder_name)
1017_MSBuildOnly(_midl, 'TypeLibFormat',
1018             _Enumeration([], new=['NewFormat',  # /newtlb
1019                                   'OldFormat']))  # /oldtlb
1020
1021
1022# Directives for converting VCLibrarianTool to Lib.
1023# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\lib.xml" for
1024# the schema of the MSBuild Lib settings.
1025
1026_Same(_lib, 'AdditionalDependencies', _file_list)
1027_Same(_lib, 'AdditionalLibraryDirectories', _folder_list)  # /LIBPATH
1028_Same(_lib, 'AdditionalOptions', _string_list)
1029_Same(_lib, 'ExportNamedFunctions', _string_list)  # /EXPORT
1030_Same(_lib, 'ForceSymbolReferences', _string)  # /INCLUDE
1031_Same(_lib, 'IgnoreAllDefaultLibraries', _boolean)  # /NODEFAULTLIB
1032_Same(_lib, 'IgnoreSpecificDefaultLibraries', _file_list)  # /NODEFAULTLIB
1033_Same(_lib, 'ModuleDefinitionFile', _file_name)  # /DEF
1034_Same(_lib, 'OutputFile', _file_name)  # /OUT
1035_Same(_lib, 'SuppressStartupBanner', _boolean)  # /NOLOGO
1036_Same(_lib, 'UseUnicodeResponseFiles', _boolean)
1037_Same(_lib, 'LinkTimeCodeGeneration', _boolean)  # /LTCG
1038_Same(_lib, 'TargetMachine', _target_machine_enumeration)
1039
1040# TODO(jeanluc) _link defines the same value that gets moved to
1041# ProjectReference.  We may want to validate that they are consistent.
1042_Moved(_lib, 'LinkLibraryDependencies', 'ProjectReference', _boolean)
1043
1044_MSBuildOnly(_lib, 'DisplayLibrary', _string)  # /LIST Visible='false'
1045_MSBuildOnly(_lib, 'ErrorReporting',
1046             _Enumeration([], new=['PromptImmediately',  # /ERRORREPORT:PROMPT
1047                                   'QueueForNextLogin',  # /ERRORREPORT:QUEUE
1048                                   'SendErrorReport',  # /ERRORREPORT:SEND
1049                                   'NoErrorReport']))  # /ERRORREPORT:NONE
1050_MSBuildOnly(_lib, 'MinimumRequiredVersion', _string)
1051_MSBuildOnly(_lib, 'Name', _file_name)  # /NAME
1052_MSBuildOnly(_lib, 'RemoveObjects', _file_list)  # /REMOVE
1053_MSBuildOnly(_lib, 'SubSystem', _subsystem_enumeration)
1054_MSBuildOnly(_lib, 'TrackerLogDirectory', _folder_name)
1055_MSBuildOnly(_lib, 'TreatLibWarningAsErrors', _boolean)  # /WX
1056_MSBuildOnly(_lib, 'Verbose', _boolean)
1057
1058
1059# Directives for converting VCManifestTool to Mt.
1060# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\mt.xml" for
1061# the schema of the MSBuild Lib settings.
1062
1063# Options that have the same name in MSVS and MSBuild
1064_Same(_manifest, 'AdditionalManifestFiles', _file_list)  # /manifest
1065_Same(_manifest, 'AdditionalOptions', _string_list)
1066_Same(_manifest, 'AssemblyIdentity', _string)  # /identity:
1067_Same(_manifest, 'ComponentFileName', _file_name)  # /dll
1068_Same(_manifest, 'GenerateCatalogFiles', _boolean)  # /makecdfs
1069_Same(_manifest, 'InputResourceManifests', _string)  # /inputresource
1070_Same(_manifest, 'OutputManifestFile', _file_name)  # /out
1071_Same(_manifest, 'RegistrarScriptFile', _file_name)  # /rgs
1072_Same(_manifest, 'ReplacementsFile', _file_name)  # /replacements
1073_Same(_manifest, 'SuppressStartupBanner', _boolean)  # /nologo
1074_Same(_manifest, 'TypeLibraryFile', _file_name)  # /tlb:
1075_Same(_manifest, 'UpdateFileHashes', _boolean)  # /hashupdate
1076_Same(_manifest, 'UpdateFileHashesSearchPath', _file_name)
1077_Same(_manifest, 'VerboseOutput', _boolean)  # /verbose
1078
1079# Options that have moved location.
1080_MovedAndRenamed(_manifest, 'ManifestResourceFile',
1081                 'ManifestResourceCompile',
1082                 'ResourceOutputFileName',
1083                 _file_name)
1084_Moved(_manifest, 'EmbedManifest', '', _boolean)
1085
1086# MSVS options not found in MSBuild.
1087_MSVSOnly(_manifest, 'DependencyInformationFile', _file_name)
1088_MSVSOnly(_manifest, 'UseFAT32Workaround', _boolean)
1089_MSVSOnly(_manifest, 'UseUnicodeResponseFiles', _boolean)
1090
1091# MSBuild options not found in MSVS.
1092_MSBuildOnly(_manifest, 'EnableDPIAwareness', _boolean)
1093_MSBuildOnly(_manifest, 'GenerateCategoryTags', _boolean)  # /category
1094_MSBuildOnly(_manifest, 'ManifestFromManagedAssembly',
1095             _file_name)  # /managedassemblyname
1096_MSBuildOnly(_manifest, 'OutputResourceManifests', _string)  # /outputresource
1097_MSBuildOnly(_manifest, 'SuppressDependencyElement', _boolean)  # /nodependency
1098_MSBuildOnly(_manifest, 'TrackerLogDirectory', _folder_name)
1099
1100
1101# Directives for MASM.
1102# See "$(VCTargetsPath)\BuildCustomizations\masm.xml" for the schema of the
1103# MSBuild MASM settings.
1104
1105# Options that have the same name in MSVS and MSBuild.
1106_Same(_masm, 'UseSafeExceptionHandlers', _boolean)  # /safeseh
1107