diff --git a/src/west/manifest.py b/src/west/manifest.py index 7d716ec..f73e5d6 100644 --- a/src/west/manifest.py +++ b/src/west/manifest.py @@ -1361,7 +1361,7 @@ class Manifest: self._posixpath: Optional[str] = None self._repo_posixpath: Optional[str] = None # This backs the userdata property - self._userdata: Optional[Any] = None + self.userdata: Any = None # Load context needed for import resolution. Do top-level # argument validation and storage if self._top_level is True, # but otherwise just get self._ctx from the caller. @@ -1803,7 +1803,7 @@ class Manifest: mp = ManifestProject( path=self._config_path if self.topdir else self.yaml_path, west_commands=self._ctx.manifest_west_commands, - topdir=self.topdir, userdata=self._userdata) + topdir=self.topdir, userdata=self.userdata) # Save the resulting projects and initialize lookup tables # that rely on the ManifestProject existing. @@ -1906,7 +1906,7 @@ class Manifest: _logger.debug('resolved self import') userdata = slf.get('userdata') - self._userdata = userdata + self.userdata = userdata # The current manifest data's west-comands comes first because # we treat imports from self as if they are defined "before" diff --git a/tests/test_manifest.py b/tests/test_manifest.py index 3b3c27b..cd8d0f5 100644 --- a/tests/test_manifest.py +++ b/tests/test_manifest.py @@ -589,12 +589,34 @@ def test_self_userdata(tmpdir): ''') foo, bar = m.get_projects(['manifest', 'bar']) + assert m.userdata == {'key': 'value'} assert foo.userdata == {'key': 'value'} assert bar.userdata is None assert 'userdata' in foo.as_dict() assert 'userdata' not in bar.as_dict() +def test_self_missing_userdata(tmpdir): + m = M(''' + defaults: + remote: r + remotes: + - name: r + url-base: base + projects: + - name: bar + self: + path: foo + ''') + foo, bar = m.get_projects(['manifest', 'bar']) + + assert m.userdata is None + assert foo.userdata is None + assert bar.userdata is None + assert 'userdata' not in foo.as_dict() + assert 'userdata' not in bar.as_dict() + + def test_no_projects(): # An empty projects list is allowed.