1/**************************************************************************** 2** 3** Copyright (C) 2016 The Qt Company Ltd. 4** Contact: http://www.qt.io/licensing 5** 6** This file is part of Qbs. 7** 8** Commercial License Usage 9** Licensees holding valid commercial Qt licenses may use this file in 10** accordance with the commercial license agreement provided with the 11** Software or, alternatively, in accordance with the terms contained in 12** a written agreement between you and The Qt Company. For licensing terms and 13** conditions see http://www.qt.io/terms-conditions. For further information 14** use the contact form at http://www.qt.io/contact-us. 15** 16** GNU Lesser General Public License Usage 17** Alternatively, this file may be used under the terms of the GNU Lesser 18** General Public License version 2.1 or version 3 as published by the Free 19** Software Foundation and appearing in the file LICENSE.LGPLv21 and 20** LICENSE.LGPLv3 included in the packaging of this file. Please review the 21** following information to ensure the GNU Lesser General Public License 22** requirements will be met: https://www.gnu.org/licenses/lgpl.html and 23** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24** 25** In addition, as a special exception, The Qt Company gives you certain additional 26** rights. These rights are described in The Qt Company LGPL Exception 27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28** 29****************************************************************************/ 30 31import qbs.FileInfo 32import qbs.ModUtils 33import qbs.Probes 34 35Module { 36 condition: qbs.targetOS.contains("windows") 37 38 Probes.InnoSetupProbe { 39 id: innoSetupProbe 40 } 41 42 property path toolchainInstallPath: innoSetupProbe.path 43 version: innoSetupProbe.version 44 property var versionParts: version ? version.split('.').map(function (item) { return parseInt(item, 10); }) : [] 45 property int versionMajor: versionParts[0] 46 property int versionMinor: versionParts[1] 47 property int versionPatch: versionParts[2] 48 49 property string compilerName: "ISCC.exe" 50 property string compilerPath: FileInfo.joinPaths(toolchainInstallPath, compilerName) 51 52 property bool verboseOutput: false 53 PropertyOptions { 54 name: "verboseOutput" 55 description: "display verbose output from the Inno Setup compiler" 56 } 57 58 property pathList includePaths 59 PropertyOptions { 60 name: "includePaths" 61 description: "directories to add to the include search path" 62 } 63 64 property stringList defines 65 PropertyOptions { 66 name: "defines" 67 description: "variables that are defined when using the Inno Setup compiler" 68 } 69 70 property stringList compilerFlags 71 PropertyOptions { 72 name: "compilerFlags" 73 description: "additional flags for the Inno Setup compiler" 74 } 75 76 readonly property string executableSuffix: ".exe" 77 78 validate: { 79 if (!innoSetupProbe.found) { 80 throw ModUtils.ModuleError("Could not find InnoSetup in Windows registry. Make " + 81 "sure InnoSetup is installed correctly."); 82 } 83 var validator = new ModUtils.PropertyValidator("innosetup"); 84 validator.setRequiredProperty("toolchainInstallPath", toolchainInstallPath); 85 validator.setRequiredProperty("version", version); 86 validator.setRequiredProperty("versionMajor", versionMajor); 87 validator.setRequiredProperty("versionMinor", versionMinor); 88 validator.setRequiredProperty("versionPatch", versionPatch); 89 validator.addVersionValidator("version", version, 3, 3); 90 validator.addRangeValidator("versionMajor", versionMajor, 1); 91 validator.addRangeValidator("versionMinor", versionMinor, 0); 92 validator.addRangeValidator("versionPatch", versionPatch, 0); 93 validator.validate(); 94 } 95 96 // Inno Setup Script 97 FileTagger { 98 patterns: ["*.iss"] 99 fileTags: ["innosetup.iss"] 100 } 101 102 Rule { 103 id: innoSetupCompiler 104 inputs: ["innosetup.iss"] 105 auxiliaryInputs: ["installable"] 106 107 Artifact { 108 fileTags: ["innosetup.exe", "application"] 109 filePath: FileInfo.joinPaths(product.destinationDirectory, 110 product.targetName 111 + ModUtils.moduleProperty(product, "executableSuffix")) 112 } 113 114 prepare: { 115 var i; 116 var args = [ 117 "/O" + FileInfo.toNativeSeparators(FileInfo.path(output.filePath)), 118 "/F" + FileInfo.toNativeSeparators(FileInfo.completeBaseName(output.fileName)) 119 ]; 120 121 if (!ModUtils.moduleProperty(product, "verboseOutput")) 122 args.push("/Q"); 123 124 var includePaths = ModUtils.moduleProperty(product, "includePaths"); 125 for (i in includePaths) 126 args.push("/I" + FileInfo.toNativeSeparators(includePaths[i])); 127 128 // User-supplied defines 129 var defines = ModUtils.moduleProperty(product, "defines"); 130 for (i in defines) 131 args.push("/D" + defines[i]); 132 133 // User-supplied flags 134 var flags = ModUtils.moduleProperty(product, "compilerFlags"); 135 for (i in flags) 136 args.push(flags[i]); 137 138 args.push(FileInfo.toNativeSeparators(input.filePath)); 139 var cmd = new Command(ModUtils.moduleProperty(product, "compilerPath"), args); 140 cmd.description = "compiling " + input.fileName; 141 cmd.highlight = "compiler"; 142 cmd.workingDirectory = FileInfo.path(input.filePath); 143 return cmd; 144 } 145 } 146} 147