Commit da55cdc0 authored by Michael Moss's avatar Michael Moss Committed by Commit Bot

Apply parent vars to recursedeps.

This fixes an issue where cumulative conditions would fail to evaluate
if the recursed DEP (or custom_var overrides) didn't happen to redeclare
all the variables used by the parent conditions.

TBR=dpranke@google.com, ehmaldonado@google.com

Bug: 825063
Change-Id: Icb53f04928f914dfacc2c3035d01be103d9f8247
Reviewed-on: https://chromium-review.googlesource.com/1000836
Commit-Queue: Michael Moss <mmoss@chromium.org>
Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: 's avatarMichael Moss <mmoss@chromium.org>
parent 3f277fc7
......@@ -766,14 +766,10 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
local_scope = {}
if deps_content:
try:
vars_override = {}
if self.parent:
vars_override = self.parent.get_vars()
vars_override.update(self.get_vars())
local_scope = gclient_eval.Parse(
deps_content, expand_vars,
self._get_option('validate_syntax', False),
filepath, vars_override)
filepath, self.get_vars())
except SyntaxError as e:
gclient_utils.SyntaxErrorToError(filepath, e)
......@@ -1369,8 +1365,15 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
'checkout_x64': 'x64' in self.target_cpu,
'host_cpu': detect_host_arch.HostArch(),
}
# Variables defined in DEPS file override built-in ones.
# Variable precedence:
# - built-in
# - DEPS vars
# - parents, from first to last
# - custom_vars overrides
result.update(self._vars)
if self.parent:
parent_vars = self.parent.get_vars()
result.update(parent_vars)
result.update(self.custom_vars or {})
return result
......
......@@ -5,6 +5,6 @@ Once upon a time, a budding web browser dev team needed a CI system.
All they had was one poor machine under a desk, and its name was Batty,
the Build and Test Yeti.
Then suddenly,
Then suddenly,
😒
......@@ -382,8 +382,15 @@ deps_os = {
self._commit_git('repo_2', {
'origin': 'git/repo_2@1\n',
'DEPS': """
vars = {
'repo2_false_var': 'False',
}
deps = {
'foo/bar': '/repo_3',
'foo/bar': {
'url': '/repo_3',
'condition': 'repo2_false_var',
}
}
""",
})
......
......@@ -839,7 +839,7 @@ class GClientSmokeGIT(GClientSmokeBase):
' # src -> src/repo2 -> foo/bar',
' "foo/bar": {',
' "url": "/repo_3",',
' "condition": \'true_str_var\',',
' "condition": \'(repo2_false_var) and (true_str_var)\',',
' },',
'',
' # src',
......@@ -968,6 +968,9 @@ class GClientSmokeGIT(GClientSmokeBase):
' # src',
' "hook1_contents": \'git_hooked1\',',
'',
' # src -> src/repo2',
' "repo2_false_var": \'False\',',
'',
' # src',
' "repo5_var": \'/repo_5\',',
'',
......@@ -1015,7 +1018,7 @@ class GClientSmokeGIT(GClientSmokeBase):
' # src -> src/repo2 -> foo/bar',
' "foo/bar": {',
' "url": "/repo_3@%s",' % (self.githash('repo_3', 2)),
' "condition": \'true_str_var\',',
' "condition": \'(repo2_false_var) and (true_str_var)\',',
' },',
'',
' # src',
......@@ -1145,6 +1148,9 @@ class GClientSmokeGIT(GClientSmokeBase):
' # src',
' "hook1_contents": \'git_hooked1\',',
'',
' # src -> src/repo2',
' "repo2_false_var": \'False\',',
'',
' # src',
' "repo5_var": \'/repo_5\',',
'',
......
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