redsnow 0.0.8

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