OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2011 Google Inc. All rights reserved. | 3 # Copyright (c) 2011 Google Inc. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 import copy | 7 import copy |
8 import ntpath | 8 import ntpath |
9 import os | 9 import os |
10 import posixpath | 10 import posixpath |
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 # Add rules. | 871 # Add rules. |
872 actions_to_add = {} | 872 actions_to_add = {} |
873 _GenerateRulesForMSVS(p, gyp_dir, options, spec, | 873 _GenerateRulesForMSVS(p, gyp_dir, options, spec, |
874 sources, excluded_sources, | 874 sources, excluded_sources, |
875 actions_to_add) | 875 actions_to_add) |
876 sources, excluded_sources, excluded_idl = ( | 876 sources, excluded_sources, excluded_idl = ( |
877 _AdjustSourcesAndConvertToFilterHierarchy( | 877 _AdjustSourcesAndConvertToFilterHierarchy( |
878 spec, options, gyp_dir, sources, excluded_sources)) | 878 spec, options, gyp_dir, sources, excluded_sources)) |
879 | 879 |
880 # Add in files. | 880 # Add in files. |
| 881 _VerifySourcesExist(sources, gyp_dir) |
881 p.AddFiles(sources) | 882 p.AddFiles(sources) |
882 | 883 |
883 _AddToolFilesToMSVS(p, spec) | 884 _AddToolFilesToMSVS(p, spec) |
884 _HandlePreCompileHeaderStubs(p, spec) | 885 _HandlePreCompileHeaderStubs(p, spec) |
885 _AddActions(actions_to_add, spec, relative_path_of_gyp_file) | 886 _AddActions(actions_to_add, spec, relative_path_of_gyp_file) |
886 _AddCopies(actions_to_add, spec) | 887 _AddCopies(actions_to_add, spec) |
887 _WriteMSVSUserFile(project.path, version, spec) | 888 _WriteMSVSUserFile(project.path, version, spec) |
888 | 889 |
889 # NOTE: this stanza must appear after all actions have been decided. | 890 # NOTE: this stanza must appear after all actions have been decided. |
890 # Don't excluded sources with actions attached, or they won't run. | 891 # Don't excluded sources with actions attached, or they won't run. |
(...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2599 char = ' ' | 2600 char = ' ' |
2600 else: | 2601 else: |
2601 char = ';' | 2602 char = ';' |
2602 formatted_value = char.join( | 2603 formatted_value = char.join( |
2603 [MSVSSettings.ConvertVCMacrosToMSBuild(i) for i in value]) | 2604 [MSVSSettings.ConvertVCMacrosToMSBuild(i) for i in value]) |
2604 else: | 2605 else: |
2605 formatted_value = MSVSSettings.ConvertVCMacrosToMSBuild(value) | 2606 formatted_value = MSVSSettings.ConvertVCMacrosToMSBuild(value) |
2606 return formatted_value | 2607 return formatted_value |
2607 | 2608 |
2608 | 2609 |
2609 def _GetMSBuildSources(spec, root_dir, sources, exclusions, | 2610 def _VerifySourcesExist(sources, root_dir): |
2610 extension_to_rule_name, actions_spec, | 2611 """Verifies that all source files exist on disk. |
2611 sources_handled_by_action): | 2612 |
| 2613 Checks that all regular source files, i.e. not created at run time, |
| 2614 exist on disk. Missing files cause needless recompilation but no otherwise |
| 2615 visible errors. |
| 2616 |
| 2617 Arguments: |
| 2618 sources: A recursive list of Filter/file names. |
| 2619 root_dir: The root directory for the relative path names. |
| 2620 """ |
| 2621 for source in sources: |
| 2622 if isinstance(source, MSVSProject.Filter): |
| 2623 _VerifySourcesExist(source.contents, root_dir) |
| 2624 else: |
| 2625 if '$' not in source: |
| 2626 full_path = os.path.join(root_dir, source) |
| 2627 if not os.path.exists(full_path): |
| 2628 print 'Error: Missing input file ' + full_path |
| 2629 |
| 2630 |
| 2631 def _GetMSBuildSources(spec, sources, exclusions, extension_to_rule_name, |
| 2632 actions_spec, sources_handled_by_action): |
2612 groups = ['none', 'midl', 'include', 'compile', 'resource', 'rule'] | 2633 groups = ['none', 'midl', 'include', 'compile', 'resource', 'rule'] |
2613 grouped_sources = {} | 2634 grouped_sources = {} |
2614 for g in groups: | 2635 for g in groups: |
2615 grouped_sources[g] = [] | 2636 grouped_sources[g] = [] |
2616 | 2637 |
2617 _AddSources2(spec, root_dir, sources, exclusions, grouped_sources, | 2638 _AddSources2(spec, sources, exclusions, grouped_sources, |
2618 extension_to_rule_name, sources_handled_by_action) | 2639 extension_to_rule_name, sources_handled_by_action) |
2619 sources = [] | 2640 sources = [] |
2620 for g in groups: | 2641 for g in groups: |
2621 if grouped_sources[g]: | 2642 if grouped_sources[g]: |
2622 sources.append(['ItemGroup'] + grouped_sources[g]) | 2643 sources.append(['ItemGroup'] + grouped_sources[g]) |
2623 if actions_spec: | 2644 if actions_spec: |
2624 sources.append(['ItemGroup'] + actions_spec) | 2645 sources.append(['ItemGroup'] + actions_spec) |
2625 return sources | 2646 return sources |
2626 | 2647 |
2627 | 2648 |
2628 def _AddSources2(spec, root_dir, sources, exclusions, grouped_sources, | 2649 def _AddSources2(spec, sources, exclusions, grouped_sources, |
2629 extension_to_rule_name, sources_handled_by_action): | 2650 extension_to_rule_name, sources_handled_by_action): |
2630 for source in sources: | 2651 for source in sources: |
2631 if isinstance(source, MSVSProject.Filter): | 2652 if isinstance(source, MSVSProject.Filter): |
2632 _AddSources2(spec, root_dir, source.contents, exclusions, grouped_sources, | 2653 _AddSources2(spec, source.contents, exclusions, grouped_sources, |
2633 extension_to_rule_name, sources_handled_by_action) | 2654 extension_to_rule_name, sources_handled_by_action) |
2634 else: | 2655 else: |
2635 # If it is a regular source file, i.e. not created at run time, | |
2636 # warn if it does not exists. Missing header files will cause needless | |
2637 # recompilation but no otherwise visible errors. | |
2638 if '$' not in source: | |
2639 full_path = os.path.join(root_dir, source) | |
2640 if not os.path.exists(full_path): | |
2641 print 'Warning: Missing input file ' + full_path | |
2642 if not source in sources_handled_by_action: | 2656 if not source in sources_handled_by_action: |
2643 detail = [] | 2657 detail = [] |
2644 excluded_configurations = exclusions.get(source, []) | 2658 excluded_configurations = exclusions.get(source, []) |
2645 if len(excluded_configurations) == len(spec['configurations']): | 2659 if len(excluded_configurations) == len(spec['configurations']): |
2646 detail.append(['ExcludedFromBuild', 'true']) | 2660 detail.append(['ExcludedFromBuild', 'true']) |
2647 else: | 2661 else: |
2648 for config_name, configuration in sorted(excluded_configurations): | 2662 for config_name, configuration in sorted(excluded_configurations): |
2649 condition = _GetConfigurationCondition(config_name, configuration) | 2663 condition = _GetConfigurationCondition(config_name, configuration) |
2650 detail.append(['ExcludedFromBuild', | 2664 detail.append(['ExcludedFromBuild', |
2651 {'Condition': condition}, | 2665 {'Condition': condition}, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2718 # Don't excluded sources with actions attached, or they won't run. | 2732 # Don't excluded sources with actions attached, or they won't run. |
2719 excluded_sources = _FilterActionsFromExcluded( | 2733 excluded_sources = _FilterActionsFromExcluded( |
2720 excluded_sources, actions_to_add) | 2734 excluded_sources, actions_to_add) |
2721 | 2735 |
2722 exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) | 2736 exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) |
2723 actions_spec, sources_handled_by_action = _GenerateActionsForMSBuild( | 2737 actions_spec, sources_handled_by_action = _GenerateActionsForMSBuild( |
2724 spec, actions_to_add) | 2738 spec, actions_to_add) |
2725 | 2739 |
2726 _GenerateMSBuildFiltersFile(project.path + '.filters', sources, | 2740 _GenerateMSBuildFiltersFile(project.path + '.filters', sources, |
2727 extension_to_rule_name) | 2741 extension_to_rule_name) |
| 2742 _VerifySourcesExist(sources, gyp_dir) |
2728 | 2743 |
2729 for (_, configuration) in configurations.iteritems(): | 2744 for (_, configuration) in configurations.iteritems(): |
2730 _FinalizeMSBuildSettings(spec, configuration) | 2745 _FinalizeMSBuildSettings(spec, configuration) |
2731 | 2746 |
2732 # Add attributes to root element | 2747 # Add attributes to root element |
2733 | 2748 |
2734 doc = easy_xml.EasyXml( | 2749 doc = easy_xml.EasyXml( |
2735 'Project', | 2750 'Project', |
2736 {'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003', | 2751 {'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003', |
2737 'ToolsVersion': version.ProjectVersion(), | 2752 'ToolsVersion': version.ProjectVersion(), |
(...skipping 13 matching lines...) Expand all Loading... |
2751 content += import_default_section | 2766 content += import_default_section |
2752 content += _GetMSBuildConfigurationDetails(spec, project.build_file) | 2767 content += _GetMSBuildConfigurationDetails(spec, project.build_file) |
2753 content += import_cpp_props_section | 2768 content += import_cpp_props_section |
2754 content += _GetMSBuildExtensions(props_files_of_rules) | 2769 content += _GetMSBuildExtensions(props_files_of_rules) |
2755 content += _GetMSBuildPropertySheets(configurations) | 2770 content += _GetMSBuildPropertySheets(configurations) |
2756 content += macro_section | 2771 content += macro_section |
2757 content += _GetMSBuildConfigurationGlobalProperties(spec, configurations, | 2772 content += _GetMSBuildConfigurationGlobalProperties(spec, configurations, |
2758 project.build_file) | 2773 project.build_file) |
2759 content += _GetMSBuildToolSettingsSections(spec, configurations) | 2774 content += _GetMSBuildToolSettingsSections(spec, configurations) |
2760 content += _GetMSBuildSources( | 2775 content += _GetMSBuildSources( |
2761 spec, gyp_dir, sources, exclusions, extension_to_rule_name, actions_spec, | 2776 spec, sources, exclusions, extension_to_rule_name, actions_spec, |
2762 sources_handled_by_action) | 2777 sources_handled_by_action) |
2763 content += _GetMSBuildProjectReferences(project) | 2778 content += _GetMSBuildProjectReferences(project) |
2764 content += import_cpp_targets_section | 2779 content += import_cpp_targets_section |
2765 content += _GetMSBuildExtensionTargets(targets_files_of_rules) | 2780 content += _GetMSBuildExtensionTargets(targets_files_of_rules) |
2766 | 2781 |
2767 # TODO(jeanluc) File a bug to get rid of runas. We had in MSVS: | 2782 # TODO(jeanluc) File a bug to get rid of runas. We had in MSVS: |
2768 # has_run_as = _WriteMSVSUserFile(project.path, version, spec) | 2783 # has_run_as = _WriteMSVSUserFile(project.path, version, spec) |
2769 | 2784 |
2770 doc.AppendChildren(doc.Root(), content) | 2785 doc.AppendChildren(doc.Root(), content) |
2771 doc.WriteIfChanged(project.path) | 2786 doc.WriteIfChanged(project.path) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2843 action_spec.extend( | 2858 action_spec.extend( |
2844 # TODO(jeanluc) 'Document' for all or just if as_sources? | 2859 # TODO(jeanluc) 'Document' for all or just if as_sources? |
2845 [['FileType', 'Document'], | 2860 [['FileType', 'Document'], |
2846 ['Command', command], | 2861 ['Command', command], |
2847 ['Message', description], | 2862 ['Message', description], |
2848 ['Outputs', outputs] | 2863 ['Outputs', outputs] |
2849 ]) | 2864 ]) |
2850 if additional_inputs: | 2865 if additional_inputs: |
2851 action_spec.append(['AdditionalInputs', additional_inputs]) | 2866 action_spec.append(['AdditionalInputs', additional_inputs]) |
2852 actions_spec.append(action_spec) | 2867 actions_spec.append(action_spec) |
OLD | NEW |