Browse Source

Reflect the fact that we are using ldd rather than otool

master
probonopd 8 years ago
parent
commit
7fedb50c74
  1. 34
      shared/shared.cpp
  2. 8
      shared/shared.h

34
shared/shared.cpp

@ -144,19 +144,19 @@ bool linkFilePrintStatus(const QString &file, const QString &link)
} }
} }
OtoolInfo findDependencyInfo(const QString &binaryPath) LddInfo findDependencyInfo(const QString &binaryPath)
{ {
OtoolInfo info; LddInfo info;
info.binaryPath = binaryPath; info.binaryPath = binaryPath;
LogDebug() << "Using ldd:"; LogDebug() << "Using ldd:";
LogDebug() << " inspecting" << binaryPath; LogDebug() << " inspecting" << binaryPath;
QProcess otool; QProcess ldd;
otool.start("ldd", QStringList() << binaryPath); ldd.start("ldd", QStringList() << binaryPath);
otool.waitForFinished(); ldd.waitForFinished();
if (otool.exitStatus() != QProcess::NormalExit || otool.exitCode() != 0) { if (ldd.exitStatus() != QProcess::NormalExit || ldd.exitCode() != 0) {
LogError() << "findDependencyInfo:" << otool.readAllStandardError(); LogError() << "findDependencyInfo:" << ldd.readAllStandardError();
return info; return info;
} }
@ -170,7 +170,7 @@ OtoolInfo findDependencyInfo(const QString &binaryPath)
*/ */
QString output = otool.readAllStandardOutput(); QString output = ldd.readAllStandardOutput();
QStringList outputLines = output.split("\n", QString::SkipEmptyParts); QStringList outputLines = output.split("\n", QString::SkipEmptyParts);
if (outputLines.size() < 2) { if (outputLines.size() < 2) {
if (output.contains("statically linked") == false){ if (output.contains("statically linked") == false){
@ -209,7 +209,7 @@ OtoolInfo findDependencyInfo(const QString &binaryPath)
return info; return info;
} }
LibraryInfo parseOtoolLibraryLine(const QString &line, const QString &appBundlePath, const QSet<QString> &rpaths, bool useDebugLibs) LibraryInfo parseLddLibraryLine(const QString &line, const QString &appBundlePath, const QSet<QString> &rpaths, bool useDebugLibs)
{ {
LibraryInfo info; LibraryInfo info;
QString trimmed = line.trimmed(); QString trimmed = line.trimmed();
@ -358,7 +358,7 @@ QList<LibraryInfo> getQtLibraries(const QList<DylibInfo> &dependencies, const QS
{ {
QList<LibraryInfo> libraries; QList<LibraryInfo> libraries;
for (const DylibInfo &dylibInfo : dependencies) { for (const DylibInfo &dylibInfo : dependencies) {
LibraryInfo info = parseOtoolLibraryLine(dylibInfo.binaryPath, appBundlePath, rpaths, useDebugLibs); LibraryInfo info = parseLddLibraryLine(dylibInfo.binaryPath, appBundlePath, rpaths, useDebugLibs);
if (info.libraryName.isEmpty() == false) { if (info.libraryName.isEmpty() == false) {
LogDebug() << "Adding library:"; LogDebug() << "Adding library:";
LogDebug() << info; LogDebug() << info;
@ -373,19 +373,19 @@ QSet<QString> getBinaryRPaths(const QString &path, bool resolve = true, QString
{ {
QSet<QString> rpaths; QSet<QString> rpaths;
QProcess otool; QProcess ldd;
otool.start("objdump", QStringList() << "-x" << path); ldd.start("objdump", QStringList() << "-x" << path);
otool.waitForFinished(); ldd.waitForFinished();
if (otool.exitCode() != 0) { if (ldd.exitCode() != 0) {
LogError() << "getBinaryRPaths:" << otool.readAllStandardError(); LogError() << "getBinaryRPaths:" << ldd.readAllStandardError();
} }
if (resolve && executablePath.isEmpty()) { if (resolve && executablePath.isEmpty()) {
executablePath = path; executablePath = path;
} }
QString output = otool.readAllStandardOutput(); QString output = ldd.readAllStandardOutput();
QStringList outputLines = output.split("\n"); QStringList outputLines = output.split("\n");
QStringListIterator i(outputLines); QStringListIterator i(outputLines);
@ -407,7 +407,7 @@ QSet<QString> getBinaryRPaths(const QString &path, bool resolve = true, QString
QList<LibraryInfo> getQtLibraries(const QString &path, const QString &appBundlePath, const QSet<QString> &rpaths, bool useDebugLibs) QList<LibraryInfo> getQtLibraries(const QString &path, const QString &appBundlePath, const QSet<QString> &rpaths, bool useDebugLibs)
{ {
const OtoolInfo info = findDependencyInfo(path); const LddInfo info = findDependencyInfo(path);
return getQtLibraries(info.dependencies, appBundlePath, rpaths + getBinaryRPaths(path), useDebugLibs); return getQtLibraries(info.dependencies, appBundlePath, rpaths + getBinaryRPaths(path), useDebugLibs);
} }

8
shared/shared.h

@ -70,7 +70,7 @@ public:
QVersionNumber compatibilityVersion; QVersionNumber compatibilityVersion;
}; };
class OtoolInfo class LddInfo
{ {
public: public:
QString installName; QString installName;
@ -107,11 +107,11 @@ inline QDebug operator<<(QDebug debug, const ApplicationBundleInfo &info);
void changeQtLibraries(const QString appPath, const QString &qtPath, bool useDebugLibs); void changeQtLibraries(const QString appPath, const QString &qtPath, bool useDebugLibs);
void changeQtLibraries(const QList<LibraryInfo> libraries, const QStringList &binaryPaths, const QString &qtPath); void changeQtLibraries(const QList<LibraryInfo> libraries, const QStringList &binaryPaths, const QString &qtPath);
OtoolInfo findDependencyInfo(const QString &binaryPath); LddInfo findDependencyInfo(const QString &binaryPath);
LibraryInfo parseOtoolLibraryLine(const QString &line, const QString &appBundlePath, const QSet<QString> &rpaths, bool useDebugLibs); LibraryInfo parseLddLibraryLine(const QString &line, const QString &appBundlePath, const QSet<QString> &rpaths, bool useDebugLibs);
QString findAppBinary(const QString &appBundlePath); QString findAppBinary(const QString &appBundlePath);
QList<LibraryInfo> getQtLibraries(const QString &path, const QString &appBundlePath, const QSet<QString> &rpaths, bool useDebugLibs); QList<LibraryInfo> getQtLibraries(const QString &path, const QString &appBundlePath, const QSet<QString> &rpaths, bool useDebugLibs);
QList<LibraryInfo> getQtLibraries(const QStringList &otoolLines, const QString &appBundlePath, const QSet<QString> &rpaths, bool useDebugLibs); QList<LibraryInfo> getQtLibraries(const QStringList &lddLines, const QString &appBundlePath, const QSet<QString> &rpaths, bool useDebugLibs);
QString copyLibrary(const LibraryInfo &library, const QString path); QString copyLibrary(const LibraryInfo &library, const QString path);
DeploymentInfo deployQtLibraries(const QString &appBundlePath, const QStringList &additionalExecutables, bool useDebugLibs); DeploymentInfo deployQtLibraries(const QString &appBundlePath, const QStringList &additionalExecutables, bool useDebugLibs);
DeploymentInfo deployQtLibraries(QList<LibraryInfo> libraries,const QString &bundlePath, const QStringList &binaryPaths, bool useDebugLibs, bool useLoaderPath); DeploymentInfo deployQtLibraries(QList<LibraryInfo> libraries,const QString &bundlePath, const QStringList &binaryPaths, bool useDebugLibs, bool useLoaderPath);

Loading…
Cancel
Save