3 # Windeployqt-to-wix - Convert the output of windeployqt to an equivalent set of
4 # Wix file and component statements.
6 # Copyright 2016 Michael Mann
8 # Wireshark - Network traffic analyzer
9 # By Gerald Combs <gerald@wireshark.org>
10 # Copyright 1998 Gerald Combs
12 # SPDX-License-Identifier: GPL-2.0-or-later
18 Creates Wix components required for Qt packaging
.
21 This script creates n Wix-compatible include file based on the output of
22 windeployqt
. If Qt is present
, version
5.3 or later is required
.
23 Otherwise a dummy file will be created
.
25 If building with Qt
, QMake must be
in your PATH
.
28 The path to a Qt application
. It will be examined for dependent DLLs
.
34 -Executable Path to the Qt application
.
35 -FilePath Output Wix include file
.
38 Wix file required to package supporting DLLs
.
41 C
:\PS
> .\windeployqt-to-wix
.ps1 windeployqt
.exe
..\
..\staging\wireshark
.exe qt-dll-manifest
.wxs
45 [Parameter
(Mandatory
=$true, Position
=0)]
48 [Parameter
(Position
=1)]
49 [String
] $FilePath = "qt-dll-manifest.wxs"
54 $qtVersion = [version
](qmake
-query QT_VERSION
)
55 $wixComponents = "<Wix xmlns=`"http
://schemas
.microsoft
.com
/wix
/2006/wi`
">
56 <?include InputPaths.wxi ?>
58 $wixComponents += @
("<!-- Qt version " + $qtVersion ; "-->
61 if ($qtVersion -lt
"5.3") {
62 Throw
"Qt " + $qtVersion + " found. 5.3 or later is required."
65 # windeployqt lists translation files that it don't exist (e.g.
66 # qtbase_ar.qm), so we handle those by hand.
67 # https://bugreports.qt.io/browse/QTBUG-65974
68 $wdqtList = windeployqt `
70 --no-compiler-runtime `
75 $dllPath = Split-Path -Parent
$Executable
77 $dllList = " <Fragment>
78 <DirectoryRef Id=`"INSTALLFOLDER`
">
82 $startDirList = " <Fragment>
83 <DirectoryRef Id=`"INSTALLFOLDER`
">
85 $endDirList = " </Directory>
89 $currentDirList = $startDirList
91 $componentGroup = " <Fragment>
92 <ComponentGroup Id=`"CG
.QtDependencies`
">
94 foreach ($entry in $wdqtList) {
95 $dir = Split-Path -Parent
$entry
96 $wix_name = $entry -ireplace
"[^a-z0-9]", "_"
99 if ($dir -ne
$currentDir) {
100 if ($currentDir -ne
"") { # for everything but first directory found
101 $currentDirList += $endDirList
103 # Previous directory complete, add to list
104 $dirList += $currentDirList
107 $currentDirList = $startDirList + " <Directory Id=`"dir$dir`
" Name=`"$dir`
">
113 $currentDirList += " <Component Id=`"cmp
$wix_name`
" Guid=`"*`
">
114 <File Id=`"fil
$wix_name`
" KeyPath=`"yes`
" Source=`"`$(var.Staging.Dir)\
$entry`
" />
117 $componentGroup += " <ComponentRef Id=`"cmp
$wix_name`
" />
120 $dllList += " <Component Id=`"cmp
$wix_name`
" Guid=`"*`
">
121 <File Id=`"fil
$wix_name`
" KeyPath=`"yes`
" Source=`"`$(var.Staging.Dir)\
$entry`
" />
124 $componentGroup += " <ComponentRef Id=`"cmp
$wix_name`
" />
129 #finish up the last directory
130 $currentDirList += $endDirList
131 $dirList += $currentDirList
133 $dllList += " </DirectoryRef>
136 $componentGroup += " </ComponentGroup>
140 $wixComponents += $dllList + $dirList + $componentGroup
150 $wixComponents = "<?xml version=`"1.0`
" encoding=`"utf-8`
"?>
152 <!--- Qt not configured -->
158 Set-Content $FilePath @
"
159 <?xml version=`"1.0`
" encoding=`"utf-8`
"?>
161 Automatically generated by $($MyInvocation.MyCommand.Name)
165 Add-Content $FilePath $wixComponents