[rtems-central commit] interface: No implicit groups for headers

Sebastian Huber sebh at rtems.org
Wed Oct 14 09:38:10 UTC 2020


Module:    rtems-central
Branch:    master
Commit:    dc46c689e3ee20c904f9d391ad35d5ba1f787524
Changeset: http://git.rtems.org/rtems-central/commit/?id=dc46c689e3ee20c904f9d391ad35d5ba1f787524

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Oct 13 16:11:50 2020 +0200

interface: No implicit groups for headers

---

 rtemsspec/interface.py               | 31 ++++++++-----------------------
 rtemsspec/tests/spec-interface/h.yml |  6 ++++++
 2 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/rtemsspec/interface.py b/rtemsspec/interface.py
index 5c12168..502cc96 100644
--- a/rtemsspec/interface.py
+++ b/rtemsspec/interface.py
@@ -178,11 +178,10 @@ class Node:
     """ Nodes of a header file. """
 
     # pylint: disable=too-many-instance-attributes
-    def __init__(self, header_file: "_HeaderFile", item: Item,
-                 ingroups: ItemMap):
+    def __init__(self, header_file: "_HeaderFile", item: Item):
         self.header_file = header_file
         self.item = item
-        self.ingroups = ingroups
+        self.ingroups = _get_ingroups(item)
         self.dependents = set()  # type: Set["Node"]
         self.depends_on = set()  # type: Set["Node"]
         self.content = CContent()
@@ -279,7 +278,6 @@ class Node:
 
     def generate_group(self) -> None:
         """ Generates a group. """
-        self.header_file.add_ingroup(self.item)
         for ingroup in self.ingroups.values():
             self.header_file.add_dependency(self, ingroup)
         self.content.add_group(self.item["identifier"], self.item["name"],
@@ -472,7 +470,7 @@ class _HeaderFile:
         self._item = item
         self._content = CContent()
         self._content.register_license_and_copyrights_of_item(item)
-        self._ingroups = {}  # type: ItemMap
+        self._ingroups = _get_ingroups(item)
         self._includes = []  # type: List[Item]
         self._nodes = {}  # type: Dict[str, Node]
         self.enabled_by_defined = enabled_by_defined
@@ -483,15 +481,8 @@ class _HeaderFile:
             if parent.type == "interface/header-file":
                 self._includes.append(parent)
 
-    def add_ingroup(self, item: Item) -> None:
-        """ Adds an ingroup to the header file. """
-        self._ingroups[item.uid] = item
-
     def _add_child(self, item: Item) -> None:
-        ingroups = _get_ingroups(item)
-        if item["interface-type"] != "group":
-            self._ingroups.update(ingroups)
-        self._nodes[item.uid] = Node(self, item, ingroups)
+        self._nodes[item.uid] = Node(self, item)
         self._content.register_license_and_copyrights_of_item(item)
 
     def add_dependency(self, node: Node, item: Item) -> None:
@@ -601,14 +592,6 @@ def _generate_header_file(item: Item, domains: Dict[str, str],
     header_file.write(domain_path)
 
 
-def _visit_header_files(item: Item, domains: Dict[str, str],
-                        enabled_by_defined: Dict[str, str]) -> None:
-    for child in item.children(["interface-placement", "interface-ingroup"]):
-        _visit_header_files(child, domains, enabled_by_defined)
-    if item.type == "interface/header-file":
-        _generate_header_file(item, domains, enabled_by_defined)
-
-
 def _gather_enabled_by_defined(item_level_interfaces: List[str],
                                item_cache: ItemCache) -> Dict[str, str]:
     enabled_by_defined = {}  # type: Dict[str, str]
@@ -626,7 +609,9 @@ def generate(config: dict, item_cache: ItemCache) -> None:
     :param config: A dictionary with configuration entries.
     :param item_cache: The specification item cache containing the interfaces.
     """
+    domains = config["domains"]
     enabled_by_defined = _gather_enabled_by_defined(
         config["item-level-interfaces"], item_cache)
-    for item in item_cache.top_level.values():
-        _visit_header_files(item, config["domains"], enabled_by_defined)
+    for item in item_cache.all.values():
+        if item.type == "interface/header-file":
+            _generate_header_file(item, domains, enabled_by_defined)
diff --git a/rtemsspec/tests/spec-interface/h.yml b/rtemsspec/tests/spec-interface/h.yml
index 9b334d4..5c85f17 100644
--- a/rtemsspec/tests/spec-interface/h.yml
+++ b/rtemsspec/tests/spec-interface/h.yml
@@ -25,6 +25,12 @@ links:
   uid: h4
 - role: interface-placement
   uid: domain-abc
+- role: interface-ingroup
+  uid: ga
+- role: interface-ingroup
+  uid: gc
+- role: interface-ingroup
+  uid: gb
 path: h.h
 prefix: include
 type: interface



More information about the vc mailing list