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 |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 sources, excluded_sources, excluded_idl = ( | 898 sources, excluded_sources, excluded_idl = ( |
899 _AdjustSourcesAndConvertToFilterHierarchy( | 899 _AdjustSourcesAndConvertToFilterHierarchy( |
900 spec, options, project_dir, sources, excluded_sources, list_excluded)) | 900 spec, options, project_dir, sources, excluded_sources, list_excluded)) |
901 | 901 |
902 # Add in files. | 902 # Add in files. |
903 missing_sources = _VerifySourcesExist(sources, project_dir) | 903 missing_sources = _VerifySourcesExist(sources, project_dir) |
904 p.AddFiles(sources) | 904 p.AddFiles(sources) |
905 | 905 |
906 _AddToolFilesToMSVS(p, spec) | 906 _AddToolFilesToMSVS(p, spec) |
907 _HandlePreCompiledHeaders(p, sources, spec) | 907 _HandlePreCompiledHeaders(p, sources, spec) |
908 _AddActions(actions_to_add, spec, relative_path_of_gyp_file) | 908 _AddActions(actions_to_add, spec, relative_path_of_gyp_file, project.path) |
909 _AddCopies(actions_to_add, spec) | 909 _AddCopies(actions_to_add, spec) |
910 _WriteMSVSUserFile(project.path, version, spec) | 910 _WriteMSVSUserFile(project.path, version, spec) |
911 | 911 |
912 # NOTE: this stanza must appear after all actions have been decided. | 912 # NOTE: this stanza must appear after all actions have been decided. |
913 # Don't excluded sources with actions attached, or they won't run. | 913 # Don't excluded sources with actions attached, or they won't run. |
914 excluded_sources = _FilterActionsFromExcluded( | 914 excluded_sources = _FilterActionsFromExcluded( |
915 excluded_sources, actions_to_add) | 915 excluded_sources, actions_to_add) |
916 _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_idl, | 916 _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_idl, |
917 list_excluded) | 917 list_excluded) |
918 _AddAccumulatedActionsToMSVS(p, spec, actions_to_add) | 918 _AddAccumulatedActionsToMSVS(p, spec, actions_to_add) |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 {'UsePrecompiledHeader': '0', | 1434 {'UsePrecompiledHeader': '0', |
1435 'ForcedIncludeFiles': '$(NOINHERIT)'}) | 1435 'ForcedIncludeFiles': '$(NOINHERIT)'}) |
1436 p.AddFileConfig(_FixPath(source), | 1436 p.AddFileConfig(_FixPath(source), |
1437 _ConfigFullName(config_name, config), | 1437 _ConfigFullName(config_name, config), |
1438 {}, tools=[tool]) | 1438 {}, tools=[tool]) |
1439 # Do nothing if there was no precompiled source. | 1439 # Do nothing if there was no precompiled source. |
1440 if extensions_excluded_from_precompile: | 1440 if extensions_excluded_from_precompile: |
1441 DisableForSourceTree(sources) | 1441 DisableForSourceTree(sources) |
1442 | 1442 |
1443 | 1443 |
1444 def _AddActions(actions_to_add, spec, relative_path_of_gyp_file): | 1444 def _WriteFileIfChanged(filename, data): |
| 1445 if os.path.exists(filename): |
| 1446 fh = open(filename, 'r') |
| 1447 old_data = fh.read() |
| 1448 fh.close() |
| 1449 if old_data == data: |
| 1450 return |
| 1451 fh = open(filename, 'w') |
| 1452 fh.write(data) |
| 1453 fh.close() |
| 1454 |
| 1455 |
| 1456 def _AddActions(actions_to_add, spec, relative_path_of_gyp_file, vcproj_file): |
1445 # Add actions. | 1457 # Add actions. |
1446 actions = spec.get('actions', []) | 1458 actions = spec.get('actions', []) |
1447 for a in actions: | 1459 for a in actions: |
1448 cmd = _BuildCommandLineForRule(spec, a, has_input_path=False) | 1460 cmd = _BuildCommandLineForRule(spec, a, has_input_path=False) |
1449 # Attach actions to the gyp file if nothing else is there. | 1461 # Attach actions to the gyp file if nothing else is there. |
1450 inputs = a.get('inputs') or [relative_path_of_gyp_file] | 1462 inputs = a.get('inputs') or [relative_path_of_gyp_file] |
| 1463 if vcproj_file: |
| 1464 # Additionally, on MSVS 2008, we record the command in a file |
| 1465 # and add this as a dependency so that when the command changes, |
| 1466 # the action gets re-run. This is not necessary on MSVS 2010 |
| 1467 # which tracks command changes for us. |
| 1468 command_file = '%s_%s.gypcmd' % (vcproj_file, a['action_name']) |
| 1469 _WriteFileIfChanged(command_file, cmd) |
| 1470 inputs = inputs + [os.path.basename(command_file)] |
1451 # Add the action. | 1471 # Add the action. |
1452 _AddActionStep(actions_to_add, | 1472 _AddActionStep(actions_to_add, |
1453 inputs=inputs, | 1473 inputs=inputs, |
1454 outputs=a.get('outputs', []), | 1474 outputs=a.get('outputs', []), |
1455 description=a.get('message', a['action_name']), | 1475 description=a.get('message', a['action_name']), |
1456 command=cmd) | 1476 command=cmd) |
1457 | 1477 |
1458 | 1478 |
1459 def _WriteMSVSUserFile(project_path, version, spec): | 1479 def _WriteMSVSUserFile(project_path, version, spec): |
1460 # Add run_as and test targets. | 1480 # Add run_as and test targets. |
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2885 | 2905 |
2886 | 2906 |
2887 def _GenerateMSBuildProject(project, options, version, generator_flags): | 2907 def _GenerateMSBuildProject(project, options, version, generator_flags): |
2888 spec = project.spec | 2908 spec = project.spec |
2889 configurations = spec['configurations'] | 2909 configurations = spec['configurations'] |
2890 project_dir, project_file_name = os.path.split(project.path) | 2910 project_dir, project_file_name = os.path.split(project.path) |
2891 msbuildproj_dir = os.path.dirname(project.path) | 2911 msbuildproj_dir = os.path.dirname(project.path) |
2892 if msbuildproj_dir and not os.path.exists(msbuildproj_dir): | 2912 if msbuildproj_dir and not os.path.exists(msbuildproj_dir): |
2893 os.makedirs(msbuildproj_dir) | 2913 os.makedirs(msbuildproj_dir) |
2894 # Prepare list of sources and excluded sources. | 2914 # Prepare list of sources and excluded sources. |
2895 gyp_path = _NormalizedSource(project.build_file) | |
2896 relative_path_of_gyp_file = gyp.common.RelativePath(gyp_path, project_dir) | |
2897 | |
2898 gyp_file = os.path.split(project.build_file)[1] | 2915 gyp_file = os.path.split(project.build_file)[1] |
2899 sources, excluded_sources = _PrepareListOfSources(spec, gyp_file) | 2916 sources, excluded_sources = _PrepareListOfSources(spec, gyp_file) |
2900 # Add rules. | 2917 # Add rules. |
2901 actions_to_add = {} | 2918 actions_to_add = {} |
2902 props_files_of_rules = set() | 2919 props_files_of_rules = set() |
2903 targets_files_of_rules = set() | 2920 targets_files_of_rules = set() |
2904 extension_to_rule_name = {} | 2921 extension_to_rule_name = {} |
2905 list_excluded = generator_flags.get('msvs_list_excluded_files', True) | 2922 list_excluded = generator_flags.get('msvs_list_excluded_files', True) |
2906 _GenerateRulesForMSBuild(project_dir, options, spec, | 2923 _GenerateRulesForMSBuild(project_dir, options, spec, |
2907 sources, excluded_sources, | 2924 sources, excluded_sources, |
2908 props_files_of_rules, targets_files_of_rules, | 2925 props_files_of_rules, targets_files_of_rules, |
2909 actions_to_add, extension_to_rule_name) | 2926 actions_to_add, extension_to_rule_name) |
2910 sources, excluded_sources, excluded_idl = ( | 2927 sources, excluded_sources, excluded_idl = ( |
2911 _AdjustSourcesAndConvertToFilterHierarchy(spec, options, | 2928 _AdjustSourcesAndConvertToFilterHierarchy(spec, options, |
2912 project_dir, sources, | 2929 project_dir, sources, |
2913 excluded_sources, | 2930 excluded_sources, |
2914 list_excluded)) | 2931 list_excluded)) |
2915 _AddActions(actions_to_add, spec, project.build_file) | 2932 _AddActions(actions_to_add, spec, project.build_file, None) |
2916 _AddCopies(actions_to_add, spec) | 2933 _AddCopies(actions_to_add, spec) |
2917 | 2934 |
2918 # NOTE: this stanza must appear after all actions have been decided. | 2935 # NOTE: this stanza must appear after all actions have been decided. |
2919 # Don't excluded sources with actions attached, or they won't run. | 2936 # Don't excluded sources with actions attached, or they won't run. |
2920 excluded_sources = _FilterActionsFromExcluded( | 2937 excluded_sources = _FilterActionsFromExcluded( |
2921 excluded_sources, actions_to_add) | 2938 excluded_sources, actions_to_add) |
2922 | 2939 |
2923 exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) | 2940 exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) |
2924 actions_spec, sources_handled_by_action = _GenerateActionsForMSBuild( | 2941 actions_spec, sources_handled_by_action = _GenerateActionsForMSBuild( |
2925 spec, actions_to_add) | 2942 spec, actions_to_add) |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3047 action_spec.extend( | 3064 action_spec.extend( |
3048 # TODO(jeanluc) 'Document' for all or just if as_sources? | 3065 # TODO(jeanluc) 'Document' for all or just if as_sources? |
3049 [['FileType', 'Document'], | 3066 [['FileType', 'Document'], |
3050 ['Command', command], | 3067 ['Command', command], |
3051 ['Message', description], | 3068 ['Message', description], |
3052 ['Outputs', outputs] | 3069 ['Outputs', outputs] |
3053 ]) | 3070 ]) |
3054 if additional_inputs: | 3071 if additional_inputs: |
3055 action_spec.append(['AdditionalInputs', additional_inputs]) | 3072 action_spec.append(['AdditionalInputs', additional_inputs]) |
3056 actions_spec.append(action_spec) | 3073 actions_spec.append(action_spec) |
OLD | NEW |