From fd245ce5cf4b0d1a6841fc6dccbf98acbd8fe401 Mon Sep 17 00:00:00 2001 From: Alexis Jeandet Date: Fri, 30 Mar 2018 01:07:43 +0200 Subject: [Qt module] add some logic to detect if resources are in build dir In order to handle generated resources embedded in qrc file, we need to be able to detect if files pointed from qrc are in build directory or not. Signed-off-by: Alexis Jeandet --- mesonbuild/modules/qt.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py index 11f10b3..77b1bb4 100644 --- a/mesonbuild/modules/qt.py +++ b/mesonbuild/modules/qt.py @@ -88,7 +88,27 @@ class QtBaseModule: mlog.warning("malformed rcc file: ", os.path.join(state.subdir, rcc_file)) break else: - result.append(os.path.join(relative_part, child.text)) + resource_path = child.text + # We need to guess if the pointed resource is: + # a) in build directory -> implies a generated file + # b) in source directory + # c) somewhere else external dependency file to bundle + if os.path.isabs(resource_path): + # a) + if resource_path.startswith(os.path.abspath(state.environment.build_dir)): + resource_relpath = os.path.relpath(resource_path, state.environment.build_dir) + result.append(File(is_built=True, subdir=state.subdir, fname=resource_relpath)) + # either b) or c) + else: + result.append(File(is_built=False, subdir=state.subdir, fname=resource_path)) + else: + # a) + if os.path.exists(state.environment.build_dir+resource_path): + result.append(File(is_built=True, subdir=state.subdir, fname=resource_path)) + # b) + else: + result.append(File(is_built=False, subdir=state.subdir, + fname=os.path.join(relative_part, resource_path))) return result except Exception: return [] -- cgit v1.1