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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 """Returns the flags that need to be added to link commands.""" | 301 """Returns the flags that need to be added to link commands.""" |
302 ldflags = [] | 302 ldflags = [] |
303 ld = self._GetWrapper(self, self.msvs_settings[config], | 303 ld = self._GetWrapper(self, self.msvs_settings[config], |
304 'VCLinkerTool', append=ldflags) | 304 'VCLinkerTool', append=ldflags) |
305 self._GetDefFileAsLdflags(self.spec, ldflags, gyp_to_build_path) | 305 self._GetDefFileAsLdflags(self.spec, ldflags, gyp_to_build_path) |
306 ld('GenerateDebugInformation', map={'true': '/DEBUG'}) | 306 ld('GenerateDebugInformation', map={'true': '/DEBUG'}) |
307 ld('TargetMachine', map={'1': 'X86', '17': 'X64'}, prefix='/MACHINE:') | 307 ld('TargetMachine', map={'1': 'X86', '17': 'X64'}, prefix='/MACHINE:') |
308 ldflags.extend(self._GetAdditionalLibraryDirectories( | 308 ldflags.extend(self._GetAdditionalLibraryDirectories( |
309 'VCLinkerTool', config, gyp_to_build_path)) | 309 'VCLinkerTool', config, gyp_to_build_path)) |
310 ld('DelayLoadDLLs', prefix='/DELAYLOAD:') | 310 ld('DelayLoadDLLs', prefix='/DELAYLOAD:') |
311 out = self._Setting(('VCLinkerTool', 'OutputFile'), config, prefix='/OUT:') | 311 out = self._Setting(('VCLinkerTool', 'OutputFile'), config) |
312 if out: | 312 if out: |
313 ldflags.append(self.ConvertVSMacros(out)) | 313 ldflags.append('/OUT:' + gyp_to_build_path(self.ConvertVSMacros(out))) |
314 ld('AdditionalOptions', prefix='') | 314 ld('AdditionalOptions', prefix='') |
315 ld('SubSystem', map={'1': 'CONSOLE', '2': 'WINDOWS'}, prefix='/SUBSYSTEM:') | 315 ld('SubSystem', map={'1': 'CONSOLE', '2': 'WINDOWS'}, prefix='/SUBSYSTEM:') |
316 ld('LinkIncremental', map={'1': ':NO', '2': ''}, prefix='/INCREMENTAL') | 316 ld('LinkIncremental', map={'1': ':NO', '2': ''}, prefix='/INCREMENTAL') |
317 ld('FixedBaseAddress', map={'1': ':NO', '2': ''}, prefix='/FIXED') | 317 ld('FixedBaseAddress', map={'1': ':NO', '2': ''}, prefix='/FIXED') |
318 ld('RandomizedBaseAddress', | 318 ld('RandomizedBaseAddress', |
319 map={'1': ':NO', '2': ''}, prefix='/DYNAMICBASE') | 319 map={'1': ':NO', '2': ''}, prefix='/DYNAMICBASE') |
320 ld('DataExecutionPrevention', | 320 ld('DataExecutionPrevention', |
321 map={'1': ':NO', '2': ''}, prefix='/NXCOMPAT') | 321 map={'1': ':NO', '2': ''}, prefix='/NXCOMPAT') |
322 ld('OptimizeReferences', map={'1': 'NOREF', '2': 'REF'}, prefix='/OPT:') | 322 ld('OptimizeReferences', map={'1': 'NOREF', '2': 'REF'}, prefix='/OPT:') |
323 ld('EnableCOMDATFolding', map={'1': 'NOICF', '2': 'ICF'}, prefix='/OPT:') | 323 ld('EnableCOMDATFolding', map={'1': 'NOICF', '2': 'ICF'}, prefix='/OPT:') |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 midl_get = self._GetWrapper(self, self.msvs_settings[config], 'VCMIDLTool') | 404 midl_get = self._GetWrapper(self, self.msvs_settings[config], 'VCMIDLTool') |
405 def midl(name, default=None): | 405 def midl(name, default=None): |
406 return self.ConvertVSMacros(midl_get(name, default=default)) | 406 return self.ConvertVSMacros(midl_get(name, default=default)) |
407 tlb = midl('TypeLibraryName', default='${root}.tlb') | 407 tlb = midl('TypeLibraryName', default='${root}.tlb') |
408 header = midl('HeaderFileName', default='${root}.h') | 408 header = midl('HeaderFileName', default='${root}.h') |
409 dlldata = midl('DLLDataFileName', default='dlldata.c') | 409 dlldata = midl('DLLDataFileName', default='dlldata.c') |
410 iid = midl('InterfaceIdentifierFileName', default='${root}_i.c') | 410 iid = midl('InterfaceIdentifierFileName', default='${root}_i.c') |
411 proxy = midl('ProxyFileName', default='${root}_p.c') | 411 proxy = midl('ProxyFileName', default='${root}_p.c') |
412 # Note that .tlb is not included in the outputs as it is not always | 412 # Note that .tlb is not included in the outputs as it is not always |
413 # generated depending on the content of the input idl file. | 413 # generated depending on the content of the input idl file. |
414 outdir = midl('OutputDirectory') | 414 outdir = midl('OutputDirectory', '') |
415 output = [header, dlldata, iid, proxy] | 415 output = [header, dlldata, iid, proxy] |
416 variables = [('tlb', tlb), | 416 variables = [('tlb', tlb), |
417 ('h', header), | 417 ('h', header), |
418 ('dlldata', dlldata), | 418 ('dlldata', dlldata), |
419 ('iid', iid), | 419 ('iid', iid), |
420 ('proxy', proxy)] | 420 ('proxy', proxy)] |
421 # TODO(scottmg): Are there configuration settings to set these flags? | 421 # TODO(scottmg): Are there configuration settings to set these flags? |
422 flags = ['/char', 'signed', '/env', 'win32', '/Oicf'] | 422 flags = ['/char', 'signed', '/env', 'win32', '/Oicf'] |
423 return outdir, output, variables, flags | 423 return outdir, output, variables, flags |
424 | 424 |
425 vs_version = None | 425 vs_version = None |
426 def GetVSVersion(generator_flags): | 426 def GetVSVersion(generator_flags): |
427 global vs_version | 427 global vs_version |
428 if not vs_version: | 428 if not vs_version: |
429 vs_version = gyp.MSVSVersion.SelectVisualStudioVersion( | 429 vs_version = gyp.MSVSVersion.SelectVisualStudioVersion( |
430 generator_flags.get('msvs_version', 'auto')) | 430 generator_flags.get('msvs_version', 'auto')) |
431 return vs_version | 431 return vs_version |
432 | 432 |
433 def _GetBinaryPath(generator_flags, tool): | 433 def _GetBinaryPath(generator_flags, tool): |
434 vs = GetVSVersion(generator_flags) | 434 vs = GetVSVersion(generator_flags) |
435 return ('"' + | 435 return ('"' + |
436 os.path.normpath(os.path.join(vs.Path(), "VC/bin", tool)) + | 436 os.path.normpath(os.path.join(vs.Path(), "VC/bin", tool)).lower() + |
437 '"') | 437 '"') |
438 | 438 |
439 def GetCLPath(generator_flags): | 439 def GetCLPath(generator_flags): |
440 return _GetBinaryPath(generator_flags, 'cl.exe') | 440 return _GetBinaryPath(generator_flags, 'cl.exe') |
441 | 441 |
442 def GetLinkPath(generator_flags): | 442 def GetLinkPath(generator_flags): |
443 return _GetBinaryPath(generator_flags, 'link.exe') | 443 return _GetBinaryPath(generator_flags, 'link.exe') |
444 | 444 |
445 def GetLibPath(generator_flags): | 445 def GetLibPath(generator_flags): |
446 return _GetBinaryPath(generator_flags, 'lib.exe') | 446 return _GetBinaryPath(generator_flags, 'lib.exe') |
(...skipping 21 matching lines...) Expand all Loading... |
468 vs.Path(), r'Common7\Tools\vsvars32.bat')) | 468 vs.Path(), r'Common7\Tools\vsvars32.bat')) |
469 | 469 |
470 def ExpandMacros(string, expansions): | 470 def ExpandMacros(string, expansions): |
471 """Expand $(Variable) per expansions dict. See MsvsSettings.GetVSMacroEnv | 471 """Expand $(Variable) per expansions dict. See MsvsSettings.GetVSMacroEnv |
472 for the canonical way to retrieve a suitable dict.""" | 472 for the canonical way to retrieve a suitable dict.""" |
473 if '$' in string: | 473 if '$' in string: |
474 for old, new in expansions.iteritems(): | 474 for old, new in expansions.iteritems(): |
475 assert '$(' not in new, new | 475 assert '$(' not in new, new |
476 string = string.replace(old, new) | 476 string = string.replace(old, new) |
477 return string | 477 return string |
OLD | NEW |