From 49cb039a5c15d434514e81a7573778c8b2db566a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 4 Aug 2017 11:01:25 +0200 Subject: make compiler invocation error messages mention host/target it's unclear where to look for the error when the message talks about 'g++' when '${CROSS_COMPILE}g++' would have been expected. help it by saying whether it was supposed to be the host or target compiler. this also centralizes the error emissions in a function. Change-Id: I454c6ff7c0e7dd945dcee0de01e2818caeeb7409 Reviewed-by: Simon Hausmann Reviewed-by: Frederik Gladhorn --- mkspecs/features/toolchain.prf | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf index 813dbffbd4..21c18c7f7b 100644 --- a/mkspecs/features/toolchain.prf +++ b/mkspecs/features/toolchain.prf @@ -12,6 +12,16 @@ defineReplace(qtMakeExpand) { } } +defineTest(qtCompilerErrror) { + !cross_compile: \ + what = + else: host_build: \ + what = " host" + else: \ + what = " target" + error("Cannot run$$what compiler '$$1'. Maybe you forgot to setup the environment?") +} + cross_compile:host_build: \ target_prefix = QMAKE_HOST_CXX else: \ @@ -58,8 +68,7 @@ isEmpty($${target_prefix}.INCDIRS) { cxx_flags += -E -v output = $$system("$$cmd_prefix $$QMAKE_CXX $$qtMakeExpand($$cxx_flags) -xc++ - 2>&1 $$cmd_suffix", lines, ec) - !equals(ec, 0): \ - error("Cannot run compiler '$$QMAKE_CXX'. Maybe you forgot to setup the environment?") + !equals(ec, 0): qtCompilerErrror($$QMAKE_CXX) rim_qcc { for (line, output) { @@ -119,8 +128,7 @@ isEmpty($${target_prefix}.INCDIRS) { # What's more, -print-search-dirs can't be used on clang on Apple because it # won't print all the library paths (only the clang-internal ones). output = $$system("$$cmd_prefix $$QMAKE_CXX -print-search-dirs", lines, ec) - !equals(ec, 0): \ - error("Cannot run compiler '$$QMAKE_CXX'. Maybe you forgot to setup the environment?") + !equals(ec, 0): qtCompilerErrror($$QMAKE_CXX) for (line, output) { contains(line, "^libraries: .*") { @@ -162,8 +170,7 @@ isEmpty($${target_prefix}.INCDIRS) { defineReplace(qtVariablesFromMSVC) { ret = $$system("$$1 -nologo -E $$2 $$system_quote($$PWD/data/macros.cpp) NUL", lines, ec) - !equals(ec, 0): \ - error("Cannot run compiler '$$1'. Maybe you forgot to setup the environment?") + !equals(ec, 0): qtCompilerErrror($$1) return($$ret) } @@ -171,8 +178,7 @@ defineReplace(qtVariablesFromGCC) { null_device = /dev/null equals(QMAKE_HOST.os, Windows): null_device = NUL ret = $$system("$$1 -E $$system_quote($$PWD/data/macros.cpp) <$$null_device 2>$$null_device", lines, ec) - !equals(ec, 0): \ - error("Cannot run compiler '$$1'. Maybe you forgot to setup the environment?") + !equals(ec, 0): qtCompilerErrror($$1) return($$ret) } -- cgit v1.2.3