Chromium Code Reviews

Unified Diff: gclient.py

Issue 23875029: Handle conflicting os deps better in gclient. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Addressed review issues. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient.py
diff --git a/gclient.py b/gclient.py
index 407b9ad4e99f1efd3f31270f3695e18f458b1fcb..e8b4e7d12057ee9dd6d6b409aa8cc254cde98753 100755
--- a/gclient.py
+++ b/gclient.py
@@ -488,22 +488,42 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
self.local_target_os = local_scope['target_os']
# load os specific dependencies if defined. these dependencies may
# override or extend the values defined by the 'deps' member.
- target_os_deps = {}
- if 'deps_os' in local_scope:
- for deps_os_key in self.target_os:
- os_deps = local_scope['deps_os'].get(deps_os_key, {})
- if len(self.target_os) > 1:
- # Ignore any conflict when including deps for more than one
- # platform, so we collect the broadest set of dependencies
- # available. We may end up with the wrong revision of something for
- # our platform, but this is the best we can do.
- target_os_deps.update(
- [x for x in os_deps.items() if not x[0] in target_os_deps])
- else:
- target_os_deps.update(os_deps)
+ if 'deps_os' in local_scope and self.target_os:
Isaac (away) 2013/12/09 10:33:13 self.target_os is a recursive function, let's save
Daniel Bratell 2013/12/11 18:09:49 To make the code faster?
Isaac (away) 2013/12/11 18:58:27 yes, also because in theory the order could change
+ target_os_deps = {}
+ the_first_os = self.target_os[0]
Isaac (away) 2013/12/09 10:33:13 It seems like we're going to have two decision pat
+ # |set_by_os| tracks what deps are overridden and by whom.
+ set_by_os = dict.fromkeys(deps.keys(), the_first_os)
+
+ os_deps = local_scope['deps_os'].get(the_first_os, {})
+ for os_dep_key, os_dep_value in os_deps.iteritems():
+ target_os_deps[os_dep_key] = os_dep_value
+ set_by_os[os_dep_key] = the_first_os
+
+ for the_target_os in self.target_os[1:]:
+ # Ignore (but warn) for any conflict when including deps for
+ # more than one platform, so we collect the broadest set of
+ # dependencies available. We may end up with the wrong
+ # revision of something for our platform, but this is the
+ # best we can do.
+ os_deps = local_scope['deps_os'].get(the_target_os, {})
+ for os_dep_key, os_dep_value in os_deps.iteritems():
+ prev_value = target_os_deps.get(os_dep_key, deps.get(os_dep_key))
+ if os_dep_key in set_by_os and prev_value is not None:
+ # Some platforms override with None just to create a
+ # smaller checkout. No reason to warn about that.
+ if os_dep_value is not None and os_dep_value != prev_value:
+ print('Conflicting dependencies for %s. %s wants %s '
Isaac (away) 2013/12/09 10:33:13 Use logging calls instead of print
+ 'while %s wants %s. '
+ '%s will be used since %s was listed before %s.' %
Isaac (away) 2013/12/09 10:33:13 Order is completely arbitrary in this list since t
Daniel Bratell 2013/12/11 18:09:49 The problem with that is that it won't be the pers
+ (os_dep_key, the_target_os, os_dep_value,
+ set_by_os[os_dep_key], prev_value,
+ prev_value, set_by_os[os_dep_key], the_target_os))
+ else:
+ target_os_deps[os_dep_key] = os_dep_value
+ set_by_os[os_dep_key] = the_target_os
- # deps_os overrides paths from deps
- deps.update(target_os_deps)
+ # deps_os overrides paths from deps
+ deps.update(target_os_deps)
# If a line is in custom_deps, but not in the solution, we want to append
# this line to the solution.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine