Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(946)

Unified Diff: pylib/gyp/generator/msvs.py

Issue 10378042: Correct the order in which OutputDirectory and IntermediateDirectory are defined. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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,
« no previous file with comments | « no previous file | test/msvs/shared_output/common.gypi » ('j') | test/msvs/shared_output/gyptest-shared_output.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698