| 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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 ldflags.append('/DYNAMICBASE') | 505 ldflags.append('/DYNAMICBASE') |
| 506 | 506 |
| 507 # If the NXCOMPAT flag has not been specified, default to on. Despite the | 507 # If the NXCOMPAT flag has not been specified, default to on. Despite the |
| 508 # documentation that says this only defaults to on when the subsystem is | 508 # documentation that says this only defaults to on when the subsystem is |
| 509 # Vista or greater (which applies to the linker), the IDE defaults it on | 509 # Vista or greater (which applies to the linker), the IDE defaults it on |
| 510 # unless it's explicitly off. | 510 # unless it's explicitly off. |
| 511 if not filter(lambda x: 'NXCOMPAT' in x, ldflags): | 511 if not filter(lambda x: 'NXCOMPAT' in x, ldflags): |
| 512 ldflags.append('/NXCOMPAT') | 512 ldflags.append('/NXCOMPAT') |
| 513 | 513 |
| 514 have_def_file = filter(lambda x: x.startswith('/DEF:'), ldflags) | 514 have_def_file = filter(lambda x: x.startswith('/DEF:'), ldflags) |
| 515 manifest_flags, intermediate_manifest_file = self._GetLdManifestFlags( | 515 manifest_flags, manifest_files = self._GetLdManifestFlags( |
| 516 config, manifest_base_name, is_executable and not have_def_file) | 516 config, manifest_base_name, gyp_to_build_path, |
| 517 is_executable and not have_def_file) |
| 517 ldflags.extend(manifest_flags) | 518 ldflags.extend(manifest_flags) |
| 518 manifest_files = self._GetAdditionalManifestFiles(config, gyp_to_build_path) | |
| 519 manifest_files.append(intermediate_manifest_file) | |
| 520 | |
| 521 return ldflags, manifest_files | 519 return ldflags, manifest_files |
| 522 | 520 |
| 523 def _GetLdManifestFlags(self, config, name, allow_isolation): | 521 def _GetLdManifestFlags(self, config, name, gyp_to_build_path, |
| 522 allow_isolation): |
| 524 """Returns the set of flags that need to be added to the link to generate | 523 """Returns the set of flags that need to be added to the link to generate |
| 525 a default manifest, as well as the name of the generated file.""" | 524 a default manifest, as well as the list of all the manifest files to be |
| 526 # The manifest is generated by default. | 525 merged by the manifest tool.""" |
| 526 generate_manifest = self._Setting(('VCLinkerTool', 'GenerateManifest'), |
| 527 config, |
| 528 default='true') |
| 529 if generate_manifest != 'true': |
| 530 # This means not only that the linker should not generate the intermediate |
| 531 # manifest but also that the manifest tool should do nothing even when |
| 532 # additional manifests are specified. |
| 533 return ['/MANIFEST:NO'], [] |
| 534 |
| 527 output_name = name + '.intermediate.manifest' | 535 output_name = name + '.intermediate.manifest' |
| 528 flags = [ | 536 flags = [ |
| 529 '/MANIFEST', | 537 '/MANIFEST', |
| 530 '/ManifestFile:' + output_name, | 538 '/ManifestFile:' + output_name, |
| 531 ] | 539 ] |
| 532 | 540 |
| 533 config = self._TargetConfig(config) | 541 config = self._TargetConfig(config) |
| 534 enable_uac = self._Setting(('VCLinkerTool', 'EnableUAC'), config, | 542 enable_uac = self._Setting(('VCLinkerTool', 'EnableUAC'), config, |
| 535 default='true') | 543 default='true') |
| 536 if enable_uac == 'true': | 544 if enable_uac == 'true': |
| 537 execution_level = self._Setting(('VCLinkerTool', 'UACExecutionLevel'), | 545 execution_level = self._Setting(('VCLinkerTool', 'UACExecutionLevel'), |
| 538 config, default='0') | 546 config, default='0') |
| 539 execution_level_map = { | 547 execution_level_map = { |
| 540 '0': 'asInvoker', | 548 '0': 'asInvoker', |
| 541 '1': 'highestAvailable', | 549 '1': 'highestAvailable', |
| 542 '2': 'requireAdministrator' | 550 '2': 'requireAdministrator' |
| 543 } | 551 } |
| 544 | 552 |
| 545 ui_access = self._Setting(('VCLinkerTool', 'UACUIAccess'), config, | 553 ui_access = self._Setting(('VCLinkerTool', 'UACUIAccess'), config, |
| 546 default='false') | 554 default='false') |
| 547 flags.append('''/MANIFESTUAC:"level='%s' uiAccess='%s'"''' % | 555 flags.append('''/MANIFESTUAC:"level='%s' uiAccess='%s'"''' % |
| 548 (execution_level_map[execution_level], ui_access)) | 556 (execution_level_map[execution_level], ui_access)) |
| 549 else: | 557 else: |
| 550 flags.append('/MANIFESTUAC:NO') | 558 flags.append('/MANIFESTUAC:NO') |
| 551 | 559 |
| 552 if allow_isolation: | 560 if allow_isolation: |
| 553 flags.append('/ALLOWISOLATION') | 561 flags.append('/ALLOWISOLATION') |
| 554 return flags, output_name | 562 |
| 563 manifest_files = [output_name] |
| 564 manifest_files += self._GetAdditionalManifestFiles(config, |
| 565 gyp_to_build_path) |
| 566 return flags, manifest_files |
| 555 | 567 |
| 556 def _GetAdditionalManifestFiles(self, config, gyp_to_build_path): | 568 def _GetAdditionalManifestFiles(self, config, gyp_to_build_path): |
| 557 """Gets additional manifest files that are added to the default one | 569 """Gets additional manifest files that are added to the default one |
| 558 generated by the linker.""" | 570 generated by the linker.""" |
| 559 files = self._Setting(('VCManifestTool', 'AdditionalManifestFiles'), config, | 571 files = self._Setting(('VCManifestTool', 'AdditionalManifestFiles'), config, |
| 560 default=[]) | 572 default=[]) |
| 561 if isinstance(files, str): | 573 if isinstance(files, str): |
| 562 files = files.split(';') | 574 files = files.split(';') |
| 563 return [os.path.normpath( | 575 return [os.path.normpath( |
| 564 gyp_to_build_path(self.ConvertVSMacros(f, config=config))) | 576 gyp_to_build_path(self.ConvertVSMacros(f, config=config))) |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 | 884 |
| 873 # To determine processor word size on Windows, in addition to checking | 885 # To determine processor word size on Windows, in addition to checking |
| 874 # PROCESSOR_ARCHITECTURE (which reflects the word size of the current | 886 # PROCESSOR_ARCHITECTURE (which reflects the word size of the current |
| 875 # process), it is also necessary to check PROCESSOR_ARCHITEW6432 (which | 887 # process), it is also necessary to check PROCESSOR_ARCHITEW6432 (which |
| 876 # contains the actual word size of the system when running thru WOW64). | 888 # contains the actual word size of the system when running thru WOW64). |
| 877 if ('64' in os.environ.get('PROCESSOR_ARCHITECTURE', '') or | 889 if ('64' in os.environ.get('PROCESSOR_ARCHITECTURE', '') or |
| 878 '64' in os.environ.get('PROCESSOR_ARCHITEW6432', '')): | 890 '64' in os.environ.get('PROCESSOR_ARCHITEW6432', '')): |
| 879 default_variables['MSVS_OS_BITS'] = 64 | 891 default_variables['MSVS_OS_BITS'] = 64 |
| 880 else: | 892 else: |
| 881 default_variables['MSVS_OS_BITS'] = 32 | 893 default_variables['MSVS_OS_BITS'] = 32 |
| OLD | NEW |