Skip to content

Commit

Permalink
Add notify_sdk function
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Miura <[email protected]>
  • Loading branch information
miurahr committed Mar 20, 2022
1 parent cd70975 commit 5824ade
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions aqt/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,57 @@ 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, base_dir, qt_version, arch, os_name, toolchain, component_name):
if os_name == "windows":
sdktoolbinary = pathlib.Path(base_dir) / "Tools" / "QtCreator" / "bin" / "sdktool.exe"
else:
sdktoolbinary = pathlib.Path(base_dir) / "Tools" / "QtCreator" / "libexec" / "qtcreator" / "sdktool"
if not sdktoolbinary.exists():
return
# register Qt
if self._detect_qmake():
qmake_full_path = pathlib.Path(self.qmake_path).absolute()
command_args = [
sdktoolbinary,
"addQt",
"--id",
component_name,
"--name",
"Desktop Qt {} {}".format(qt_version, arch),
"--type",
"Qt4ProjectManager.QtVersion.Desktop",
"--qmake",
qmake_full_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):
"""
Expand Down Expand Up @@ -296,9 +347,25 @@ 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(
base_dir,
version,
arch,
os_name,
"x86-linux-generic-elf-64bit",
"fix.me.component.name.should.unique", # FIXME
)
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(
base_dir,
version,
arch,
os_name,
"x86-macos-generic-mach_o-64bit",
"fix.me.component.name.should.unique", # FIXME
)
elif target.os_name == "windows":
updater.make_qtenv2(base_dir, version_dir, arch_dir)
if version < Version("5.14.0"):
Expand Down

0 comments on commit 5824ade

Please sign in to comment.