diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2019-04-12 11:45:43 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2019-04-12 11:35:09 +0000 |
commit | 95cdb0d1ae62b4aa801eec32949ad18c61032e49 (patch) | |
tree | 0a7c584233ad53564a0c3fdd55991b9ab3fe26be /util | |
parent | 2ec3f492a7964648e838ef663fe41e4e7351c9df (diff) |
CMake: pro2cmake.py: Inherrit VPATH from parent scopes
Change-Id: I95b62fdf3a4cba674bef5a58f0d414464daa3b0c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-x | util/cmake/pro2cmake.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 44326e488e..75d52957a9 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -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 |