From 0690c145db99da66dd3e2dc936848862661a161b Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 22 Jan 2019 14:16:41 +0100 Subject: [PATCH] CMake: pro2cmake.py: Better output in debug dumps Report more error conditions in debug dump and make the output easier to read in the non-error case by wrapping all strings in "". Change-Id: I3c99deda3dfa27dcc0c9ce2800bfb891747e6934 Reviewed-by: Frederik Gladhorn --- util/cmake/pro2cmake.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index ca53234f068..ff814efcf2a 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -139,13 +139,27 @@ class Operation: def __repr__(self): assert(False) + def _dump(self): + if not self._value: + return '' + + if not isinstance(self._value, list): + return '' + + result = [] + for i in self._value: + if not i: + result.append('') + else: + result.append(str(i)) + return '"' + '", "'.join(result) + '"' class AddOperation(Operation): def process(self, input): return input + self._value def __repr__(self): - return '+({})'.format(','.join(self._value)) + return '+({})'.format(self._dump()) class UniqueAddOperation(Operation): @@ -157,7 +171,7 @@ class UniqueAddOperation(Operation): return result def __repr__(self): - return '*({})'.format(self._value) + return '*({})'.format(self._dump()) class SetOperation(Operation): @@ -165,7 +179,7 @@ class SetOperation(Operation): return self._value def __repr__(self): - return '=({})'.format(self._value) + return '=({})'.format(self._dump()) class RemoveOperation(Operation): @@ -183,7 +197,7 @@ class RemoveOperation(Operation): return result def __repr__(self): - return '-({})'.format(self._value) + return '-({})'.format(self._dump()) class Scope: