diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-05-17 14:52:10 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-05-22 10:21:51 +0000 |
commit | f3371669822ab307ceb6df9258cb73ce74447e93 (patch) | |
tree | 8e158e4999ea92c5598a803be5b7d62c607dc312 | |
parent | 5fb53111815c9399e4ddce94c22bacfffafe7f53 (diff) |
pyside6-project: Fix qmllint not working on Windows
The tool passed "nul" (os.devnull) as output file for qmltyperegistrar
to suppress the .cpp registration file, but qmltyperegistrar cannot
open it.
Change pyside6-project to handle lists of artifacts and add it
as a real file.
Change-Id: If8b1ed70305de7b8087a1351dceccd6481b8c085
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
(cherry picked from commit 6592dafb90ba24a1a32165b3adcbcb7fb13bcea8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-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) |