qmake: refactor QMakeMetaInfo::findLib() interface

move the logic for trying different extensions to
MakefileGenerator::processPrlFile(), which is the only user of that
functionality. that makes findLib() rather trivial and a bit of a
misnomer, so rename it to checkLib().

Change-Id: If9738cc17367452853ab8d3866fa36b5d4b57213
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Oswald Buddenhagen 2018-07-09 19:15:42 +02:00
parent eb9da60f0c
commit caaceb30e6
4 changed files with 16 additions and 15 deletions

View File

@ -848,7 +848,8 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
encode the version number in the Project file which might be a bad encode the version number in the Project file which might be a bad
things in days to come? --Sam things in days to come? --Sam
*/ */
QString lib_file = QMakeMetaInfo::findLib(Option::normalizePath((*lit) + Option::dir_sep + lib)); QString lib_file = QMakeMetaInfo::checkLib(Option::normalizePath(
(*lit) + Option::dir_sep + lib + Option::prl_ext));
if (!lib_file.isEmpty()) { if (!lib_file.isEmpty()) {
QMakeMetaInfo libinfo(project); QMakeMetaInfo libinfo(project);
if(libinfo.readLib(lib_file)) { if(libinfo.readLib(lib_file)) {

View File

@ -880,15 +880,19 @@ MakefileGenerator::processPrlFile(QString &file)
{ {
bool try_replace_file = false; bool try_replace_file = false;
QString f = fileFixify(file, FileFixifyBackwards); QString f = fileFixify(file, FileFixifyBackwards);
QString meta_file = QMakeMetaInfo::findLib(f); QString meta_file;
if (!meta_file.isEmpty()) { if (f.endsWith(Option::prl_ext)) {
meta_file = QMakeMetaInfo::checkLib(f);
try_replace_file = true; try_replace_file = true;
} else { } else {
QString tmp = f; meta_file = QMakeMetaInfo::checkLib(f + Option::prl_ext);
int ext = tmp.lastIndexOf('.'); if (!meta_file.isEmpty()) {
if(ext != -1) try_replace_file = true;
tmp = tmp.left(ext); } else {
meta_file = QMakeMetaInfo::findLib(tmp); int ext = f.lastIndexOf('.');
if (ext != -1)
meta_file = QMakeMetaInfo::checkLib(f.left(ext) + Option::prl_ext);
}
} }
if (meta_file.isEmpty()) if (meta_file.isEmpty())
return false; return false;

View File

@ -60,13 +60,9 @@ QMakeMetaInfo::readLib(const QString &meta_file)
QString QString
QMakeMetaInfo::findLib(const QString &lib) QMakeMetaInfo::checkLib(const QString &lib)
{ {
QString ret; QString ret = QFile::exists(lib) ? lib : QString();
if (lib.endsWith(Option::prl_ext))
ret = QFile::exists(lib) ? lib : QString();
else if (QFile::exists(lib + Option::prl_ext))
ret = lib + Option::prl_ext;
if(ret.isNull()) { if(ret.isNull()) {
debug_msg(2, "QMakeMetaInfo: Cannot find info file for %s", lib.toLatin1().constData()); debug_msg(2, "QMakeMetaInfo: Cannot find info file for %s", lib.toLatin1().constData());
} else { } else {

View File

@ -48,7 +48,7 @@ public:
QMakeMetaInfo(QMakeProject *_conf); QMakeMetaInfo(QMakeProject *_conf);
// These functions expect the path to be normalized // These functions expect the path to be normalized
static QString findLib(const QString &lib); static QString checkLib(const QString &lib);
bool readLib(const QString &meta_file); bool readLib(const QString &meta_file);
bool isEmpty(const ProKey &v); bool isEmpty(const ProKey &v);