Fix custom_deps, hooks and custom_vars to be evaluated even if no DEPS file.

Previously, solution's properties would be ignored if there was no DEPS file in
source control. Change the behavior to evaluate the properties anyway.

TEST=new smoke test
BUG=none

Review URL: http://codereview.chromium.org/4154004

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@64232 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
maruel@chromium.org 15 years ago
parent d5766bb0ce
commit 463042941a

@ -49,7 +49,7 @@ Hooks
]
"""
__version__ = "0.6"
__version__ = "0.6.1"
import copy
import logging
@ -254,14 +254,6 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem):
logging.debug('%s was already parsed' % self.name)
return
self.deps_parsed = True
filepath = os.path.join(self.root_dir(), self.name, self.deps_file)
if not os.path.isfile(filepath):
logging.info('%s: No DEPS file found at %s' % (self.name, filepath))
return
deps_content = gclient_utils.FileRead(filepath)
logging.debug(deps_content)
# Eval the content.
# One thing is unintuitive, vars= {} must happen before Var() use.
local_scope = {}
var = self.VarImpl(self.custom_vars, local_scope)
@ -271,10 +263,17 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem):
'Var': var.Lookup,
'deps_os': {},
}
try:
exec(deps_content, global_scope, local_scope)
except SyntaxError, e:
gclient_utils.SyntaxErrorToError(filepath, e)
filepath = os.path.join(self.root_dir(), self.name, self.deps_file)
if not os.path.isfile(filepath):
logging.info('%s: No DEPS file found at %s' % (self.name, filepath))
else:
deps_content = gclient_utils.FileRead(filepath)
logging.debug(deps_content)
# Eval the content.
try:
exec(deps_content, global_scope, local_scope)
except SyntaxError, e:
gclient_utils.SyntaxErrorToError(filepath, e)
deps = local_scope.get('deps', {})
# load os specific dependencies if defined. these dependencies may
# override or extend the values defined by the 'deps' member.
@ -283,9 +282,9 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem):
os_deps = local_scope['deps_os'].get(deps_os_key, {})
if len(self.enforced_os()) > 1:
# Ignore any conflict when including deps for more than one
# platform, so we collect the broadest set of dependencies available.
# We may end up with the wrong revision of something for our
# platform, but this is the best we can do.
# platform, so we collect the broadest set of dependencies
# available. We may end up with the wrong revision of something for
# our platform, but this is the best we can do.
deps.update([x for x in os_deps.items() if not x[0] in deps])
else:
deps.update(os_deps)

@ -434,6 +434,34 @@ class GClientSmokeSVN(GClientSmokeBase):
tree['src/svn_hooked1'] = 'svn_hooked1'
self.assertTree(tree)
def testSyncCustomDepsNoDeps(self):
if not self.enabled:
return
out = (
'solutions = [\n'
# This directory has no DEPS file.
' { "name" : "src/third_party",\n'
' "url" : "%(base)s/src/third_party",\n'
' "custom_deps" : {\n'
# Add 1.
' "src/other": \'/trunk/other\',\n'
' },\n'
' "safesync_url": "",\n'
' },\n'
']\n\n' %
{ 'base': self.svn_base + 'trunk' })
fileobj = open(os.path.join(self.root_dir, '.gclient'), 'w')
fileobj.write(out)
fileobj.close()
self.parseGclient(
['sync', '--deps', 'mac', '--jobs', '1'],
['running', 'running'],
untangle=True)
tree = self.mangle_svn_tree(
('trunk/src/third_party@2', 'src/third_party'),
('trunk/other@2', 'src/other'))
self.assertTree(tree)
def testRevertAndStatus(self):
if not self.enabled:
return

Loading…
Cancel
Save