From 98d445a0708e56a511fb91c6189dea97b0a57d43 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 7 Aug 2020 10:06:33 -0400 Subject: msubprojects: Support git subprojects with no wrap file User could have cloned manually a subproject. --- mesonbuild/wrap/wrap.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'mesonbuild/wrap/wrap.py') diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 68f83c1..26f3d4a 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -118,10 +118,22 @@ class PackageDefinition: self.provided_deps[self.name] = None if fname.endswith('.wrap'): self.parse_wrap(fname) + else: + self.guess_type(); self.directory = self.values.get('directory', self.name) if os.path.dirname(self.directory): raise WrapException('Directory key must be a name and not a path') + def guess_type(self) -> None: + if os.path.exists(os.path.join(self.filename, '.git')): + # This is a git subproject without wrap file. Either the user cloned + # it manually, or it's a git submodule. The revision is used in + # msubprojects.py to update the git repo. If it's a submodule the repo + # is likely detached and revision will be empty. + res, stdout = quiet_git(['branch', '--show-current'], self.filename) + self.values['revision'] = stdout.strip() + self.type = 'git' + def parse_wrap(self, fname: str) -> None: try: self.config = configparser.ConfigParser(interpolation=None) -- cgit v1.1