summaryrefslogtreecommitdiffstats
path: root/tools/configure
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-03-27 14:43:45 -0300
committerQt by Nokia <qt-info@nokia.com>2012-05-30 17:27:56 +0200
commit1533bfc5fcc4ec5865c1de606504b6aba8a5f6fe (patch)
tree01fcdf5c915e19be1fc79363fda08c8b6d6a2750 /tools/configure
parentd17cf14185eb84863549e0119c8b7bd20db78580 (diff)
Improve the architecture-detection mechanism
For the Unix part, this now obeys the -v option, printing the full command-line it used to compile, allowing testers to identify why something went wrong. Unfortunately, it requires a full compilation cycle, instead of just preprocessing. Just one more among the many on Unix, but maybe a noticeable slow-down on Windows. Change-Id: I654b70d99887e04c96731a5b91be9ad555e4d8fe Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Diffstat (limited to 'tools/configure')
-rw-r--r--tools/configure/configureapp.cpp47
1 files changed, 39 insertions, 8 deletions
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index 050dd6b8e1..1059f0f83b 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -2561,16 +2561,47 @@ void Configure::detectArch()
QString qmakespec = dictionary.value(pair.first);
QString key = pair.second;
+ // run qmake
QString command =
- fixSeparators(QString("%1/bin/qmake.exe -spec %2 %3/config.tests/arch/arch.pro -o %4/Makefile.unused 2>&1")
- .arg(buildPath, qmakespec, sourcePath, newpwd));
- QString output = Environment::execute(command);
- if (output.isEmpty())
- continue;
+ fixSeparators(QString("%1/bin/qmake.exe -spec %2 %3/config.tests/arch/arch.pro 2>&1")
+ .arg(buildPath, qmakespec, sourcePath));
+ Environment::execute(command);
+
+ // compile
+ command = dictionary[ "MAKE" ];
+ if (command.contains("nmake"))
+ command += " /NOLOGO";
+ command += " -s";
+ Environment::execute(command);
+
+ // find the executable that was generated
+ QFile exe("arch.exe");
+ if (!exe.open(QFile::ReadOnly)) { // no Text, this is binary
+ cout << "Could not find output file: " << qPrintable(exe.errorString()) << endl;
+ dictionary["DONE"] = "error";
+ return;
+ }
+ QByteArray exeContents = exe.readAll();
+ exe.close();
+
+ static const char magic[] = "==Qt=magic=Qt== Architecture:";
+ int magicPos = exeContents.indexOf(magic);
+ if (magicPos == -1) {
+ cout << "Internal error, could not find the architecture of the executable" << endl;
+ dictionary["DONE"] = "error";
+ return;
+ }
+ //cout << "Found magic at offset 0x" << hex << magicPos << endl;
+
+ // the conversion from QByteArray will stop at the ending NUL anyway
+ QString arch = QString::fromLatin1(exeContents.constData() + magicPos
+ + sizeof(magic) - 1);
+ dictionary[key] = arch;
+
+ //cout << "Detected arch '" << qPrintable(arch) << "'\n";
- QRegExp re("Project MESSAGE:.*Architecture: ([a-zA-Z0-9_]*)");
- if (re.indexIn(output) != -1)
- dictionary[key] = re.cap(1);
+ // clean up
+ Environment::execute(command + " distclean");
}
if (!dictionary.contains("QT_HOST_ARCH"))