Warning, /sdk/cutehmi/qbs/imports/cutehmi/WixInstaller.qbs is written in an unsupported language. File is not indexed.
0001 import qbs 0002 import qbs.File 0003 import qbs.FileInfo 0004 import qbs.TextFile 0005 import qbs.Xml 0006 0007 import "CommonProduct.qbs" as CommonProduct 0008 0009 import "js/wixInstaller.js" as Wix 0010 0011 /** 0012 WixInstaller product. 0013 0014 This product creates Windows installers with the aid of WiX Toolset. You can get WiX Toolset from [here](https://wixtoolset.org/). 0015 0016 To create the installer specify product(s) you would want to install with `Depends` item. All of its dpendencies will be listed in 0017 `wxs` file and pulled to the resulting `msi` by WiX linker. 0018 0019 WixInstaller item can also understand artifacts created by `cutehmi.windeployqt` Qbs module to pull Qt runtime into resulting `msi`. 0020 Module `cutehmi.windeployqt` can be enabled globally with `windeployqt` property defined in `CuteHMI.qbs`. The property can be 0021 modified by editting the file locally, but product, project and module properties can be also [overriden from command line](https://doc.qt.io/qbs/language-introduction.html#overriding-property-values-from-the-command-line). 0022 0023 For complete runtime you may need to specify MSVC merge modules and 3rd party libraries. WixInstaller rule packs to `msi` all 0024 files marked with "installable" tag from products it depends on. Merge modules can be specified with `mergeModules` property. 0025 0026 Note that WixInstaller products are not built by default. 0027 0028 You may want to set `destinationDirectory` property to move artifacts in desired location. 0029 */ 0030 CommonProduct { 0031 condition: qbs.targetOS.contains("windows") 0032 0033 builtByDefault: false 0034 0035 type: ["msi"] 0036 0037 baseName: isNaN(name.substr(name.lastIndexOf(".", name.length - 1) + 1)) ? name : name.substring(0, name.lastIndexOf(".", name.length - 1)) 0038 0039 major: isNaN(name.substr(name.lastIndexOf(".", name.length - 1) + 1)) ? 1 : Number(name.substr(name.lastIndexOf(".", name.length - 1) + 1)) 0040 0041 targetName: name + "-" + minor + "-" + micro 0042 0043 /** 0044 Prefefined id of manufacturer installation directory. 0045 */ 0046 readonly property string manufacturerInstallationDirectoryId: "manufacturerInstallationDirectory" 0047 0048 /** 0049 Predefined id of start menu directory. 0050 */ 0051 readonly property string startMenuDirectoryId: "startMenuDirectory" 0052 0053 /** 0054 List of file tags defining files that should be packed into resulting `msi`. This list rather does not need to be modified. 0055 */ 0056 property stringList inputFileTags: ["installable", "cutehmi.windeployqt.json"] 0057 0058 /** 0059 Default culture (locale) used by the installer. 0060 */ 0061 property string defaultCulture: "en-us" 0062 0063 /** 0064 List of cultures as passed to _light_ linker. 0065 */ 0066 property string cultures: "en-us" 0067 0068 /** 0069 Translations to be used in generated wxl file for default culture (`defaultCulture` property). If not specified a fallback 0070 string for `en-us` culture is being used. Array has the form: 0071 0072 @verbatim 0073 ({ 0074 "<culture>": { 0075 <string id>: <translation> 0076 }, 0077 }) 0078 @endverbatim 0079 0080 For example Polish translation could look like: 0081 @verbatim 0082 ({ 0083 "pl-pl": { 0084 "DowngradeErrorMessage": "Produkt [ProductName] jest już zainstalowany w nowszej wersji. Program instalacyjny zakończy teraz działanie", 0085 "startMenuShortcut_6a40770c84216f8b0_Name": "My HMI", 0086 }, 0087 }) 0088 @endverbatim 0089 0090 Functionality of translating with this property is limitted. Rule generating `wxs` file can recognize only sevaral types of string ids: 0091 - DowngradeErrorMessage 0092 - ProductName 0093 - PackageDescription 0094 - <feature id>_Title 0095 - <feature id>_Description 0096 - <start menu shortcut id>_Name 0097 - <desktop shortcut id>_Name 0098 0099 Refer to generated `cutehmi.wxs` file to find relevant id. 0100 0101 The general way of translating messages is by providing appropriate `wxl` file in project files. 0102 */ 0103 property var defaultTranslations: ({}) 0104 0105 /** 0106 Name of `wxl` artifact with translations for default culture. 0107 */ 0108 property path wxlArtifact: "cutehmi_" + defaultCulture + ".wxl" 0109 0110 /** 0111 Name of `wxs` artifact. 0112 */ 0113 property path wxsArtifact: "cutehmi.wxs" 0114 0115 /** 0116 The file with UpgradeCode GUID. This code has to be persistent accross releases. It is automatically generated by the 0117 WixInstaller item, so there is no need to create one. Because it has to be persistent it's not treated as an artifact and 0118 it is a good idea to add this file to version control system. 0119 */ 0120 property path wixUpgradeCodeFile: "wix_upgrade_code.guid" 0121 0122 /** 0123 Language of the product being installed. This property refers to Product XML entity in `wxs` file. 0124 */ 0125 property int productLanguage: 1033 0126 0127 /** 0128 List of languages supported in the package. 0129 */ 0130 property string packageLanguages: productLanguage.toString() 0131 0132 /** 0133 Codepage used in the `wxs` document. Note that WiX has troubles with "UTF-8" (see https://wixtoolset.org/documentation/manual/v3/overview/codepage.html). 0134 */ 0135 property string xmlCodepage: "iso-8859-1" 0136 0137 /** 0138 Codepage of the resulting MSI. 0139 */ 0140 property string productCodepage: "Windows-1252" 0141 0142 /** 0143 Codepage for the package summary info strings. 0144 */ 0145 property string packageSummaryCodepage: productCodepage 0146 0147 /** 0148 Product version. Note that hash is not used and other parts must be numbers. 0149 See: https://learn.microsoft.com/en-us/windows/win32/msi/productversion. 0150 */ 0151 property string productVersion: major + "." + minor + "." + micro 0152 0153 /** 0154 Product manufacturer. 0155 */ 0156 property string productManufacturer: vendor 0157 0158 /** 0159 Package manufacturer. 0160 */ 0161 property string packageManufacturer: productManufacturer 0162 0163 /** 0164 Package keywords. 0165 */ 0166 property string packageKeywords: undefined 0167 0168 /** 0169 The minimum version of the Windows Installer required to install this package. 0170 */ 0171 property string packageInstallerVersion: "450" 0172 0173 /** 0174 Name of the start menu directory for the installed product. 0175 */ 0176 property string startMenuDirectory: friendlyName 0177 0178 // See: https://stackoverflow.com/questions/1929038/compilation-error-ice80-the-64bitcomponent-uses-32bitdirectory 0179 /** 0180 Program files directory id. WiX expects `ProgramFilesFolder` or `ProgramFiles64Folder` depending on the architecture of 0181 the binary. 0182 */ 0183 property string programFilesFolderId: qbs.architecture === "x86_64" ? "ProgramFiles64Folder" : "ProgramFilesFolder" 0184 0185 /** 0186 Manufacturer installation directory. Files are installed to @a (programFilesFolderId) / @a manufacturerInstallationDirectory / @a installdirDirectory. 0187 */ 0188 property string manufacturerInstallationDirectory: productManufacturer 0189 0190 /** 0191 Product installation directory. Files are installed to @a (programFilesFolderId) / @a manufacturerInstallationDirectory / @a installdirDirectory. 0192 */ 0193 property string installdirDirectory: friendlyName + " " + productVersion 0194 0195 /** 0196 A list of featured products. List any product names (as defined in Qbs through `name` property) that should appear as the 0197 features to isntall. If the list is empty then all products and their components will be installed within a single "root" 0198 feature. 0199 0200 For Qt runtime gathered with _windeployqt_ you can use special `/QtRuntime/` product name. 0201 */ 0202 property stringList featuredProducts: [] 0203 0204 /** 0205 A list of ids, which should be included within `<UIRef>` elements. If you use WiX UI extensions you also need to add 0206 `-ext WixUIEXtension` to `wix.linkerFlags`. Sample `sampleUI.wxs` file is provided in project root "extra" directory. To use 0207 the file refer to `Id` of the `UI` element. For example to include mentioned file the list could look like: 0208 0209 @verbatim 0210 uiRefIds: [ 0211 "sampleUI", 0212 "WixUI_ErrorProgressText", 0213 ] 0214 @endverbatim 0215 0216 Custom UI `wxs` file must be listed in project files (but not WiX UI extension files). 0217 */ 0218 property stringList uiRefIds: [] 0219 0220 /** 0221 A list of ids, which should be included within `<FeatureRef>` elements. 0222 */ 0223 property stringList featureRefIds: [] 0224 0225 /** 0226 Icon definitions. Property value is a map which has following form: 0227 0228 @verbatim 0229 ({ 0230 "<icon id>": "<path to icon file>", 0231 }) 0232 @endverbatim 0233 0234 Due to weirdness of WiX/Windows Installer icon ids need to have the same "extension" as the file they are used for 0235 (e.g., "exe" files need icon with "*.exe" id). So you may need to set something like: 0236 0237 @verbatim 0238 ({ 0239 "myIcon.exe": sourceDirectory + "/myIcon.ico", 0240 }) 0241 @endverbatim 0242 0243 */ 0244 property var icons: ({}) 0245 0246 /** 0247 Icon assignemnts. The value is a map which has following form: 0248 0249 @verbatim 0250 ({ 0251 "<element id>": { 0252 "Id": "<icon id>", 0253 ["IconIndex": "<index>] 0254 }, 0255 }) 0256 @endverbatim 0257 0258 As an example this map sets desktop and start menu shortcut icons and icon in the "Add or Remove Programs" (ARPPRODUCTICON 0259 icon): 0260 0261 @verbatim 0262 ({ 0263 "startMenuShortcut_7a40770c84216f8b0": {"Id": "myIcon.exe" }, 0264 "desktopShortcut_7a40770c84216f8b0": {"Id": "myIcon.exe" }, 0265 "ARPPRODUCTICON": {"Id": "myIcon.exe" }, 0266 }) 0267 @endverbatim 0268 0269 Optional property `IconIndex` is recognized for shortuct elements. 0270 */ 0271 property var iconAssignments: ({}) 0272 0273 /** 0274 Whether to create MajorUpgrade element. 0275 */ 0276 property bool majorUpgrade: true 0277 0278 /** 0279 Merge modules map. The map should contain merge modules that should be used for feature associated with specific product. 0280 Product `<product name>` must be listed in @a featuredProducts. If no products are featured, then name of the WixInstaller 0281 product can be used. 0282 0283 @verbatim 0284 ({ 0285 "<product name>": [<path to msm file>,] 0286 }, 0287 }) 0288 @endverbatim 0289 */ 0290 property var mergeModules: {} 0291 0292 Depends { name: "cpp" } 0293 0294 // For cultures see: https://wixtoolset.org/documentation/manual/v3/wixdev/extensions/localized_extensions.html, https://github.com/wixtoolset/issues/issues/5685, https://github.com/wixtoolset/issues/issues/3007 0295 Depends { name: "wix" } 0296 wix.linkerFlags: [ 0297 "-b", qbs.installRoot + qbs.installPrefix, 0298 "-ext", "WixUIEXtension", 0299 "-cultures:" + cultures 0300 ] 0301 0302 Rule { 0303 multiplex: true 0304 inputsFromDependencies: product.inputFileTags 0305 //<WixInstaller-1.workaround target="windeployqt" cause="bug"> 0306 // Run wxs generation after wxl, because there is race condition due to workaround - both functions: dumpProductToWxl() and 0307 // dumpProductToWxs() call buildFileComponentGroups(), which attempts to copy missing files. 0308 auxiliaryInputs: ["wxl"] 0309 //</WixInstaller-1.workaround> 0310 0311 prepare: { 0312 var cmd = new JavaScriptCommand(); 0313 cmd.description = 'generating ' + output.filePath 0314 cmd.highlight = 'codegen'; 0315 var tagName = "qml" 0316 cmd.sourceCode = function() { 0317 if (!File.exists(product.wixUpgradeCodeFile)) { 0318 var upgradeCodeFile = new TextFile(product.wixUpgradeCodeFile, TextFile.WriteOnly) 0319 try { 0320 upgradeCodeFile.writeLine(Wix.createGuid()) 0321 } finally { 0322 upgradeCodeFile.close() 0323 } 0324 } 0325 upgradeCodeFile = new TextFile(product.wixUpgradeCodeFile, TextFile.ReadOnly) 0326 var upgradeCodeGuid = upgradeCodeFile.readLine() 0327 upgradeCodeFile.close() 0328 0329 var wxsFile = Xml.DomDocument() 0330 Wix.dumpProductToWxs(product, inputs, upgradeCodeGuid, wxsFile) 0331 wxsFile.save(output.filePath, 4) 0332 0333 //<WixInstaller-2.workaround target="Qbs" cause="missing"> 0334 // Module qbs.Xml writes strings as they come, therefore as a workaround TextFile codec is used to convert WXS 0335 // file to proper codepage. 0336 if (!["UTF-8", "WINDOWS-1252", "ISO-8859-1"].contains(product.xmlCodepage.toUpperCase())) { 0337 var wxsTextFile = TextFile(output.filePath, TextFile.ReadOnly) 0338 try { 0339 var wxsContent = wxsTextFile.readAll() 0340 } finally { 0341 wxsTextFile.close() 0342 } 0343 wxsTextFile = TextFile(output.filePath, TextFile.WriteOnly) 0344 wxsTextFile.setCodec(product.xmlCodepage) 0345 try { 0346 wxsTextFile.write(wxsContent) 0347 } finally { 0348 wxsTextFile.close() 0349 } 0350 } 0351 //</WixInstaller-2.workaround> 0352 } 0353 return [cmd] 0354 } 0355 0356 Artifact { 0357 filePath: product.wxsArtifact 0358 fileTags: ["wxs"] 0359 } 0360 } 0361 0362 Rule { 0363 multiplex: true 0364 inputsFromDependencies: product.inputFileTags 0365 0366 prepare: { 0367 var cmd = new JavaScriptCommand(); 0368 cmd.description = 'generating ' + output.filePath 0369 cmd.highlight = 'codegen'; 0370 cmd.sourceCode = function() { 0371 var wxlFile = Xml.DomDocument() 0372 Wix.dumpProductToWxl(product, inputs, wxlFile) 0373 wxlFile.save(output.filePath, 4) 0374 } 0375 return [cmd] 0376 } 0377 0378 Artifact { 0379 filePath: product.wxlArtifact 0380 fileTags: ["wxl"] 0381 } 0382 } 0383 } 0384 0385 //(c)C: Copyright © 2022-2024, Michał Policht <michal@policht.pl>. All rights reserved. 0386 //(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT 0387 //(c)C: This file is a part of CuteHMI. 0388 //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 0389 //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 0390 //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see <https://www.gnu.org/licenses/>. 0391 //(c)C: Additionally, this file is licensed under terms of MIT license as expressed below. 0392 //(c)C: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 0393 //(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 0394 //(c)C: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.