<commit_before>import qbs 1.0
import qbs.File
import qbs.FileInfo
import "../utils.js" as ModUtils

Module {
    condition: qbs.hostOS.contains("windows") && qbs.targetOS.contains("windows")

    property path toolchainInstallPath: getNativeSetting(registryKey, "InstallFolder")
    property path toolchainInstallRoot: getNativeSetting(registryKey, "InstallRoot")
    property string version: getNativeSetting(registryKey, "ProductVersion")
    property var versionParts: version ? version.split('.').map(function(item) { return parseInt(item, 10); }) : []
    property int versionMajor: versionParts[0]
    property int versionMinor: versionParts[1]
    property int versionPatch: versionParts[2]
    property int versionBuild: versionParts[3]

    property string compilerName: "candle.exe"
    property string compilerPath: compilerName
    property string linkerName: "light.exe"
    property string linkerPath: linkerName

    property string warningLevel: "normal"
    PropertyOptions {
        name: "warningLevel"
        allowedValues: ["none", "normal", "pedantic"]
    }

    property bool debugInformation: qbs.debugInformation
    property bool treatWarningsAsErrors: false
    property bool verboseOutput: false
    PropertyOptions {
        name: "verboseOutput"
        description: "display verbose output from the compiler and linker"
    }

    property bool visualStudioCompatibility: true
    PropertyOptions {
        name: "visualStudioCompatibility"
        description: "whether to define most of the same variables as " +
                     "Visual Studio when using the Candle compiler"
    }

    property bool enableQbsDefines: true
    PropertyOptions {
        name: "enableQbsDefines"
        description: "built-in variables that are defined when using the Candle compiler"
    }

    property pathList includePaths
    PropertyOptions {
        name: "includePaths"
        description: "directories to add to the include search path"
    }

    property stringList defines
    PropertyOptions {
        name: "defines"
        description: "variables that are defined when using the Candle compiler"
    }

    property stringList compilerFlags
    PropertyOptions {
        name: "compilerFlags"
        description: "additional flags for the Candle compiler"
    }

    property stringList linkerFlags
    PropertyOptions {
        name: "linkerFlags"
        description: "additional flags for the Light linker"
    }

    property stringList cultures
    PropertyOptions {
        name: "cultures"
        description: "the list of localizations to build the MSI for; leave undefined to build all localizations"
    }

    property stringList extensions: type.contains("wixsetup") ? ["WixBalExtension"] : [] // default to WiX Standard Bootstrapper extension

    // private properties
    property string targetSuffix: {
        if (type.contains("msi")) {
            return windowsInstallerSuffix;
        } else if (type.contains("wixsetup")) {
            return executableSuffix;
        }
    }

    property string executableSuffix: ".exe"
    property string windowsInstallerSuffix: ".msi"

    property string registryKey: {
        var knownVersions = [ "4.0", "3.8", "3.7", "3.6", "3.5", "3.0", "2.0" ];
        var keyNative = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Installer XML\\";
        var keyWoW64 = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows Installer XML\\";

        for (i in knownVersions) {
            if (getNativeSetting(keyNative + knownVersions[i], "ProductVersion"))
                return keyNative + knownVersions[i];
            if (getNativeSetting(keyWoW64 + knownVersions[i], "ProductVersion"))
                return keyWoW64 + knownVersions[i];
        }
    }

    validate: {
        if (!toolchainInstallPath)
            throw "wix.toolchainInstallPath is not defined. Set wix.toolchainInstallPath in your profile.";

        if (!toolchainInstallRoot)
            throw "wix.toolchainInstallRoot is not defined. Set wix.toolchainInstallRoot in your profile."

        if (!version)
            throw "wix.version is not defined. Set wix.version in your profile.";

        if (!/^[0-9]+(\.[0-9]+){1,3}$/.test(version)) {
            throw "wix.version is in an invalid format; it must be of the form x.y.z.w " +
                    "where x, y, z and w are positive integers.";
        }
    }

    setupBuildEnvironment: {
        var v = new ModUtils.EnvironmentVariable("PATH", ";", true);
        v.prepend(toolchainInstallPath);
        v.prepend(toolchainInstallRoot);
        v.set();<commit_msg>WiX: add missing qbs. qualifiers.<commit_after>import qbs 1.0
import qbs.File
import qbs.FileInfo
import "../utils.js" as ModUtils

Module {
    condition: qbs.hostOS.contains("windows") && qbs.targetOS.contains("windows")

    property path toolchainInstallPath: qbs.getNativeSetting(registryKey, "InstallFolder")
    property path toolchainInstallRoot: qbs.getNativeSetting(registryKey, "InstallRoot")
    property string version: qbs.getNativeSetting(registryKey, "ProductVersion")
    property var versionParts: version ? version.split('.').map(function(item) { return parseInt(item, 10); }) : []
    property int versionMajor: versionParts[0]
    property int versionMinor: versionParts[1]
    property int versionPatch: versionParts[2]
    property int versionBuild: versionParts[3]

    property string compilerName: "candle.exe"
    property string compilerPath: compilerName
    property string linkerName: "light.exe"
    property string linkerPath: linkerName

    property string warningLevel: "normal"
    PropertyOptions {
        name: "warningLevel"
        allowedValues: ["none", "normal", "pedantic"]
    }

    property bool debugInformation: qbs.debugInformation
    property bool treatWarningsAsErrors: false
    property bool verboseOutput: false
    PropertyOptions {
        name: "verboseOutput"
        description: "display verbose output from the compiler and linker"
    }

    property bool visualStudioCompatibility: true
    PropertyOptions {
        name: "visualStudioCompatibility"
        description: "whether to define most of the same variables as " +
                     "Visual Studio when using the Candle compiler"
    }

    property bool enableQbsDefines: true
    PropertyOptions {
        name: "enableQbsDefines"
        description: "built-in variables that are defined when using the Candle compiler"
    }

    property pathList includePaths
    PropertyOptions {
        name: "includePaths"
        description: "directories to add to the include search path"
    }

    property stringList defines
    PropertyOptions {
        name: "defines"
        description: "variables that are defined when using the Candle compiler"
    }

    property stringList compilerFlags
    PropertyOptions {
        name: "compilerFlags"
        description: "additional flags for the Candle compiler"
    }

    property stringList linkerFlags
    PropertyOptions {
        name: "linkerFlags"
        description: "additional flags for the Light linker"
    }

    property stringList cultures
    PropertyOptions {
        name: "cultures"
        description: "the list of localizations to build the MSI for; leave undefined to build all localizations"
    }

    property stringList extensions: type.contains("wixsetup") ? ["WixBalExtension"] : [] // default to WiX Standard Bootstrapper extension

    // private properties
    property string targetSuffix: {
        if (type.contains("msi")) {
            return windowsInstallerSuffix;
        } else if (type.contains("wixsetup")) {
            return executableSuffix;
        }
    }

    property string executableSuffix: ".exe"
    property string windowsInstallerSuffix: ".msi"

    property string registryKey: {
        var knownVersions = [ "4.0", "3.8", "3.7", "3.6", "3.5", "3.0", "2.0" ];
        var keyNative = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Installer XML\\";
        var keyWoW64 = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows Installer XML\\";

        for (i in knownVersions) {
            if (qbs.getNativeSetting(keyNative + knownVersions[i], "ProductVersion"))
                return keyNative + knownVersions[i];
            if (qbs.getNativeSetting(keyWoW64 + knownVersions[i], "ProductVersion"))
                return keyWoW64 + knownVersions[i];
        }
    }

    validate: {
        if (!toolchainInstallPath)
            throw "wix.toolchainInstallPath is not defined. Set wix.toolchainInstallPath in your profile.";

        if (!toolchainInstallRoot)
            throw "wix.toolchainInstallRoot is not defined. Set wix.toolchainInstallRoot in your profile."

        if (!version)
            throw "wix.version is not defined. Set wix.version in your profile.";

        if (!/^[0-9]+(\.[0-9]+){1,3}$/.test(version)) {
            throw "wix.version is in an invalid format; it must be of the form x.y.z.w " +
                    "where x, y, z and w are positive integers.";
        }
    }

    setupBuildEnvironment: {
        var v = new ModUtils.EnvironmentVariable("PATH", ";", true);
        v.prepend(toolchainInstallPath);
        v.prepend(toolchainInstallRoot);
        v.set();
{'fraction_non_alphanumeric': 0.09226126320327657, 'fraction_numerical': 0.008191420564776892, 'mean_word_length': 2.872704507512521, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6326776', 'n_tokens_mistral': 2560, 'n_tokens_neox': 2449, 'n_words': 743}