diff --git a/src/plugins/qmakeprojectmanager/makefileparse.cpp b/src/plugins/qmakeprojectmanager/makefileparse.cpp index 206270f481f..17e140f82e4 100644 --- a/src/plugins/qmakeprojectmanager/makefileparse.cpp +++ b/src/plugins/qmakeprojectmanager/makefileparse.cpp @@ -126,13 +126,12 @@ void dumpQMakeAssignments(const QList &list) } } -void MakeFileParse::parseAssignments(QList *assignments) +QList MakeFileParse::parseAssignments(const QList &assignments) { bool foundSeparateDebugInfo = false; bool foundForceDebugInfo = false; - QList oldAssignments = *assignments; - assignments->clear(); - foreach (const QMakeAssignment &qa, oldAssignments) { + QList filteredAssignments; + foreach (const QMakeAssignment &qa, assignments) { if (qa.variable == QLatin1String("CONFIG")) { QStringList values = qa.value.split(QLatin1Char(' ')); QStringList newValues; @@ -218,10 +217,10 @@ void MakeFileParse::parseAssignments(QList *assignments) if (!newValues.isEmpty()) { QMakeAssignment newQA = qa; newQA.value = newValues.join(QLatin1Char(' ')); - assignments->append(newQA); + filteredAssignments.append(newQA); } } else { - assignments->append(qa); + filteredAssignments.append(qa); } } @@ -233,15 +232,16 @@ void MakeFileParse::parseAssignments(QList *assignments) newQA.variable = QLatin1String("CONFIG"); newQA.op = QLatin1String("+="); newQA.value = QLatin1String("force_debug_info"); - assignments->append(newQA); + filteredAssignments.append(newQA); } else if (foundSeparateDebugInfo) { // Found only separate_debug_info, so readd it QMakeAssignment newQA; newQA.variable = QLatin1String("CONFIG"); newQA.op = QLatin1String("+="); newQA.value = QLatin1String("separate_debug_info"); - assignments->append(newQA); + filteredAssignments.append(newQA); } + return filteredAssignments; } static FilePath findQMakeBinaryFromMakefile(const QString &makefile) @@ -270,7 +270,7 @@ static FilePath findQMakeBinaryFromMakefile(const QString &makefile) return FilePath(); } -MakeFileParse::MakeFileParse(const QString &makefile) +MakeFileParse::MakeFileParse(const QString &makefile, Mode mode) : m_mode(mode) { qCDebug(logging()) << "Parsing makefile" << makefile; if (!QFileInfo::exists(makefile)) { @@ -367,9 +367,9 @@ void MakeFileParse::parseCommandLine(const QString &command, const QString &proj dumpQMakeAssignments(assignments); // Filter out CONFIG arguments we know into m_qmakeBuildConfig and m_config - parseAssignments(&assignments); + const QList filteredAssignments = parseAssignments(assignments); qCDebug(logging()) << " After parsing"; - dumpQMakeAssignments(assignments); + dumpQMakeAssignments(filteredAssignments); qCDebug(logging()) << " Explicit Debug" << m_qmakeBuildConfig.explicitDebug; qCDebug(logging()) << " Explicit Release" << m_qmakeBuildConfig.explicitRelease; @@ -385,7 +385,9 @@ void MakeFileParse::parseCommandLine(const QString &command, const QString &proj << (m_config.separateDebugInfo == TriState::Enabled); // Create command line of all unfiltered arguments - foreach (const QMakeAssignment &qa, assignments) + const QList &assignmentsToUse = m_mode == Mode::FilterKnownConfigValues + ? filteredAssignments : assignments; + foreach (const QMakeAssignment &qa, assignmentsToUse) QtcProcess::addArg(&m_unparsedArguments, qa.variable + qa.op + qa.value); if (!afterAssignments.isEmpty()) { QtcProcess::addArg(&m_unparsedArguments, QLatin1String("-after")); @@ -517,7 +519,7 @@ void QmakeProjectManagerPlugin::testMakefileParser() QFETCH(bool, separateDebugInfo); QFETCH(int, effectiveBuildConfig); - MakeFileParse parser("/tmp/something"); + MakeFileParse parser("/tmp/something", MakeFileParse::Mode::FilterKnownConfigValues); parser.parseCommandLine(command, project); QCOMPARE(Utils::QtcProcess::splitArgs(parser.unparsedArguments()), diff --git a/src/plugins/qmakeprojectmanager/makefileparse.h b/src/plugins/qmakeprojectmanager/makefileparse.h index 90d34156620..87613188edd 100644 --- a/src/plugins/qmakeprojectmanager/makefileparse.h +++ b/src/plugins/qmakeprojectmanager/makefileparse.h @@ -42,7 +42,8 @@ struct QMakeAssignment class MakeFileParse { public: - MakeFileParse(const QString &makefile); + enum class Mode { FilterKnownConfigValues, DoNotFilterKnownConfigValues }; + MakeFileParse(const QString &makefile, Mode mode); enum MakefileState { MakefileMissing, CouldNotParse, Okay }; @@ -63,7 +64,7 @@ public: private: void parseArgs(const QString &args, const QString &project, QList *assignments, QList *afterAssignments); - void parseAssignments(QList *assignments); + QList parseAssignments(const QList &assignments); class QmakeBuildConfig { @@ -74,6 +75,7 @@ private: bool explicitNoBuildAll = false; }; + const Mode m_mode; MakefileState m_state; Utils::FilePath m_qmakePath; QString m_srcProFile; diff --git a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp index b15557e8654..3d3ec6af01d 100644 --- a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp +++ b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp @@ -490,7 +490,7 @@ QmakeBuildConfiguration::MakefileState QmakeBuildConfiguration::compareToImportF qCDebug(logs) << "QMakeBuildConfiguration::compareToImport"; QMakeStep *qs = qmakeStep(); - MakeFileParse parse(makefile); + MakeFileParse parse(makefile, MakeFileParse::Mode::DoNotFilterKnownConfigValues); if (parse.makeFileState() == MakeFileParse::MakefileMissing) { qCDebug(logs) << "**Makefile missing"; @@ -546,10 +546,12 @@ QmakeBuildConfiguration::MakefileState QmakeBuildConfiguration::compareToImportF // and compare that on its own QString workingDirectory = QFileInfo(makefile).absolutePath(); QStringList actualArgs; - QString userArgs = macroExpander()->expandProcessArgs(qs->userArguments()); - // This copies the settings from userArgs to actualArgs (minus some we + QString allArgs = macroExpander()->expandProcessArgs(qs->allArguments( + QtKitAspect::qtVersion(target()->kit()), QMakeStep::ArgumentFlag::Expand)); + // This copies the settings from allArgs to actualArgs (minus some we // are not interested in), splitting them up into individual strings: - extractSpecFromArguments(&userArgs, workingDirectory, version, &actualArgs); + extractSpecFromArguments(&allArgs, workingDirectory, version, &actualArgs); + actualArgs.removeFirst(); // Project file. const QString actualSpec = qs->mkspec(); QString qmakeArgs = parse.unparsedArguments(); diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp index ba4b9d8601c..3fec5661f11 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp @@ -126,7 +126,7 @@ QList QmakeProjectImporter::examineDirectory(const FilePath &importPath) qCDebug(logs) << " Parsing makefile" << file; // find interesting makefiles QString makefile = importPath.toString() + QLatin1Char('/') + file; - MakeFileParse parse(makefile); + MakeFileParse parse(makefile, MakeFileParse::Mode::FilterKnownConfigValues); if (parse.makeFileState() != MakeFileParse::Okay) { qCDebug(logs) << " Parsing the makefile failed" << makefile; continue;