| 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 2617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2628 """ | 2628 """ |
| 2629 if name not in properties: | 2629 if name not in properties: |
| 2630 properties[name] = {} | 2630 properties[name] = {} |
| 2631 values = properties[name] | 2631 values = properties[name] |
| 2632 if value not in values: | 2632 if value not in values: |
| 2633 values[value] = [] | 2633 values[value] = [] |
| 2634 conditions = values[value] | 2634 conditions = values[value] |
| 2635 conditions.append(condition) | 2635 conditions.append(condition) |
| 2636 | 2636 |
| 2637 | 2637 |
| 2638 # Regex for msvs variable references ( i.e. $(FOO) ). |
| 2639 MSVS_VARIABLE_REFERENCE = re.compile('\$\(([a-zA-Z_][a-zA-Z0-9_]*)\)') |
| 2640 |
| 2641 |
| 2638 def _GetMSBuildPropertyGroup(spec, label, properties): | 2642 def _GetMSBuildPropertyGroup(spec, label, properties): |
| 2639 """Returns a PropertyGroup definition for the specified properties. | 2643 """Returns a PropertyGroup definition for the specified properties. |
| 2640 | 2644 |
| 2641 Arguments: | 2645 Arguments: |
| 2642 spec: The target project dict. | 2646 spec: The target project dict. |
| 2643 label: An optional label for the PropertyGroup. | 2647 label: An optional label for the PropertyGroup. |
| 2644 properties: The dictionary to be converted. The key is the name of the | 2648 properties: The dictionary to be converted. The key is the name of the |
| 2645 property. The value is itself a dictionary; its key is the value and | 2649 property. The value is itself a dictionary; its key is the value and |
| 2646 the value a list of condition for which this value is true. | 2650 the value a list of condition for which this value is true. |
| 2647 """ | 2651 """ |
| 2648 group = ['PropertyGroup'] | 2652 group = ['PropertyGroup'] |
| 2649 if label: | 2653 if label: |
| 2650 group.append({'Label': label}) | 2654 group.append({'Label': label}) |
| 2651 num_configurations = len(spec['configurations']) | 2655 num_configurations = len(spec['configurations']) |
| 2652 for name, values in sorted(properties.iteritems()): | 2656 def GetEdges(node): |
| 2657 edges = set() |
| 2658 for value in sorted(properties[node].keys()): |
| 2659 # Add to edges all $(...) references to variables. |
| 2660 # |
| 2661 # Variable references that refer to names not in properties are excluded |
| 2662 # These can exist for instance to refer built in definitions like |
| 2663 # $(SolutionDir). |
| 2664 # |
| 2665 # Self references are ignored. Self reference is used in a few places to |
| 2666 # append to the default value. I.e. PATH=$(PATH);other_path |
| 2667 edges.update(set([v for v in MSVS_VARIABLE_REFERENCE.findall(value) |
| 2668 if v in properties and v != node])) |
| 2669 return edges |
| 2670 properties_ordered = gyp.common.TopologicallySorted( |
| 2671 properties.keys(), GetEdges) |
| 2672 for name in reversed(properties_ordered): |
| 2673 values = properties[name] |
| 2653 for value, conditions in sorted(values.iteritems()): | 2674 for value, conditions in sorted(values.iteritems()): |
| 2654 if len(conditions) == num_configurations: | 2675 if len(conditions) == num_configurations: |
| 2655 # If the value is the same all configurations, | 2676 # If the value is the same all configurations, |
| 2656 # just add one unconditional entry. | 2677 # just add one unconditional entry. |
| 2657 group.append([name, value]) | 2678 group.append([name, value]) |
| 2658 else: | 2679 else: |
| 2659 for condition in conditions: | 2680 for condition in conditions: |
| 2660 group.append([name, {'Condition': condition}, value]) | 2681 group.append([name, {'Condition': condition}, value]) |
| 2661 return [group] | 2682 return [group] |
| 2662 | 2683 |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3064 action_spec.extend( | 3085 action_spec.extend( |
| 3065 # TODO(jeanluc) 'Document' for all or just if as_sources? | 3086 # TODO(jeanluc) 'Document' for all or just if as_sources? |
| 3066 [['FileType', 'Document'], | 3087 [['FileType', 'Document'], |
| 3067 ['Command', command], | 3088 ['Command', command], |
| 3068 ['Message', description], | 3089 ['Message', description], |
| 3069 ['Outputs', outputs] | 3090 ['Outputs', outputs] |
| 3070 ]) | 3091 ]) |
| 3071 if additional_inputs: | 3092 if additional_inputs: |
| 3072 action_spec.append(['AdditionalInputs', additional_inputs]) | 3093 action_spec.append(['AdditionalInputs', additional_inputs]) |
| 3073 actions_spec.append(action_spec) | 3094 actions_spec.append(action_spec) |
| OLD | NEW |