CMake: pro2cmake.py: Inherrit VPATH from parent scopes

Change-Id: I95b62fdf3a4cba674bef5a58f0d414464daa3b0c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Tobias Hunger 2019-04-12 11:45:43 +02:00
parent 2ec3f492a7
commit 95cdb0d1ae

View File

@ -510,10 +510,14 @@ class Scope(object):
def _evalOps(self, key: str,
transformer: typing.Optional[typing.Callable[[Scope, typing.List[str]], typing.List[str]]],
result: typing.List[str]) \
result: typing.List[str], *, inherrit: bool = False) \
-> typing.List[str]:
self._visited_keys.add(key)
# Inherrit values from above:
if self._parent and inherrit:
result = self._parent._evalOps(key, transformer, result)
if transformer:
op_transformer = lambda files: transformer(self, files)
else:
@ -527,13 +531,13 @@ class Scope(object):
return result
def get(self, key: str, *, ignore_includes: bool = False) -> typing.List[str]:
def get(self, key: str, *, ignore_includes: bool = False, inherrit: bool = False) -> typing.List[str]:
if key == 'PWD':
return ['${CMAKE_CURRENT_SOURCE_DIR}/' + os.path.relpath(self.currentdir, self.basedir),]
if key == 'OUT_PWD':
return ['${CMAKE_CURRENT_BUILD_DIR}/' + os.path.relpath(self.currentdir, self.basedir),]
return self._evalOps(key, None, [])
return self._evalOps(key, None, [], inherrit=inherrit)
def get_string(self, key: str, default: str = '') -> str:
v = self.get(key)
@ -553,7 +557,7 @@ class Scope(object):
mapped_files = list(map(lambda f: map_to_file(f, self, is_include=is_include), expanded_files))
if use_vpath:
result = list(map(lambda f: handle_vpath(f, self.basedir, self.get('VPATH')), mapped_files))
result = list(map(lambda f: handle_vpath(f, self.basedir, self.get('VPATH', inherrit=True)), mapped_files))
else:
result = mapped_files