manifest: allow missing projects list

It's annoying to have to specify projects lists in some cases
when all you're trying to do is exercise something else.

Though the number of situations where a manifest with no projects is
useful may be limited, they nonetheless exist, so make it possible.

This is a backwards incompatible change, so bump the schema version.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
Martí Bolívar 2021-02-11 18:38:03 -08:00 committed by Carles Cufí
parent c90b4157e4
commit 984aec8ecd
5 changed files with 23 additions and 6 deletions

View File

@ -68,8 +68,12 @@ mapping:
# The "projects" key specifies a sequence of "projects", each of which has a
# remote, and may specify additional configuration.
#
# A manifest without projects was forbidden up through west 0.9.x,
# but it can be convenient to create such manifests at times, so it
# is now allowed.
projects:
required: true
required: false
type: seq
sequence:
- type: map

View File

@ -49,7 +49,7 @@ QUAL_REFS_WEST = 'refs/west/'
#:
#: This value changes when a new version of west includes new manifest
#: file features not supported by earlier versions of west.
SCHEMA_VERSION = '0.9'
SCHEMA_VERSION = '0.10'
# MAINTAINERS:
#
# If you want to update the schema version, you need to make sure that
@ -1836,6 +1836,9 @@ class Manifest:
# information about which ones have imports that need to be
# processed next.
if 'projects' not in manifest:
return
have_imports = []
names = set()
for pd in manifest['projects']:

View File

@ -6,6 +6,8 @@
# https://packaging.python.org/guides/single-sourcing-package-version/#single-sourcing-the-version
__version__ = '0.9.99'
# !!! DO NOT CUT 0.10 without updating west.manifest.SCHEMA_VERSION !!!
#
# MAINTAINERS:
#
# Make sure to update west.manifest.SCHEMA_VERSION if there have been

View File

@ -1,4 +0,0 @@
manifest:
remotes:
- name: testremote
url-base: https://example.com

View File

@ -535,6 +535,18 @@ def test_project_repr():
assert repr(m.projects[1]) == \
'Project("zephyr", "https://foo.com", revision="r", path=\'zephyr\', clone_depth=None, west_commands=[\'some-path/west-commands.yml\'], topdir=None, groups=[])' # noqa: E501
def test_no_projects():
# An empty projects list is allowed.
m = Manifest.from_data('manifest: {}')
assert len(m.projects) == 1 # just ManifestProject
m = M('''
self:
path: foo
''')
assert len(m.projects) == 1 # just ManifestProject
#########################################
# Tests for the manifest repository