Merge pull request #1145 from AlexandreFoley/wrap-fix

build regeneration can update wrap-git and wrap-hg in some cases.
pull/1154/head
Jussi Pakkanen 8 years ago committed by GitHub
commit 541dd92ef7
  1. 5
      mesonbuild/interpreter.py
  2. 29
      mesonbuild/wrap/wrap.py

@ -1740,8 +1740,9 @@ requirements use the version keyword argument instead.''')
raise
# If the subproject execution failed in a non-fatal way, don't raise an
# exception; let the caller handle things.
except:
mlog.log('Also couldn\'t find a fallback subproject in',
except Exception as e:
mlog.warning(e)
mlog.log('Couldn\'t find a fallback subproject in',
mlog.bold(os.path.join(self.subproject_dir, dirname)),
'for the dependency', mlog.bold(name))
return None

@ -95,14 +95,16 @@ class Resolver:
dirname = os.path.join(self.subdir_root, packagename)
try:
if os.listdir(dirname):
# The directory is there and not empty? Great, use it.
return packagename
if not os.path.isfile(fname) :
# The directory is there, not empty and there isn't a wrap file?
# Great, use it.
return packagename
else:
mlog.warning('Subproject directory %s is empty, possibly because of an unfinished'
'checkout, removing to reclone' % dirname)
os.rmdir(checkoutdir)
mlog.warning('Subproject directory %s is empty, removing to'
' ensure clean download' % dirname)
os.rmdir(dirname)
except NotADirectoryError:
raise RuntimeError('%s is not a directory, can not use as subproject.' % dirname)
raise RuntimeError('%s is not a directory, can not use as subproject.' %dirname)
except FileNotFoundError:
pass
@ -111,6 +113,11 @@ class Resolver:
return None
p = PackageDefinition(fname)
if p.type == 'file':
if os.path.isdir(dirname):
# project already there? great, use it!
# only for the file case because otherwise we prevent git
# and hg from updating the subproject.
return packagename
if not os.path.isdir(self.cachedir):
os.mkdir(self.cachedir)
self.download(p, packagename)
@ -130,12 +137,11 @@ class Resolver:
if is_there:
try:
subprocess.check_call(['git', 'rev-parse'])
is_there = True
except subprocess.CalledProcessError:
raise RuntimeError('%s is not empty but is not a valid '
'git repository, we can not work with it'
' as a subproject directory.' % (
checkoutdir))
' as a subproject directory.'
% (checkoutdir))
if revno.lower() == 'head':
# Failure to do pull is not a fatal error,
@ -163,12 +169,17 @@ class Resolver:
revno = p.get('revision')
is_there = os.path.isdir(checkoutdir)
if is_there:
if not os.path.isdir(os.path.join(checkoutdir, '.hg')):
raise RuntimeError('Subproject %s is not a valid mercurial repo.'%p.get('directory'))
if revno.lower() == 'tip':
# Failure to do pull is not a fatal error,
# because otherwise you can't develop without
# a working net connection.
subprocess.call(['hg', 'pull'], cwd=checkoutdir)
subprocess.call(['hg', 'update', 'tip'],cwd = checkoutdir)
else:
# check that the tag/branch/revision we want is available in the
# repo, if not, pull and update.
if subprocess.call(['hg', 'checkout', revno], cwd=checkoutdir) != 0:
subprocess.check_call(['hg', 'pull'], cwd=checkoutdir)
subprocess.check_call(['hg', 'checkout', revno],

Loading…
Cancel
Save