make .prl processing less convoluted
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 <joerg.bornemann@theqtcompany.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
3e01f1ad3b
commit
c00e11d573
@ -833,8 +833,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 = (*lit) + Option::dir_sep + lib;
|
QString lib_file = QMakeMetaInfo::findLib(Option::normalizePath((*lit) + Option::dir_sep + lib));
|
||||||
if(QMakeMetaInfo::libExists(lib_file)) {
|
if (!lib_file.isEmpty()) {
|
||||||
QMakeMetaInfo libinfo(project);
|
QMakeMetaInfo libinfo(project);
|
||||||
if(libinfo.readLib(lib_file)) {
|
if(libinfo.readLib(lib_file)) {
|
||||||
if(!libinfo.isEmpty("QMAKE_PRL_TARGET")) {
|
if(!libinfo.isEmpty("QMAKE_PRL_TARGET")) {
|
||||||
|
@ -872,31 +872,31 @@ MakefileGenerator::init()
|
|||||||
bool
|
bool
|
||||||
MakefileGenerator::processPrlFile(QString &file)
|
MakefileGenerator::processPrlFile(QString &file)
|
||||||
{
|
{
|
||||||
bool ret = false, try_replace_file=false;
|
bool try_replace_file = false;
|
||||||
QString meta_file, orig_file = file;
|
QString f = fileFixify(file, FileFixifyBackwards);
|
||||||
if(QMakeMetaInfo::libExists(file)) {
|
QString meta_file = QMakeMetaInfo::findLib(f);
|
||||||
|
if (!meta_file.isEmpty()) {
|
||||||
try_replace_file = true;
|
try_replace_file = true;
|
||||||
meta_file = file;
|
|
||||||
} else {
|
} else {
|
||||||
QString tmp = file;
|
QString tmp = f;
|
||||||
int ext = tmp.lastIndexOf('.');
|
int ext = tmp.lastIndexOf('.');
|
||||||
if(ext != -1)
|
if(ext != -1)
|
||||||
tmp = tmp.left(ext);
|
tmp = tmp.left(ext);
|
||||||
meta_file = tmp;
|
meta_file = QMakeMetaInfo::findLib(tmp);
|
||||||
}
|
}
|
||||||
// meta_file = fileFixify(meta_file);
|
if (meta_file.isEmpty())
|
||||||
QString real_meta_file = Option::normalizePath(meta_file);
|
return false;
|
||||||
if(!meta_file.isEmpty()) {
|
|
||||||
QString f = fileFixify(real_meta_file, FileFixifyBackwards);
|
|
||||||
if(QMakeMetaInfo::libExists(f)) {
|
|
||||||
QMakeMetaInfo libinfo(project);
|
QMakeMetaInfo libinfo(project);
|
||||||
debug_msg(1, "Processing PRL file: %s", real_meta_file.toLatin1().constData());
|
debug_msg(1, "Processing PRL file: %s", meta_file.toLatin1().constData());
|
||||||
if(!libinfo.readLib(f)) {
|
if (!libinfo.readLib(meta_file)) {
|
||||||
fprintf(stderr, "Error processing meta file: %s\n", real_meta_file.toLatin1().constData());
|
fprintf(stderr, "Error processing meta file %s\n", meta_file.toLatin1().constData());
|
||||||
} else if(project->isActiveConfig("no_read_prl_" + libinfo.type().toLower())) {
|
return false;
|
||||||
debug_msg(2, "Ignored meta file %s [%s]", real_meta_file.toLatin1().constData(), libinfo.type().toLatin1().constData());
|
}
|
||||||
} else {
|
if (project->isActiveConfig("no_read_prl_" + libinfo.type().toLower())) {
|
||||||
ret = true;
|
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");
|
project->values("QMAKE_CURRENT_PRL_LIBS") = libinfo.values("QMAKE_PRL_LIBS");
|
||||||
ProStringList &defs = project->values("DEFINES");
|
ProStringList &defs = project->values("DEFINES");
|
||||||
const ProStringList &prl_defs = project->values("PRL_EXPORT_DEFINES");
|
const ProStringList &prl_defs = project->values("PRL_EXPORT_DEFINES");
|
||||||
@ -905,31 +905,23 @@ MakefileGenerator::processPrlFile(QString &file)
|
|||||||
defs.append(def);
|
defs.append(def);
|
||||||
if (try_replace_file) {
|
if (try_replace_file) {
|
||||||
ProString tgt = libinfo.first("QMAKE_PRL_TARGET");
|
ProString tgt = libinfo.first("QMAKE_PRL_TARGET");
|
||||||
if (!tgt.isEmpty()) {
|
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;
|
int off = qMax(file.lastIndexOf('/'), file.lastIndexOf('\\')) + 1;
|
||||||
debug_msg(1, " Replacing library reference %s with %s",
|
debug_msg(1, " Replacing library reference %s with %s",
|
||||||
file.mid(off).toLatin1().constData(), tgt.toQString().toLatin1().constData());
|
file.mid(off).toLatin1().constData(),
|
||||||
|
tgt.toQString().toLatin1().constData());
|
||||||
file.replace(off, 1000, tgt.toQString());
|
file.replace(off, 1000, tgt.toQString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
QString mf = fileFixify(meta_file);
|
||||||
}
|
if (!project->values("QMAKE_PRL_INTERNAL_FILES").contains(mf))
|
||||||
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);
|
project->values("QMAKE_PRL_INTERNAL_FILES").append(mf);
|
||||||
if(project->values("QMAKE_INTERNAL_INCLUDED_FILES").indexOf(mf) == -1)
|
if (!project->values("QMAKE_INTERNAL_INCLUDED_FILES").contains(mf))
|
||||||
project->values("QMAKE_INTERNAL_INCLUDED_FILES").append(mf);
|
project->values("QMAKE_INTERNAL_INCLUDED_FILES").append(mf);
|
||||||
}
|
return true;
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -48,10 +48,8 @@ QMakeMetaInfo::QMakeMetaInfo(QMakeProject *_conf)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
QMakeMetaInfo::readLib(QString lib)
|
QMakeMetaInfo::readLib(const QString &meta_file)
|
||||||
{
|
{
|
||||||
QString meta_file = findLib(lib);
|
|
||||||
|
|
||||||
if(cache_vars.contains(meta_file)) {
|
if(cache_vars.contains(meta_file)) {
|
||||||
vars = cache_vars[meta_file];
|
vars = cache_vars[meta_file];
|
||||||
return true;
|
return true;
|
||||||
@ -84,10 +82,8 @@ QMakeMetaInfo::readLib(QString lib)
|
|||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
QMakeMetaInfo::findLib(QString lib)
|
QMakeMetaInfo::findLib(const QString &lib)
|
||||||
{
|
{
|
||||||
lib = Option::normalizePath(lib);
|
|
||||||
|
|
||||||
QString ret;
|
QString ret;
|
||||||
QString extns[] = { Option::prl_ext, /*Option::pkgcfg_ext, Option::libtool_ext,*/ QString() };
|
QString extns[] = { Option::prl_ext, /*Option::pkgcfg_ext, Option::libtool_ext,*/ QString() };
|
||||||
for(int extn = 0; !extns[extn].isNull(); extn++) {
|
for(int extn = 0; !extns[extn].isNull(); extn++) {
|
||||||
|
11
qmake/meta.h
11
qmake/meta.h
@ -55,11 +55,11 @@ class QMakeMetaInfo
|
|||||||
public:
|
public:
|
||||||
QMakeMetaInfo(QMakeProject *_conf);
|
QMakeMetaInfo(QMakeProject *_conf);
|
||||||
|
|
||||||
bool readLib(QString lib);
|
// These functions expect the path to be normalized
|
||||||
static QString findLib(QString lib);
|
static QString findLib(const QString &lib);
|
||||||
static bool libExists(QString lib);
|
bool readLib(const QString &meta_file);
|
||||||
QString type() const;
|
|
||||||
|
|
||||||
|
QString type() const;
|
||||||
bool isEmpty(const ProKey &v);
|
bool isEmpty(const ProKey &v);
|
||||||
ProStringList &values(const ProKey &v);
|
ProStringList &values(const ProKey &v);
|
||||||
ProString first(const ProKey &v);
|
ProString first(const ProKey &v);
|
||||||
@ -91,9 +91,6 @@ inline ProString QMakeMetaInfo::first(const ProKey &v)
|
|||||||
inline ProValueMap &QMakeMetaInfo::variables()
|
inline ProValueMap &QMakeMetaInfo::variables()
|
||||||
{ return vars; }
|
{ return vars; }
|
||||||
|
|
||||||
inline bool QMakeMetaInfo::libExists(QString lib)
|
|
||||||
{ return !findLib(lib).isNull(); }
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif // META_H
|
#endif // META_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user