Skip to content

Commit

Permalink
make .prl processing less convoluted
Browse files Browse the repository at this point in the history
don't look up the files and normalize the paths multiple times, as this
is inefficient and hard to understand.
on the way, processPrlFile() got unnested, and libExists() got nuked.

note that a missing QMAKE_PRL_TARGET will be now complained about, which
really should never happen.

Change-Id: Ibcd77a7f963204c013548496ecd2d635e1a4baba
Reviewed-by: Joerg Bornemann <[email protected]>
Reviewed-by: Oswald Buddenhagen <[email protected]>
  • Loading branch information
ossilator committed Oct 2, 2015
1 parent 3e01f1a commit c00e11d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 66 deletions.
4 changes: 2 additions & 2 deletions qmake/generators/mac/pbuilder_pbx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,8 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
encode the version number in the Project file which might be a bad
things in days to come? --Sam
*/
QString lib_file = (*lit) + Option::dir_sep + lib;
if(QMakeMetaInfo::libExists(lib_file)) {
QString lib_file = QMakeMetaInfo::findLib(Option::normalizePath((*lit) + Option::dir_sep + lib));
if (!lib_file.isEmpty()) {
QMakeMetaInfo libinfo(project);
if(libinfo.readLib(lib_file)) {
if(!libinfo.isEmpty("QMAKE_PRL_TARGET")) {
Expand Down
94 changes: 43 additions & 51 deletions qmake/generators/makefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,64 +872,56 @@ MakefileGenerator::init()
bool
MakefileGenerator::processPrlFile(QString &file)
{
bool ret = false, try_replace_file=false;
QString meta_file, orig_file = file;
if(QMakeMetaInfo::libExists(file)) {
bool try_replace_file = false;
QString f = fileFixify(file, FileFixifyBackwards);
QString meta_file = QMakeMetaInfo::findLib(f);
if (!meta_file.isEmpty()) {
try_replace_file = true;
meta_file = file;
} else {
QString tmp = file;
QString tmp = f;
int ext = tmp.lastIndexOf('.');
if(ext != -1)
tmp = tmp.left(ext);
meta_file = tmp;
}
// meta_file = fileFixify(meta_file);
QString real_meta_file = Option::normalizePath(meta_file);
if(!meta_file.isEmpty()) {
QString f = fileFixify(real_meta_file, FileFixifyBackwards);
if(QMakeMetaInfo::libExists(f)) {
QMakeMetaInfo libinfo(project);
debug_msg(1, "Processing PRL file: %s", real_meta_file.toLatin1().constData());
if(!libinfo.readLib(f)) {
fprintf(stderr, "Error processing meta file: %s\n", real_meta_file.toLatin1().constData());
} else if(project->isActiveConfig("no_read_prl_" + libinfo.type().toLower())) {
debug_msg(2, "Ignored meta file %s [%s]", real_meta_file.toLatin1().constData(), libinfo.type().toLatin1().constData());
} else {
ret = true;
project->values("QMAKE_CURRENT_PRL_LIBS") = libinfo.values("QMAKE_PRL_LIBS");
ProStringList &defs = project->values("DEFINES");
const ProStringList &prl_defs = project->values("PRL_EXPORT_DEFINES");
foreach (const ProString &def, libinfo.values("QMAKE_PRL_DEFINES"))
if (!defs.contains(def) && prl_defs.contains(def))
defs.append(def);
if (try_replace_file) {
ProString tgt = libinfo.first("QMAKE_PRL_TARGET");
if (!tgt.isEmpty()) {
int off = qMax(file.lastIndexOf('/'), file.lastIndexOf('\\')) + 1;
debug_msg(1, " Replacing library reference %s with %s",
file.mid(off).toLatin1().constData(), tgt.toQString().toLatin1().constData());
file.replace(off, 1000, tgt.toQString());
}
}
}
}
if(ret) {
QString mf = QMakeMetaInfo::findLib(meta_file);
if(project->values("QMAKE_PRL_INTERNAL_FILES").indexOf(mf) == -1)
project->values("QMAKE_PRL_INTERNAL_FILES").append(mf);
if(project->values("QMAKE_INTERNAL_INCLUDED_FILES").indexOf(mf) == -1)
project->values("QMAKE_INTERNAL_INCLUDED_FILES").append(mf);
}
meta_file = QMakeMetaInfo::findLib(tmp);
}
if(try_replace_file && file.isEmpty()) {
#if 0
warn_msg(WarnLogic, "Found prl [%s] file with no target [%s]!", meta_file.toLatin1().constData(),
orig_file.toLatin1().constData());
#endif
file = orig_file;
if (meta_file.isEmpty())
return false;
QMakeMetaInfo libinfo(project);
debug_msg(1, "Processing PRL file: %s", meta_file.toLatin1().constData());
if (!libinfo.readLib(meta_file)) {
fprintf(stderr, "Error processing meta file %s\n", meta_file.toLatin1().constData());
return false;
}
return ret;
if (project->isActiveConfig("no_read_prl_" + libinfo.type().toLower())) {
debug_msg(2, "Ignored meta file %s [%s]",
meta_file.toLatin1().constData(), libinfo.type().toLatin1().constData());
return false;
}
project->values("QMAKE_CURRENT_PRL_LIBS") = libinfo.values("QMAKE_PRL_LIBS");
ProStringList &defs = project->values("DEFINES");
const ProStringList &prl_defs = project->values("PRL_EXPORT_DEFINES");
foreach (const ProString &def, libinfo.values("QMAKE_PRL_DEFINES"))
if (!defs.contains(def) && prl_defs.contains(def))
defs.append(def);
if (try_replace_file) {
ProString tgt = libinfo.first("QMAKE_PRL_TARGET");
if (tgt.isEmpty()) {
fprintf(stderr, "Error: %s does not define QMAKE_PRL_TARGET\n",
meta_file.toLatin1().constData());
} else {
int off = qMax(file.lastIndexOf('/'), file.lastIndexOf('\\')) + 1;
debug_msg(1, " Replacing library reference %s with %s",
file.mid(off).toLatin1().constData(),
tgt.toQString().toLatin1().constData());
file.replace(off, 1000, tgt.toQString());
}
}
QString mf = fileFixify(meta_file);
if (!project->values("QMAKE_PRL_INTERNAL_FILES").contains(mf))
project->values("QMAKE_PRL_INTERNAL_FILES").append(mf);
if (!project->values("QMAKE_INTERNAL_INCLUDED_FILES").contains(mf))
project->values("QMAKE_INTERNAL_INCLUDED_FILES").append(mf);
return true;
}

void
Expand Down
8 changes: 2 additions & 6 deletions qmake/meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ QMakeMetaInfo::QMakeMetaInfo(QMakeProject *_conf)


bool
QMakeMetaInfo::readLib(QString lib)
QMakeMetaInfo::readLib(const QString &meta_file)
{
QString meta_file = findLib(lib);

if(cache_vars.contains(meta_file)) {
vars = cache_vars[meta_file];
return true;
Expand Down Expand Up @@ -84,10 +82,8 @@ QMakeMetaInfo::readLib(QString lib)


QString
QMakeMetaInfo::findLib(QString lib)
QMakeMetaInfo::findLib(const QString &lib)
{
lib = Option::normalizePath(lib);

QString ret;
QString extns[] = { Option::prl_ext, /*Option::pkgcfg_ext, Option::libtool_ext,*/ QString() };
for(int extn = 0; !extns[extn].isNull(); extn++) {
Expand Down
11 changes: 4 additions & 7 deletions qmake/meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ class QMakeMetaInfo
public:
QMakeMetaInfo(QMakeProject *_conf);

bool readLib(QString lib);
static QString findLib(QString lib);
static bool libExists(QString lib);
QString type() const;
// These functions expect the path to be normalized
static QString findLib(const QString &lib);
bool readLib(const QString &meta_file);

QString type() const;
bool isEmpty(const ProKey &v);
ProStringList &values(const ProKey &v);
ProString first(const ProKey &v);
Expand Down Expand Up @@ -91,9 +91,6 @@ inline ProString QMakeMetaInfo::first(const ProKey &v)
inline ProValueMap &QMakeMetaInfo::variables()
{ return vars; }

inline bool QMakeMetaInfo::libExists(QString lib)
{ return !findLib(lib).isNull(); }

QT_END_NAMESPACE

#endif // META_H

0 comments on commit c00e11d

Please sign in to comment.