TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags
[wireshark-sm.git] / packaging / wix / windeployqt-to-wix.ps1
blobe350abfbc79e3539de01ab229e9f343e180f0e71
1 # windeployqt-to-wix
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
14 #requires -version 2
17 .SYNOPSIS
18 Creates Wix components required for Qt packaging.
20 .DESCRIPTION
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.
27 .PARAMETER Executable
28 The path to a Qt application. It will be examined for dependent DLLs.
30 .PARAMETER FilePath
31 Output filename.
33 .INPUTS
34 -Executable Path to the Qt application.
35 -FilePath Output Wix include file.
37 .OUTPUTS
38 Wix file required to package supporting DLLs.
40 .EXAMPLE
41 C:\PS> .\windeployqt-to-wix.ps1 windeployqt.exe ..\..\staging\wireshark.exe qt-dll-manifest.wxs
44 Param(
45 [Parameter(Mandatory=$true, Position=0)]
46 [String] $Executable,
48 [Parameter(Position=1)]
49 [String] $FilePath = "qt-dll-manifest.wxs"
53 try {
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 `
69 --release `
70 --no-compiler-runtime `
71 --no-translations `
72 --list relative `
73 $Executable
75 $dllPath = Split-Path -Parent $Executable
77 $dllList = " <Fragment>
78 <DirectoryRef Id=`"INSTALLFOLDER`">
80 $dirList = ""
81 $currentDir = ""
82 $startDirList = " <Fragment>
83 <DirectoryRef Id=`"INSTALLFOLDER`">
85 $endDirList = " </Directory>
86 </DirectoryRef>
87 </Fragment>
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]", "_"
98 if ($dir) {
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`">
110 $currentDir = $dir
113 $currentDirList += " <Component Id=`"cmp$wix_name`" Guid=`"*`">
114 <File Id=`"fil$wix_name`" KeyPath=`"yes`" Source=`"`$(var.Staging.Dir)\$entry`" />
115 </Component>
117 $componentGroup += " <ComponentRef Id=`"cmp$wix_name`" />
119 } else {
120 $dllList += " <Component Id=`"cmp$wix_name`" Guid=`"*`">
121 <File Id=`"fil$wix_name`" KeyPath=`"yes`" Source=`"`$(var.Staging.Dir)\$entry`" />
122 </Component>
124 $componentGroup += " <ComponentRef Id=`"cmp$wix_name`" />
129 #finish up the last directory
130 $currentDirList += $endDirList
131 $dirList += $currentDirList
133 $dllList += " </DirectoryRef>
134 </Fragment>
136 $componentGroup += " </ComponentGroup>
137 </Fragment>
140 $wixComponents += $dllList + $dirList + $componentGroup
142 $wixComponents += @"
143 </Wix>
148 catch {
150 $wixComponents = "<?xml version=`"1.0`" encoding=`"utf-8`"?>
151 <Include>
152 <!--- Qt not configured -->
153 </Include>
158 Set-Content $FilePath @"
159 <?xml version=`"1.0`" encoding=`"utf-8`"?>
160 <!--
161 Automatically generated by $($MyInvocation.MyCommand.Name)
165 Add-Content $FilePath $wixComponents