From 298e119ae4c4fe6c8687083b03a60a451600d482 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Tue, 6 Jun 2017 15:28:58 -0700 Subject: Allow the GccProbe to fail more gracefully This lets error handling be deferred to a more appropriate venue like module validate scripts rather than failing with an error message like "could not find/execute g++". Change-Id: I90223339a1b4ac4fa6674c8c2ddd95acc19d395e Reviewed-by: Christian Kandeler --- share/qbs/imports/qbs/Probes/GccProbe.qbs | 6 ++++++ share/qbs/modules/cpp/GenericGCC.qbs | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/share/qbs/imports/qbs/Probes/GccProbe.qbs b/share/qbs/imports/qbs/Probes/GccProbe.qbs index c08ab7d9a..7214ffacb 100644 --- a/share/qbs/imports/qbs/Probes/GccProbe.qbs +++ b/share/qbs/imports/qbs/Probes/GccProbe.qbs @@ -29,6 +29,7 @@ ****************************************************************************/ import qbs +import qbs.File import qbs.ModUtils import "../../../modules/cpp/gcc.js" as Gcc @@ -53,6 +54,11 @@ PathProbe { property stringList frameworkPaths configure: { + if (!File.exists(compilerFilePath)) { + found = false; + return; + } + var macros = Gcc.dumpMacros(environment, compilerFilePath, flags, _nullDevice); var defaultPaths = Gcc.dumpDefaultPaths(environment, compilerFilePath, flags, _nullDevice, _pathListSeparator, _sysroot); diff --git a/share/qbs/modules/cpp/GenericGCC.qbs b/share/qbs/modules/cpp/GenericGCC.qbs index 5cad42578..d81fb15c8 100644 --- a/share/qbs/modules/cpp/GenericGCC.qbs +++ b/share/qbs/modules/cpp/GenericGCC.qbs @@ -242,6 +242,17 @@ CppModule { } validate: { + if (!File.exists(compilerPath)) { + var pathMessage = FileInfo.isAbsolutePath(compilerPath) + ? "at '" + compilerPath + "'" + : "'" + compilerPath + "' in PATH"; + throw ModUtils.ModuleError("Could not find selected C++ compiler " + pathMessage + ". " + + "Ensure that the compiler is properly " + + "installed, or set cpp.toolchainInstallPath to a valid " + + "toolchain path, or consider whether you meant to set " + + "cpp.compilerName instead."); + } + var validator = new ModUtils.PropertyValidator("cpp"); validator.setRequiredProperty("architecture", architecture, "you might want to re-run 'qbs-setup-toolchains'"); -- cgit v1.2.3