From 4cc9523a3153a0e7b012de3919e0c4f4ccb96265 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Tue, 20 Mar 2012 21:01:20 -0700 Subject: Make architecture detection more robust. Any message/error in mkspecs or qmake feature files ends up confusing the current arch detection logic. Instead, search for "Project MESSAGE: .* Architecture: ". Change-Id: I308932a5b75f3a1fcbc4fe30c74faf2e83b2d752 Reviewed-by: Oswald Buddenhagen --- config.tests/arch/arch.cpp | 26 +++++++++++++------------- config.tests/arch/arch.pro | 4 ++-- configure | 5 +++-- tools/configure/configureapp.cpp | 29 +++-------------------------- 4 files changed, 21 insertions(+), 43 deletions(-) diff --git a/config.tests/arch/arch.cpp b/config.tests/arch/arch.cpp index f942d0adc7..1a96fb982f 100644 --- a/config.tests/arch/arch.cpp +++ b/config.tests/arch/arch.cpp @@ -55,29 +55,29 @@ #undef sparc #undef unknown #if defined(Q_PROCESSOR_ALPHA) -alpha +Architecture: alpha #elif defined(Q_PROCESSOR_ARM) -arm +Architecture: arm #elif defined(Q_PROCESSOR_AVR32) -avr32 +Architecture: avr32 #elif defined(Q_PROCESSOR_BLACKFIN) -bfin +Architecture: bfin #elif defined(Q_PROCESSOR_X86_32) -i386 +Architecture: i386 #elif defined(Q_PROCESSOR_X86_64) -x86_64 +Architecture: x86_64 #elif defined(Q_PROCESSOR_IA64) -ia64 +Architecture: ia64 #elif defined(Q_PROCESSOR_MIPS) -mips +Architecture: mips #elif defined(Q_PROCESSOR_POWER) -power +Architecture: power #elif defined(Q_PROCESSOR_S390) -s390 +Architecture: s390 #elif defined(Q_PROCESSOR_SH) -sh +Architecture: sh #elif defined(Q_PROCESSOR_SPARC) -sparc +Architecture: sparc #else -unknown +Architecture: unknown #endif diff --git a/config.tests/arch/arch.pro b/config.tests/arch/arch.pro index 108f262a55..ea85a52b97 100644 --- a/config.tests/arch/arch.pro +++ b/config.tests/arch/arch.pro @@ -1,7 +1,7 @@ CONFIG -= qt debug_and_release # Detect target by preprocessing a file that uses Q_PROCESSOR_* macros from qprocessordetection.h COMMAND = $$QMAKE_CXX $$QMAKE_CXXFLAGS -E $$PWD/arch.cpp -# 'false' as second argument to system() prevents qmake from stripping newlines -COMPILER_ARCH = $$system($$COMMAND, false) +# system function converts newline in output into spaces +COMPILER_ARCH = $$system($$COMMAND) # Message back to configure so that it can set QT_ARCH and QT_HOST_ARCH message($$COMPILER_ARCH) diff --git a/configure b/configure index 1d03e14a79..6b2cca4aac 100755 --- a/configure +++ b/configure @@ -3933,11 +3933,12 @@ fi # Build qmake #------------------------------------------------------------------------------- # Use config.tests/arch/arch.pro to has the compiler tell us what the target architecture is -CFG_ARCH=`"$outpath/bin/qmake" -spec "$XQMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -e "s,^Project MESSAGE: ,," -e "s,^#.*$,,g" | grep -v "^$"` +CFG_ARCH=`"$outpath/bin/qmake" -spec "$XQMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -n -e 's,^Project MESSAGE:.*Architecture: \([a-zA-Z0-9]*\).*,\1,p'` + [ -z "$CFG_ARCH" ] && CFG_ARCH="unknown" if [ "$QMAKESPEC" != "$XQMAKESPEC" ]; then # Do the same test again, using the host compiler - CFG_HOST_ARCH=`"$outpath/bin/qmake" -spec "$QMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -e "s,^Project MESSAGE: ,," -e "s,^#.*$,,g" | grep -v "^$"` + CFG_HOST_ARCH=`"$outpath/bin/qmake" -spec "$QMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -n -e 's,^Project MESSAGE:.*Architecture: \([a-zA-Z0-9]*\).*,\1,p'` [ -z "$CFG_HOST_ARCH" ] && CFG_HOST_ARCH="unknown" else # not cross compiling, host == target diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 0c9907f6d5..58ffd28ff3 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -2584,32 +2584,9 @@ void Configure::detectArch() if (output.isEmpty()) continue; - // strip everything up to and including 'Project MESSAGE: ' - QString ProjectMESSAGE = QStringLiteral("Project MESSAGE: "); - int at = output.indexOf(ProjectMESSAGE); - if (at != -1) - output = output.mid(at + ProjectMESSAGE.length()); - - // strip lines beginning with a # - at = 0; - while ((at = output.indexOf('#', at)) != -1) { - if (at > 0 && output.at(at - 1) != '\n') { - // # isnt' at the beginning of a line, skip it - ++at; - continue; - } - - int eol = output.indexOf('\n', at); - if (eol == -1) { - // end of string - output.remove(at, output.length() - at); - break; - } - - output.remove(at, eol - at + 1); - } - - dictionary[key] = output.simplified(); + QRegExp re("Project MESSAGE:.*Architecture: ([a-zA-Z0-9]*)"); + if (re.indexIn(output) != -1) + dictionary[key] = re.cap(1); } if (!dictionary.contains("QT_HOST_ARCH")) -- cgit v1.2.3