Merge pull request #1683 from ernestask/submodules

wrap: submodule fixes
pull/1691/merge
Jussi Pakkanen 8 years ago committed by GitHub
commit f74f78dd89
  1. 1
      authors.txt
  2. 11
      mesonbuild/wrap/wrap.py

@ -81,3 +81,4 @@ Wade Berrier
Richard Hughes Richard Hughes
Rafael Fontenelle Rafael Fontenelle
Michael Olbrich Michael Olbrich
Ernestas Kulik

@ -38,8 +38,9 @@ def build_ssl_context():
ctx.load_default_certs() ctx.load_default_certs()
return ctx return ctx
def quiet_git(cmd): def quiet_git(cmd, workingdir):
pc = subprocess.Popen(['git'] + cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) pc = subprocess.Popen(['git', '-C', workingdir] + cmd,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = pc.communicate() out, err = pc.communicate()
if pc.returncode != 0: if pc.returncode != 0:
return False, err return False, err
@ -150,16 +151,16 @@ class Resolver:
def resolve_git_submodule(self, dirname): def resolve_git_submodule(self, dirname):
# Are we in a git repository? # Are we in a git repository?
ret, out = quiet_git(['rev-parse']) ret, out = quiet_git(['rev-parse'], self.subdir_root)
if not ret: if not ret:
return False return False
# Is `dirname` a submodule? # Is `dirname` a submodule?
ret, out = quiet_git(['submodule', 'status', dirname]) ret, out = quiet_git(['submodule', 'status', dirname], self.subdir_root)
if not ret: if not ret:
return False return False
# Submodule has not been added, add it # Submodule has not been added, add it
if out.startswith(b'-'): if out.startswith(b'-'):
if subprocess.call(['git', 'submodule', 'update', dirname]) != 0: if subprocess.call(['git', '-C', self.subdir_root, 'submodule', 'update', '--init', dirname]) != 0:
return False return False
# Submodule was added already, but it wasn't populated. Do a checkout. # Submodule was added already, but it wasn't populated. Do a checkout.
elif out.startswith(b' '): elif out.startswith(b' '):

Loading…
Cancel
Save