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): ...@@ -1864,7 +1864,17 @@ def _DepsOsToLines(deps_os):
s = ['deps_os = {'] s = ['deps_os = {']
for dep_os, os_deps in sorted(deps_os.iteritems()): for dep_os, os_deps in sorted(deps_os.iteritems()):
s.append(' "%s": {' % dep_os) 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([' },', ''])
s.extend(['}', '']) s.extend(['}', ''])
return s return s
...@@ -1884,7 +1894,7 @@ def _HooksToLines(name, hooks): ...@@ -1884,7 +1894,7 @@ def _HooksToLines(name, hooks):
s.append(' "pattern": "%s",' % hook.pattern) s.append(' "pattern": "%s",' % hook.pattern)
s.extend( s.extend(
# Hooks run in the parent directory of their dep. # 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": ['] + [' "action": ['] +
[' "%s",' % arg for arg in hook.action] + [' "%s",' % arg for arg in hook.action] +
[' ]', ' },', ''] [' ]', ' },', '']
......
...@@ -9,6 +9,22 @@ from third_party import schema ...@@ -9,6 +9,22 @@ from third_party import schema
# See https://github.com/keleshev/schema for docs how to configure 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 = [{ _GCLIENT_HOOKS_SCHEMA = [{
# Hook action: list of command-line arguments to invoke. # Hook action: list of command-line arguments to invoke.
'action': [basestring], 'action': [basestring],
...@@ -43,27 +59,12 @@ _GCLIENT_SCHEMA = schema.Schema({ ...@@ -43,27 +59,12 @@ _GCLIENT_SCHEMA = schema.Schema({
# #
# Var(): allows variable substitution (either from 'vars' dict below, # Var(): allows variable substitution (either from 'vars' dict below,
# or command-line override) # or command-line override)
schema.Optional('deps'): { schema.Optional('deps'): _GCLIENT_DEPS_SCHEMA,
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,
},
),
},
# Similar to 'deps' (see above) - also keyed by OS (e.g. 'linux'). # Similar to 'deps' (see above) - also keyed by OS (e.g. 'linux').
# Also see 'target_os'. # Also see 'target_os'.
schema.Optional('deps_os'): { schema.Optional('deps_os'): {
schema.Optional(basestring): { schema.Optional(basestring): _GCLIENT_DEPS_SCHEMA,
schema.Optional(basestring): schema.Or(basestring, None)
}
}, },
# Path to GN args file to write selected variables. # Path to GN args file to write selected variables.
......
...@@ -609,36 +609,27 @@ class GClientSmokeGIT(GClientSmokeBase): ...@@ -609,36 +609,27 @@ class GClientSmokeGIT(GClientSmokeBase):
'', '',
'deps_os = {', 'deps_os = {',
' "mac": {', ' "mac": {',
' deps = {', ' # src -> src/mac_repo',
' # src -> src/mac_repo', ' "src/mac_repo": {',
' "src/mac_repo": {', ' "url": "/repo_5",',
' "url": "/repo_5",', ' },',
' },', '',
' ',
' }',
' ',
' },', ' },',
'', '',
' "unix": {', ' "unix": {',
' deps = {', ' # src -> src/unix_repo',
' # src -> src/unix_repo', ' "src/unix_repo": {',
' "src/unix_repo": {', ' "url": "/repo_5",',
' "url": "/repo_5",', ' },',
' },', '',
' ',
' }',
' ',
' },', ' },',
'', '',
' "win": {', ' "win": {',
' deps = {', ' # src -> src/win_repo',
' # src -> src/win_repo', ' "src/win_repo": {',
' "src/win_repo": {', ' "url": "/repo_5",',
' "url": "/repo_5",', ' },',
' },', '',
' ',
' }',
' ',
' },', ' },',
'', '',
'}', '}',
...@@ -647,7 +638,7 @@ class GClientSmokeGIT(GClientSmokeBase): ...@@ -647,7 +638,7 @@ class GClientSmokeGIT(GClientSmokeBase):
' # src', ' # src',
' {', ' {',
' "pattern": ".",', ' "pattern": ".",',
' "cwd": "."', ' "cwd": ".",',
' "action": [', ' "action": [',
' "python",', ' "python",',
' "-c",', ' "-c",',
...@@ -658,7 +649,7 @@ class GClientSmokeGIT(GClientSmokeBase): ...@@ -658,7 +649,7 @@ class GClientSmokeGIT(GClientSmokeBase):
' # src', ' # src',
' {', ' {',
' "pattern": "nonexistent",', ' "pattern": "nonexistent",',
' "cwd": "."', ' "cwd": ".",',
' "action": [', ' "action": [',
' "python",', ' "python",',
' "-c",', ' "-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