| 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 import copy | 5 import copy |
| 6 import ntpath | 6 import ntpath |
| 7 import os | 7 import os |
| 8 import posixpath | 8 import posixpath |
| 9 import re | 9 import re |
| 10 import subprocess | 10 import subprocess |
| 11 import sys | 11 import sys |
| 12 | 12 |
| 13 import gyp.common | 13 import gyp.common |
| 14 import gyp.easy_xml as easy_xml | 14 import gyp.easy_xml as easy_xml |
| 15 import gyp.generator.ninja as ninja_generator |
| 15 import gyp.MSVSNew as MSVSNew | 16 import gyp.MSVSNew as MSVSNew |
| 16 import gyp.MSVSProject as MSVSProject | 17 import gyp.MSVSProject as MSVSProject |
| 17 import gyp.MSVSSettings as MSVSSettings | 18 import gyp.MSVSSettings as MSVSSettings |
| 18 import gyp.MSVSToolFile as MSVSToolFile | 19 import gyp.MSVSToolFile as MSVSToolFile |
| 19 import gyp.MSVSUserFile as MSVSUserFile | 20 import gyp.MSVSUserFile as MSVSUserFile |
| 20 import gyp.MSVSUtil as MSVSUtil | 21 import gyp.MSVSUtil as MSVSUtil |
| 21 import gyp.MSVSVersion as MSVSVersion | 22 import gyp.MSVSVersion as MSVSVersion |
| 22 from gyp.common import GypError | 23 from gyp.common import GypError |
| 23 from gyp.common import OrderedSet | 24 from gyp.common import OrderedSet |
| 24 | 25 |
| (...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1780 # Set all the dependencies, but not if we are using an external builder like | 1781 # Set all the dependencies, but not if we are using an external builder like |
| 1781 # ninja | 1782 # ninja |
| 1782 for project in projects.values(): | 1783 for project in projects.values(): |
| 1783 if not project.spec.get('msvs_external_builder'): | 1784 if not project.spec.get('msvs_external_builder'): |
| 1784 deps = project.spec.get('dependencies', []) | 1785 deps = project.spec.get('dependencies', []) |
| 1785 deps = [projects[d] for d in deps] | 1786 deps = [projects[d] for d in deps] |
| 1786 project.set_dependencies(deps) | 1787 project.set_dependencies(deps) |
| 1787 return projects | 1788 return projects |
| 1788 | 1789 |
| 1789 | 1790 |
| 1790 def _InitNinjaFlavor(options, target_list, target_dicts): | 1791 def _InitNinjaFlavor(params, target_list, target_dicts): |
| 1791 """Initialize targets for the ninja flavor. | 1792 """Initialize targets for the ninja flavor. |
| 1792 | 1793 |
| 1793 This sets up the necessary variables in the targets to generate msvs projects | 1794 This sets up the necessary variables in the targets to generate msvs projects |
| 1794 that use ninja as an external builder. The variables in the spec are only set | 1795 that use ninja as an external builder. The variables in the spec are only set |
| 1795 if they have not been set. This allows individual specs to override the | 1796 if they have not been set. This allows individual specs to override the |
| 1796 default values initialized here. | 1797 default values initialized here. |
| 1797 Arguments: | 1798 Arguments: |
| 1798 options: Options provided to the generator. | 1799 params: Params provided to the generator. |
| 1799 target_list: List of target pairs: 'base/base.gyp:base'. | 1800 target_list: List of target pairs: 'base/base.gyp:base'. |
| 1800 target_dicts: Dict of target properties keyed on target pair. | 1801 target_dicts: Dict of target properties keyed on target pair. |
| 1801 """ | 1802 """ |
| 1802 for qualified_target in target_list: | 1803 for qualified_target in target_list: |
| 1803 spec = target_dicts[qualified_target] | 1804 spec = target_dicts[qualified_target] |
| 1804 if spec.get('msvs_external_builder'): | 1805 if spec.get('msvs_external_builder'): |
| 1805 # The spec explicitly defined an external builder, so don't change it. | 1806 # The spec explicitly defined an external builder, so don't change it. |
| 1806 continue | 1807 continue |
| 1807 | 1808 |
| 1808 path_to_ninja = spec.get('msvs_path_to_ninja', 'ninja.exe') | 1809 path_to_ninja = spec.get('msvs_path_to_ninja', 'ninja.exe') |
| 1809 | 1810 |
| 1810 spec['msvs_external_builder'] = 'ninja' | 1811 spec['msvs_external_builder'] = 'ninja' |
| 1811 if not spec.get('msvs_external_builder_out_dir'): | 1812 if not spec.get('msvs_external_builder_out_dir'): |
| 1812 spec['msvs_external_builder_out_dir'] = \ | 1813 gyp_file, _, _ = gyp.common.ParseQualifiedTarget(qualified_target) |
| 1813 options.depth + '/out/$(Configuration)' | 1814 gyp_dir = os.path.dirname(gyp_file) |
| 1815 spec['msvs_external_builder_out_dir'] = os.path.join( |
| 1816 gyp.common.RelativePath(params['options'].toplevel_dir, gyp_dir), |
| 1817 ninja_generator.ComputeOutputDir(params), |
| 1818 '$(Configuration)') |
| 1814 if not spec.get('msvs_external_builder_build_cmd'): | 1819 if not spec.get('msvs_external_builder_build_cmd'): |
| 1815 spec['msvs_external_builder_build_cmd'] = [ | 1820 spec['msvs_external_builder_build_cmd'] = [ |
| 1816 path_to_ninja, | 1821 path_to_ninja, |
| 1817 '-C', | 1822 '-C', |
| 1818 '$(OutDir)', | 1823 '$(OutDir)', |
| 1819 '$(ProjectName)', | 1824 '$(ProjectName)', |
| 1820 ] | 1825 ] |
| 1821 if not spec.get('msvs_external_builder_clean_cmd'): | 1826 if not spec.get('msvs_external_builder_clean_cmd'): |
| 1822 spec['msvs_external_builder_clean_cmd'] = [ | 1827 spec['msvs_external_builder_clean_cmd'] = [ |
| 1823 path_to_ninja, | 1828 path_to_ninja, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 # Optionally shard targets marked with 'msvs_shard': SHARD_COUNT. | 1903 # Optionally shard targets marked with 'msvs_shard': SHARD_COUNT. |
| 1899 (target_list, target_dicts) = MSVSUtil.ShardTargets(target_list, target_dicts) | 1904 (target_list, target_dicts) = MSVSUtil.ShardTargets(target_list, target_dicts) |
| 1900 | 1905 |
| 1901 # Optionally use the large PDB workaround for targets marked with | 1906 # Optionally use the large PDB workaround for targets marked with |
| 1902 # 'msvs_large_pdb': 1. | 1907 # 'msvs_large_pdb': 1. |
| 1903 (target_list, target_dicts) = MSVSUtil.InsertLargePdbShims( | 1908 (target_list, target_dicts) = MSVSUtil.InsertLargePdbShims( |
| 1904 target_list, target_dicts, generator_default_variables) | 1909 target_list, target_dicts, generator_default_variables) |
| 1905 | 1910 |
| 1906 # Optionally configure each spec to use ninja as the external builder. | 1911 # Optionally configure each spec to use ninja as the external builder. |
| 1907 if params.get('flavor') == 'ninja': | 1912 if params.get('flavor') == 'ninja': |
| 1908 _InitNinjaFlavor(options, target_list, target_dicts) | 1913 _InitNinjaFlavor(params, target_list, target_dicts) |
| 1909 | 1914 |
| 1910 # Prepare the set of configurations. | 1915 # Prepare the set of configurations. |
| 1911 configs = set() | 1916 configs = set() |
| 1912 for qualified_target in target_list: | 1917 for qualified_target in target_list: |
| 1913 spec = target_dicts[qualified_target] | 1918 spec = target_dicts[qualified_target] |
| 1914 for config_name, config in spec['configurations'].iteritems(): | 1919 for config_name, config in spec['configurations'].iteritems(): |
| 1915 configs.add(_ConfigFullName(config_name, config)) | 1920 configs.add(_ConfigFullName(config_name, config)) |
| 1916 configs = list(configs) | 1921 configs = list(configs) |
| 1917 | 1922 |
| 1918 # Figure out all the projects that will be generated and their guids | 1923 # Figure out all the projects that will be generated and their guids |
| (...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3310 action_spec.extend( | 3315 action_spec.extend( |
| 3311 # TODO(jeanluc) 'Document' for all or just if as_sources? | 3316 # TODO(jeanluc) 'Document' for all or just if as_sources? |
| 3312 [['FileType', 'Document'], | 3317 [['FileType', 'Document'], |
| 3313 ['Command', command], | 3318 ['Command', command], |
| 3314 ['Message', description], | 3319 ['Message', description], |
| 3315 ['Outputs', outputs] | 3320 ['Outputs', outputs] |
| 3316 ]) | 3321 ]) |
| 3317 if additional_inputs: | 3322 if additional_inputs: |
| 3318 action_spec.append(['AdditionalInputs', additional_inputs]) | 3323 action_spec.append(['AdditionalInputs', additional_inputs]) |
| 3319 actions_spec.append(action_spec) | 3324 actions_spec.append(action_spec) |
| OLD | NEW |