diff options
author | Jake Petroules <jake.petroules@petroules.com> | 2013-10-31 10:16:43 -0400 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@digia.com> | 2013-11-04 11:53:01 +0100 |
commit | 972747d63aaae6e755e1c9f55cec96cb3faef5de (patch) | |
tree | 827181f15e9a893934cb694a1b10bbcc2503e511 /share/qbs/modules/qbs/common.qbs | |
parent | 4e136110b1b6ac0cbc5ace5077a26aa258338e21 (diff) |
Add a hostOSVersion property, defined for Windows and OS X.
Change-Id: I04da329f17c54f010fd467841f305d6ab7e922f0
Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'share/qbs/modules/qbs/common.qbs')
-rw-r--r-- | share/qbs/modules/qbs/common.qbs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/share/qbs/modules/qbs/common.qbs b/share/qbs/modules/qbs/common.qbs index d81379709..94d104ac9 100644 --- a/share/qbs/modules/qbs/common.qbs +++ b/share/qbs/modules/qbs/common.qbs @@ -7,6 +7,21 @@ Module { property bool debugInformation: (buildVariant == "debug") property string optimization: (buildVariant == "debug" ? "none" : "fast") property stringList hostOS: getHostOS() + property string hostOSVersion: { + if (hostOS.contains("osx")) { + return getNativeSetting("/System/Library/CoreServices/SystemVersion.plist", "ProductVersion") || + getNativeSetting("/System/Library/CoreServices/ServerVersion.plist", "ProductVersion"); + } else if (hostOS.contains("windows")) { + var version = getNativeSetting("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion", "CurrentVersion"); + var build = getNativeSetting("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion", "CurrentBuildNumber"); + return version + "." + build; + } + } + readonly property var hostOSVersionParts: hostOSVersion ? hostOSVersion.split('.').map(function(item) { return parseInt(item, 10); }) : [] + readonly property int hostOSVersionMajor: hostOSVersionParts[0] || 0 + readonly property int hostOSVersionMinor: hostOSVersionParts[1] || 0 + readonly property int hostOSVersionPatch: hostOSVersionParts[2] || 0 + property stringList targetOS: hostOS property string pathListSeparator: hostOS.contains("windows") ? ";" : ":" property string pathSeparator: hostOS.contains("windows") ? "\\" : "/" @@ -56,5 +71,16 @@ Module { "You must use the canonical name '" + arch + "'"; } } + + if ((hostOS.contains("windows") || hostOS.contains("osx")) && !hostOSVersion) { + throw "Could not detect host operating system version; " + + "verify that system files or registry have not been " + + "tampered with."; + } + + if (!/^[0-9]+(\.[0-9]+){1,3}$/.test(hostOSVersion)) { + throw "qbs.hostOSVersion is in an invalid format; it must be of the form x.y or " + + "x.y.z or x.y.z.w where x, y, z and w are positive integers."; + } } } |