msubprojects: Stop trying to guess subproject type

It was done to include them in `meson subprojects foreach` without
--types argument, but it's better to special case missing --types and
include wraps that have type=None too. It was a bad idea because that
was messing them in `meson subprojects update`, now they are ignored by
that command.
pull/7752/head
Xavier Claessens 4 years ago committed by Nirbheek Chauhan
parent c203e2f92b
commit e0cd54a322
  1. 6
      mesonbuild/msubprojects.py
  2. 12
      mesonbuild/wrap/wrap.py
  3. 8
      run_unittests.py

@ -268,7 +268,7 @@ def foreach(wrap, repo_dir, options):
def add_common_arguments(p):
p.add_argument('--sourcedir', default='.',
help='Path to source directory')
p.add_argument('--types', default=ALL_TYPES_STRING,
p.add_argument('--types', default='',
help='Comma-separated list of subproject types. Supported types are: {} (default: all)'.format(ALL_TYPES_STRING))
def add_subprojects_argument(p):
@ -328,13 +328,13 @@ def run(options):
wraps = [wrap for name, wrap in r.wraps.items() if name in options.subprojects]
else:
wraps = r.wraps.values()
types = [t.strip() for t in options.types.split(',')]
types = [t.strip() for t in options.types.split(',')] if options.types else []
for t in types:
if t not in ALL_TYPES:
raise MesonException('Unknown subproject type {!r}, supported types are: {}'.format(t, ALL_TYPES_STRING))
failures = []
for wrap in wraps:
if wrap.type not in types:
if types and wrap.type not in types:
continue
dirname = os.path.join(subprojects_dir, wrap.directory)
if not options.subprojects_func(wrap, dirname, options):

@ -103,24 +103,12 @@ 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')
if self.type and self.type not in ALL_TYPES:
raise WrapException('Unknown wrap type {!r}'.format(self.type))
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)

@ -9100,6 +9100,8 @@ class SubprojectsCommandTests(BasePlatformTests):
def test_foreach(self):
self._create_project(self.subprojects_dir / 'sub_file')
self._wrap_create_file('sub_file')
self._git_create_local_repo('sub_git')
self._wrap_create_git('sub_git')
self._git_create_local_repo('sub_git_no_wrap')
def ran_in(s):
@ -9112,13 +9114,13 @@ class SubprojectsCommandTests(BasePlatformTests):
dummy_cmd = ['true']
out = self._subprojects_cmd(['foreach'] + dummy_cmd)
self.assertEqual(ran_in(out), sorted(['./subprojects/sub_git_no_wrap', './subprojects/sub_file']))
self.assertEqual(ran_in(out), sorted(['./subprojects/sub_file', './subprojects/sub_git', './subprojects/sub_git_no_wrap']))
out = self._subprojects_cmd(['foreach', '--types', 'git,file'] + dummy_cmd)
self.assertEqual(ran_in(out), sorted(['./subprojects/sub_git_no_wrap', './subprojects/sub_file']))
self.assertEqual(ran_in(out), sorted(['./subprojects/sub_file', './subprojects/sub_git']))
out = self._subprojects_cmd(['foreach', '--types', 'file'] + dummy_cmd)
self.assertEqual(ran_in(out), ['./subprojects/sub_file'])
out = self._subprojects_cmd(['foreach', '--types', 'git'] + dummy_cmd)
self.assertEqual(ran_in(out), ['./subprojects/sub_git_no_wrap'])
self.assertEqual(ran_in(out), ['./subprojects/sub_git'])
def _clang_at_least(compiler, minver: str, apple_minver: str) -> bool:
"""

Loading…
Cancel
Save