QtVersion: Special treatment for qthooser

Resolve which qmake qtchooser will forward too, as that qmake will put
it's path into the makefile.

Task-number: QTCREATORBUG-9841
Change-Id: Ib7a17c7683550ce3bb9172c7428a0efc328652f5
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Daniel Teske
2013-08-05 13:03:43 +02:00
parent e61c797c6d
commit 84b479225e
3 changed files with 38 additions and 1 deletions

View File

@@ -37,6 +37,32 @@
namespace Utils { namespace Utils {
bool BuildableHelperLibrary::isQtChooser(const QFileInfo &info)
{
return info.isSymLink() && info.symLinkTarget().endsWith(QLatin1String("/qtchooser"));
}
QString BuildableHelperLibrary::qtChooserToQmakePath(const QString &path)
{
QProcess proc;
proc.start(path, QStringList(QLatin1String("-print-env")));
if (!proc.waitForStarted(1000))
return QString();
if (!proc.waitForFinished(1000))
return QString();
QByteArray output = proc.readAllStandardOutput();
int pos = output.indexOf("QTTOOLDIR=");
if (pos == -1)
return QString();
pos += strlen("QTTOOLDIR=\"");
int end = output.indexOf('\"', pos);
if (end == -1)
return QString();
QString result = QString::fromLocal8Bit(output.mid(pos, end - pos)) + QLatin1String("/qmake");
return result;
}
Utils::FileName BuildableHelperLibrary::findSystemQt(const Utils::Environment &env) Utils::FileName BuildableHelperLibrary::findSystemQt(const Utils::Environment &env)
{ {
QStringList paths = env.path(); QStringList paths = env.path();
@@ -45,8 +71,11 @@ Utils::FileName BuildableHelperLibrary::findSystemQt(const Utils::Environment &e
if (!prefix.endsWith(QLatin1Char('/'))) if (!prefix.endsWith(QLatin1Char('/')))
prefix.append(QLatin1Char('/')); prefix.append(QLatin1Char('/'));
foreach (const QString &possibleCommand, possibleQMakeCommands()) { foreach (const QString &possibleCommand, possibleQMakeCommands()) {
const QFileInfo qmake(prefix + possibleCommand); QFileInfo qmake(prefix + possibleCommand);
if (qmake.exists()) { if (qmake.exists()) {
if (isQtChooser(qmake))
qmake.setFile(qtChooserToQmakePath(qmake.symLinkTarget()));
if (!qtVersionForQMake(qmake.absoluteFilePath()).isNull()) if (!qtVersionForQMake(qmake.absoluteFilePath()).isNull())
return Utils::FileName(qmake); return Utils::FileName(qmake);
} }

View File

@@ -43,6 +43,8 @@ public:
// returns the full path to the first qmake, qmake-qt4, qmake4 that has // returns the full path to the first qmake, qmake-qt4, qmake4 that has
// at least version 2.0.0 and thus is a qt4 qmake // at least version 2.0.0 and thus is a qt4 qmake
static FileName findSystemQt(const Utils::Environment &env); static FileName findSystemQt(const Utils::Environment &env);
static bool isQtChooser(const QFileInfo &info);
static QString qtChooserToQmakePath(const QString &path);
// return true if the qmake at qmakePath is qt4 (used by QtVersion) // return true if the qmake at qmakePath is qt4 (used by QtVersion)
static QString qtVersionForQMake(const QString &qmakePath); static QString qtVersionForQMake(const QString &qmakePath);
static QString qtVersionForQMake(const QString &qmakePath, bool *qmakeIsExecutable); static QString qtVersionForQMake(const QString &qmakePath, bool *qmakeIsExecutable);

View File

@@ -635,6 +635,12 @@ void QtOptionsPageWidget::addQtDir()
QFileDialog::DontResolveSymlinks)); QFileDialog::DontResolveSymlinks));
if (qtVersion.isNull()) if (qtVersion.isNull())
return; return;
QFileInfo fi(qtVersion.toString());
// should add all qt versions here ?
if (BuildableHelperLibrary::isQtChooser(fi))
qtVersion = Utils::FileName::fromString(BuildableHelperLibrary::qtChooserToQmakePath(fi.symLinkTarget()));
BaseQtVersion *version = 0; BaseQtVersion *version = 0;
foreach (BaseQtVersion *v, m_versions) { foreach (BaseQtVersion *v, m_versions) {
if (v->qmakeCommand() == qtVersion) { if (v->qmakeCommand() == qtVersion) {