Qt4ProjectManager: Support Makefile variable

Pass on the makefile to make, check the right makefile for importing.

Task-Nr: QTCREATORBUG-102
This commit is contained in:
dt
2010-10-05 17:38:45 +02:00
parent 51bfe658da
commit a36dc1d41e
10 changed files with 91 additions and 34 deletions

View File

@@ -803,12 +803,12 @@ void QtVersion::updateSourcePath()
// That is returns the directory
// To find out whether we already have a qtversion for that directory call
// QtVersion *QtVersionManager::qtVersionForDirectory(const QString directory);
QString QtVersionManager::findQMakeBinaryFromMakefile(const QString &directory)
QString QtVersionManager::findQMakeBinaryFromMakefile(const QString &makefile)
{
bool debugAdding = false;
QFile makefile(directory + "/Makefile" );
if (makefile.exists() && makefile.open(QFile::ReadOnly)) {
QTextStream ts(&makefile);
QFile fi(makefile);
if (fi.exists() && fi.open(QFile::ReadOnly)) {
QTextStream ts(&fi);
QRegExp r1("QMAKE\\s*=(.*)");
while (!ts.atEnd()) {
QString line = ts.readLine();
@@ -854,32 +854,31 @@ void dumpQMakeAssignments(const QList<QMakeAssignment> &list)
}
}
bool QtVersionManager::makefileIsFor(const QString &directory, const QString &proFile)
bool QtVersionManager::makefileIsFor(const QString &makefile, const QString &proFile)
{
if (proFile.isEmpty())
return true;
QString line = findQMakeLine(directory, QLatin1String("# Project:")).trimmed();
QString line = findQMakeLine(makefile, QLatin1String("# Project:")).trimmed();
if (line.isEmpty())
return false;
line = line.mid(line.indexOf(QChar(':')) + 1);
line = line.trimmed();
QFileInfo srcFileInfo(QDir(directory), line);
QFileInfo srcFileInfo(QFileInfo(makefile).absoluteDir(), line);
QFileInfo proFileInfo(proFile);
return srcFileInfo == proFileInfo;
}
QPair<QtVersion::QmakeBuildConfigs, QStringList> QtVersionManager::scanMakeFile(const QString &directory, QtVersion::QmakeBuildConfigs defaultBuildConfig)
QPair<QtVersion::QmakeBuildConfigs, QStringList> QtVersionManager::scanMakeFile(const QString &makefile, QtVersion::QmakeBuildConfigs defaultBuildConfig)
{
if (debug)
qDebug()<<"ScanMakeFile, the gory details:";
QtVersion::QmakeBuildConfigs result = defaultBuildConfig;
QStringList result2;
QString line = findQMakeLine(directory, QLatin1String("# Command:"));
QString line = findQMakeLine(makefile, QLatin1String("# Command:"));
if (!line.isEmpty()) {
if (debug)
qDebug()<<"Found line"<<line;
@@ -930,11 +929,11 @@ QPair<QtVersion::QmakeBuildConfigs, QStringList> QtVersionManager::scanMakeFile(
return qMakePair(result, result2);
}
QString QtVersionManager::findQMakeLine(const QString &directory, const QString &key)
QString QtVersionManager::findQMakeLine(const QString &makefile, const QString &key)
{
QFile makefile(directory + QLatin1String("/Makefile" ));
if (makefile.exists() && makefile.open(QFile::ReadOnly)) {
QTextStream ts(&makefile);
QFile fi(makefile);
if (fi.exists() && fi.open(QFile::ReadOnly)) {
QTextStream ts(&fi);
while (!ts.atEnd()) {
const QString line = ts.readLine();
if (line.startsWith(key))