[rtems-central commit] content: Add support for CPU port options

Sebastian Huber sebh at rtems.org
Wed Mar 17 17:37:29 UTC 2021


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Mar 17 12:24:56 2021 +0100

content: Add support for CPU port options

---

 rtemsspec/content.py            | 4 +++-
 rtemsspec/tests/test_content.py | 5 +++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/rtemsspec/content.py b/rtemsspec/content.py
index c509d4a..f6c3fdf 100644
--- a/rtemsspec/content.py
+++ b/rtemsspec/content.py
@@ -1053,6 +1053,8 @@ class ExpressionMapper:
     # pylint: disable=no-self-use
     def map_symbol(self, symbol: str) -> str:
         """ Maps a symbol to build an expression. """
+        if symbol.startswith("CPU_"):
+            return f"( {symbol} == TRUE )"
         return f"defined({symbol})"
 
     def op_and(self) -> str:
@@ -1138,7 +1140,7 @@ def enabled_by_to_exp(enabled_by: Any, mapper: ExpressionMapper) -> str:
     """
     exp = _to_expression(enabled_by, mapper)
     if exp.startswith("("):
-        return exp[1:-1]
+        return exp[1:-1].strip()
     return exp
 
 
diff --git a/rtemsspec/tests/test_content.py b/rtemsspec/tests/test_content.py
index 7505206..517bb07 100644
--- a/rtemsspec/tests/test_content.py
+++ b/rtemsspec/tests/test_content.py
@@ -258,6 +258,11 @@ def test_enabled_by_to_exp():
     assert to_c_exp(True) == "1"
     assert to_c_exp(False) == "0"
     assert to_c_exp([]) == ""
+    assert to_c_exp(["CPU_A"]) == "CPU_A == TRUE"
+    assert to_c_exp({"not": "CPU_A"}) == "!( CPU_A == TRUE )"
+    assert to_c_exp(["CPU_B", {
+        "not": "CPU_A"
+    }, "A"]) == "( CPU_B == TRUE ) || !( CPU_A == TRUE ) || defined(A)"
     assert to_c_exp(["A"]) == "defined(A)"
     assert to_c_exp(["B"]) == "defined(B)"
     assert to_c_exp(["A", "B"]) == "defined(A) || defined(B)"



More information about the vc mailing list