Commit 5705acab authored by Eric Boren's avatar Eric Boren Committed by Commit Bot

[gclient] Make getdep and setdep to provide builtin vars

Bug: 906114
Change-Id: I069cc21343911f7fdb3c91ecbd8fcba53fc8099f
Reviewed-on: https://chromium-review.googlesource.com/c/1340461Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Eric Boren <borenet@chromium.org>
parent 8ada4d52
......@@ -2831,7 +2831,9 @@ def CMDgetdep(parser, args):
'DEPS file %s does not exist.' % options.deps_file)
with open(options.deps_file) as f:
contents = f.read()
local_scope = gclient_eval.Exec(contents, options.deps_file)
client = GClient.LoadCurrentConfig(options)
local_scope = gclient_eval.Exec(contents, options.deps_file,
builtin_vars=client.get_builtin_vars())
for var in options.vars:
print(gclient_eval.GetVar(local_scope, var))
......@@ -2881,7 +2883,9 @@ def CMDsetdep(parser, args):
'DEPS file %s does not exist.' % options.deps_file)
with open(options.deps_file) as f:
contents = f.read()
local_scope = gclient_eval.Exec(contents, options.deps_file)
client = GClient.LoadCurrentConfig(options)
local_scope = gclient_eval.Exec(contents, options.deps_file,
builtin_vars=client.get_builtin_vars())
for var in options.vars:
name, _, value = var.partition('=')
......
......@@ -881,6 +881,7 @@ class GClientSmokeGIT(GClientSmokeBase):
self.assertEqual(out, output_json)
def testSetDep(self):
self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
fake_deps = os.path.join(self.root_dir, 'DEPS.fake')
with open(fake_deps, 'w') as f:
f.write('\n'.join([
......@@ -894,6 +895,12 @@ class GClientSmokeGIT(GClientSmokeBase):
' },',
' "bar": "url@bar_rev",',
'}',
'hooks = [{',
' "name": "uses_builtin_var",',
' "pattern": ".",',
' "action": ["python", "fake.py",',
' "--with-android={checkout_android}"],',
'}]',
]))
results = self.gclient([
......@@ -916,9 +923,16 @@ class GClientSmokeGIT(GClientSmokeBase):
' },',
' "bar": "url@new_bar",',
'}',
'hooks = [{',
' "name": "uses_builtin_var",',
' "pattern": ".",',
' "action": ["python", "fake.py",',
' "--with-android={checkout_android}"],',
'}]',
], contents)
def testGetDep(self):
self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
fake_deps = os.path.join(self.root_dir, 'DEPS.fake')
with open(fake_deps, 'w') as f:
f.write('\n'.join([
......@@ -932,6 +946,12 @@ class GClientSmokeGIT(GClientSmokeBase):
' },',
' "bar": "url@bar_rev",',
'}',
'hooks = [{',
' "name": "uses_builtin_var",',
' "pattern": ".",',
' "action": ["python", "fake.py",',
' "--with-android={checkout_android}"],',
'}]',
]))
results = self.gclient([
......
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