CMake: pro2cmake.py: Handle setting a key with $$key in the value
Change-Id: I86552ed2a30f07f8c6060b2bad04fd5489b1d482 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
8f0eb65579
commit
2ec3f492a7
@ -189,7 +189,7 @@ class Operation:
|
|||||||
else:
|
else:
|
||||||
self._value = [str(value), ]
|
self._value = [str(value), ]
|
||||||
|
|
||||||
def process(self, input, transformer):
|
def process(self, key, input, transformer):
|
||||||
assert(False)
|
assert(False)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@ -212,7 +212,7 @@ class Operation:
|
|||||||
|
|
||||||
|
|
||||||
class AddOperation(Operation):
|
class AddOperation(Operation):
|
||||||
def process(self, input, transformer):
|
def process(self, key, input, transformer):
|
||||||
return input + transformer(self._value)
|
return input + transformer(self._value)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@ -220,7 +220,7 @@ class AddOperation(Operation):
|
|||||||
|
|
||||||
|
|
||||||
class UniqueAddOperation(Operation):
|
class UniqueAddOperation(Operation):
|
||||||
def process(self, input, transformer):
|
def process(self, key, input, transformer):
|
||||||
result = input
|
result = input
|
||||||
for v in transformer(self._value):
|
for v in transformer(self._value):
|
||||||
if v not in result:
|
if v not in result:
|
||||||
@ -232,11 +232,18 @@ class UniqueAddOperation(Operation):
|
|||||||
|
|
||||||
|
|
||||||
class SetOperation(Operation):
|
class SetOperation(Operation):
|
||||||
def process(self, input, transformer):
|
def process(self, key, input, transformer):
|
||||||
if transformer:
|
values = [] # typing.List[str]
|
||||||
return list(transformer(self._value))
|
for v in self._value:
|
||||||
|
if v != '$$' + key:
|
||||||
|
values.append(v)
|
||||||
else:
|
else:
|
||||||
return self._value
|
values += input
|
||||||
|
|
||||||
|
if transformer:
|
||||||
|
return list(transformer(values))
|
||||||
|
else:
|
||||||
|
return values
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '=({})'.format(self._dump())
|
return '=({})'.format(self._dump())
|
||||||
@ -246,7 +253,7 @@ class RemoveOperation(Operation):
|
|||||||
def __init__(self, value):
|
def __init__(self, value):
|
||||||
super().__init__(value)
|
super().__init__(value)
|
||||||
|
|
||||||
def process(self, input, transformer):
|
def process(self, key, input, transformer):
|
||||||
input_set = set(input)
|
input_set = set(input)
|
||||||
value_set = set(self._value)
|
value_set = set(self._value)
|
||||||
result = []
|
result = []
|
||||||
@ -513,7 +520,7 @@ class Scope(object):
|
|||||||
op_transformer = lambda files: files
|
op_transformer = lambda files: files
|
||||||
|
|
||||||
for op in self._operations.get(key, []):
|
for op in self._operations.get(key, []):
|
||||||
result = op.process(result, op_transformer)
|
result = op.process(key, result, op_transformer)
|
||||||
|
|
||||||
for ic in self._included_children:
|
for ic in self._included_children:
|
||||||
result = list(ic._evalOps(key, transformer, result))
|
result = list(ic._evalOps(key, transformer, result))
|
||||||
@ -540,7 +547,8 @@ class Scope(object):
|
|||||||
|
|
||||||
expanded_files = [] # typing.List[str]
|
expanded_files = [] # typing.List[str]
|
||||||
for f in files:
|
for f in files:
|
||||||
expanded_files += self._expand_value(f)
|
r = self._expand_value(f)
|
||||||
|
expanded_files += r
|
||||||
|
|
||||||
mapped_files = list(map(lambda f: map_to_file(f, self, is_include=is_include), expanded_files))
|
mapped_files = list(map(lambda f: map_to_file(f, self, is_include=is_include), expanded_files))
|
||||||
|
|
||||||
@ -568,7 +576,7 @@ class Scope(object):
|
|||||||
if match.group(0) == value:
|
if match.group(0) == value:
|
||||||
return self.get(match.group(1))
|
return self.get(match.group(1))
|
||||||
|
|
||||||
replacement = self.expand(match.group(1))
|
replacement = self.get(match.group(1))
|
||||||
replacement_str = replacement[0] if replacement else ''
|
replacement_str = replacement[0] if replacement else ''
|
||||||
result = result[:match.start()] \
|
result = result[:match.start()] \
|
||||||
+ replacement_str \
|
+ replacement_str \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user