Commit 772c838a authored by Tobias Hunger's avatar Tobias Hunger

Add a method to find pro-files used to create a Makefile

Reviewed-by: dt
parent 75da336d
......@@ -778,6 +778,24 @@ void dumpQMakeAssignments(const QList<QMakeAssignment> &list)
bool QtVersionManager::makefileIsFor(const QString &directory, const QString &proFile)
if (proFile.isEmpty())
return true;
QString line = findQMakeLine(directory, QLatin1String("# Project:")).trimmed();
if (line.isEmpty())
return false;
line = line.mid(line.indexOf(QChar(':')) + 1);
line = line.trimmed();
QFileInfo srcFileInfo(QDir(directory), line);
QFileInfo proFileInfo(proFile);
return srcFileInfo == proFileInfo;
QPair<QtVersion::QmakeBuildConfigs, QStringList> QtVersionManager::scanMakeFile(const QString &directory, QtVersion::QmakeBuildConfigs defaultBuildConfig)
if (debug)
......@@ -785,7 +803,7 @@ QPair<QtVersion::QmakeBuildConfigs, QStringList> QtVersionManager::scanMakeFile(
QtVersion::QmakeBuildConfigs result = defaultBuildConfig;
QStringList result2;
QString line = findQMakeLine(directory);
QString line = findQMakeLine(directory, QLatin1String("# Command:"));
if (!line.isEmpty()) {
if (debug)
qDebug()<<"Found line"<<line;
......@@ -835,14 +853,14 @@ QPair<QtVersion::QmakeBuildConfigs, QStringList> QtVersionManager::scanMakeFile(
return qMakePair(result, result2);
QString QtVersionManager::findQMakeLine(const QString &directory)
QString QtVersionManager::findQMakeLine(const QString &directory, const QString &key)
QFile makefile(directory + QLatin1String("/Makefile" ));
if (makefile.exists() && {
QTextStream ts(&makefile);
while (!ts.atEnd()) {
const QString line = ts.readLine();
if (line.startsWith(QLatin1String("# Command:")))
if (line.startsWith(key))
return line;
......@@ -225,6 +225,7 @@ public:
QSet<QString> supportedTargetIds() const;
// Static Methods
static bool makefileIsFor(const QString &directory, const QString &proFile);
static QPair<QtVersion::QmakeBuildConfigs, QStringList> scanMakeFile(const QString &directory,
QtVersion::QmakeBuildConfigs defaultBuildConfig);
static QString findQMakeBinaryFromMakefile(const QString &directory);
......@@ -239,7 +240,7 @@ private slots:
// This function is really simplistic...
static bool equals(QtVersion *a, QtVersion *b);
static QString findQMakeLine(const QString &directory);
static QString findQMakeLine(const QString &directory, const QString &key);
static QString trimLine(const QString line);
static QStringList splitLine(const QString &line);
static void parseParts(const QStringList &parts,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment