MakefileGenerator: deduplicate code
Factor out a resolveDependency method. We will enhance it in a subsequent commit. Change-Id: I4eead8bd03066c2ccbc9d9276acbc9f6c3bc6b97 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
af99497bdb
commit
b95a4bbe84
@ -1839,6 +1839,18 @@ static QStringList splitDeps(const QString &indeps, bool lineMode)
|
|||||||
return deps;
|
return deps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString MakefileGenerator::resolveDependency(const QDir &outDir, const QString &file)
|
||||||
|
{
|
||||||
|
const QList<QMakeLocalFileName> &depdirs = QMakeSourceFileInfo::dependencyPaths();
|
||||||
|
for (const auto &depdir : depdirs) {
|
||||||
|
const QString &local = depdir.local();
|
||||||
|
QString lf = outDir.absoluteFilePath(local + '/' + file);
|
||||||
|
if (exists(lf))
|
||||||
|
return lf;
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
||||||
{
|
{
|
||||||
@ -1991,16 +2003,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
|||||||
} else if (exists(absFile)) {
|
} else if (exists(absFile)) {
|
||||||
file = absFile;
|
file = absFile;
|
||||||
} else {
|
} else {
|
||||||
QString localFile;
|
QString localFile = resolveDependency(outDir, file);
|
||||||
QList<QMakeLocalFileName> depdirs = QMakeSourceFileInfo::dependencyPaths();
|
|
||||||
for (QList<QMakeLocalFileName>::Iterator dit = depdirs.begin();
|
|
||||||
dit != depdirs.end(); ++dit) {
|
|
||||||
QString lf = outDir.absoluteFilePath((*dit).local() + '/' + file);
|
|
||||||
if (exists(lf)) {
|
|
||||||
localFile = lf;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (localFile.isEmpty()) {
|
if (localFile.isEmpty()) {
|
||||||
if (exists(file))
|
if (exists(file))
|
||||||
warn_msg(WarnDeprecated, ".depend_command for extra compiler %s"
|
warn_msg(WarnDeprecated, ".depend_command for extra compiler %s"
|
||||||
@ -2088,16 +2091,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
|||||||
} else if (exists(absFile)) {
|
} else if (exists(absFile)) {
|
||||||
file = absFile;
|
file = absFile;
|
||||||
} else {
|
} else {
|
||||||
QString localFile;
|
QString localFile = resolveDependency(outDir, file);
|
||||||
QList<QMakeLocalFileName> depdirs = QMakeSourceFileInfo::dependencyPaths();
|
|
||||||
for (QList<QMakeLocalFileName>::Iterator dit = depdirs.begin();
|
|
||||||
dit != depdirs.end(); ++dit) {
|
|
||||||
QString lf = outDir.absoluteFilePath((*dit).local() + '/' + file);
|
|
||||||
if (exists(lf)) {
|
|
||||||
localFile = lf;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (localFile.isEmpty()) {
|
if (localFile.isEmpty()) {
|
||||||
if (exists(file))
|
if (exists(file))
|
||||||
warn_msg(WarnDeprecated, ".depend_command for extra compiler %s"
|
warn_msg(WarnDeprecated, ".depend_command for extra compiler %s"
|
||||||
|
@ -82,6 +82,7 @@ protected:
|
|||||||
void writeExportedVariables(QTextStream &t);
|
void writeExportedVariables(QTextStream &t);
|
||||||
void writeExtraVariables(QTextStream &t);
|
void writeExtraVariables(QTextStream &t);
|
||||||
void writeExtraTargets(QTextStream &t);
|
void writeExtraTargets(QTextStream &t);
|
||||||
|
QString resolveDependency(const QDir &outDir, const QString &file);
|
||||||
void writeExtraCompilerTargets(QTextStream &t);
|
void writeExtraCompilerTargets(QTextStream &t);
|
||||||
void writeExtraCompilerVariables(QTextStream &t);
|
void writeExtraCompilerVariables(QTextStream &t);
|
||||||
bool writeDummyMakefile(QTextStream &t);
|
bool writeDummyMakefile(QTextStream &t);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user