forked from qt-creator/qt-creator
QmakeProjectManager: Compare the right set of arguments
... when determining whether to re-run qmake. We need to look at the effective arguments, not the user arguments. Of course, the whole approach is still a shaky heuristic, but it should be more correct now than it was before. Fixes: QTCREATORBUG-24538 Change-Id: I763f8095becacde0f9549890161b8a47c6344b6b Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -126,13 +126,12 @@ void dumpQMakeAssignments(const QList<QMakeAssignment> &list)
|
||||
}
|
||||
}
|
||||
|
||||
void MakeFileParse::parseAssignments(QList<QMakeAssignment> *assignments)
|
||||
QList<QMakeAssignment> MakeFileParse::parseAssignments(const QList<QMakeAssignment> &assignments)
|
||||
{
|
||||
bool foundSeparateDebugInfo = false;
|
||||
bool foundForceDebugInfo = false;
|
||||
QList<QMakeAssignment> oldAssignments = *assignments;
|
||||
assignments->clear();
|
||||
foreach (const QMakeAssignment &qa, oldAssignments) {
|
||||
QList<QMakeAssignment> 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<QMakeAssignment> *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<QMakeAssignment> *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<QMakeAssignment> 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<QMakeAssignment> &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()),
|
||||
|
@@ -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<QMakeAssignment> *assignments, QList<QMakeAssignment> *afterAssignments);
|
||||
void parseAssignments(QList<QMakeAssignment> *assignments);
|
||||
QList<QMakeAssignment> parseAssignments(const QList<QMakeAssignment> &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;
|
||||
|
@@ -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();
|
||||
|
@@ -126,7 +126,7 @@ QList<void *> 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;
|
||||
|
Reference in New Issue
Block a user