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 <simon.hausmann@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
This commit is contained in:
Oswald Buddenhagen 2017-08-04 11:01:25 +02:00 committed by Liang Qi
parent feb2415363
commit 49cb039a5c

View File

@ -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 2>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)
}