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