diff --git a/gclient.py b/gclient.py index e8e496ef0..437190a7c 100755 --- a/gclient.py +++ b/gclient.py @@ -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 diff --git a/recipes/trigger_recipe_roller.txt b/recipes/trigger_recipe_roller.txt index 4c8146176..2f6ceb644 100644 --- a/recipes/trigger_recipe_roller.txt +++ b/recipes/trigger_recipe_roller.txt @@ -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, 😒 diff --git a/testing_support/fake_repos.py b/testing_support/fake_repos.py index 9a476a220..2496f9bba 100755 --- a/testing_support/fake_repos.py +++ b/testing_support/fake_repos.py @@ -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', + } } """, }) diff --git a/tests/gclient_smoketest.py b/tests/gclient_smoketest.py index 5927b243a..a7233a298 100755 --- a/tests/gclient_smoketest.py +++ b/tests/gclient_smoketest.py @@ -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\',', '',