summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2015-08-17 19:33:52 +0200
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2015-10-02 14:00:56 +0000
commit2677cc47fc9e5bfa1d3daf69e464521041a8144c (patch)
tree16b430c2dbb078e617d2daf6b13a7414c5b1b39c
parentd49169ae890bcf4f341b7c2f36b875668f063de6 (diff)
downloadqtbase-2677cc47fc9e5bfa1d3daf69e464521041a8144c.tar.gz
merge processPrlFiles() into findLibraries()
seems pointless to tear apart the functions, on the way duplicating some boilerplate. Change-Id: Ide3697ca1c931e8de607ac48c21cecce4781fe13 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
-rw-r--r--qmake/generators/makefile.cpp16
-rw-r--r--qmake/generators/makefile.h5
-rw-r--r--qmake/generators/unix/unixmake.cpp132
-rw-r--r--qmake/generators/unix/unixmake.h3
-rw-r--r--qmake/generators/win32/mingw_make.cpp40
-rw-r--r--qmake/generators/win32/mingw_make.h2
-rw-r--r--qmake/generators/win32/winmakefile.cpp81
-rw-r--r--qmake/generators/win32/winmakefile.h3
8 files changed, 121 insertions, 161 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index 4a03fafd77..0d7571341a 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -252,10 +252,12 @@ MakefileGenerator::setProjectFile(QMakeProject *p)
else
target_mode = TARG_UNIX_MODE;
init();
- findLibraries();
- if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE &&
- project->isActiveConfig("link_prl")) //load up prl's'
- processPrlFiles();
+ bool linkPrl = (Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE)
+ && project->isActiveConfig("link_prl");
+ bool mergeLflags = linkPrl
+ && !project->isActiveConfig("no_smart_library_merge")
+ && !project->isActiveConfig("no_lflags_merge");
+ findLibraries(linkPrl, mergeLflags);
}
ProStringList
@@ -944,12 +946,6 @@ MakefileGenerator::filterIncludedFiles(const char *var)
}
}
-void
-MakefileGenerator::processPrlFiles()
-{
- qFatal("MakefileGenerator::processPrlFiles() called!");
-}
-
static QString
qv(const ProString &val)
{
diff --git a/qmake/generators/makefile.h b/qmake/generators/makefile.h
index 07483dbcb0..8aec360147 100644
--- a/qmake/generators/makefile.h
+++ b/qmake/generators/makefile.h
@@ -197,11 +197,10 @@ protected:
QString prlFileName(bool fixify=true);
void writePrlFile();
bool processPrlFile(QString &);
- virtual void processPrlFiles();
virtual void writePrlFile(QTextStream &);
//make sure libraries are found
- virtual bool findLibraries();
+ virtual bool findLibraries(bool linkPrl, bool mergeLflags);
//for retrieving values and lists of values
virtual QString var(const ProKey &var) const;
@@ -276,7 +275,7 @@ inline bool MakefileGenerator::noIO() const
inline QString MakefileGenerator::defaultInstall(const QString &)
{ return QString(""); }
-inline bool MakefileGenerator::findLibraries()
+inline bool MakefileGenerator::findLibraries(bool, bool)
{ return true; }
inline MakefileGenerator::~MakefileGenerator()
diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp
index 25f686646b..288bd6e498 100644
--- a/qmake/generators/unix/unixmake.cpp
+++ b/qmake/generators/unix/unixmake.cpp
@@ -375,12 +375,14 @@ UnixMakefileGenerator::fixLibFlag(const ProString &lib)
}
bool
-UnixMakefileGenerator::findLibraries()
+UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
{
- QList<QMakeLocalFileName> libdirs;
- int libidx = 0;
+ QList<QMakeLocalFileName> libdirs, frameworkdirs;
+ int libidx = 0, fwidx = 0;
foreach (const ProString &dlib, project->values("QMAKE_DEFAULT_LIBDIRS"))
libdirs.append(QMakeLocalFileName(dlib.toQString()));
+ frameworkdirs.append(QMakeLocalFileName("/System/Library/Frameworks"));
+ frameworkdirs.append(QMakeLocalFileName("/Library/Frameworks"));
static const char * const lflags[] = { "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", 0 };
for (int i = 0; lflags[i]; i++) {
ProStringList &l = project->values(lflags[i]);
@@ -398,94 +400,58 @@ UnixMakefileGenerator::findLibraries()
libdirs.insert(libidx++, f);
} else if(opt.startsWith("-l")) {
QString lib = opt.mid(2);
- bool found = false;
ProStringList extens;
extens << project->first("QMAKE_EXTENSION_SHLIB") << "a";
- for (ProStringList::Iterator extit = extens.begin(); extit != extens.end(); ++extit) {
- for (QList<QMakeLocalFileName>::Iterator dep_it = libdirs.begin();
- dep_it != libdirs.end(); ++dep_it) {
- QString pathToLib = ((*dep_it).local() + '/'
- + project->first("QMAKE_PREFIX_SHLIB")
- + lib + '.' + (*extit));
- if (exists(pathToLib)) {
- found = true;
- break;
- }
+ for (QList<QMakeLocalFileName>::Iterator dep_it = libdirs.begin();
+ dep_it != libdirs.end(); ++dep_it) {
+ QString libBase = (*dep_it).local() + '/'
+ + project->first("QMAKE_PREFIX_SHLIB") + lib;
+ if (linkPrl && processPrlFile(libBase))
+ goto found;
+ for (ProStringList::Iterator extit = extens.begin(); extit != extens.end(); ++extit) {
+ if (exists(libBase + '.' + (*extit)))
+ goto found;
}
}
- } else if (target_mode == TARG_MAC_MODE && opt.startsWith("-framework")) {
- if (opt.length() == 10)
- ++it;
- // Skip
- }
- }
- ++it;
- }
- }
- return false;
-}
-
-void
-UnixMakefileGenerator::processPrlFiles()
-{
- QList<QMakeLocalFileName> libdirs, frameworkdirs;
- int libidx = 0, fwidx = 0;
- foreach (const ProString &dlib, project->values("QMAKE_DEFAULT_LIBDIRS"))
- libdirs.append(QMakeLocalFileName(dlib.toQString()));
- frameworkdirs.append(QMakeLocalFileName("/System/Library/Frameworks"));
- frameworkdirs.append(QMakeLocalFileName("/Library/Frameworks"));
- static const char * const lflags[] = { "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", 0 };
- for (int i = 0; lflags[i]; i++) {
- ProStringList &l = project->values(lflags[i]);
- for(int lit = 0; lit < l.size(); ++lit) {
- QString opt = l.at(lit).toQString();
- if(opt.startsWith("-")) {
- if (opt.startsWith("-L")) {
- QMakeLocalFileName l(opt.mid(2));
- if(!libdirs.contains(l))
- libdirs.insert(libidx++, l);
- } else if(opt.startsWith("-l")) {
- QString lib = opt.right(opt.length() - 2);
- for(int dep_i = 0; dep_i < libdirs.size(); ++dep_i) {
- QString prl = libdirs[dep_i].local() + '/'
- + project->first("QMAKE_PREFIX_SHLIB") + lib;
- if (processPrlFile(prl))
- break;
- }
+ found: ;
} else if (target_mode == TARG_MAC_MODE && opt.startsWith("-F")) {
- QMakeLocalFileName f(opt.right(opt.length()-2));
- if(!frameworkdirs.contains(f))
+ QMakeLocalFileName f(opt.mid(2));
+ if (!frameworkdirs.contains(f))
frameworkdirs.insert(fwidx++, f);
} else if (target_mode == TARG_MAC_MODE && opt.startsWith("-framework")) {
- if(opt.length() > 11)
- opt = opt.mid(11).trimmed();
- else
- opt = l.at(++lit).toQString();
- foreach (const QMakeLocalFileName &dir, frameworkdirs) {
- QString prl = dir.local() + "/" + opt + ".framework/" + opt + Option::prl_ext;
- if(processPrlFile(prl))
- break;
+ if (linkPrl) {
+ if (opt.length() == 10)
+ opt = (*++it).toQString();
+ else
+ opt = opt.mid(10).trimmed();
+ foreach (const QMakeLocalFileName &dir, frameworkdirs) {
+ QString prl = dir.local() + "/" + opt + ".framework/" + opt + Option::prl_ext;
+ if (processPrlFile(prl))
+ break;
+ }
+ } else {
+ if (opt.length() == 10)
+ ++it;
+ // Skip
}
}
- } else if(!opt.isNull()) {
+ } else if (linkPrl) {
processPrlFile(opt);
}
ProStringList &prl_libs = project->values("QMAKE_CURRENT_PRL_LIBS");
- if(!prl_libs.isEmpty()) {
- for(int prl = 0; prl < prl_libs.size(); ++prl)
- l.insert(++lit, prl_libs.at(prl));
- prl_libs.clear();
- }
+ for (int prl = 0; prl < prl_libs.size(); ++prl)
+ it = l.insert(++it, prl_libs.at(prl));
+ prl_libs.clear();
+ ++it;
}
- //merge them into a logical order
- if(!project->isActiveConfig("no_smart_library_merge") && !project->isActiveConfig("no_lflags_merge")) {
+ if (mergeLflags) {
QHash<ProKey, ProStringList> lflags;
for(int lit = 0; lit < l.size(); ++lit) {
ProKey arch("default");
ProString opt = l.at(lit);
- if(opt.startsWith("-")) {
+ if (opt.startsWith('-')) {
if (target_mode == TARG_MAC_MODE && opt.startsWith("-Xarch")) {
if (opt.length() > 7) {
arch = opt.mid(7).toKey();
@@ -493,21 +459,20 @@ UnixMakefileGenerator::processPrlFiles()
}
}
- if (opt.startsWith("-L") ||
- (target_mode == TARG_MAC_MODE && opt.startsWith("-F"))) {
- if(!lflags[arch].contains(opt))
+ if (opt.startsWith("-L")
+ || (target_mode == TARG_MAC_MODE && opt.startsWith("-F"))) {
+ if (!lflags[arch].contains(opt))
lflags[arch].append(opt);
- } else if(opt.startsWith("-l") || opt == "-pthread") {
- // Make sure we keep the dependency-order of libraries
- if (lflags[arch].contains(opt))
- lflags[arch].removeAll(opt);
+ } else if (opt.startsWith("-l") || opt == "-pthread") {
+ // Make sure we keep the dependency order of libraries
+ lflags[arch].removeAll(opt);
lflags[arch].append(opt);
} else if (target_mode == TARG_MAC_MODE && opt.startsWith("-framework")) {
- if(opt.length() > 11)
- opt = opt.mid(11);
- else {
+ if (opt.length() > 10) {
+ opt = opt.mid(10).trimmed();
+ } else {
opt = l.at(++lit);
- if (target_mode == TARG_MAC_MODE && opt.startsWith("-Xarch"))
+ if (opt.startsWith("-Xarch"))
opt = l.at(++lit); // The user has done the right thing and prefixed each part
}
bool found = false;
@@ -544,6 +509,7 @@ UnixMakefileGenerator::processPrlFiles()
}
}
}
+ return false;
}
QString
diff --git a/qmake/generators/unix/unixmake.h b/qmake/generators/unix/unixmake.h
index b136ea04d0..db3f59f517 100644
--- a/qmake/generators/unix/unixmake.h
+++ b/qmake/generators/unix/unixmake.h
@@ -54,9 +54,8 @@ protected:
virtual bool doDepends() const { return !Option::mkfile::do_stub_makefile && MakefileGenerator::doDepends(); }
virtual QString defaultInstall(const QString &);
virtual ProString fixLibFlag(const ProString &lib);
- virtual void processPrlFiles();
- virtual bool findLibraries();
+ virtual bool findLibraries(bool linkPrl, bool mergeLflags);
virtual QString escapeFilePath(const QString &path) const;
ProString escapeFilePath(const ProString &path) const { return MakefileGenerator::escapeFilePath(path); }
virtual QStringList &findDependencies(const QString &);
diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp
index 506aff5c6f..f8b19b3785 100644
--- a/qmake/generators/win32/mingw_make.cpp
+++ b/qmake/generators/win32/mingw_make.cpp
@@ -33,7 +33,6 @@
#include "mingw_make.h"
#include "option.h"
-#include "meta.h"
#include <proitems.h>
@@ -68,7 +67,7 @@ ProString MingwMakefileGenerator::fixLibFlag(const ProString &lib)
return escapeFilePath(lib);
}
-bool MingwMakefileGenerator::findLibraries()
+bool MingwMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
{
QList<QMakeLocalFileName> dirs;
static const char * const lflags[] = { "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", 0 };
@@ -78,15 +77,16 @@ bool MingwMakefileGenerator::findLibraries()
while (it != l.end()) {
if ((*it).startsWith("-l")) {
QString steam = (*it).mid(2).toQString();
- ProString out;
+ QString out;
for (QList<QMakeLocalFileName>::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
QString extension;
int ver = findHighestVersion((*dir_it).local(), steam);
if (ver > 0)
extension += QString::number(ver);
- if (QMakeMetaInfo::libExists((*dir_it).local() + '/' + steam)
- || exists((*dir_it).local() + '/' + steam + extension + ".a")
- || exists((*dir_it).local() + '/' + steam + extension + ".dll.a")) {
+ QString libBase = (*dir_it).local() + '/' + steam;
+ if ((linkPrl && processPrlFile(libBase))
+ || exists(libBase + extension + ".a")
+ || exists(libBase + extension + ".dll.a")) {
out = *it + extension;
break;
}
@@ -97,10 +97,38 @@ bool MingwMakefileGenerator::findLibraries()
QMakeLocalFileName f((*it).mid(2).toQString());
dirs.append(f);
*it = "-L" + f.real();
+ } else if (linkPrl && !(*it).startsWith('-')) {
+ QString prl = (*it).toQString();
+ if (!processPrlFile(prl) && QDir::isRelativePath(prl)) {
+ for (QList<QMakeLocalFileName>::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
+ prl = (*dir_it).local() + '/' + *it;
+ if (processPrlFile(prl))
+ break;
+ }
+ }
}
+ ProStringList &prl_libs = project->values("QMAKE_CURRENT_PRL_LIBS");
+ for (int prl = 0; prl < prl_libs.size(); ++prl)
+ it = l.insert(++it, prl_libs.at(prl));
+ prl_libs.clear();
++it;
}
+ if (mergeLflags) {
+ ProStringList lopts;
+ for (int lit = 0; lit < l.size(); ++lit) {
+ ProString opt = l.at(lit);
+ if (opt.startsWith("-L")) {
+ if (!lopts.contains(opt))
+ lopts.append(opt);
+ } else {
+ // Make sure we keep the dependency order of libraries
+ lopts.removeAll(opt);
+ lopts.append(opt);
+ }
+ }
+ l = lopts;
+ }
}
return true;
}
diff --git a/qmake/generators/win32/mingw_make.h b/qmake/generators/win32/mingw_make.h
index 73018319bc..9a30bc8ea6 100644
--- a/qmake/generators/win32/mingw_make.h
+++ b/qmake/generators/win32/mingw_make.h
@@ -62,7 +62,7 @@ private:
QString preCompHeaderOut;
- virtual bool findLibraries();
+ virtual bool findLibraries(bool linkPrl, bool mergeLflags);
QString objectsLinkLine;
};
diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
index 3d511ea7e8..e5eee2ed90 100644
--- a/qmake/generators/win32/winmakefile.cpp
+++ b/qmake/generators/win32/winmakefile.cpp
@@ -87,7 +87,7 @@ ProString Win32MakefileGenerator::fixLibFlag(const ProString &lib)
}
bool
-Win32MakefileGenerator::findLibraries()
+Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
{
QList<QMakeLocalFileName> dirs;
static const char * const lflags[] = { "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", 0 };
@@ -123,8 +123,9 @@ Win32MakefileGenerator::findLibraries()
if(ver > 0)
extension += QString::number(ver);
extension += ".lib";
- if (QMakeMetaInfo::libExists((*it).local() + '/' + lib)
- || exists((*it).local() + '/' + lib + extension)) {
+ QString libBase = (*it).local() + '/' + lib;
+ if ((linkPrl && processPrlFile(libBase))
+ || exists(libBase + extension)) {
out = (*it).real() + Option::dir_sep + lib + extension;
break;
}
@@ -133,67 +134,39 @@ Win32MakefileGenerator::findLibraries()
if(out.isEmpty())
out = lib + ".lib";
(*it) = out;
+ } else if (linkPrl && !processPrlFile(opt) && QDir::isRelativePath(opt)) {
+ for (QList<QMakeLocalFileName>::Iterator it = dirs.begin(); it != dirs.end(); ++it) {
+ QString prl = (*it).local() + '/' + opt;
+ if (processPrlFile(prl))
+ break;
+ }
}
+
+ ProStringList &prl_libs = project->values("QMAKE_CURRENT_PRL_LIBS");
+ for (int prl = 0; prl < prl_libs.size(); ++prl)
+ it = l.insert(++it, prl_libs.at(prl));
+ prl_libs.clear();
++it;
}
- }
- return true;
-}
-
-void
-Win32MakefileGenerator::processPrlFiles()
-{
- const QString libArg = project->first("QMAKE_L_FLAG").toQString();
- QList<QMakeLocalFileName> libdirs;
- static const char * const lflags[] = { "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", 0 };
- for (int i = 0; lflags[i]; i++) {
- ProStringList &l = project->values(lflags[i]);
+ if (mergeLflags) {
+ ProStringList lopts;
for (int lit = 0; lit < l.size(); ++lit) {
- QString opt = l.at(lit).toQString();
- if (opt.startsWith(libArg)) {
- QMakeLocalFileName l(opt.mid(libArg.length()));
- if (!libdirs.contains(l))
- libdirs.append(l);
+ ProString opt = l.at(lit);
+ if (opt.startsWith("/LIBPATH:")) {
+ if (!lopts.contains(opt))
+ lopts.append(opt);
} else {
- if (!processPrlFile(opt) && (QDir::isRelativePath(opt) || opt.startsWith("-l"))) {
- QString tmp;
- if (opt.startsWith("-l"))
- tmp = opt.mid(2);
- else
- tmp = opt;
- for(QList<QMakeLocalFileName>::Iterator it = libdirs.begin(); it != libdirs.end(); ++it) {
- QString prl = (*it).local() + '/' + tmp;
- if (processPrlFile(prl))
- break;
- }
- }
- }
- ProStringList &prl_libs = project->values("QMAKE_CURRENT_PRL_LIBS");
- for (int prl = 0; prl < prl_libs.size(); ++prl)
- l.insert(++lit, prl_libs.at(prl));
- prl_libs.clear();
- }
-
- // Merge them into a logical order
- if (!project->isActiveConfig("no_smart_library_merge") && !project->isActiveConfig("no_lflags_merge")) {
- ProStringList lflags;
- for (int lit = 0; lit < l.size(); ++lit) {
- ProString opt = l.at(lit);
- if (opt.startsWith(libArg)) {
- if (!lflags.contains(opt))
- lflags.append(opt);
- } else {
- // Make sure we keep the dependency-order of libraries
- lflags.removeAll(opt);
- lflags.append(opt);
- }
+ // Make sure we keep the dependency order of libraries
+ lopts.removeAll(opt);
+ lopts.append(opt);
}
- l = lflags;
}
+ l = lopts;
}
+ }
+ return true;
}
-
void Win32MakefileGenerator::processVars()
{
project->values("QMAKE_ORIG_TARGET") = project->values("TARGET");
diff --git a/qmake/generators/win32/winmakefile.h b/qmake/generators/win32/winmakefile.h
index 25b555ec86..7698f13285 100644
--- a/qmake/generators/win32/winmakefile.h
+++ b/qmake/generators/win32/winmakefile.h
@@ -58,11 +58,10 @@ protected:
virtual void writeRcFilePart(QTextStream &t);
int findHighestVersion(const QString &dir, const QString &stem);
- virtual bool findLibraries();
+ virtual bool findLibraries(bool linkPrl, bool mergeLflags);
virtual ProString fixLibFlag(const ProString &lib);
- virtual void processPrlFiles();
void processVars();
void fixTargetExt();
void processRcFileVar();