From 9db67382fb54cd8a6e07c2d185228adc4a3e685a Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Tue, 11 Jan 2022 21:31:18 +0900 Subject: [PATCH 1/2] Experimental implementation of notify_sdk function Signed-off-by: Hiroshi Miura --- aqt/updater.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/aqt/updater.py b/aqt/updater.py index 23920223..c3f1c062 100644 --- a/aqt/updater.py +++ b/aqt/updater.py @@ -250,6 +250,54 @@ def patch_target_qt_conf(self, base_dir, qt_version, arch_dir, os_name): self._patch_textfile(target_qt_conf, "HostPrefix=../../", new_hostprefix) self._patch_textfile(target_qt_conf, "HostData=target", new_hostdata) + def notify_sdk(self, qt_version, arch, os_name, toolchain, component_name): + if os_name == "windows": + sdktoolbinary = self.prefix / "sdktool.exe" + else: + sdktoolbinary = self.prefix / "sdktool" + # register Qt + if self._detect_qmake(): + command_args = [ + sdktoolbinary, + "addQt", + "--id", + component_name, + "--name", + "Desktop Qt {} {}".format(qt_version, arch), + "--type", + "Qt4ProjectManager.QtVersion.Desktop", + "--qmake", + self.qmake_path, + ] + try: + subprocess.run(command_args, stdout=subprocess.PIPE, check=True) + except subprocess.CalledProcessError as cpe: + msg = "\n".join(filter(None, [f"sdktool error: {cpe.returncode}", cpe.stdout, cpe.stderr])) + raise UpdaterError(msg) from cpe + # register SDK + kitname = component_name + "_kit" + command_args = [ + sdktoolbinary, + "addKit", + "--id", + kitname, + "--name", + "Desktop Qt {} {}".format(qt_version, arch), + "--Ctoolchain", + toolchain, + "--Cxxtoolchain", + toolchain, + "--qt", + component_name, + "--devicetype", + "Desktop", + ] + try: + subprocess.run(command_args, stdout=subprocess.PIPE, check=True) + except subprocess.CalledProcessError as cpe: + msg = "\n".join(filter(None, [f"sdktool error: {cpe.returncode}", cpe.stdout, cpe.stderr])) + raise UpdaterError(msg) from cpe + @classmethod def update(cls, target: TargetConfig, base_dir: str): """ @@ -296,9 +344,15 @@ def update(cls, target: TargetConfig, base_dir: str): if target.os_name == "linux": updater.patch_pkgconfig("/home/qt/work/install", target.os_name) updater.patch_libtool("/home/qt/work/install/lib", target.os_name) + updater.notify_sdk( + version, arch, os_name, "x86-linux-generic-elf-64bit", "fix.me.component.name.should.unique" + ) elif target.os_name == "mac": updater.patch_pkgconfig("/Users/qt/work/install", target.os_name) updater.patch_libtool("/Users/qt/work/install/lib", target.os_name) + updater.notify_sdk( + version, arch, os_name, "x86-macos-generic-mach_o-64bit", "fix.me.component.name.should.unique" + ) elif target.os_name == "windows": updater.make_qtenv2(base_dir, version_dir, arch_dir) if version < Version("5.14.0"): From b265d15ad3c22cd1bdbea288491b8fc6f2150a93 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Fri, 11 Feb 2022 10:02:01 +0900 Subject: [PATCH 2/2] Update sdk updater - Fix sdktool path - Check sdktool exists Signed-off-by: Hiroshi Miura --- aqt/updater.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/aqt/updater.py b/aqt/updater.py index c3f1c062..db5b0073 100644 --- a/aqt/updater.py +++ b/aqt/updater.py @@ -250,11 +250,13 @@ def patch_target_qt_conf(self, base_dir, qt_version, arch_dir, os_name): self._patch_textfile(target_qt_conf, "HostPrefix=../../", new_hostprefix) self._patch_textfile(target_qt_conf, "HostData=target", new_hostdata) - def notify_sdk(self, qt_version, arch, os_name, toolchain, component_name): + def notify_sdk(self, base_dir, qt_version, arch, os_name, toolchain, component_name): if os_name == "windows": - sdktoolbinary = self.prefix / "sdktool.exe" + sdktoolbinary = pathlib.Path(base_dir) / "Tools" / "QtCreator" / "bin" / "sdktool.exe" else: - sdktoolbinary = self.prefix / "sdktool" + sdktoolbinary = pathlib.Path(base_dir) / "Tools" / "QtCreator" / "bin" / "sdktool" + if not sdktoolbinary.exists(): + return # register Qt if self._detect_qmake(): command_args = [ @@ -345,13 +347,23 @@ def update(cls, target: TargetConfig, base_dir: str): updater.patch_pkgconfig("/home/qt/work/install", target.os_name) updater.patch_libtool("/home/qt/work/install/lib", target.os_name) updater.notify_sdk( - version, arch, os_name, "x86-linux-generic-elf-64bit", "fix.me.component.name.should.unique" + base_dir, + version, + arch, + os_name, + "x86-linux-generic-elf-64bit", + "fix.me.component.name.should.unique", ) elif target.os_name == "mac": updater.patch_pkgconfig("/Users/qt/work/install", target.os_name) updater.patch_libtool("/Users/qt/work/install/lib", target.os_name) updater.notify_sdk( - version, arch, os_name, "x86-macos-generic-mach_o-64bit", "fix.me.component.name.should.unique" + base_dir, + version, + arch, + os_name, + "x86-macos-generic-mach_o-64bit", + "fix.me.component.name.should.unique", ) elif target.os_name == "windows": updater.make_qtenv2(base_dir, version_dir, arch_dir)