mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
gclient: evaluate variables before passing them to GN
This helps make sure they have proper types (e.g. True instead of "True" for booleans). Also see https://chromium-review.googlesource.com/c/chromium/src/+/681854 for context. Bug: 756688, 570091 Change-Id: I1e4d26df724e8e94cc3daba361191856f80a1b2c Reviewed-on: https://chromium-review.googlesource.com/681705 Reviewed-by: Dirk Pranke <dpranke@chromium.org> Commit-Queue: Paweł Hajdan Jr. <phajdan.jr@chromium.org>
This commit is contained in:
committed by
Commit Bot
parent
df64ee138a
commit
b495bf5017
@@ -959,8 +959,10 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
|
||||
|
||||
def WriteGNArgsFile(self):
|
||||
lines = ['# Generated from %r' % self.deps_file]
|
||||
variables = self.get_vars()
|
||||
for arg in self._gn_args:
|
||||
lines.append('%s = %s' % (arg, ToGNString(self.get_vars()[arg])))
|
||||
value = gclient_eval.EvaluateCondition(variables[arg], variables)
|
||||
lines.append('%s = %s' % (arg, ToGNString(value)))
|
||||
with open(os.path.join(self.root.root_dir, self._gn_args_file), 'w') as f:
|
||||
f.write('\n'.join(lines))
|
||||
|
||||
|
||||
@@ -329,9 +329,16 @@ class FakeRepos(FakeReposBase):
|
||||
'DEPS': """
|
||||
vars = {
|
||||
'DummyVariable': 'repo',
|
||||
'false_var': 'False',
|
||||
'true_var': 'True',
|
||||
'str_var': '"abc"',
|
||||
}
|
||||
gclient_gn_args_file = 'src/gclient.args'
|
||||
gclient_gn_args = ['DummyVariable']
|
||||
gclient_gn_args = [
|
||||
'false_var',
|
||||
'true_var',
|
||||
'str_var',
|
||||
]
|
||||
deps = {
|
||||
'src/repo2': {
|
||||
'url': '%(git_base)srepo_2',
|
||||
@@ -467,9 +474,19 @@ vars = {
|
||||
'git_base': '%(git_base)s',
|
||||
'hook1_contents': 'git_hooked1',
|
||||
'repo5_var': '/repo_5',
|
||||
|
||||
'false_var': 'False',
|
||||
'true_var': 'True',
|
||||
'str_var': '"abc"',
|
||||
}
|
||||
|
||||
gclient_gn_args_file = 'src/gclient.args'
|
||||
gclient_gn_args = ['DummyVariable']
|
||||
gclient_gn_args = [
|
||||
'false_var',
|
||||
'true_var',
|
||||
'str_var',
|
||||
]
|
||||
|
||||
allowed_hosts = [
|
||||
'%(git_base)s',
|
||||
]
|
||||
|
||||
@@ -326,7 +326,9 @@ class GClientSmokeGIT(GClientSmokeBase):
|
||||
tree['src/git_hooked2'] = 'git_hooked2'
|
||||
tree['src/gclient.args'] = '\n'.join([
|
||||
'# Generated from \'DEPS\'',
|
||||
'DummyVariable = "repo"',
|
||||
'false_var = false',
|
||||
'true_var = true',
|
||||
'str_var = "abc"',
|
||||
])
|
||||
self.assertTree(tree)
|
||||
# Test incremental sync: delete-unversioned_trees isn't there.
|
||||
@@ -342,7 +344,9 @@ class GClientSmokeGIT(GClientSmokeBase):
|
||||
tree['src/git_hooked2'] = 'git_hooked2'
|
||||
tree['src/gclient.args'] = '\n'.join([
|
||||
'# Generated from \'DEPS\'',
|
||||
'DummyVariable = "repo"',
|
||||
'false_var = false',
|
||||
'true_var = true',
|
||||
'str_var = "abc"',
|
||||
])
|
||||
self.assertTree(tree)
|
||||
|
||||
@@ -379,7 +383,9 @@ class GClientSmokeGIT(GClientSmokeBase):
|
||||
('repo_4@2', 'src/repo4'))
|
||||
tree['src/gclient.args'] = '\n'.join([
|
||||
'# Generated from \'DEPS\'',
|
||||
'DummyVariable = "repo"',
|
||||
'false_var = false',
|
||||
'true_var = true',
|
||||
'str_var = "abc"',
|
||||
])
|
||||
self.assertTree(tree)
|
||||
|
||||
@@ -419,7 +425,9 @@ class GClientSmokeGIT(GClientSmokeBase):
|
||||
tree['src/git_hooked2'] = 'git_hooked2'
|
||||
tree['src/gclient.args'] = '\n'.join([
|
||||
'# Generated from \'DEPS\'',
|
||||
'DummyVariable = "repo"',
|
||||
'false_var = false',
|
||||
'true_var = true',
|
||||
'str_var = "abc"',
|
||||
])
|
||||
self.assertTree(tree)
|
||||
# Test incremental sync: delete-unversioned_trees isn't there.
|
||||
@@ -436,7 +444,9 @@ class GClientSmokeGIT(GClientSmokeBase):
|
||||
tree['src/git_hooked2'] = 'git_hooked2'
|
||||
tree['src/gclient.args'] = '\n'.join([
|
||||
'# Generated from \'DEPS\'',
|
||||
'DummyVariable = "repo"',
|
||||
'false_var = false',
|
||||
'true_var = true',
|
||||
'str_var = "abc"',
|
||||
])
|
||||
self.assertTree(tree)
|
||||
|
||||
@@ -616,7 +626,7 @@ class GClientSmokeGIT(GClientSmokeBase):
|
||||
self.maxDiff = None
|
||||
self.assertEqual([
|
||||
'gclient_gn_args_file = "src/gclient.args"',
|
||||
'gclient_gn_args = [\'DummyVariable\']',
|
||||
'gclient_gn_args = [\'false_var\', \'true_var\', \'str_var\']',
|
||||
'allowed_hosts = [',
|
||||
' "git://127.0.0.1:20000/git/",',
|
||||
']',
|
||||
@@ -738,6 +748,9 @@ class GClientSmokeGIT(GClientSmokeBase):
|
||||
' "DummyVariable": \'repo\',',
|
||||
'',
|
||||
' # src',
|
||||
' "false_var": \'False\',',
|
||||
'',
|
||||
' # src',
|
||||
' "git_base": \'git://127.0.0.1:20000/git/\',',
|
||||
'',
|
||||
' # src',
|
||||
@@ -746,6 +759,12 @@ class GClientSmokeGIT(GClientSmokeBase):
|
||||
' # src',
|
||||
' "repo5_var": \'/repo_5\',',
|
||||
'',
|
||||
' # src',
|
||||
' "str_var": \'"abc"\',',
|
||||
'',
|
||||
' # src',
|
||||
' "true_var": \'True\',',
|
||||
'',
|
||||
'}',
|
||||
'',
|
||||
'# git://127.0.0.1:20000/git/repo_2@%s, DEPS' % (
|
||||
@@ -770,7 +789,7 @@ class GClientSmokeGIT(GClientSmokeBase):
|
||||
|
||||
self.assertEqual([
|
||||
'gclient_gn_args_file = "src/gclient.args"',
|
||||
'gclient_gn_args = [\'DummyVariable\']',
|
||||
'gclient_gn_args = [\'false_var\', \'true_var\', \'str_var\']',
|
||||
'allowed_hosts = [',
|
||||
' "git://127.0.0.1:20000/git/",',
|
||||
']',
|
||||
@@ -893,6 +912,9 @@ class GClientSmokeGIT(GClientSmokeBase):
|
||||
' "DummyVariable": \'repo\',',
|
||||
'',
|
||||
' # src',
|
||||
' "false_var": \'False\',',
|
||||
'',
|
||||
' # src',
|
||||
' "git_base": \'git://127.0.0.1:20000/git/\',',
|
||||
'',
|
||||
' # src',
|
||||
@@ -901,6 +923,12 @@ class GClientSmokeGIT(GClientSmokeBase):
|
||||
' # src',
|
||||
' "repo5_var": \'/repo_5\',',
|
||||
'',
|
||||
' # src',
|
||||
' "str_var": \'"abc"\',',
|
||||
'',
|
||||
' # src',
|
||||
' "true_var": \'True\',',
|
||||
'',
|
||||
'}',
|
||||
'',
|
||||
'# git://127.0.0.1:20000/git/repo_2@%s, DEPS' % (
|
||||
|
||||
Reference in New Issue
Block a user