diff options
author | Jake Petroules <jake.petroules@qt.io> | 2016-05-25 10:10:51 -0700 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2016-05-30 20:30:38 +0000 |
commit | 9d28325c404a87757c61b7dba10f54b43c28cd11 (patch) | |
tree | e8a7316525799e33d90eaa2cad0bf2033fa990ec /share/qbs/imports/qbs/WindowsUtils/windows-utils.js | |
parent | c885c061f0a062e5a15f08654cb1e6e8c76f5711 (diff) |
Print more descriptive "unknown Windows version" warning messages.
Incidentally, this also fixes a bug causing Windows 10 to be treated as
Windows 1.0 in the subsystem version.
Task-number: QBS-978
Change-Id: I5aa1763ce9d0a9b12aa50e864086cc2ae4ceb3c1
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Diffstat (limited to 'share/qbs/imports/qbs/WindowsUtils/windows-utils.js')
-rw-r--r-- | share/qbs/imports/qbs/WindowsUtils/windows-utils.js | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/share/qbs/imports/qbs/WindowsUtils/windows-utils.js b/share/qbs/imports/qbs/WindowsUtils/windows-utils.js index 5d90ff7b4..70d8d1b36 100644 --- a/share/qbs/imports/qbs/WindowsUtils/windows-utils.js +++ b/share/qbs/imports/qbs/WindowsUtils/windows-utils.js @@ -37,9 +37,26 @@ function characterSetDefines(charset) { return defines; } -function isValidWindowsVersion(systemVersion) { +function canonicalizeVersion(version) { + switch (version) { + case "7": + return "6.1"; + case "8": + return "6.2"; + case "8.1": + return "6.3"; + default: + return version; + } +} + +function knownWindowsVersions() { // Add new Windows versions to this list when they are released - var realVersions = [ '10.0', '6.3', '6.2', '6.1', '6.0', '5.2', '5.1', '5.0', '4.0' ]; + return ['10.0', '6.3', '6.2', '6.1', '6.0', '5.2', '5.1', '5.0', '4.0']; +} + +function isValidWindowsVersion(systemVersion) { + var realVersions = knownWindowsVersions(); for (i in realVersions) if (systemVersion === realVersions[i]) return true; @@ -48,18 +65,20 @@ function isValidWindowsVersion(systemVersion) { } function getWindowsVersionInFormat(systemVersion, format) { - if (!isValidWindowsVersion(systemVersion)) + if (!systemVersion) return undefined; - var major = parseInt(systemVersion.split('.')[0]); - var minor = parseInt(systemVersion.split('.')[1]); + var major = parseInt(systemVersion.split('.')[0], 10); + var minor = parseInt(systemVersion.split('.')[1], 10); - if (format === 'hex') { - return '0x' + major + (minor < 10 ? '0' : '') + minor; - } else if (format === 'subsystem') { - // http://msdn.microsoft.com/en-us/library/fcc1zstk.aspx + switch (format) { + case "hex": + // https://msdn.microsoft.com/en-us/library/6sehtctf.aspx + return "0x" + ("0000" + ((major << 8) | minor).toString(16)).slice(-4); + case "subsystem": + // https://msdn.microsoft.com/en-us/library/fcc1zstk.aspx return major + '.' + (minor < 10 ? '0' : '') + minor; - } else { + default: throw ("Unrecognized Windows version format " + format + ". Must be in {hex, subsystem}."); } } |