diff options
author | Jake Petroules <jake.petroules@qt.io> | 2017-06-06 16:14:26 -0700 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2017-06-07 16:06:17 +0000 |
commit | d6d0dd718812a4e602383403ba6585bfc5c351e0 (patch) | |
tree | e186f6788493e8bd219e80700cffc02f49228777 | |
parent | d7c0b9fba5fc8e4106f9f9707f06846928900874 (diff) |
Provide more user-friendly errors in module validation
Instead of a cryptic message simply stating that various properties
are not set, try to provide the user with real-world, actionable
suggestions to aid in project setup.
This new style in the QNX module vs usage of the old
PropertyValidator is kind of a "trial" run and could be expanded to
the rest of the modules later.
Change-Id: I2763540351fa609a14470110a3971624a7f7cf13
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r-- | share/qbs/imports/qbs/ModUtils/utils.js | 6 | ||||
-rw-r--r-- | share/qbs/modules/qnx/qnx.qbs | 27 |
2 files changed, 27 insertions, 6 deletions
diff --git a/share/qbs/imports/qbs/ModUtils/utils.js b/share/qbs/imports/qbs/ModUtils/utils.js index 393ed34e6..39fee80f1 100644 --- a/share/qbs/imports/qbs/ModUtils/utils.js +++ b/share/qbs/imports/qbs/ModUtils/utils.js @@ -258,6 +258,12 @@ function flattenEnvironmentDictionary(dict, pathListSeparator) { return list; } +function ModuleError(message) { + var e = new Error(message); + e.fileName = ""; + return e; +} + var EnvironmentVariable = (function () { function EnvironmentVariable(name, separator, convertPathSeparators) { if (!name) diff --git a/share/qbs/modules/qnx/qnx.qbs b/share/qbs/modules/qnx/qnx.qbs index ead5ce3b2..8eb952290 100644 --- a/share/qbs/modules/qnx/qnx.qbs +++ b/share/qbs/modules/qnx/qnx.qbs @@ -103,11 +103,26 @@ Module { qbs.sysroot: targetDir validate: { - var validator = new ModUtils.PropertyValidator("qnx"); - validator.setRequiredProperty("sdkDir", sdkDir); - validator.setRequiredProperty("hostArch", hostArch); - validator.setRequiredProperty("hostOs", hostOs); - validator.setRequiredProperty("targetOs", targetOs); - return validator.validate(); + if (!sdkDir) { + throw ModUtils.ModuleError("Could not find a QNX SDK in any of the following " + + "locations:\n\t" + qnxSdkProbe.candidatePaths.join("\n\t") + + "\nInstall the QNX SDK to one of the above locations, " + + "or set the qnx.sdkDir property to a valid QNX SDK " + + "location."); + } + + if (!hostOs) { + throw ModUtils.ModuleError("Host operating system '" + qbs.hostOS + + "' is not supported by the QNX SDK."); + } else if (!File.exists(hostDir)) { + throw ModUtils.ModuleError("Detected host tools operating system '" + hostOs + + "' and architecture '" + hostArch + "' directory is not " + + "present in the QNX SDK installed at '" + sdkDir + + "' in the expected location '" + hostDir + + "'; did you forget to install it?"); + } + + if (!targetOs) + throw ModUtils.ModuleError("Could not find any QNX targets in '" + targetDir + "'"); } } |