diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-12-06 20:31:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-06 20:31:24 +0200 |
commit | 541dd92ef7a10b0f657f3c8532ffb71a8d921f54 (patch) | |
tree | 7f9f252cd0fe52e97ba5973d8a1e0bd582920046 | |
parent | 155617e539a9aeccda6bd186398123b9d5521ed4 (diff) | |
parent | 27cd8c1e28f310891fa671976a0f3b4231ceb4b0 (diff) | |
download | meson-541dd92ef7a10b0f657f3c8532ffb71a8d921f54.zip meson-541dd92ef7a10b0f657f3c8532ffb71a8d921f54.tar.gz meson-541dd92ef7a10b0f657f3c8532ffb71a8d921f54.tar.bz2 |
Merge pull request #1145 from AlexandreFoley/wrap-fix
build regeneration can update wrap-git and wrap-hg in some cases.
-rw-r--r-- | mesonbuild/interpreter.py | 5 | ||||
-rw-r--r-- | mesonbuild/wrap/wrap.py | 29 |
2 files changed, 23 insertions, 11 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index bb523b4..e54d906 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.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 diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 37d6df7..12536fe 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -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], |