Chromium Code Reviews| Index: pylib/gyp/generator/msvs.py |
| =================================================================== |
| --- pylib/gyp/generator/msvs.py (revision 1364) |
| +++ pylib/gyp/generator/msvs.py (working copy) |
| @@ -2635,6 +2635,51 @@ |
| conditions.append(condition) |
| +MSBUILD_PROPERTY_ORDER = [ |
|
gab
2012/05/09 15:27:11
Does this mean we will need to add each new proper
bradn
2012/05/10 01:48:52
So I'm gonna swap this all out for the topological
|
| + 'OutDir', |
| + 'IntDir', # IntDir is usually defined is terms of OutDir so put it later. |
|
gab
2012/05/09 15:27:11
typo: is => in
bradn
2012/05/10 01:48:52
Done.
|
| + 'TargetName', |
| + 'TargetPath', |
| + 'ExecutablePath', |
| +] |
| + |
| + |
| +def _MSBuildPropertyRank(name): |
| + """Decide a rank for a property name. |
| + |
| + Returns: |
| + A numerical value which is lower if a property should be |
| + defined earlier. |
| + Place unknown property names last (as other typically don't |
| + rely on them). |
| + """ |
| + try: |
| + return MSBUILD_PROPERTY_ORDER.index(name) |
| + except ValueError: |
| + return len(MSBUILD_PROPERTY_ORDER) |
| + |
| + |
| +def _CompareMSBuildProperties(a, b): |
| + """Compare two property pairs (name, values). |
| + |
| + Order of definition in msbuild matters. In general we don't make |
| + use of properties defined at the same level, but there are exceptions. |
| + This function defines a sort order that is mostly alphabetical, |
| + with a few items that commonly are used in self reference brought to the |
| + front. |
| + |
| + Args: |
| + a: (name, values) pair. |
| + b: (name, values) pair. |
| + Returns: |
| + -1, 0, 1 for comparison. |
| + """ |
| + result = cmp(_MSBuildPropertyRank(a[0]), _MSBuildPropertyRank(b[0])) |
| + if result != 0: |
| + return result |
| + return cmp(a, b) |
| + |
| + |
| def _GetMSBuildPropertyGroup(spec, label, properties): |
| """Returns a PropertyGroup definition for the specified properties. |
| @@ -2649,7 +2694,7 @@ |
| if label: |
| group.append({'Label': label}) |
| num_configurations = len(spec['configurations']) |
| - for name, values in sorted(properties.iteritems()): |
| + for name, values in sorted(properties.iteritems(), _CompareMSBuildProperties): |
| for value, conditions in sorted(values.iteritems()): |
| if len(conditions) == num_configurations: |
| # If the value is the same all configurations, |