Allow DEPS file to specify 'target_os'.


BUG=155792


Review URL: https://chromiumcodereview.appspot.com/11246004

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@163955 0039d316-1c4b-4281-b951-d872f2087c98
parent cb5667aa
......@@ -172,6 +172,9 @@ class DependencySettings(GClientKeywords):
# dependency. It is read from the actual DEPS file so cannot be set on
# class instantiation.
self.recursion_override = None
# This is a mutable value which has the list of 'target_os' OSes listed in
# the current deps file.
self.local_target_os = None
# These are only set in .gclient and not in DEPS files.
self._custom_vars = custom_vars or {}
......@@ -239,6 +242,13 @@ class DependencySettings(GClientKeywords):
return self.recursion_override
return max(self.parent.recursion_limit - 1, 0)
@property
def target_os(self):
if self.local_target_os is not None:
return tuple(set(self.local_target_os).union(self.parent.target_os))
else:
return self.parent.target_os
def get_custom_deps(self, name, url):
"""Returns a custom deps if applicable."""
if self.parent:
......@@ -455,13 +465,15 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
self.recursion_override = local_scope.get('recursion')
logging.warning(
'Setting %s recursion to %d.', self.name, self.recursion_limit)
# If present, save 'target_os' in the local_target_os property.
if 'target_os' in local_scope:
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.
if 'deps_os' in local_scope:
enforced_os = self.root.enforced_os
for deps_os_key in enforced_os:
for deps_os_key in self.target_os:
os_deps = local_scope['deps_os'].get(deps_os_key, {})
if len(enforced_os) > 1:
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
......@@ -1166,6 +1178,10 @@ solutions = [
"""How recursive can each dependencies in DEPS file can load DEPS file."""
return self._recursion_limit
@property
def target_os(self):
return self._enforced_os
#### gclient commands.
......
......@@ -307,6 +307,45 @@ class GclientTest(trial_dir.TestCase):
obj = gclient.GClient.LoadCurrentConfig(options)
self.assertEqual(['baz', 'unix'], sorted(obj.enforced_os))
def testTargetOsInDepsFile(self):
"""Verifies that specifying a target_os value in a DEPS file pulls in all
relevant dependencies.
The target_os variable in a DEPS file allows specifying the name of an
additional OS which should be considered when selecting dependencies from a
DEPS' deps_os. The value will be appended to the _enforced_os tuple.
"""
write(
'.gclient',
'solutions = [\n'
' { "name": "foo",\n'
' "url": "svn://example.com/foo",\n'
' }]\n')
write(
os.path.join('foo', 'DEPS'),
'target_os = ["baz"]\n'
'deps_os = {\n'
' "unix": { "foo/unix": "/unix", },\n'
' "baz": { "foo/baz": "/baz", },\n'
' "jaz": { "foo/jaz": "/jaz", },\n'
'}')
parser = gclient.Parser()
options, _ = parser.parse_args(['--jobs', '1'])
options.deps_os = 'unix'
obj = gclient.GClient.LoadCurrentConfig(options)
obj.RunOnDeps('None', [])
self.assertEqual(['unix'], sorted(obj.enforced_os))
self.assertEquals(
[
'svn://example.com/foo',
'svn://example.com/foo/baz',
'svn://example.com/foo/unix',
],
sorted(self._get_processed()))
def testRecursionOverride(self):
"""Verifies gclient respects the recursion var syntax.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment