aboutsummaryrefslogtreecommitdiffstats
path: root/share/qbs/imports/qbs/WindowsUtils/windows-utils.js
blob: 35414eed76e92766f5c856d8f1a4132e22566a6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function characterSetDefines(charset) {
    var defines = [];
    if (charset === "unicode")
        defines.push("UNICODE", "_UNICODE");
    else if (charset === "mbcs")
        defines.push("_MBCS");
    return defines;
}

function isValidWindowsVersion(systemVersion) {
    // Add new Windows versions to this list when they are released
    var realVersions = [ '6.3', '6.2', '6.1', '6.0', '5.2', '5.1', '5.0', '4.0' ];
    for (i in realVersions)
        if (systemVersion === realVersions[i])
            return true;

    return false;
}

function getWindowsVersionInFormat(systemVersion, format) {
    if (!isValidWindowsVersion(systemVersion))
        return undefined;

    var major = parseInt(systemVersion.split('.')[0]);
    var minor = parseInt(systemVersion.split('.')[1]);

    if (format === 'hex') {
        return '0x' + major + (minor < 10 ? '0' : '') + minor;
    } else if (format === 'subsystem') {
        // http://msdn.microsoft.com/en-us/library/fcc1zstk.aspx
        return major + '.' + (minor < 10 ? '0' : '') + minor;
    } else {
        throw ("Unrecognized Windows version format " + format + ". Must be in {hex, subsystem}.");
    }
}