Commit ad30de63 authored by Paweł Hajdan, Jr's avatar Paweł Hajdan, Jr Committed by Commit Bot

gclient flatten: syntax and schema fixes from actual testing

Bug: 570091
Change-Id: Iae9dad68a75d751ceac6379baac588f32c59aa06
Reviewed-on: https://chromium-review.googlesource.com/548935Reviewed-by: 's avatarMichael Moss <mmoss@chromium.org>
Commit-Queue: Paweł Hajdan Jr. <phajdan.jr@chromium.org>
parent 7625d880
......@@ -1864,7 +1864,17 @@ def _DepsOsToLines(deps_os):
s = ['deps_os = {']
for dep_os, os_deps in sorted(deps_os.iteritems()):
s.append(' "%s": {' % dep_os)
s.extend([' %s' % l for l in _DepsToLines(os_deps)])
for name, dep in sorted(os_deps.iteritems()):
condition_part = ([' "condition": "%s",' % dep.condition]
if dep.condition else [])
s.extend([
' # %s' % dep.hierarchy(include_url=False),
' "%s": {' % (name,),
' "url": "%s",' % (dep.url,),
] + condition_part + [
' },',
'',
])
s.extend([' },', ''])
s.extend(['}', ''])
return s
......@@ -1884,7 +1894,7 @@ def _HooksToLines(name, hooks):
s.append(' "pattern": "%s",' % hook.pattern)
s.extend(
# Hooks run in the parent directory of their dep.
[' "cwd": "%s"' % os.path.normpath(os.path.dirname(dep.name))] +
[' "cwd": "%s",' % os.path.normpath(os.path.dirname(dep.name))] +
[' "action": ['] +
[' "%s",' % arg for arg in hook.action] +
[' ]', ' },', '']
......
......@@ -9,6 +9,22 @@ from third_party import schema
# See https://github.com/keleshev/schema for docs how to configure schema.
_GCLIENT_DEPS_SCHEMA = {
schema.Optional(basestring): schema.Or(
None,
basestring,
{
# Repo and revision to check out under the path
# (same as if no dict was used).
'url': basestring,
# Optional condition string. The dep will only be processed
# if the condition evaluates to True.
schema.Optional('condition'): basestring,
},
),
}
_GCLIENT_HOOKS_SCHEMA = [{
# Hook action: list of command-line arguments to invoke.
'action': [basestring],
......@@ -43,27 +59,12 @@ _GCLIENT_SCHEMA = schema.Schema({
#
# Var(): allows variable substitution (either from 'vars' dict below,
# or command-line override)
schema.Optional('deps'): {
schema.Optional(basestring): schema.Or(
basestring,
{
# Repo and revision to check out under the path
# (same as if no dict was used).
'url': basestring,
# Optional condition string. The dep will only be processed
# if the condition evaluates to True.
schema.Optional('condition'): basestring,
},
),
},
schema.Optional('deps'): _GCLIENT_DEPS_SCHEMA,
# Similar to 'deps' (see above) - also keyed by OS (e.g. 'linux').
# Also see 'target_os'.
schema.Optional('deps_os'): {
schema.Optional(basestring): {
schema.Optional(basestring): schema.Or(basestring, None)
}
schema.Optional(basestring): _GCLIENT_DEPS_SCHEMA,
},
# Path to GN args file to write selected variables.
......
......@@ -609,36 +609,27 @@ class GClientSmokeGIT(GClientSmokeBase):
'',
'deps_os = {',
' "mac": {',
' deps = {',
' # src -> src/mac_repo',
' "src/mac_repo": {',
' "url": "/repo_5",',
' },',
' ',
' }',
' ',
' # src -> src/mac_repo',
' "src/mac_repo": {',
' "url": "/repo_5",',
' },',
'',
' },',
'',
' "unix": {',
' deps = {',
' # src -> src/unix_repo',
' "src/unix_repo": {',
' "url": "/repo_5",',
' },',
' ',
' }',
' ',
' # src -> src/unix_repo',
' "src/unix_repo": {',
' "url": "/repo_5",',
' },',
'',
' },',
'',
' "win": {',
' deps = {',
' # src -> src/win_repo',
' "src/win_repo": {',
' "url": "/repo_5",',
' },',
' ',
' }',
' ',
' # src -> src/win_repo',
' "src/win_repo": {',
' "url": "/repo_5",',
' },',
'',
' },',
'',
'}',
......@@ -647,7 +638,7 @@ class GClientSmokeGIT(GClientSmokeBase):
' # src',
' {',
' "pattern": ".",',
' "cwd": "."',
' "cwd": ".",',
' "action": [',
' "python",',
' "-c",',
......@@ -658,7 +649,7 @@ class GClientSmokeGIT(GClientSmokeBase):
' # src',
' {',
' "pattern": "nonexistent",',
' "cwd": "."',
' "cwd": ".",',
' "action": [',
' "python",',
' "-c",',
......
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