aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside-tools/project_lib/utils.py
diff options
context:
space:
mode:
authorJaime Resano <Jaime.Resano-Aisa@qt.io>2025-01-21 11:23:15 +0100
committerJaime Resano <Jaime.Resano-Aisa@qt.io>2025-01-23 11:10:26 +0100
commit658724013cd177123e97bad8fd7c24e639ce2b66 (patch)
treed14a70cc620cfda2985aff6c780feccb0b589d67 /sources/pyside-tools/project_lib/utils.py
parent23b7ff61fb899ef8ae305df134d2c0968dce1fa2 (diff)
pyside6-project: 4. Enable building Design Studio projects
pyside6-project tool needs to be more flexible to build Design Studio projects. The path where a .qrc compilation output is stored has to be configurable. In addition, a check is performed to see whether the .qrc file needs to be rebuild by looking at the files that are referenced. This avoids unnecesary rebuilds. Task-number: PYSIDE-1612 Pick-to: 6.8 Change-Id: I8aafd5e66e477bbb360f3cf691d43e12c8866ec4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside-tools/project_lib/utils.py')
-rw-r--r--sources/pyside-tools/project_lib/utils.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/sources/pyside-tools/project_lib/utils.py b/sources/pyside-tools/project_lib/utils.py
index a2d91375b..f1e3f0c0e 100644
--- a/sources/pyside-tools/project_lib/utils.py
+++ b/sources/pyside-tools/project_lib/utils.py
@@ -5,6 +5,7 @@ from __future__ import annotations
import sys
import subprocess
from pathlib import Path
+import xml.etree.ElementTree as ET
from . import QTPATHS_CMD, PROJECT_FILE_SUFFIX, ClOptions
@@ -20,14 +21,33 @@ def run_command(command: list[str], cwd: str = None, ignore_fail: bool = False):
sys.exit(ex)
+def qrc_file_requires_rebuild(resources_file_path: Path, compiled_resources_path: Path) -> bool:
+ """Returns whether a compiled qrc file needs to be rebuilt based on the files that references"""
+ root_element = ET.parse(resources_file_path).getroot()
+ project_root = resources_file_path.parent
+
+ files = [project_root / file.text for file in root_element.findall(".//file")]
+
+ compiled_resources_time = compiled_resources_path.stat().st_mtime
+ # If any of the resource files has been modified after the compiled qrc file, the compiled qrc
+ # file needs to be rebuilt
+ if any(file.is_file() and file.stat().st_mtime > compiled_resources_time for file in files):
+ return True
+ return False
+
+
def requires_rebuild(sources: list[Path], artifact: Path) -> bool:
"""Returns whether artifact needs to be rebuilt depending on sources"""
if not artifact.is_file():
return True
+
artifact_mod_time = artifact.stat().st_mtime
for source in sources:
if source.stat().st_mtime > artifact_mod_time:
return True
+ # The .qrc file references other files that might have changed
+ if source.suffix == '.qrc' and qrc_file_requires_rebuild(source, artifact):
+ return True
return False