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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 config = self._TargetConfig(config) | 310 config = self._TargetConfig(config) |
311 type = self.spec['type'] | 311 type = self.spec['type'] |
312 root = 'VCLibrarianTool' if type == 'static_library' else 'VCLinkerTool' | 312 root = 'VCLibrarianTool' if type == 'static_library' else 'VCLinkerTool' |
313 # TODO(scottmg): Handle OutputDirectory without OutputFile. | 313 # TODO(scottmg): Handle OutputDirectory without OutputFile. |
314 output_file = self._Setting((root, 'OutputFile'), config) | 314 output_file = self._Setting((root, 'OutputFile'), config) |
315 if output_file: | 315 if output_file: |
316 output_file = expand_special(self.ConvertVSMacros( | 316 output_file = expand_special(self.ConvertVSMacros( |
317 output_file, config=config)) | 317 output_file, config=config)) |
318 return output_file | 318 return output_file |
319 | 319 |
320 def GetPDBName(self, config, expand_special): | 320 def GetPDBName(self, config, expand_special, default): |
321 """Gets the explicitly overridden pdb name for a target or returns None | 321 """Gets the explicitly overridden pdb name for a target or returns |
322 if it's not overridden.""" | 322 default if it's not overridden, or if no pdb will be generated.""" |
323 config = self._TargetConfig(config) | 323 config = self._TargetConfig(config) |
324 output_file = self._Setting(('VCLinkerTool', 'ProgramDatabaseFile'), config) | 324 output_file = self._Setting(('VCLinkerTool', 'ProgramDatabaseFile'), config) |
325 if output_file: | 325 generate_debug_info = self._Setting( |
326 output_file = expand_special(self.ConvertVSMacros( | 326 ('VCLinkerTool', 'GenerateDebugInformation'), config) |
327 output_file, config=config)) | 327 if generate_debug_info: |
328 return output_file | 328 if output_file: |
| 329 return expand_special(self.ConvertVSMacros(output_file, config=config)) |
| 330 else: |
| 331 return default |
| 332 else: |
| 333 return None |
329 | 334 |
330 def GetCflags(self, config): | 335 def GetCflags(self, config): |
331 """Returns the flags that need to be added to .c and .cc compilations.""" | 336 """Returns the flags that need to be added to .c and .cc compilations.""" |
332 config = self._TargetConfig(config) | 337 config = self._TargetConfig(config) |
333 cflags = [] | 338 cflags = [] |
334 cflags.extend(['/wd' + w for w in self.msvs_disabled_warnings[config]]) | 339 cflags.extend(['/wd' + w for w in self.msvs_disabled_warnings[config]]) |
335 cl = self._GetWrapper(self, self.msvs_settings[config], | 340 cl = self._GetWrapper(self, self.msvs_settings[config], |
336 'VCCLCompilerTool', append=cflags) | 341 'VCCLCompilerTool', append=cflags) |
337 cl('Optimization', | 342 cl('Optimization', |
338 map={'0': 'd', '1': '1', '2': '2', '3': 'x'}, prefix='/O', default='2') | 343 map={'0': 'd', '1': '1', '2': '2', '3': 'x'}, prefix='/O', default='2') |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 if it's not overridden.""" | 452 if it's not overridden.""" |
448 config = self._TargetConfig(config) | 453 config = self._TargetConfig(config) |
449 output_file = self._Setting( | 454 output_file = self._Setting( |
450 ('VCLinkerTool', 'ProfileGuidedDatabase'), config) | 455 ('VCLinkerTool', 'ProfileGuidedDatabase'), config) |
451 if output_file: | 456 if output_file: |
452 output_file = expand_special(self.ConvertVSMacros( | 457 output_file = expand_special(self.ConvertVSMacros( |
453 output_file, config=config)) | 458 output_file, config=config)) |
454 return output_file | 459 return output_file |
455 | 460 |
456 def GetLdflags(self, config, gyp_to_build_path, expand_special, | 461 def GetLdflags(self, config, gyp_to_build_path, expand_special, |
457 manifest_base_name, is_executable, build_dir): | 462 manifest_base_name, output_name, is_executable, build_dir): |
458 """Returns the flags that need to be added to link commands, and the | 463 """Returns the flags that need to be added to link commands, and the |
459 manifest files.""" | 464 manifest files.""" |
460 config = self._TargetConfig(config) | 465 config = self._TargetConfig(config) |
461 ldflags = [] | 466 ldflags = [] |
462 ld = self._GetWrapper(self, self.msvs_settings[config], | 467 ld = self._GetWrapper(self, self.msvs_settings[config], |
463 'VCLinkerTool', append=ldflags) | 468 'VCLinkerTool', append=ldflags) |
464 self._GetDefFileAsLdflags(ldflags, gyp_to_build_path) | 469 self._GetDefFileAsLdflags(ldflags, gyp_to_build_path) |
465 ld('GenerateDebugInformation', map={'true': '/DEBUG'}) | 470 ld('GenerateDebugInformation', map={'true': '/DEBUG'}) |
466 ld('TargetMachine', map={'1': 'X86', '17': 'X64'}, prefix='/MACHINE:') | 471 ld('TargetMachine', map={'1': 'X86', '17': 'X64'}, prefix='/MACHINE:') |
467 ldflags.extend(self._GetAdditionalLibraryDirectories( | 472 ldflags.extend(self._GetAdditionalLibraryDirectories( |
468 'VCLinkerTool', config, gyp_to_build_path)) | 473 'VCLinkerTool', config, gyp_to_build_path)) |
469 ld('DelayLoadDLLs', prefix='/DELAYLOAD:') | 474 ld('DelayLoadDLLs', prefix='/DELAYLOAD:') |
470 ld('TreatLinkerWarningAsErrors', prefix='/WX', | 475 ld('TreatLinkerWarningAsErrors', prefix='/WX', |
471 map={'true': '', 'false': ':NO'}) | 476 map={'true': '', 'false': ':NO'}) |
472 out = self.GetOutputName(config, expand_special) | 477 out = self.GetOutputName(config, expand_special) |
473 if out: | 478 if out: |
474 ldflags.append('/OUT:' + out) | 479 ldflags.append('/OUT:' + out) |
475 pdb = self.GetPDBName(config, expand_special) | 480 pdb = self.GetPDBName(config, expand_special, output_name + '.pdb') |
476 if pdb: | 481 if pdb: |
477 ldflags.append('/PDB:' + pdb) | 482 ldflags.append('/PDB:' + pdb) |
478 pgd = self.GetPGDName(config, expand_special) | 483 pgd = self.GetPGDName(config, expand_special) |
479 if pgd: | 484 if pgd: |
480 ldflags.append('/PGD:' + pgd) | 485 ldflags.append('/PGD:' + pgd) |
481 map_file = self.GetMapFileName(config, expand_special) | 486 map_file = self.GetMapFileName(config, expand_special) |
482 ld('GenerateMapFile', map={'true': '/MAP:' + map_file if map_file | 487 ld('GenerateMapFile', map={'true': '/MAP:' + map_file if map_file |
483 else '/MAP'}) | 488 else '/MAP'}) |
484 ld('MapExports', map={'true': '/MAPINFO:EXPORTS'}) | 489 ld('MapExports', map={'true': '/MAPINFO:EXPORTS'}) |
485 ld('AdditionalOptions', prefix='') | 490 ld('AdditionalOptions', prefix='') |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 | 950 |
946 # To determine processor word size on Windows, in addition to checking | 951 # To determine processor word size on Windows, in addition to checking |
947 # PROCESSOR_ARCHITECTURE (which reflects the word size of the current | 952 # PROCESSOR_ARCHITECTURE (which reflects the word size of the current |
948 # process), it is also necessary to check PROCESSOR_ARCHITEW6432 (which | 953 # process), it is also necessary to check PROCESSOR_ARCHITEW6432 (which |
949 # contains the actual word size of the system when running thru WOW64). | 954 # contains the actual word size of the system when running thru WOW64). |
950 if ('64' in os.environ.get('PROCESSOR_ARCHITECTURE', '') or | 955 if ('64' in os.environ.get('PROCESSOR_ARCHITECTURE', '') or |
951 '64' in os.environ.get('PROCESSOR_ARCHITEW6432', '')): | 956 '64' in os.environ.get('PROCESSOR_ARCHITEW6432', '')): |
952 default_variables['MSVS_OS_BITS'] = 64 | 957 default_variables['MSVS_OS_BITS'] = 64 |
953 else: | 958 else: |
954 default_variables['MSVS_OS_BITS'] = 32 | 959 default_variables['MSVS_OS_BITS'] = 32 |
OLD | NEW |