diff options
Diffstat (limited to 'sources/pyside-tools/project.py')
| -rw-r--r-- | sources/pyside-tools/project.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/sources/pyside-tools/project.py b/sources/pyside-tools/project.py index 0daedbbb4..003bde319 100644 --- a/sources/pyside-tools/project.py +++ b/sources/pyside-tools/project.py @@ -95,31 +95,33 @@ class Project: print(f"{self.project.project_file.name}, {count} QML file(s)," f" {self._qml_project_data}") - def _get_artifact(self, file: Path) -> Tuple[Optional[Path], Optional[List[str]]]: + def _get_artifacts(self, file: Path) -> Tuple[List[Path], Optional[List[str]]]: """Return path and command for a file's artifact""" if file.suffix == ".ui": # Qt form files py_file = f"{file.parent}/ui_{file.stem}.py" - return (Path(py_file), [UIC_CMD, os.fspath(file), "--rc-prefix", "-o", py_file]) + return ([Path(py_file)], [UIC_CMD, os.fspath(file), "--rc-prefix", "-o", py_file]) if file.suffix == ".qrc": # Qt resources py_file = f"{file.parent}/rc_{file.stem}.py" - return (Path(py_file), [RCC_CMD, os.fspath(file), "-o", py_file]) + return ([Path(py_file)], [RCC_CMD, os.fspath(file), "-o", py_file]) # generate .qmltypes from sources with Qml decorators if file.suffix == ".py" and file in self._qml_module_sources: assert self._qml_module_dir qml_module_dir = os.fspath(self._qml_module_dir) json_file = f"{qml_module_dir}/{file.stem}{METATYPES_JSON_SUFFIX}" - return (Path(json_file), [MOD_CMD, "-o", json_file, os.fspath(file)]) + return ([Path(json_file)], [MOD_CMD, "-o", json_file, os.fspath(file)]) # Run qmltyperegistrar if file.name.endswith(METATYPES_JSON_SUFFIX): assert self._qml_module_dir stem = file.name[: len(file.name) - len(METATYPES_JSON_SUFFIX)] qmltypes_file = self._qml_module_dir / f"{stem}.qmltypes" + cpp_file = self._qml_module_dir / f"{stem}_qmltyperegistrations.cpp" cmd = [QMLTYPEREGISTRAR_CMD, "--generate-qmltypes", - os.fspath(qmltypes_file), "-o", os.devnull, os.fspath(file)] + os.fspath(qmltypes_file), "-o", os.fspath(cpp_file), + os.fspath(file)] cmd.extend(self._qml_project_data.registrar_options()) - return (qmltypes_file, cmd) + return ([qmltypes_file, cpp_file], cmd) - return (None, None) + return ([], None) def _regenerate_qmldir(self): """Regenerate the 'qmldir' file.""" @@ -133,12 +135,11 @@ class Project: def _build_file(self, source: Path): """Build an artifact.""" - artifact, command = self._get_artifact(source) - if not artifact: - return - if opt_force or requires_rebuild([source], artifact): - run_command(command, cwd=self.project.project_file.parent) - self._build_file(artifact) # Recurse for QML (json->qmltypes) + artifacts, command = self._get_artifacts(source) + for artifact in artifacts: + if opt_force or requires_rebuild([source], artifact): + run_command(command, cwd=self.project.project_file.parent) + self._build_file(artifact) # Recurse for QML (json->qmltypes) def build(self): """Build.""" @@ -158,8 +159,8 @@ class Project: def _clean_file(self, source: Path): """Clean an artifact.""" - artifact, command = self._get_artifact(source) - if artifact and artifact.is_file(): + artifacts, command = self._get_artifacts(source) + for artifact in artifacts: remove_path(artifact) self._clean_file(artifact) # Recurse for QML (json->qmltypes) |
