OLD | NEW |
1 # Copyright (c) 2012 Google Inc. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """ | 5 """ |
6 This module helps emulate Visual Studio 2008 behavior on top of other | 6 This module helps emulate Visual Studio 2008 behavior on top of other |
7 build systems, primarily ninja. | 7 build systems, primarily ninja. |
8 """ | 8 """ |
9 | 9 |
10 import os | 10 import os |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 # the WDK_DIR environment variable, may be None. | 138 # the WDK_DIR environment variable, may be None. |
139 self.wdk_dir = os.environ.get('WDK_DIR') | 139 self.wdk_dir = os.environ.get('WDK_DIR') |
140 | 140 |
141 supported_fields = [ | 141 supported_fields = [ |
142 ('msvs_configuration_attributes', dict), | 142 ('msvs_configuration_attributes', dict), |
143 ('msvs_settings', dict), | 143 ('msvs_settings', dict), |
144 ('msvs_system_include_dirs', list), | 144 ('msvs_system_include_dirs', list), |
145 ('msvs_disabled_warnings', list), | 145 ('msvs_disabled_warnings', list), |
146 ('msvs_precompiled_header', str), | 146 ('msvs_precompiled_header', str), |
147 ('msvs_precompiled_source', str), | 147 ('msvs_precompiled_source', str), |
| 148 ('msvs_target_platform', str), |
148 ] | 149 ] |
149 configs = spec['configurations'] | 150 configs = spec['configurations'] |
150 for field, default in supported_fields: | 151 for field, default in supported_fields: |
151 setattr(self, field, {}) | 152 setattr(self, field, {}) |
152 for configname, config in configs.iteritems(): | 153 for configname, config in configs.iteritems(): |
153 getattr(self, field)[configname] = config.get(field, default()) | 154 getattr(self, field)[configname] = config.get(field, default()) |
154 | 155 |
155 self.msvs_cygwin_dirs = spec.get('msvs_cygwin_dirs', ['.']) | 156 self.msvs_cygwin_dirs = spec.get('msvs_cygwin_dirs', ['.']) |
156 | 157 |
157 def GetVSMacroEnv(self, base_to_build=None): | 158 def GetVSMacroEnv(self, base_to_build=None): |
158 """Get a dict of variables mapping internal VS macro names to their gyp | 159 """Get a dict of variables mapping internal VS macro names to their gyp |
159 equivalents.""" | 160 equivalents.""" |
160 replacements = { | 161 replacements = { |
161 '$(VSInstallDir)': self.vs_version.Path(), | 162 '$(VSInstallDir)': self.vs_version.Path(), |
162 '$(VCInstallDir)': os.path.join(self.vs_version.Path(), 'VC') + '\\', | 163 '$(VCInstallDir)': os.path.join(self.vs_version.Path(), 'VC') + '\\', |
163 '$(OutDir)\\': base_to_build + '\\' if base_to_build else '', | 164 '$(OutDir)\\': base_to_build + '\\' if base_to_build else '', |
164 '$(IntDir)': '$!INTERMEDIATE_DIR', | 165 '$(IntDir)': '$!INTERMEDIATE_DIR', |
165 '$(InputPath)': '${source}', | 166 '$(InputPath)': '${source}', |
166 '$(InputName)': '${root}', | 167 '$(InputName)': '${root}', |
167 '$(ProjectName)': self.spec['target_name'], | 168 '$(ProjectName)': self.spec['target_name'], |
168 '$(PlatformName)': 'Win32', # TODO(scottmg): Support for x64 toolchain. | 169 '$(PlatformName)': 'BOGUS', |
169 } | 170 } |
170 # Chromium uses DXSDK_DIR in include/lib paths, but it may or may not be | 171 # Chromium uses DXSDK_DIR in include/lib paths, but it may or may not be |
171 # set. This happens when the SDK is sync'd via src-internal, rather than | 172 # set. This happens when the SDK is sync'd via src-internal, rather than |
172 # by typical end-user installation of the SDK. If it's not set, we don't | 173 # by typical end-user installation of the SDK. If it's not set, we don't |
173 # want to leave the unexpanded variable in the path, so simply strip it. | 174 # want to leave the unexpanded variable in the path, so simply strip it. |
174 replacements['$(DXSDK_DIR)'] = self.dxsdk_dir if self.dxsdk_dir else '' | 175 replacements['$(DXSDK_DIR)'] = self.dxsdk_dir if self.dxsdk_dir else '' |
175 replacements['$(WDK_DIR)'] = self.wdk_dir if self.wdk_dir else '' | 176 replacements['$(WDK_DIR)'] = self.wdk_dir if self.wdk_dir else '' |
176 return replacements | 177 return replacements |
177 | 178 |
178 def ConvertVSMacros(self, s, base_to_build=None): | 179 def ConvertVSMacros(self, s, base_to_build=None): |
(...skipping 18 matching lines...) Expand all Loading... |
197 class _GetWrapper(object): | 198 class _GetWrapper(object): |
198 def __init__(self, parent, field, base_path, append=None): | 199 def __init__(self, parent, field, base_path, append=None): |
199 self.parent = parent | 200 self.parent = parent |
200 self.field = field | 201 self.field = field |
201 self.base_path = [base_path] | 202 self.base_path = [base_path] |
202 self.append = append | 203 self.append = append |
203 def __call__(self, name, map=None, prefix='', default=None): | 204 def __call__(self, name, map=None, prefix='', default=None): |
204 return self.parent._GetAndMunge(self.field, self.base_path + [name], | 205 return self.parent._GetAndMunge(self.field, self.base_path + [name], |
205 default=default, prefix=prefix, append=self.append, map=map) | 206 default=default, prefix=prefix, append=self.append, map=map) |
206 | 207 |
| 208 def GetTargetPlatform(self, config): |
| 209 target_platform = self.msvs_target_platform.get(config, '') |
| 210 if not target_platform: |
| 211 target_platform = 'Win32' |
| 212 return {'Win32': 'x86'}.get(target_platform, target_platform) |
| 213 |
| 214 def _RealConfig(self, config): |
| 215 target_platform = self.GetTargetPlatform(config) |
| 216 if target_platform == 'x64' and not config.endswith('_x64'): |
| 217 config += '_x64' |
| 218 return config |
| 219 |
207 def _Setting(self, path, config, | 220 def _Setting(self, path, config, |
208 default=None, prefix='', append=None, map=None): | 221 default=None, prefix='', append=None, map=None): |
209 """_GetAndMunge for msvs_settings.""" | 222 """_GetAndMunge for msvs_settings.""" |
| 223 config = self._RealConfig(config) |
210 return self._GetAndMunge( | 224 return self._GetAndMunge( |
211 self.msvs_settings[config], path, default, prefix, append, map) | 225 self.msvs_settings[config], path, default, prefix, append, map) |
212 | 226 |
213 def _ConfigAttrib(self, path, config, | 227 def _ConfigAttrib(self, path, config, |
214 default=None, prefix='', append=None, map=None): | 228 default=None, prefix='', append=None, map=None): |
215 """_GetAndMunge for msvs_configuration_attributes.""" | 229 """_GetAndMunge for msvs_configuration_attributes.""" |
| 230 config = self._RealConfig(config) |
216 return self._GetAndMunge( | 231 return self._GetAndMunge( |
217 self.msvs_configuration_attributes[config], | 232 self.msvs_configuration_attributes[config], |
218 path, default, prefix, append, map) | 233 path, default, prefix, append, map) |
219 | 234 |
220 def AdjustIncludeDirs(self, include_dirs, config): | 235 def AdjustIncludeDirs(self, include_dirs, config): |
221 """Updates include_dirs to expand VS specific paths, and adds the system | 236 """Updates include_dirs to expand VS specific paths, and adds the system |
222 include dirs used for platform SDK and similar.""" | 237 include dirs used for platform SDK and similar.""" |
| 238 config = self._RealConfig(config) |
223 includes = include_dirs + self.msvs_system_include_dirs[config] | 239 includes = include_dirs + self.msvs_system_include_dirs[config] |
224 includes.extend(self._Setting( | 240 includes.extend(self._Setting( |
225 ('VCCLCompilerTool', 'AdditionalIncludeDirectories'), config, default=[])) | 241 ('VCCLCompilerTool', 'AdditionalIncludeDirectories'), config, default=[])) |
226 return [self.ConvertVSMacros(p) for p in includes] | 242 return [self.ConvertVSMacros(p) for p in includes] |
227 | 243 |
228 def GetComputedDefines(self, config): | 244 def GetComputedDefines(self, config): |
229 """Returns the set of defines that are injected to the defines list based | 245 """Returns the set of defines that are injected to the defines list based |
230 on other VS settings.""" | 246 on other VS settings.""" |
| 247 config = self._RealConfig(config) |
231 defines = [] | 248 defines = [] |
232 if self._ConfigAttrib(['CharacterSet'], config) == '1': | 249 if self._ConfigAttrib(['CharacterSet'], config) == '1': |
233 defines.extend(('_UNICODE', 'UNICODE')) | 250 defines.extend(('_UNICODE', 'UNICODE')) |
234 if self._ConfigAttrib(['CharacterSet'], config) == '2': | 251 if self._ConfigAttrib(['CharacterSet'], config) == '2': |
235 defines.append('_MBCS') | 252 defines.append('_MBCS') |
236 defines.extend(self._Setting( | 253 defines.extend(self._Setting( |
237 ('VCCLCompilerTool', 'PreprocessorDefinitions'), config, default=[])) | 254 ('VCCLCompilerTool', 'PreprocessorDefinitions'), config, default=[])) |
238 return defines | 255 return defines |
239 | 256 |
240 def GetOutputName(self, config, expand_special): | 257 def GetOutputName(self, config, expand_special): |
241 """Gets the explicitly overridden output name for a target or returns None | 258 """Gets the explicitly overridden output name for a target or returns None |
242 if it's not overridden.""" | 259 if it's not overridden.""" |
| 260 config = self._RealConfig(config) |
243 type = self.spec['type'] | 261 type = self.spec['type'] |
244 root = 'VCLibrarianTool' if type == 'static_library' else 'VCLinkerTool' | 262 root = 'VCLibrarianTool' if type == 'static_library' else 'VCLinkerTool' |
245 # TODO(scottmg): Handle OutputDirectory without OutputFile. | 263 # TODO(scottmg): Handle OutputDirectory without OutputFile. |
246 output_file = self._Setting((root, 'OutputFile'), config) | 264 output_file = self._Setting((root, 'OutputFile'), config) |
247 if output_file: | 265 if output_file: |
248 output_file = expand_special(self.ConvertVSMacros(output_file)) | 266 output_file = expand_special(self.ConvertVSMacros(output_file)) |
249 return output_file | 267 return output_file |
250 | 268 |
251 def GetCflags(self, config): | 269 def GetCflags(self, config): |
252 """Returns the flags that need to be added to .c and .cc compilations.""" | 270 """Returns the flags that need to be added to .c and .cc compilations.""" |
| 271 config = self._RealConfig(config) |
253 cflags = [] | 272 cflags = [] |
254 cflags.extend(['/wd' + w for w in self.msvs_disabled_warnings[config]]) | 273 cflags.extend(['/wd' + w for w in self.msvs_disabled_warnings[config]]) |
255 cl = self._GetWrapper(self, self.msvs_settings[config], | 274 cl = self._GetWrapper(self, self.msvs_settings[config], |
256 'VCCLCompilerTool', append=cflags) | 275 'VCCLCompilerTool', append=cflags) |
257 cl('Optimization', | 276 cl('Optimization', |
258 map={'0': 'd', '1': '1', '2': '2', '3': 'x'}, prefix='/O') | 277 map={'0': 'd', '1': '1', '2': '2', '3': 'x'}, prefix='/O') |
259 cl('InlineFunctionExpansion', prefix='/Ob') | 278 cl('InlineFunctionExpansion', prefix='/Ob') |
260 cl('OmitFramePointers', map={'false': '-', 'true': ''}, prefix='/Oy') | 279 cl('OmitFramePointers', map={'false': '-', 'true': ''}, prefix='/Oy') |
261 cl('FavorSizeOrSpeed', map={'1': 't', '2': 's'}, prefix='/O') | 280 cl('FavorSizeOrSpeed', map={'1': 't', '2': 's'}, prefix='/O') |
262 cl('WholeProgramOptimization', map={'true': '/GL'}) | 281 cl('WholeProgramOptimization', map={'true': '/GL'}) |
(...skipping 10 matching lines...) Expand all Loading... |
273 map={'0': 'T', '1': 'Td', '2': 'D', '3': 'Dd'}, prefix='/M') | 292 map={'0': 'T', '1': 'Td', '2': 'D', '3': 'Dd'}, prefix='/M') |
274 cl('ExceptionHandling', map={'1': 'sc','2': 'a'}, prefix='/EH') | 293 cl('ExceptionHandling', map={'1': 'sc','2': 'a'}, prefix='/EH') |
275 cl('AdditionalOptions', prefix='') | 294 cl('AdditionalOptions', prefix='') |
276 # ninja handles parallelism by itself, don't have the compiler do it too. | 295 # ninja handles parallelism by itself, don't have the compiler do it too. |
277 cflags = filter(lambda x: not x.startswith('/MP'), cflags) | 296 cflags = filter(lambda x: not x.startswith('/MP'), cflags) |
278 return cflags | 297 return cflags |
279 | 298 |
280 def GetPrecompiledHeader(self, config, gyp_to_build_path): | 299 def GetPrecompiledHeader(self, config, gyp_to_build_path): |
281 """Returns an object that handles the generation of precompiled header | 300 """Returns an object that handles the generation of precompiled header |
282 build steps.""" | 301 build steps.""" |
| 302 config = self._RealConfig(config) |
283 return _PchHelper(self, config, gyp_to_build_path) | 303 return _PchHelper(self, config, gyp_to_build_path) |
284 | 304 |
285 def _GetPchFlags(self, config, extension): | 305 def _GetPchFlags(self, config, extension): |
286 """Get the flags to be added to the cflags for precompiled header support. | 306 """Get the flags to be added to the cflags for precompiled header support. |
287 """ | 307 """ |
| 308 config = self._RealConfig(config) |
288 # The PCH is only built once by a particular source file. Usage of PCH must | 309 # The PCH is only built once by a particular source file. Usage of PCH must |
289 # only be for the same language (i.e. C vs. C++), so only include the pch | 310 # only be for the same language (i.e. C vs. C++), so only include the pch |
290 # flags when the language matches. | 311 # flags when the language matches. |
291 if self.msvs_precompiled_header[config]: | 312 if self.msvs_precompiled_header[config]: |
292 source_ext = os.path.splitext(self.msvs_precompiled_source[config])[1] | 313 source_ext = os.path.splitext(self.msvs_precompiled_source[config])[1] |
293 if _LanguageMatchesForPch(source_ext, extension): | 314 if _LanguageMatchesForPch(source_ext, extension): |
294 pch = os.path.split(self.msvs_precompiled_header[config])[1] | 315 pch = os.path.split(self.msvs_precompiled_header[config])[1] |
295 return ['/Yu' + pch, '/FI' + pch, '/Fp${pchprefix}.' + pch + '.pch'] | 316 return ['/Yu' + pch, '/FI' + pch, '/Fp${pchprefix}.' + pch + '.pch'] |
296 return [] | 317 return [] |
297 | 318 |
298 def GetCflagsC(self, config): | 319 def GetCflagsC(self, config): |
299 """Returns the flags that need to be added to .c compilations.""" | 320 """Returns the flags that need to be added to .c compilations.""" |
| 321 config = self._RealConfig(config) |
300 return self._GetPchFlags(config, '.c') | 322 return self._GetPchFlags(config, '.c') |
301 | 323 |
302 def GetCflagsCC(self, config): | 324 def GetCflagsCC(self, config): |
303 """Returns the flags that need to be added to .cc compilations.""" | 325 """Returns the flags that need to be added to .cc compilations.""" |
| 326 config = self._RealConfig(config) |
304 return ['/TP'] + self._GetPchFlags(config, '.cc') | 327 return ['/TP'] + self._GetPchFlags(config, '.cc') |
305 | 328 |
306 def _GetAdditionalLibraryDirectories(self, root, config, gyp_to_build_path): | 329 def _GetAdditionalLibraryDirectories(self, root, config, gyp_to_build_path): |
307 """Get and normalize the list of paths in AdditionalLibraryDirectories | 330 """Get and normalize the list of paths in AdditionalLibraryDirectories |
308 setting.""" | 331 setting.""" |
| 332 config = self._RealConfig(config) |
309 libpaths = self._Setting((root, 'AdditionalLibraryDirectories'), | 333 libpaths = self._Setting((root, 'AdditionalLibraryDirectories'), |
310 config, default=[]) | 334 config, default=[]) |
311 libpaths = [os.path.normpath(gyp_to_build_path(self.ConvertVSMacros(p))) | 335 libpaths = [os.path.normpath(gyp_to_build_path(self.ConvertVSMacros(p))) |
312 for p in libpaths] | 336 for p in libpaths] |
313 return ['/LIBPATH:"' + p + '"' for p in libpaths] | 337 return ['/LIBPATH:"' + p + '"' for p in libpaths] |
314 | 338 |
315 def GetLibFlags(self, config, gyp_to_build_path): | 339 def GetLibFlags(self, config, gyp_to_build_path): |
316 """Returns the flags that need to be added to lib commands.""" | 340 """Returns the flags that need to be added to lib commands.""" |
| 341 config = self._RealConfig(config) |
317 libflags = [] | 342 libflags = [] |
318 lib = self._GetWrapper(self, self.msvs_settings[config], | 343 lib = self._GetWrapper(self, self.msvs_settings[config], |
319 'VCLibrarianTool', append=libflags) | 344 'VCLibrarianTool', append=libflags) |
320 libflags.extend(self._GetAdditionalLibraryDirectories( | 345 libflags.extend(self._GetAdditionalLibraryDirectories( |
321 'VCLibrarianTool', config, gyp_to_build_path)) | 346 'VCLibrarianTool', config, gyp_to_build_path)) |
322 lib('AdditionalOptions') | 347 lib('AdditionalOptions') |
323 return libflags | 348 return libflags |
324 | 349 |
325 def _GetDefFileAsLdflags(self, spec, ldflags, gyp_to_build_path): | 350 def _GetDefFileAsLdflags(self, spec, ldflags, gyp_to_build_path): |
326 """.def files get implicitly converted to a ModuleDefinitionFile for the | 351 """.def files get implicitly converted to a ModuleDefinitionFile for the |
327 linker in the VS generator. Emulate that behaviour here.""" | 352 linker in the VS generator. Emulate that behaviour here.""" |
328 def_file = '' | 353 def_file = '' |
329 if spec['type'] in ('shared_library', 'loadable_module', 'executable'): | 354 if spec['type'] in ('shared_library', 'loadable_module', 'executable'): |
330 def_files = [s for s in spec.get('sources', []) if s.endswith('.def')] | 355 def_files = [s for s in spec.get('sources', []) if s.endswith('.def')] |
331 if len(def_files) == 1: | 356 if len(def_files) == 1: |
332 ldflags.append('/DEF:"%s"' % gyp_to_build_path(def_files[0])) | 357 ldflags.append('/DEF:"%s"' % gyp_to_build_path(def_files[0])) |
333 elif len(def_files) > 1: | 358 elif len(def_files) > 1: |
334 raise Exception("Multiple .def files") | 359 raise Exception("Multiple .def files") |
335 | 360 |
336 def GetLdflags(self, config, gyp_to_build_path, expand_special): | 361 def GetLdflags(self, config, gyp_to_build_path, expand_special): |
337 """Returns the flags that need to be added to link commands.""" | 362 """Returns the flags that need to be added to link commands.""" |
| 363 config = self._RealConfig(config) |
338 ldflags = [] | 364 ldflags = [] |
339 ld = self._GetWrapper(self, self.msvs_settings[config], | 365 ld = self._GetWrapper(self, self.msvs_settings[config], |
340 'VCLinkerTool', append=ldflags) | 366 'VCLinkerTool', append=ldflags) |
341 self._GetDefFileAsLdflags(self.spec, ldflags, gyp_to_build_path) | 367 self._GetDefFileAsLdflags(self.spec, ldflags, gyp_to_build_path) |
342 ld('GenerateDebugInformation', map={'true': '/DEBUG'}) | 368 ld('GenerateDebugInformation', map={'true': '/DEBUG'}) |
343 ld('TargetMachine', map={'1': 'X86', '17': 'X64'}, prefix='/MACHINE:') | 369 ld('TargetMachine', map={'1': 'X86', '17': 'X64'}, prefix='/MACHINE:') |
344 ldflags.extend(self._GetAdditionalLibraryDirectories( | 370 ldflags.extend(self._GetAdditionalLibraryDirectories( |
345 'VCLinkerTool', config, gyp_to_build_path)) | 371 'VCLinkerTool', config, gyp_to_build_path)) |
346 ld('DelayLoadDLLs', prefix='/DELAYLOAD:') | 372 ld('DelayLoadDLLs', prefix='/DELAYLOAD:') |
347 out = self.GetOutputName(config, expand_special) | 373 out = self.GetOutputName(config, expand_special) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 # Vista or greater (which applies to the linker), the IDE defaults it on | 406 # Vista or greater (which applies to the linker), the IDE defaults it on |
381 # unless it's explicitly off. | 407 # unless it's explicitly off. |
382 if not filter(lambda x: 'NXCOMPAT' in x, ldflags): | 408 if not filter(lambda x: 'NXCOMPAT' in x, ldflags): |
383 ldflags.append('/NXCOMPAT') | 409 ldflags.append('/NXCOMPAT') |
384 | 410 |
385 return ldflags | 411 return ldflags |
386 | 412 |
387 def IsUseLibraryDependencyInputs(self, config): | 413 def IsUseLibraryDependencyInputs(self, config): |
388 """Returns whether the target should be linked via Use Library Dependency | 414 """Returns whether the target should be linked via Use Library Dependency |
389 Inputs (using component .objs of a given .lib).""" | 415 Inputs (using component .objs of a given .lib).""" |
| 416 config = self._RealConfig(config) |
390 uldi = self._Setting(('VCLinkerTool', 'UseLibraryDependencyInputs'), config) | 417 uldi = self._Setting(('VCLinkerTool', 'UseLibraryDependencyInputs'), config) |
391 return uldi == 'true' | 418 return uldi == 'true' |
392 | 419 |
393 def GetRcflags(self, config, gyp_to_ninja_path): | 420 def GetRcflags(self, config, gyp_to_ninja_path): |
394 """Returns the flags that need to be added to invocations of the resource | 421 """Returns the flags that need to be added to invocations of the resource |
395 compiler.""" | 422 compiler.""" |
| 423 config = self._RealConfig(config) |
396 rcflags = [] | 424 rcflags = [] |
397 rc = self._GetWrapper(self, self.msvs_settings[config], | 425 rc = self._GetWrapper(self, self.msvs_settings[config], |
398 'VCResourceCompilerTool', append=rcflags) | 426 'VCResourceCompilerTool', append=rcflags) |
399 rc('AdditionalIncludeDirectories', map=gyp_to_ninja_path, prefix='/I') | 427 rc('AdditionalIncludeDirectories', map=gyp_to_ninja_path, prefix='/I') |
400 rcflags.append('/I' + gyp_to_ninja_path('.')) | 428 rcflags.append('/I' + gyp_to_ninja_path('.')) |
401 rc('PreprocessorDefinitions', prefix='/d') | 429 rc('PreprocessorDefinitions', prefix='/d') |
402 # /l arg must be in hex without leading '0x' | 430 # /l arg must be in hex without leading '0x' |
403 rc('Culture', prefix='/l', map=lambda x: hex(int(x))[2:]) | 431 rc('Culture', prefix='/l', map=lambda x: hex(int(x))[2:]) |
404 return rcflags | 432 return rcflags |
405 | 433 |
(...skipping 27 matching lines...) Expand all Loading... |
433 """Determine if there's an explicit rule for idl files. When there isn't we | 461 """Determine if there's an explicit rule for idl files. When there isn't we |
434 need to generate implicit rules to build MIDL .idl files.""" | 462 need to generate implicit rules to build MIDL .idl files.""" |
435 for rule in spec.get('rules', []): | 463 for rule in spec.get('rules', []): |
436 if rule['extension'] == 'idl' and int(rule.get('msvs_external_rule', 0)): | 464 if rule['extension'] == 'idl' and int(rule.get('msvs_external_rule', 0)): |
437 return True | 465 return True |
438 return False | 466 return False |
439 | 467 |
440 def GetIdlBuildData(self, source, config): | 468 def GetIdlBuildData(self, source, config): |
441 """Determine the implicit outputs for an idl file. Returns output | 469 """Determine the implicit outputs for an idl file. Returns output |
442 directory, outputs, and variables and flags that are required.""" | 470 directory, outputs, and variables and flags that are required.""" |
| 471 config = self._RealConfig(config) |
443 midl_get = self._GetWrapper(self, self.msvs_settings[config], 'VCMIDLTool') | 472 midl_get = self._GetWrapper(self, self.msvs_settings[config], 'VCMIDLTool') |
444 def midl(name, default=None): | 473 def midl(name, default=None): |
445 return self.ConvertVSMacros(midl_get(name, default=default)) | 474 return self.ConvertVSMacros(midl_get(name, default=default)) |
446 tlb = midl('TypeLibraryName', default='${root}.tlb') | 475 tlb = midl('TypeLibraryName', default='${root}.tlb') |
447 header = midl('HeaderFileName', default='${root}.h') | 476 header = midl('HeaderFileName', default='${root}.h') |
448 dlldata = midl('DLLDataFileName', default='dlldata.c') | 477 dlldata = midl('DLLDataFileName', default='dlldata.c') |
449 iid = midl('InterfaceIdentifierFileName', default='${root}_i.c') | 478 iid = midl('InterfaceIdentifierFileName', default='${root}_i.c') |
450 proxy = midl('ProxyFileName', default='${root}_p.c') | 479 proxy = midl('ProxyFileName', default='${root}_p.c') |
451 # Note that .tlb is not included in the outputs as it is not always | 480 # Note that .tlb is not included in the outputs as it is not always |
452 # generated depending on the content of the input idl file. | 481 # generated depending on the content of the input idl file. |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 an absolute path, instead preferring something like "cl.exe" in the rule | 620 an absolute path, instead preferring something like "cl.exe" in the rule |
592 which will then run whichever the environment setup has put in the path.""" | 621 which will then run whichever the environment setup has put in the path.""" |
593 vs = GetVSVersion(generator_flags) | 622 vs = GetVSVersion(generator_flags) |
594 for arch in ('x86', 'x64'): | 623 for arch in ('x86', 'x64'): |
595 args = vs.SetupScript(arch) | 624 args = vs.SetupScript(arch) |
596 args.extend(('&&', 'set')) | 625 args.extend(('&&', 'set')) |
597 popen = subprocess.Popen( | 626 popen = subprocess.Popen( |
598 args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 627 args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
599 variables, _ = popen.communicate() | 628 variables, _ = popen.communicate() |
600 env = _ExtractImportantEnvironment(variables) | 629 env = _ExtractImportantEnvironment(variables) |
| 630 env['PlatformName'] = {'x86': 'Win32'}.get(arch, arch) |
601 env_block = _FormatAsEnvironmentBlock(env) | 631 env_block = _FormatAsEnvironmentBlock(env) |
602 f = open_out(os.path.join(toplevel_build_dir, 'environment.' + arch), 'wb') | 632 f = open_out(os.path.join(toplevel_build_dir, 'environment.' + arch), 'wb') |
603 f.write(env_block) | 633 f.write(env_block) |
604 f.close() | 634 f.close() |
OLD | NEW |