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