[rtems-central commit] applconfig: Check enabled for constraints

Sebastian Huber sebh at rtems.org
Wed Nov 17 08:07:50 UTC 2021


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Nov 16 08:35:03 2021 +0100

applconfig: Check enabled for constraints

---

 config.yml                                |  1 +
 rtemsspec/applconfig.py                   | 20 +++++++++++++-------
 rtemsspec/tests/spec-applconfig/l.yml     |  2 ++
 rtemsspec/tests/spec-applconfig/not-x.yml |  9 +++++++++
 rtemsspec/tests/test_applconfig.py        |  1 +
 5 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/config.yml b/config.yml
index 19cb87a..7c786eb 100644
--- a/config.yml
+++ b/config.yml
@@ -76,6 +76,7 @@ glossary:
     target: modules/rtems-docs/eng/glossary.rst
 appl-config:
   doxygen-target: modules/rtems/cpukit/doxygen/appl-config.h
+  enabled: []
   groups:
   - uid: /acfg/if/group-bdbuf
     target: modules/rtems-docs/c-user/config/bdbuf.rst
diff --git a/rtemsspec/applconfig.py b/rtemsspec/applconfig.py
index 70030b6..72e65de 100644
--- a/rtemsspec/applconfig.py
+++ b/rtemsspec/applconfig.py
@@ -204,9 +204,12 @@ def _generate_feature(content: _ContentAdaptor, item: Item,
         content.substitute(_OPTION_DEFAULT_CONFIG[option_type](item)))
 
 
-def _get_constraints(content: _ContentAdaptor, item: Item) -> List[str]:
+def _get_constraints(content: _ContentAdaptor, item: Item,
+                     enabled: List[str]) -> List[str]:
     constraints = []  # type: List[str]
     for parent in item.parents("constraint"):
+        if not parent.is_enabled(enabled):
+            continue
         content.register_license_and_copyrights_of_item(parent)
         constraints.append(
             content.substitute(parent["text"]).replace(
@@ -214,8 +217,9 @@ def _get_constraints(content: _ContentAdaptor, item: Item) -> List[str]:
     return constraints
 
 
-def _generate_constraints(content: _ContentAdaptor, item: Item) -> None:
-    constraints = _get_constraints(content, item)
+def _generate_constraints(content: _ContentAdaptor, item: Item,
+                          enabled: List[str]) -> None:
+    constraints = _get_constraints(content, item, enabled)
     if len(constraints) > 1:
         constraint_list = Content("BSD-2-Clause", False)
         prologue = ("The following constraints apply "
@@ -241,7 +245,8 @@ _OPTION_GENERATORS = {
 }
 
 
-def _generate(group: Item, options: ItemMap, content: _ContentAdaptor) -> None:
+def _generate(group: Item, options: ItemMap, enabled: List[str],
+              content: _ContentAdaptor) -> None:
     content.register_license_and_copyrights_of_item(group)
     content.add_group(group.uid, group["name"],
                       content.substitute(group["description"]))
@@ -255,7 +260,7 @@ def _generate(group: Item, options: ItemMap, content: _ContentAdaptor) -> None:
         _OPTION_GENERATORS[option_type](content, item, option_type)
         content.add_option_description(content.substitute(item["description"]))
         content.add_option_notes(content.substitute(item["notes"]))
-        _generate_constraints(content, item)
+        _generate_constraints(content, item, enabled)
     content.add_licence_and_copyrights()
 
 
@@ -317,6 +322,7 @@ def generate(config: dict, item_cache: ItemCache) -> None:
     with doxygen_content.content.defgroup_block(
             "RTEMSApplConfig", "Application Configuration Options"):
         doxygen_content.content.add("@ingroup RTEMSAPI")
+    enabled = config["enabled"]
     for group_config in config["groups"]:
         group = item_cache[group_config["uid"]]
         assert group.type == "interface/appl-config-group"
@@ -325,9 +331,9 @@ def generate(config: dict, item_cache: ItemCache) -> None:
             assert child.type.startswith("interface/appl-config-option")
             options[child.uid] = child
         sphinx_content = _SphinxContentAdaptor(sphinx_mapper)
-        _generate(group, options, sphinx_content)
+        _generate(group, options, enabled, sphinx_content)
         sphinx_content.write(group_config["target"])
-        _generate(group, options, doxygen_content)
+        _generate(group, options, enabled, doxygen_content)
     doxygen_content.content.prepend_copyrights_and_licenses()
     doxygen_content.content.prepend_spdx_license_identifier()
     doxygen_content.write(config["doxygen-target"])
diff --git a/rtemsspec/tests/spec-applconfig/l.yml b/rtemsspec/tests/spec-applconfig/l.yml
index c0d5fe6..2e4881f 100644
--- a/rtemsspec/tests/spec-applconfig/l.yml
+++ b/rtemsspec/tests/spec-applconfig/l.yml
@@ -14,6 +14,8 @@ links:
   uid: min-zero
 - role: constraint
   uid: max-two
+- role: constraint
+  uid: not-x
 name: l
 notes: null
 type: interface
diff --git a/rtemsspec/tests/spec-applconfig/not-x.yml b/rtemsspec/tests/spec-applconfig/not-x.yml
new file mode 100644
index 0000000..a707666
--- /dev/null
+++ b/rtemsspec/tests/spec-applconfig/not-x.yml
@@ -0,0 +1,9 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+enabled-by:
+  not: X
+links: []
+text: |
+  Not X.
+type: constraint
diff --git a/rtemsspec/tests/test_applconfig.py b/rtemsspec/tests/test_applconfig.py
index c88f537..adb8d3d 100644
--- a/rtemsspec/tests/test_applconfig.py
+++ b/rtemsspec/tests/test_applconfig.py
@@ -37,6 +37,7 @@ def test_applconfig(tmpdir):
     item_cache = ItemCache(item_cache_config)
 
     applconfig_config = {}
+    applconfig_config["enabled"] = ["X"]
     g_rst = os.path.join(tmpdir, "g.rst")
     applconfig_config["groups"] = [{"uid": "/g", "target": g_rst}]
     doxygen_h = os.path.join(tmpdir, "doxygen.h")



More information about the vc mailing list