diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-03-17 12:24:56 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-03-17 18:35:11 +0100 |
commit | 9c0a1640c3dea4496a47af8f91f53e9bed76c602 (patch) | |
tree | 9de2bc02f54b7ec0e000327866eb75d4b72c6215 | |
parent | validation: Substitute context documnetation (diff) | |
download | rtems-central-9c0a1640c3dea4496a47af8f91f53e9bed76c602.tar.bz2 |
content: Add support for CPU port options
-rw-r--r-- | rtemsspec/content.py | 4 | ||||
-rw-r--r-- | rtemsspec/tests/test_content.py | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/rtemsspec/content.py b/rtemsspec/content.py index c509d4a1..f6c3fdf1 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 7505206a..517bb070 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)" |