5 # Windeployqt-to-nsh - Convert the output of windeployqt to an equivalent set of
6 # NSIS "File" function calls.
8 # Rewritten in python from windeployqt-to-nsis.ps1, that has the following copyright:
10 # Copyright 2014 Gerald Combs <gerald@wireshark.org>
12 # Wireshark - Network traffic analyzer
13 # By Gerald Combs <gerald@wireshark.org>
14 # Copyright 1998 Gerald Combs
16 # SPDX-License-Identifier: GPL-2.0-or-later
23 parser
= argparse
.ArgumentParser()
24 group
= parser
.add_mutually_exclusive_group(required
=True)
25 group
.add_argument('--mapping')
26 group
.add_argument('--executable')
27 parser
.add_argument('--sysroot')
28 parser
.add_argument('outfile')
29 args
= parser
.parse_args()
33 sys
.exit('Option --sysroot is required with option --mapping')
35 with
open(args
.mapping
, 'r', encoding
='utf-8') as f
:
41 '-query', 'QT_VERSION'
43 qmake_out
= subprocess
.run(qmake_command
, check
=True, capture_output
=True, encoding
="utf-8")
44 qt_version
= qmake_out
.stdout
.strip()
46 # XXX The powershell script asserts that the Qt version is greater than 5.3. We already require Qt6 to build the
47 # installer using MSYS2 (currently not enforced).
52 "--no-compiler-runtime",
57 out
= subprocess
.run(windeploy_command
, check
=True, capture_output
=True, encoding
="utf-8").stdout
59 with
open(args
.outfile
, 'w') as f
:
62 # Automatically generated by {}
63 #""".format(parser
.prog
)
68 #""".format(qt_version
)
73 for line
in out
.splitlines():
75 if not line
or line
.startswith('#'):
77 if line
.startswith('Adding in plugin'):
78 # https://bugreports.qt.io/browse/QTBUG-122257
79 # Affects 6.6.0 - 6.6.2
81 path
, relative
= line
.split(" ")
82 rel_path
= os
.path
.split(relative
)
84 base_dir
= rel_path
[0].strip('"')
85 if base_dir
!= current_dir
:
86 set_out_path
= r
'SetOutPath "$INSTDIR\{}"'.format(base_dir
)
87 print(set_out_path
, file=f
)
88 current_dir
= base_dir
90 path
= path
.strip('"')
92 path
= os
.path
.join(args
.sysroot
, path
)
93 if args
.mapping
and not os
.path
.isfile(path
):
94 # This hack is because Qt 6.7 renamed QWindowsVistaStylePlugin
95 # to QModernWindowsStylePlugin. (This explicit mapping because
96 # windeployqt6 doesn't work well with cross-compiling is
99 file_path
= 'File "{}"'.format(path
)
100 print(file_path
, file=f
)