summaryrefslogtreecommitdiff
path: root/share/qbs/modules/cpp/windows.js
diff options
context:
space:
mode:
Diffstat (limited to 'share/qbs/modules/cpp/windows.js')
-rw-r--r--share/qbs/modules/cpp/windows.js38
1 files changed, 21 insertions, 17 deletions
diff --git a/share/qbs/modules/cpp/windows.js b/share/qbs/modules/cpp/windows.js
index 677a450ce..710b9f304 100644
--- a/share/qbs/modules/cpp/windows.js
+++ b/share/qbs/modules/cpp/windows.js
@@ -1,22 +1,26 @@
-function getWindowsVersionInFormat(systemVersion, format) {
+function isValidWindowsVersion(systemVersion) {
// Add new Windows versions to this list when they are released
var realVersions = [ '6.2', '6.1', '6.0', '5.2', '5.1', '5.0', '4.0' ];
- for (i in realVersions) {
- // Make sure the user specified a valid Windows version we have listed here
- if (systemVersion === realVersions[i]) {
- var major = parseInt(systemVersion.split('.')[0]);
- var minor = parseInt(systemVersion.split('.')[1]);
+ for (i in realVersions)
+ if (systemVersion === realVersions[i])
+ return true;
- 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}.");
- }
- }
- }
+ return false;
+}
- return undefined
+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}.");
+ }
}