Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: pylib/gyp/msvs_emulation.py

Issue 82703007: Support Visual C++ PGO in Ninja generator (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/win/gyptest-link-ltcg.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 raise Exception("Multiple .def files") 435 raise Exception("Multiple .def files")
436 return None 436 return None
437 437
438 def _GetDefFileAsLdflags(self, ldflags, gyp_to_build_path): 438 def _GetDefFileAsLdflags(self, ldflags, gyp_to_build_path):
439 """.def files get implicitly converted to a ModuleDefinitionFile for the 439 """.def files get implicitly converted to a ModuleDefinitionFile for the
440 linker in the VS generator. Emulate that behaviour here.""" 440 linker in the VS generator. Emulate that behaviour here."""
441 def_file = self.GetDefFile(gyp_to_build_path) 441 def_file = self.GetDefFile(gyp_to_build_path)
442 if def_file: 442 if def_file:
443 ldflags.append('/DEF:"%s"' % def_file) 443 ldflags.append('/DEF:"%s"' % def_file)
444 444
445 def GetPGDName(self, config, expand_special):
446 """Gets the explicitly overridden pgd name for a target or returns None
447 if it's not overridden."""
448 config = self._TargetConfig(config)
449 output_file = self._Setting(
450 ('VCLinkerTool', 'ProfileGuidedDatabase'), config)
451 if output_file:
452 output_file = expand_special(self.ConvertVSMacros(
453 output_file, config=config))
454 return output_file
455
445 def GetLdflags(self, config, gyp_to_build_path, expand_special, 456 def GetLdflags(self, config, gyp_to_build_path, expand_special,
446 manifest_base_name, is_executable): 457 manifest_base_name, is_executable):
447 """Returns the flags that need to be added to link commands, and the 458 """Returns the flags that need to be added to link commands, and the
448 manifest files.""" 459 manifest files."""
449 config = self._TargetConfig(config) 460 config = self._TargetConfig(config)
450 ldflags = [] 461 ldflags = []
451 ld = self._GetWrapper(self, self.msvs_settings[config], 462 ld = self._GetWrapper(self, self.msvs_settings[config],
452 'VCLinkerTool', append=ldflags) 463 'VCLinkerTool', append=ldflags)
453 self._GetDefFileAsLdflags(ldflags, gyp_to_build_path) 464 self._GetDefFileAsLdflags(ldflags, gyp_to_build_path)
454 ld('GenerateDebugInformation', map={'true': '/DEBUG'}) 465 ld('GenerateDebugInformation', map={'true': '/DEBUG'})
455 ld('TargetMachine', map={'1': 'X86', '17': 'X64'}, prefix='/MACHINE:') 466 ld('TargetMachine', map={'1': 'X86', '17': 'X64'}, prefix='/MACHINE:')
456 ldflags.extend(self._GetAdditionalLibraryDirectories( 467 ldflags.extend(self._GetAdditionalLibraryDirectories(
457 'VCLinkerTool', config, gyp_to_build_path)) 468 'VCLinkerTool', config, gyp_to_build_path))
458 ld('DelayLoadDLLs', prefix='/DELAYLOAD:') 469 ld('DelayLoadDLLs', prefix='/DELAYLOAD:')
459 out = self.GetOutputName(config, expand_special) 470 out = self.GetOutputName(config, expand_special)
460 if out: 471 if out:
461 ldflags.append('/OUT:' + out) 472 ldflags.append('/OUT:' + out)
462 pdb = self.GetPDBName(config, expand_special) 473 pdb = self.GetPDBName(config, expand_special)
463 if pdb: 474 if pdb:
464 ldflags.append('/PDB:' + pdb) 475 ldflags.append('/PDB:' + pdb)
476 pgd = self.GetPGDName(config, expand_special)
477 if pgd:
478 ldflags.append('/PGD:' + pgd)
465 map_file = self.GetMapFileName(config, expand_special) 479 map_file = self.GetMapFileName(config, expand_special)
466 ld('GenerateMapFile', map={'true': '/MAP:' + map_file if map_file 480 ld('GenerateMapFile', map={'true': '/MAP:' + map_file if map_file
467 else '/MAP'}) 481 else '/MAP'})
468 ld('MapExports', map={'true': '/MAPINFO:EXPORTS'}) 482 ld('MapExports', map={'true': '/MAPINFO:EXPORTS'})
469 ld('AdditionalOptions', prefix='') 483 ld('AdditionalOptions', prefix='')
470 484
471 minimum_required_version = self._Setting( 485 minimum_required_version = self._Setting(
472 ('VCLinkerTool', 'MinimumRequiredVersion'), config, default='') 486 ('VCLinkerTool', 'MinimumRequiredVersion'), config, default='')
473 if minimum_required_version: 487 if minimum_required_version:
474 minimum_required_version = ',' + minimum_required_version 488 minimum_required_version = ',' + minimum_required_version
475 ld('SubSystem', 489 ld('SubSystem',
476 map={'1': 'CONSOLE%s' % minimum_required_version, 490 map={'1': 'CONSOLE%s' % minimum_required_version,
477 '2': 'WINDOWS%s' % minimum_required_version}, 491 '2': 'WINDOWS%s' % minimum_required_version},
478 prefix='/SUBSYSTEM:') 492 prefix='/SUBSYSTEM:')
479 493
480 ld('TerminalServerAware', map={'1': ':NO', '2': ''}, prefix='/TSAWARE') 494 ld('TerminalServerAware', map={'1': ':NO', '2': ''}, prefix='/TSAWARE')
481 ld('LinkIncremental', map={'1': ':NO', '2': ''}, prefix='/INCREMENTAL') 495 ld('LinkIncremental', map={'1': ':NO', '2': ''}, prefix='/INCREMENTAL')
482 ld('BaseAddress', prefix='/BASE:') 496 ld('BaseAddress', prefix='/BASE:')
483 ld('FixedBaseAddress', map={'1': ':NO', '2': ''}, prefix='/FIXED') 497 ld('FixedBaseAddress', map={'1': ':NO', '2': ''}, prefix='/FIXED')
484 ld('RandomizedBaseAddress', 498 ld('RandomizedBaseAddress',
485 map={'1': ':NO', '2': ''}, prefix='/DYNAMICBASE') 499 map={'1': ':NO', '2': ''}, prefix='/DYNAMICBASE')
486 ld('DataExecutionPrevention', 500 ld('DataExecutionPrevention',
487 map={'1': ':NO', '2': ''}, prefix='/NXCOMPAT') 501 map={'1': ':NO', '2': ''}, prefix='/NXCOMPAT')
488 ld('OptimizeReferences', map={'1': 'NOREF', '2': 'REF'}, prefix='/OPT:') 502 ld('OptimizeReferences', map={'1': 'NOREF', '2': 'REF'}, prefix='/OPT:')
489 ld('EnableCOMDATFolding', map={'1': 'NOICF', '2': 'ICF'}, prefix='/OPT:') 503 ld('EnableCOMDATFolding', map={'1': 'NOICF', '2': 'ICF'}, prefix='/OPT:')
490 ld('LinkTimeCodeGeneration', map={'1': '/LTCG'}) 504 ld('LinkTimeCodeGeneration',
505 map={'1': '', '2': ':PGINSTRUMENT', '3': ':PGOPTIMIZE',
506 '4': ':PGUPDATE'},
507 prefix='/LTCG')
491 ld('IgnoreDefaultLibraryNames', prefix='/NODEFAULTLIB:') 508 ld('IgnoreDefaultLibraryNames', prefix='/NODEFAULTLIB:')
492 ld('ResourceOnlyDLL', map={'true': '/NOENTRY'}) 509 ld('ResourceOnlyDLL', map={'true': '/NOENTRY'})
493 ld('EntryPointSymbol', prefix='/ENTRY:') 510 ld('EntryPointSymbol', prefix='/ENTRY:')
494 ld('Profile', map={'true': '/PROFILE'}) 511 ld('Profile', map={'true': '/PROFILE'})
495 ld('LargeAddressAware', 512 ld('LargeAddressAware',
496 map={'1': ':NO', '2': ''}, prefix='/LARGEADDRESSAWARE') 513 map={'1': ':NO', '2': ''}, prefix='/LARGEADDRESSAWARE')
497 # TODO(scottmg): This should sort of be somewhere else (not really a flag). 514 # TODO(scottmg): This should sort of be somewhere else (not really a flag).
498 ld('AdditionalDependencies', prefix='') 515 ld('AdditionalDependencies', prefix='')
499 516
500 # If the base address is not specifically controlled, DYNAMICBASE should 517 # If the base address is not specifically controlled, DYNAMICBASE should
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 901
885 # To determine processor word size on Windows, in addition to checking 902 # To determine processor word size on Windows, in addition to checking
886 # PROCESSOR_ARCHITECTURE (which reflects the word size of the current 903 # PROCESSOR_ARCHITECTURE (which reflects the word size of the current
887 # process), it is also necessary to check PROCESSOR_ARCHITEW6432 (which 904 # process), it is also necessary to check PROCESSOR_ARCHITEW6432 (which
888 # contains the actual word size of the system when running thru WOW64). 905 # contains the actual word size of the system when running thru WOW64).
889 if ('64' in os.environ.get('PROCESSOR_ARCHITECTURE', '') or 906 if ('64' in os.environ.get('PROCESSOR_ARCHITECTURE', '') or
890 '64' in os.environ.get('PROCESSOR_ARCHITEW6432', '')): 907 '64' in os.environ.get('PROCESSOR_ARCHITEW6432', '')):
891 default_variables['MSVS_OS_BITS'] = 64 908 default_variables['MSVS_OS_BITS'] = 64
892 else: 909 else:
893 default_variables['MSVS_OS_BITS'] = 32 910 default_variables['MSVS_OS_BITS'] = 32
OLDNEW
« no previous file with comments | « no previous file | test/win/gyptest-link-ltcg.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698