aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmakeprojectmanager/makefileparse.cpp
diff options
context:
space:
mode:
authorChristian Stenger <[email protected]>2023-09-27 16:20:18 +0200
committerChristian Stenger <[email protected]>2023-11-15 11:29:05 +0000
commitcf6b6b5a8ab32791c39703fd8a25a6205e0a6269 (patch)
tree2d2d6efebce4aa5285162d5a932536ce940d2451 /src/plugins/qmakeprojectmanager/makefileparse.cpp
parent5a2df08ae08becf75003f1824572397c7c5a7266 (diff)
QmakePM: Improve performance of import
Shuffle order of parse and add short cuts in case we can stop parsing early. Change-Id: If03a5cbc0e51dc77f4b03b1cf1d07243f5b2a70b Reviewed-by: Christian Kandeler <[email protected]>
Diffstat (limited to 'src/plugins/qmakeprojectmanager/makefileparse.cpp')
-rw-r--r--src/plugins/qmakeprojectmanager/makefileparse.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/plugins/qmakeprojectmanager/makefileparse.cpp b/src/plugins/qmakeprojectmanager/makefileparse.cpp
index b5a6d82a1f9..de8ff427863 100644
--- a/src/plugins/qmakeprojectmanager/makefileparse.cpp
+++ b/src/plugins/qmakeprojectmanager/makefileparse.cpp
@@ -25,7 +25,13 @@ static QString findQMakeLine(const FilePath &makefile, const QString &key)
{
QFile fi(makefile.toString());
if (fi.exists() && fi.open(QFile::ReadOnly)) {
+ static const QString cmakeLine("# CMAKE generated file: DO NOT EDIT!");
QTextStream ts(&fi);
+ if (!ts.atEnd()) {
+ if (ts.readLine() == cmakeLine)
+ return {};
+ ts.seek(0);
+ }
while (!ts.atEnd()) {
const QString line = ts.readLine();
if (line.startsWith(key))
@@ -48,7 +54,7 @@ void MakeFileParse::parseArgs(const QString &args, const QString &project,
QList<QMakeAssignment> *assignments,
QList<QMakeAssignment> *afterAssignments)
{
- const QRegularExpression regExp(QLatin1String("^([^\\s\\+-]*)\\s*(\\+=|=|-=|~=)(.*)$"));
+ static const QRegularExpression regExp(QLatin1String("^([^\\s\\+-]*)\\s*(\\+=|=|-=|~=)(.*)$"));
bool after = false;
bool ignoreNext = false;
m_unparsedArguments = args;
@@ -207,7 +213,7 @@ static FilePath findQMakeBinaryFromMakefile(const FilePath &makefile)
QFile fi(makefile.toString());
if (fi.exists() && fi.open(QFile::ReadOnly)) {
QTextStream ts(&fi);
- const QRegularExpression r1(QLatin1String("^QMAKE\\s*=(.*)$"));
+ static const QRegularExpression r1(QLatin1String("^QMAKE\\s*=(.*)$"));
while (!ts.atEnd()) {
QString line = ts.readLine();
const QRegularExpressionMatch match = r1.match(line);
@@ -228,7 +234,9 @@ static FilePath findQMakeBinaryFromMakefile(const FilePath &makefile)
return {};
}
-MakeFileParse::MakeFileParse(const FilePath &makefile, Mode mode) : m_mode(mode)
+MakeFileParse::MakeFileParse(const FilePath &makefile, Mode mode,
+ std::optional<FilePath> projectPath)
+ : m_mode(mode)
{
qCDebug(logging()) << "Parsing makefile" << makefile;
if (!makefile.exists()) {
@@ -237,10 +245,6 @@ MakeFileParse::MakeFileParse(const FilePath &makefile, Mode mode) : m_mode(mode)
return;
}
- // Qt Version!
- m_qmakePath = findQMakeBinaryFromMakefile(makefile);
- qCDebug(logging()) << " qmake:" << m_qmakePath;
-
QString project = findQMakeLine(makefile, QLatin1String("# Project:")).trimmed();
if (project.isEmpty()) {
m_state = CouldNotParse;
@@ -254,6 +258,14 @@ MakeFileParse::MakeFileParse(const FilePath &makefile, Mode mode) : m_mode(mode)
// Src Pro file
m_srcProFile = makefile.parentDir().resolvePath(project);
qCDebug(logging()) << " source .pro file:" << m_srcProFile;
+ if (projectPath && m_srcProFile != *projectPath) { // shortcut when importing
+ m_state = Okay;
+ return;
+ }
+
+ // Qt Version!
+ m_qmakePath = findQMakeBinaryFromMakefile(makefile);
+ qCDebug(logging()) << " qmake:" << m_qmakePath;
QString command = findQMakeLine(makefile, QLatin1String("# Command:")).trimmed();
if (command.isEmpty()) {