Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
shared.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3#include <QCoreApplication>
4#include <QString>
5#include <QStringList>
6#include <QDebug>
7#include <iostream>
8#include <utility>
9#include <QProcess>
10#include <QDir>
11#include <QSet>
12#include <QVariant>
13#include <QVariantMap>
14#include <QStack>
15#include <QDirIterator>
16#include <QLibraryInfo>
17#include <QJsonDocument>
18#include <QJsonObject>
19#include <QJsonArray>
20#include <QJsonValue>
21#include <QRegularExpression>
22#include <QSaveFile>
23#include "shared.h"
24
25#ifdef Q_OS_DARWIN
26#include <CoreFoundation/CoreFoundation.h>
27#endif
28
29bool runStripEnabled = true;
31bool runCodesign = true;
34bool hardenedRuntime = false;
35bool secureTimestamp = false;
36bool appstoreCompliant = false;
37int logLevel = 1;
38bool deployFramework = false;
39
40using std::cout;
41using std::endl;
42using namespace Qt::StringLiterals;
43
44bool operator==(const FrameworkInfo &a, const FrameworkInfo &b)
45{
46 return ((a.frameworkPath == b.frameworkPath) && (a.binaryPath == b.binaryPath));
47}
48
49QDebug operator<<(QDebug debug, const FrameworkInfo &info)
50{
51 debug << "Framework name" << info.frameworkName << "\n";
52 debug << "Framework directory" << info.frameworkDirectory << "\n";
53 debug << "Framework path" << info.frameworkPath << "\n";
54 debug << "Binary directory" << info.binaryDirectory << "\n";
55 debug << "Binary name" << info.binaryName << "\n";
56 debug << "Binary path" << info.binaryPath << "\n";
57 debug << "Version" << info.version << "\n";
58 debug << "Install name" << info.installName << "\n";
59 debug << "Deployed install name" << info.deployedInstallName << "\n";
60 debug << "Source file Path" << info.sourceFilePath << "\n";
61 debug << "Framework Destination Directory (relative to bundle)" << info.frameworkDestinationDirectory << "\n";
62 debug << "Binary Destination Directory (relative to bundle)" << info.binaryDestinationDirectory << "\n";
63
64 return debug;
65}
66
67const QString bundleFrameworkDirectory = "Contents/Frameworks";
68
69inline QDebug operator<<(QDebug debug, const ApplicationBundleInfo &info)
70{
71 debug << "Application bundle path" << info.path << "\n";
72 debug << "Binary path" << info.binaryPath << "\n";
73 debug << "Additional libraries" << info.libraryPaths << "\n";
74 return debug;
75}
76
77bool copyFilePrintStatus(const QString &from, const QString &to)
78{
79 if (QFile::exists(to)) {
81 QFile(to).remove();
82 } else {
83 qDebug() << "File exists, skip copy:" << to;
84 return false;
85 }
86 }
87
88 if (QFile::copy(from, to)) {
89 QFile dest(to);
90 dest.setPermissions(dest.permissions() | QFile::WriteOwner | QFile::WriteUser);
91 LogNormal() << " copied:" << from;
92 LogNormal() << " to" << to;
93
94 // The source file might not have write permissions set. Set the
95 // write permission on the target file to make sure we can use
96 // install_name_tool on it later.
97 QFile toFile(to);
98 if (toFile.permissions() & QFile::WriteOwner)
99 return true;
100
101 if (!toFile.setPermissions(toFile.permissions() | QFile::WriteOwner)) {
102 LogError() << "Failed to set u+w permissions on target file: " << to;
103 return false;
104 }
105
106 return true;
107 } else {
108 LogError() << "file copy failed from" << from;
109 LogError() << " to" << to;
110 return false;
111 }
112}
113
114bool linkFilePrintStatus(const QString &file, const QString &link)
115{
116 if (QFile::exists(link)) {
117 if (QFile(link).symLinkTarget().isEmpty())
118 LogError() << link << "exists but it's a file.";
119 else
120 LogNormal() << "Symlink exists, skipping:" << link;
121 return false;
122 } else if (QFile::link(file, link)) {
123 LogNormal() << " symlink" << link;
124 LogNormal() << " points to" << file;
125 return true;
126 } else {
127 LogError() << "failed to symlink" << link;
128 LogError() << " to" << file;
129 return false;
130 }
131}
132
133void patch_debugInInfoPlist(const QString &infoPlistPath)
134{
135 // Older versions of qmake may have the "_debug" binary as
136 // the value for CFBundleExecutable. Remove it.
137 if (QFile infoPlist(infoPlistPath); infoPlist.open(QIODevice::ReadOnly)) {
138 QByteArray contents = infoPlist.readAll();
139 infoPlist.close();
140 QSaveFile writableInfoPlist(infoPlistPath);
141 bool success = writableInfoPlist.open(QIODevice::WriteOnly | QIODevice::Truncate);
142 if (success) {
143 contents.replace("_debug", ""); // surely there are no legit uses of "_debug" in an Info.plist
144 writableInfoPlist.write(contents);
145 success = writableInfoPlist.commit();
146 }
147 if (!success) {
148 LogError() << "Failed to write Info.plist file" << infoPlistPath;
149 }
150 } else {
151 LogError() << "Failed to read Info.plist file" << infoPlistPath;
152 }
153}
154
155OtoolInfo findDependencyInfo(const QString &binaryPath)
156{
157 OtoolInfo info;
158 info.binaryPath = binaryPath;
159
160 LogDebug() << "Using otool:";
161 LogDebug() << " inspecting" << binaryPath;
162 QProcess otool;
163 otool.start("otool", QStringList() << "-L" << binaryPath);
164 otool.waitForFinished(-1);
165
166 if (otool.exitStatus() != QProcess::NormalExit || otool.exitCode() != 0) {
167 LogError() << otool.readAllStandardError();
168 return info;
169 }
170
171 static const QRegularExpression regexp(QStringLiteral(
172 "^\\t(.+) \\‍(compatibility version (\\d+\\.\\d+\\.\\d+), "
173 "current version (\\d+\\.\\d+\\.\\d+)(, weak|, reexport)?\\‍)$"));
174
175 QString output = otool.readAllStandardOutput();
176 QStringList outputLines = output.split("\n", Qt::SkipEmptyParts);
177 if (outputLines.size() < 2) {
178 LogError() << "Could not parse otool output:" << output;
179 return info;
180 }
181
182 outputLines.removeFirst(); // remove line containing the binary path
183 if (binaryPath.contains(".framework/") || binaryPath.endsWith(".dylib")) {
184 const auto match = regexp.match(outputLines.constFirst());
185 if (match.hasMatch()) {
186 QString installname = match.captured(1);
187 if (QFileInfo(binaryPath).fileName() == QFileInfo(installname).fileName()) {
188 info.installName = installname;
189 info.compatibilityVersion = QVersionNumber::fromString(match.captured(2));
190 info.currentVersion = QVersionNumber::fromString(match.captured(3));
191 outputLines.removeFirst();
192 } else {
193 info.installName = binaryPath;
194 }
195 } else {
196 LogDebug() << "Could not parse otool output line:" << outputLines.constFirst();
197 outputLines.removeFirst();
198 }
199 }
200
201 for (const QString &outputLine : outputLines) {
202 const auto match = regexp.match(outputLine);
203 if (match.hasMatch()) {
204 if (match.captured(1) == info.installName)
205 continue; // Another arch reference to the same binary
206 DylibInfo dylib;
207 dylib.binaryPath = match.captured(1);
208 dylib.compatibilityVersion = QVersionNumber::fromString(match.captured(2));
209 dylib.currentVersion = QVersionNumber::fromString(match.captured(3));
210 info.dependencies << dylib;
211 } else {
212 LogDebug() << "Could not parse otool output line:" << outputLine;
213 }
214 }
215
216 return info;
217}
218
219FrameworkInfo parseOtoolLibraryLine(const QString &line, const QString &appBundlePath, const QList<QString> &rpaths, bool useDebugLibs)
220{
221 FrameworkInfo info;
222 QString trimmed = line.trimmed();
223
224 if (trimmed.isEmpty())
225 return info;
226
227 // Don't deploy system libraries.
228 if (trimmed.startsWith("/System/Library/") ||
229 (trimmed.startsWith("/usr/lib/") && trimmed.contains("libQt") == false) // exception for libQtuitools and libQtlucene
230 || trimmed.startsWith("@executable_path") || trimmed.startsWith("@loader_path"))
231 return info;
232
233 // Resolve rpath relative libraries.
234 if (trimmed.startsWith("@rpath/")) {
235 QString rpathRelativePath = trimmed.mid(QStringLiteral("@rpath/").length());
236 bool foundInsideBundle = false;
237 for (const QString &rpath : std::as_const(rpaths)) {
238 QString path = QDir::cleanPath(rpath + "/" + rpathRelativePath);
239 // Skip paths already inside the bundle.
240 if (!appBundlePath.isEmpty()) {
241 if (QDir::isAbsolutePath(appBundlePath)) {
242 if (path.startsWith(QDir::cleanPath(appBundlePath) + "/")) {
243 foundInsideBundle = true;
244 continue;
245 }
246 } else {
247 if (path.startsWith(QDir::cleanPath(QDir::currentPath() + "/" + appBundlePath) + "/")) {
248 foundInsideBundle = true;
249 continue;
250 }
251 }
252 }
253 // Try again with substituted rpath.
254 FrameworkInfo resolvedInfo = parseOtoolLibraryLine(path, appBundlePath, rpaths, useDebugLibs);
255 if (!resolvedInfo.frameworkName.isEmpty() && QFile::exists(resolvedInfo.frameworkPath)) {
256 resolvedInfo.rpathUsed = rpath;
257 resolvedInfo.installName = trimmed;
258 return resolvedInfo;
259 }
260 }
261 if (!rpaths.isEmpty() && !foundInsideBundle) {
262 LogError() << "Cannot resolve rpath" << trimmed;
263 LogError() << " using" << rpaths;
264 }
265 return info;
266 }
267
268 enum State {QtPath, FrameworkName, DylibName, Version, FrameworkBinary, End};
269 State state = QtPath;
270 int part = 0;
271 QString name;
272 QString qtPath;
273 QString suffix = useDebugLibs ? "_debug" : "";
274
275 // Split the line into [Qt-path]/lib/qt[Module].framework/Versions/[Version]/
276 QStringList parts = trimmed.split("/");
277 while (part < parts.count()) {
278 const QString currentPart = parts.at(part).simplified();
279 ++part;
280 if (currentPart == "")
281 continue;
282
283 if (state == QtPath) {
284 // Check for library name part
285 if (part < parts.count() && parts.at(part).contains(".dylib")) {
286 info.frameworkDirectory += "/" + QString(qtPath + currentPart + "/").simplified();
287 state = DylibName;
288 continue;
289 } else if (part < parts.count() && parts.at(part).endsWith(".framework")) {
290 info.frameworkDirectory += "/" + QString(qtPath + "lib/").simplified();
291 state = FrameworkName;
292 continue;
293 } else if (trimmed.startsWith("/") == false) { // If the line does not contain a full path, the app is using a binary Qt package.
294 QStringList partsCopy = parts;
295 partsCopy.removeLast();
296 for (QString &path : librarySearchPath) {
297 if (!path.endsWith("/"))
298 path += '/';
299 QString nameInPath = path + parts.join(u'/');
300 if (QFile::exists(nameInPath)) {
301 info.frameworkDirectory = path + partsCopy.join(u'/');
302 break;
303 }
304 }
305 if (currentPart.contains(".framework")) {
306 if (info.frameworkDirectory.isEmpty())
307 info.frameworkDirectory = "/Library/Frameworks/" + partsCopy.join(u'/');
308 if (!info.frameworkDirectory.endsWith("/"))
309 info.frameworkDirectory += "/";
310 state = FrameworkName;
311 --part;
312 continue;
313 } else if (currentPart.contains(".dylib")) {
314 if (info.frameworkDirectory.isEmpty())
315 info.frameworkDirectory = "/usr/lib/" + partsCopy.join(u'/');
316 if (!info.frameworkDirectory.endsWith("/"))
317 info.frameworkDirectory += "/";
318 state = DylibName;
319 --part;
320 continue;
321 }
322 }
323 qtPath += (currentPart + "/");
324
325 } if (state == FrameworkName) {
326 // remove ".framework"
327 name = currentPart;
328 name.chop(QString(".framework").length());
329 info.isDylib = false;
330 info.frameworkName = currentPart;
331 state = Version;
332 ++part;
333 continue;
334 } if (state == DylibName) {
335 name = currentPart;
336 info.isDylib = true;
337 info.frameworkName = name;
338 info.binaryName = name.contains(suffix) ? name : name.left(name.indexOf('.')) + suffix + name.mid(name.indexOf('.'));
339 info.deployedInstallName = "@executable_path/../Frameworks/" + info.binaryName;
340 info.frameworkPath = info.frameworkDirectory + info.binaryName;
341 info.sourceFilePath = info.frameworkPath;
342 info.frameworkDestinationDirectory = bundleFrameworkDirectory + "/";
343 info.binaryDestinationDirectory = info.frameworkDestinationDirectory;
344 info.binaryDirectory = info.frameworkDirectory;
345 info.binaryPath = info.frameworkPath;
346 state = End;
347 ++part;
348 continue;
349 } else if (state == Version) {
350 info.version = currentPart;
351 info.binaryDirectory = "Versions/" + info.version;
352 info.frameworkPath = info.frameworkDirectory + info.frameworkName;
353 info.frameworkDestinationDirectory = bundleFrameworkDirectory + "/" + info.frameworkName;
354 info.binaryDestinationDirectory = info.frameworkDestinationDirectory + "/" + info.binaryDirectory;
355 state = FrameworkBinary;
356 } else if (state == FrameworkBinary) {
357 info.binaryName = currentPart.contains(suffix) ? currentPart : currentPart + suffix;
358 info.binaryPath = "/" + info.binaryDirectory + "/" + info.binaryName;
359 info.deployedInstallName = "@executable_path/../Frameworks/" + info.frameworkName + info.binaryPath;
360 info.sourceFilePath = info.frameworkPath + info.binaryPath;
361 state = End;
362 } else if (state == End) {
363 break;
364 }
365 }
366
367 if (!info.sourceFilePath.isEmpty() && QFile::exists(info.sourceFilePath)) {
368 info.installName = findDependencyInfo(info.sourceFilePath).installName;
369 if (info.installName.startsWith("@rpath/"))
370 info.deployedInstallName = info.installName;
371 }
372
373 return info;
374}
375
376QString findAppBinary(const QString &appBundlePath)
377{
378 QString binaryPath;
379
380#ifdef Q_OS_DARWIN
381 CFStringRef bundlePath = appBundlePath.toCFString();
382 CFURLRef bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, bundlePath,
383 kCFURLPOSIXPathStyle, true);
384 CFRelease(bundlePath);
385 CFBundleRef bundle = CFBundleCreate(kCFAllocatorDefault, bundleURL);
386 if (bundle) {
387 CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
388 if (executableURL) {
389 CFURLRef absoluteExecutableURL = CFURLCopyAbsoluteURL(executableURL);
390 if (absoluteExecutableURL) {
391 CFStringRef executablePath = CFURLCopyFileSystemPath(absoluteExecutableURL,
392 kCFURLPOSIXPathStyle);
393 if (executablePath) {
394 binaryPath = QString::fromCFString(executablePath);
395 CFRelease(executablePath);
396 }
397 CFRelease(absoluteExecutableURL);
398 }
399 CFRelease(executableURL);
400 }
401 CFRelease(bundle);
402 }
403 CFRelease(bundleURL);
404#endif
405
406 if (QFile::exists(binaryPath))
407 return binaryPath;
408 LogError() << "Could not find bundle binary for" << appBundlePath;
409 return QString();
410}
411
412QStringList findAppFrameworkNames(const QString &appBundlePath)
413{
414 QStringList frameworks;
415
416 // populate the frameworks list with QtFoo.framework etc,
417 // as found in /Contents/Frameworks/
418 QString searchPath = appBundlePath + "/Contents/Frameworks/";
419 QDirIterator iter(searchPath, QStringList() << QString::fromLatin1("*.framework"),
420 QDir::Dirs | QDir::NoSymLinks);
421 while (iter.hasNext()) {
422 iter.next();
423 frameworks << iter.fileInfo().fileName();
424 }
425
426 return frameworks;
427}
428
429QStringList findAppFrameworkPaths(const QString &appBundlePath)
430{
431 QStringList frameworks;
432 QString searchPath = appBundlePath + "/Contents/Frameworks/";
433 QDirIterator iter(searchPath, QStringList() << QString::fromLatin1("*.framework"),
434 QDir::Dirs | QDir::NoSymLinks);
435 while (iter.hasNext()) {
436 iter.next();
437 frameworks << iter.fileInfo().filePath();
438 }
439
440 return frameworks;
441}
442
443QStringList findAppLibraries(const QString &appBundlePath)
444{
445 QStringList result;
446 // dylibs
447 QDirIterator iter(appBundlePath, QStringList() << QString::fromLatin1("*.dylib") << QString::fromLatin1("*.so"),
448 QDir::Files | QDir::NoSymLinks, QDirIterator::Subdirectories);
449 while (iter.hasNext()) {
450 iter.next();
451 result << iter.fileInfo().filePath();
452 }
453 return result;
454}
455
456QStringList findAppBundleFiles(const QString &appBundlePath, bool absolutePath = false)
457{
458 QStringList result;
459
460 QDirIterator iter(appBundlePath, QStringList() << QString::fromLatin1("*"),
461 QDir::Files, QDirIterator::Subdirectories);
462
463 while (iter.hasNext()) {
464 iter.next();
465 if (iter.fileInfo().isSymLink())
466 continue;
467 result << (absolutePath ? iter.fileInfo().absoluteFilePath() : iter.fileInfo().filePath());
468 }
469
470 return result;
471}
472
473QString findEntitlementsFile(const QString& path)
474{
475 QDirIterator iter(path, QStringList() << QString::fromLatin1("*.entitlements"),
476 QDir::Files, QDirIterator::Subdirectories);
477
478 while (iter.hasNext()) {
479 iter.next();
480 if (iter.fileInfo().isSymLink())
481 continue;
482
483 //return the first entitlements file - only one is used for signing anyway
484 return iter.fileInfo().absoluteFilePath();
485 }
486
487 return QString();
488}
489
490QList<FrameworkInfo> getQtFrameworks(const QList<DylibInfo> &dependencies, const QString &appBundlePath, const QList<QString> &rpaths, bool useDebugLibs)
491{
492 QList<FrameworkInfo> libraries;
493 for (const DylibInfo &dylibInfo : dependencies) {
494 FrameworkInfo info = parseOtoolLibraryLine(dylibInfo.binaryPath, appBundlePath, rpaths, useDebugLibs);
495 if (info.frameworkName.isEmpty() == false) {
496 LogDebug() << "Adding framework:";
497 LogDebug() << info;
498 libraries.append(info);
499 }
500 }
501 return libraries;
502}
503
504QString resolveDyldPrefix(const QString &path, const QString &loaderPath, const QString &executablePath)
505{
506 if (path.startsWith("@")) {
507 if (path.startsWith(QStringLiteral("@executable_path/"))) {
508 // path relative to bundle executable dir
509 if (QDir::isAbsolutePath(executablePath)) {
510 return QDir::cleanPath(QFileInfo(executablePath).path() + path.mid(QStringLiteral("@executable_path").length()));
511 } else {
512 return QDir::cleanPath(QDir::currentPath() + "/" +
513 QFileInfo(executablePath).path() + path.mid(QStringLiteral("@executable_path").length()));
514 }
515 } else if (path.startsWith(QStringLiteral("@loader_path"))) {
516 // path relative to loader dir
517 if (QDir::isAbsolutePath(loaderPath)) {
518 return QDir::cleanPath(QFileInfo(loaderPath).path() + path.mid(QStringLiteral("@loader_path").length()));
519 } else {
520 return QDir::cleanPath(QDir::currentPath() + "/" +
521 QFileInfo(loaderPath).path() + path.mid(QStringLiteral("@loader_path").length()));
522 }
523 } else {
524 LogError() << "Unexpected prefix" << path;
525 }
526 }
527 return path;
528}
529
530QList<QString> getBinaryRPaths(const QString &path, bool resolve = true, QString executablePath = QString())
531{
532 QList<QString> rpaths;
533
534 QProcess otool;
535 otool.start("otool", QStringList() << "-l" << path);
536 otool.waitForFinished();
537
538 if (otool.exitCode() != 0) {
539 LogError() << otool.readAllStandardError();
540 }
541
542 if (resolve && executablePath.isEmpty()) {
543 executablePath = path;
544 }
545
546 QString output = otool.readAllStandardOutput();
547 QStringList outputLines = output.split("\n");
548
549 for (auto i = outputLines.cbegin(), end = outputLines.cend(); i != end; ++i) {
550 if (i->contains("cmd LC_RPATH") && ++i != end &&
551 i->contains("cmdsize") && ++i != end) {
552 const QString &rpathCmd = *i;
553 int pathStart = rpathCmd.indexOf("path ");
554 int pathEnd = rpathCmd.indexOf(" (");
555 if (pathStart >= 0 && pathEnd >= 0 && pathStart < pathEnd) {
556 QString rpath = rpathCmd.mid(pathStart + 5, pathEnd - pathStart - 5);
557 if (resolve) {
558 rpaths << resolveDyldPrefix(rpath, path, executablePath);
559 } else {
560 rpaths << rpath;
561 }
562 }
563 }
564 }
565
566 return rpaths;
567}
568
569QList<FrameworkInfo> getQtFrameworks(const QString &path, const QString &appBundlePath, const QList<QString> &rpaths, bool useDebugLibs)
570{
571 const OtoolInfo info = findDependencyInfo(path);
572 QList<QString> allRPaths = rpaths + getBinaryRPaths(path);
573 allRPaths.removeDuplicates();
574 return getQtFrameworks(info.dependencies, appBundlePath, allRPaths, useDebugLibs);
575}
576
577QList<FrameworkInfo> getQtFrameworksForPaths(const QStringList &paths, const QString &appBundlePath, const QList<QString> &rpaths, bool useDebugLibs)
578{
579 QList<FrameworkInfo> result;
580 QSet<QString> existing;
581 for (const QString &path : paths) {
582 for (const FrameworkInfo &info : getQtFrameworks(path, appBundlePath, rpaths, useDebugLibs)) {
583 if (!existing.contains(info.frameworkPath)) { // avoid duplicates
584 existing.insert(info.frameworkPath);
585 result << info;
586 }
587 }
588 }
589 return result;
590}
591
592QStringList getBinaryDependencies(const QString executablePath,
593 const QString &path,
594 const QList<QString> &additionalBinariesContainingRpaths)
595{
596 QStringList binaries;
597
598 const auto dependencies = findDependencyInfo(path).dependencies;
599
600 bool rpathsLoaded = false;
601 QList<QString> rpaths;
602
603 // return bundle-local dependencies. (those starting with @executable_path)
604 for (const DylibInfo &info : dependencies) {
605 QString trimmedLine = info.binaryPath;
606 if (trimmedLine.startsWith("@executable_path/")) {
607 QString binary = QDir::cleanPath(executablePath + trimmedLine.mid(QStringLiteral("@executable_path/").length()));
608 if (binary != path)
609 binaries.append(binary);
610 } else if (trimmedLine.startsWith("@loader_path/")) {
611 QString binary = QDir::cleanPath(QFileInfo(path).path() + "/" + trimmedLine.mid(QStringLiteral("@loader_path/").length()));
612 if (binary != path)
613 binaries.append(binary);
614 } else if (trimmedLine.startsWith("@rpath/")) {
615 if (!rpathsLoaded) {
616 rpaths = getBinaryRPaths(path, true, executablePath);
617 for (const QString &binaryPath : additionalBinariesContainingRpaths)
618 rpaths += getBinaryRPaths(binaryPath, true);
619 rpaths.removeDuplicates();
620 rpathsLoaded = true;
621 }
622 bool resolved = false;
623 for (const QString &rpath : std::as_const(rpaths)) {
624 QString binary = QDir::cleanPath(rpath + "/" + trimmedLine.mid(QStringLiteral("@rpath/").length()));
625 LogDebug() << "Checking for" << binary;
626 if (QFile::exists(binary)) {
627 binaries.append(binary);
628 resolved = true;
629 break;
630 }
631 }
632 if (!resolved && !rpaths.isEmpty()) {
633 LogError() << "Cannot resolve rpath" << trimmedLine;
634 LogError() << " using" << rpaths;
635 }
636 }
637 }
638
639 return binaries;
640}
641
642// copies everything _inside_ sourcePath to destinationPath
643bool recursiveCopy(const QString &sourcePath, const QString &destinationPath,
644 const QRegularExpression &ignoreRegExp = QRegularExpression())
645{
646 const QDir sourceDir(sourcePath);
647 if (!sourceDir.exists())
648 return false;
649 QDir().mkpath(destinationPath);
650
651 LogNormal() << "copy:" << sourcePath << destinationPath;
652
653 const QStringList files = sourceDir.entryList(QStringList() << "*", QDir::Files | QDir::NoDotAndDotDot);
654 const bool hasValidRegExp = ignoreRegExp.isValid() && ignoreRegExp.pattern().length() > 0;
655 for (const QString &file : files) {
656 if (hasValidRegExp && ignoreRegExp.match(file).hasMatch())
657 continue;
658 const QString fileSourcePath = sourcePath + "/" + file;
659 const QString fileDestinationPath = destinationPath + "/" + file;
660 copyFilePrintStatus(fileSourcePath, fileDestinationPath);
661 }
662
663 const QStringList subdirs = sourceDir.entryList(QStringList() << "*", QDir::Dirs | QDir::NoDotAndDotDot);
664 for (const QString &dir : subdirs) {
665 recursiveCopy(sourcePath + "/" + dir, destinationPath + "/" + dir);
666 }
667 return true;
668}
669
670void recursiveCopyAndDeploy(const QString &appBundlePath, const QList<QString> &rpaths, const QString &sourcePath, const QString &destinationPath)
671{
672 QDir().mkpath(destinationPath);
673
674 LogNormal() << "copy:" << sourcePath << destinationPath;
675
676 const QDir sourceDir(sourcePath);
677
678 const QStringList files = sourceDir.entryList(QStringList() << QStringLiteral("*"), QDir::Files | QDir::NoDotAndDotDot);
679 for (const QString &file : files) {
680 if (file.endsWith("_debug.dylib"))
681 continue; // Skip debug versions
682
683 if (file.endsWith(".qrc"))
684 continue;
685
686 const QString fileSourcePath = sourcePath + u'/' + file;
687
688 if (file.endsWith(QStringLiteral(".dylib"))) {
689 // App store code signing rules forbids code binaries in Contents/Resources/,
690 // which poses a problem for deploying mixed .qml/.dylib Qt Quick imports.
691 // Solve this by placing the dylibs in Contents/PlugIns/quick, and then
692 // creting a symlink to there from the Qt Quick import in Contents/Resources/.
693 //
694 // Example:
695 // MyApp.app/Contents/Resources/qml/QtQuick/Controls/libqtquickcontrolsplugin.dylib ->
696 // ../../../../PlugIns/quick/libqtquickcontrolsplugin.dylib
697 //
698
699 // The .dylib destination path:
700 QString fileDestinationDir = appBundlePath + QStringLiteral("/Contents/PlugIns/quick/");
701 QDir().mkpath(fileDestinationDir);
702 QString fileDestinationPath = fileDestinationDir + file;
703
704 // The .dylib symlink destination path:
705 QString linkDestinationPath = destinationPath + u'/' + file;
706
707 // The (relative) link; with a correct number of "../"'s.
708 QString linkPath = QStringLiteral("PlugIns/quick/") + file;
709 int cdupCount = linkDestinationPath.count(QStringLiteral("/")) - appBundlePath.count(QStringLiteral("/"));
710 for (int i = 0; i < cdupCount - 2; ++i)
711 linkPath.prepend("../");
712
713 if (copyFilePrintStatus(fileSourcePath, fileDestinationPath)) {
714 linkFilePrintStatus(linkPath, linkDestinationPath);
715
716 runStrip(fileDestinationPath);
717 bool useDebugLibs = false;
718 bool useLoaderPath = false;
719 QList<FrameworkInfo> frameworks = getQtFrameworks(fileDestinationPath, appBundlePath, rpaths, useDebugLibs);
720 deployQtFrameworks(frameworks, appBundlePath, QStringList(fileDestinationPath), useDebugLibs, useLoaderPath);
721 }
722 } else {
723 QString fileDestinationPath = destinationPath + u'/' + file;
724 copyFilePrintStatus(fileSourcePath, fileDestinationPath);
725 }
726 }
727
728 const QStringList subdirs = sourceDir.entryList(QStringList() << QStringLiteral("*"), QDir::Dirs | QDir::NoDotAndDotDot);
729 for (const QString &dir : subdirs) {
730 if (dir.endsWith(".dSYM"))
731 continue;
732
733 recursiveCopyAndDeploy(appBundlePath, rpaths, sourcePath + u'/' + dir, destinationPath + u'/' + dir);
734 }
735}
736
737QString copyDylib(const FrameworkInfo &framework, const QString path)
738{
739 if (!QFile::exists(framework.sourceFilePath)) {
740 LogError() << "no file at" << framework.sourceFilePath;
741 return QString();
742 }
743
744 // Construct destination paths. The full path typically looks like
745 // MyApp.app/Contents/Frameworks/libfoo.dylib
746 QString dylibDestinationDirectory = path + u'/' + framework.frameworkDestinationDirectory;
747 QString dylibDestinationBinaryPath = dylibDestinationDirectory + u'/' + framework.binaryName;
748
749 // Create destination directory
750 if (!QDir().mkpath(dylibDestinationDirectory)) {
751 LogError() << "could not create destination directory" << dylibDestinationDirectory;
752 return QString();
753 }
754
755 // Return if the dylib has already been deployed
756 if (QFileInfo::exists(dylibDestinationBinaryPath) && !alwaysOwerwriteEnabled)
757 return dylibDestinationBinaryPath;
758
759 // Copy dylib binary
760 copyFilePrintStatus(framework.sourceFilePath, dylibDestinationBinaryPath);
761 return dylibDestinationBinaryPath;
762}
763
764QString copyFramework(const FrameworkInfo &framework, const QString path)
765{
766 if (!QFile::exists(framework.sourceFilePath)) {
767 LogError() << "no file at" << framework.sourceFilePath;
768 return QString();
769 }
770
771 // Construct destination paths. The full path typically looks like
772 // MyApp.app/Contents/Frameworks/Foo.framework/Versions/5/QtFoo
773 QString frameworkDestinationDirectory = path + u'/' + framework.frameworkDestinationDirectory;
774 QString frameworkBinaryDestinationDirectory = frameworkDestinationDirectory + u'/' + framework.binaryDirectory;
775 QString frameworkDestinationBinaryPath = frameworkBinaryDestinationDirectory + u'/' + framework.binaryName;
776
777 // Return if the framework has aleardy been deployed
778 if (QDir(frameworkDestinationDirectory).exists() && !alwaysOwerwriteEnabled)
779 return QString();
780
781 // Create destination directory
782 if (!QDir().mkpath(frameworkBinaryDestinationDirectory)) {
783 LogError() << "could not create destination directory" << frameworkBinaryDestinationDirectory;
784 return QString();
785 }
786
787 // Now copy the framework. Some parts should be left out (headers/, .prl files).
788 // Some parts should be included (Resources/, symlink structure). We want this
789 // function to make as few assumptions about the framework as possible while at
790 // the same time producing a codesign-compatible framework.
791
792 // Copy framework binary
793 copyFilePrintStatus(framework.sourceFilePath, frameworkDestinationBinaryPath);
794
795 // Copy Resources/, Libraries/ and Helpers/
796 const QString resourcesSourcePath = framework.frameworkPath + "/Resources";
797 const QString resourcesDestinationPath = frameworkDestinationDirectory + "/Versions/" + framework.version + "/Resources";
798 // Ignore *.prl files that are in the Resources directory
799 recursiveCopy(resourcesSourcePath, resourcesDestinationPath,
800 QRegularExpression("\\A(?:[^/]*\\.prl)\\z"));
801 const QString librariesSourcePath = framework.frameworkPath + "/Libraries";
802 const QString librariesDestinationPath = frameworkDestinationDirectory + "/Versions/" + framework.version + "/Libraries";
803 bool createdLibraries = recursiveCopy(librariesSourcePath, librariesDestinationPath);
804 const QString helpersSourcePath = framework.frameworkPath + "/Helpers";
805 const QString helpersDestinationPath = frameworkDestinationDirectory + "/Versions/" + framework.version + "/Helpers";
806 bool createdHelpers = recursiveCopy(helpersSourcePath, helpersDestinationPath);
807
808 // Create symlink structure. Links at the framework root point to Versions/Current/
809 // which again points to the actual version:
810 // QtFoo.framework/QtFoo -> Versions/Current/QtFoo
811 // QtFoo.framework/Resources -> Versions/Current/Resources
812 // QtFoo.framework/Versions/Current -> 5
813 linkFilePrintStatus("Versions/Current/" + framework.binaryName, frameworkDestinationDirectory + "/" + framework.binaryName);
814 linkFilePrintStatus("Versions/Current/Resources", frameworkDestinationDirectory + "/Resources");
815 if (createdLibraries)
816 linkFilePrintStatus("Versions/Current/Libraries", frameworkDestinationDirectory + "/Libraries");
817 if (createdHelpers)
818 linkFilePrintStatus("Versions/Current/Helpers", frameworkDestinationDirectory + "/Helpers");
819 linkFilePrintStatus(framework.version, frameworkDestinationDirectory + "/Versions/Current");
820
821 // Correct Info.plist location for frameworks produced by older versions of qmake
822 // Contents/Info.plist should be Versions/5/Resources/Info.plist
823 const QString legacyInfoPlistPath = framework.frameworkPath + "/Contents/Info.plist";
824 const QString correctInfoPlistPath = frameworkDestinationDirectory + "/Resources/Info.plist";
825 if (QFile::exists(legacyInfoPlistPath)) {
826 copyFilePrintStatus(legacyInfoPlistPath, correctInfoPlistPath);
827 patch_debugInInfoPlist(correctInfoPlistPath);
828 }
829 return frameworkDestinationBinaryPath;
830}
831
832void runInstallNameTool(QStringList options)
833{
834 QProcess installNametool;
835 installNametool.start("install_name_tool", options);
836 installNametool.waitForFinished();
837 if (installNametool.exitCode() != 0) {
838 LogError() << installNametool.readAllStandardError();
839 LogError() << installNametool.readAllStandardOutput();
840 }
841}
842
843void changeIdentification(const QString &id, const QString &binaryPath)
844{
845 LogDebug() << "Using install_name_tool:";
846 LogDebug() << " change identification in" << binaryPath;
847 LogDebug() << " to" << id;
848 runInstallNameTool(QStringList() << "-id" << id << binaryPath);
849}
850
851void changeInstallName(const QString &bundlePath, const FrameworkInfo &framework, const QStringList &binaryPaths, bool useLoaderPath)
852{
853 const QString absBundlePath = QFileInfo(bundlePath).absoluteFilePath();
854 for (const QString &binary : binaryPaths) {
855 QString deployedInstallName;
856 if (useLoaderPath) {
857 deployedInstallName = "@loader_path/"_L1
858 + QFileInfo(binary).absoluteDir().relativeFilePath(absBundlePath + u'/' + framework.binaryDestinationDirectory + u'/' + framework.binaryName);
859 } else {
860 deployedInstallName = framework.deployedInstallName;
861 }
862 changeInstallName(framework.installName, deployedInstallName, binary);
863 // Workaround for the case when the library ID name is a symlink, while the dependencies
864 // specified using the canonical path to the library (QTBUG-56814)
865 QFileInfo fileInfo= QFileInfo(framework.installName);
866 QString canonicalInstallName = fileInfo.canonicalFilePath();
867 if (!canonicalInstallName.isEmpty() && canonicalInstallName != framework.installName) {
868 changeInstallName(canonicalInstallName, deployedInstallName, binary);
869 // some libraries' inner dependencies (such as ffmpeg, nettle) use symbol link (QTBUG-100093)
870 QString innerDependency = fileInfo.canonicalPath() + "/" + fileInfo.fileName();
871 if (innerDependency != canonicalInstallName && innerDependency != framework.installName) {
872 changeInstallName(innerDependency, deployedInstallName, binary);
873 }
874 }
875 }
876}
877
878void addRPath(const QString &rpath, const QString &binaryPath)
879{
880 runInstallNameTool(QStringList() << "-add_rpath" << rpath << binaryPath);
881}
882
883void deployRPaths(const QString &bundlePath, const QList<QString> &rpaths, const QString &binaryPath, bool useLoaderPath)
884{
885 const QString absFrameworksPath = QFileInfo(bundlePath).absoluteFilePath()
886 + "/Contents/Frameworks"_L1;
887 const QString relativeFrameworkPath = QFileInfo(binaryPath).absoluteDir().relativeFilePath(absFrameworksPath);
888 const QString loaderPathToFrameworks = "@loader_path/"_L1 + relativeFrameworkPath;
889 bool rpathToFrameworksFound = false;
890 QStringList args;
891 QList<QString> binaryRPaths = getBinaryRPaths(binaryPath, false);
892 for (const QString &rpath : std::as_const(binaryRPaths)) {
893 if (rpath == "@executable_path/../Frameworks" ||
894 rpath == loaderPathToFrameworks) {
895 rpathToFrameworksFound = true;
896 continue;
897 }
898 if (rpaths.contains(resolveDyldPrefix(rpath, binaryPath, binaryPath))) {
899 if (!args.contains(rpath))
900 args << "-delete_rpath" << rpath;
901 }
902 }
903 if (!args.length()) {
904 return;
905 }
906 if (!rpathToFrameworksFound) {
907 if (!useLoaderPath) {
908 args << "-add_rpath" << "@executable_path/../Frameworks";
909 } else {
910 args << "-add_rpath" << loaderPathToFrameworks;
911 }
912 }
913 LogDebug() << "Using install_name_tool:";
914 LogDebug() << " change rpaths in" << binaryPath;
915 LogDebug() << " using" << args;
916 runInstallNameTool(QStringList() << args << binaryPath);
917}
918
919void deployRPaths(const QString &bundlePath, const QList<QString> &rpaths, const QStringList &binaryPaths, bool useLoaderPath)
920{
921 for (const QString &binary : binaryPaths) {
922 deployRPaths(bundlePath, rpaths, binary, useLoaderPath);
923 }
924}
925
926void changeInstallName(const QString &oldName, const QString &newName, const QString &binaryPath)
927{
928 LogDebug() << "Using install_name_tool:";
929 LogDebug() << " in" << binaryPath;
930 LogDebug() << " change reference" << oldName;
931 LogDebug() << " to" << newName;
932 runInstallNameTool(QStringList() << "-change" << oldName << newName << binaryPath);
933}
934
935void runStrip(const QString &binaryPath)
936{
937 if (runStripEnabled == false)
938 return;
939
940 LogDebug() << "Using strip:";
941 LogDebug() << " stripped" << binaryPath;
942 QProcess strip;
943 strip.start("strip", QStringList() << "-x" << binaryPath);
944 strip.waitForFinished();
945 if (strip.exitCode() != 0) {
946 LogError() << strip.readAllStandardError();
947 LogError() << strip.readAllStandardOutput();
948 }
949}
950
951void stripAppBinary(const QString &bundlePath)
952{
953 runStrip(findAppBinary(bundlePath));
954}
955
956bool DeploymentInfo::containsModule(const QString &module, const QString &libInFix) const
957{
958 // Check for framework first
959 if (deployedFrameworks.contains("Qt"_L1 + module + libInFix + ".framework"_L1))
960 return true;
961 // Check for dylib
962 const QRegularExpression dylibRegExp("libQt[0-9]+"_L1
963 + module + libInFix
964 + (isDebug ? "_debug" : "")
965 + ".[0-9]+.dylib"_L1);
966 return deployedFrameworks.filter(dylibRegExp).size() > 0;
967}
968
969/*
970 Deploys the listed frameworks into an app bundle.
971 The frameworks are searched for dependencies, which are also deployed.
972 (deploying Qt3Support will also deploy QtNetwork and QtSql for example.)
973 Returns a DeploymentInfo structure containing the Qt path used and a
974 a list of actually deployed frameworks.
975*/
976DeploymentInfo deployQtFrameworks(QList<FrameworkInfo> frameworks,
977 const QString &bundlePath, const QStringList &binaryPaths, bool useDebugLibs,
978 bool useLoaderPath)
979{
980 LogNormal();
981 LogNormal() << "Deploying Qt frameworks found inside:" << binaryPaths;
982 QStringList copiedFrameworks;
983 DeploymentInfo deploymentInfo;
984 deploymentInfo.useLoaderPath = useLoaderPath;
985 deploymentInfo.isFramework = bundlePath.contains(".framework");
986 deploymentInfo.isDebug = false;
987 QList<QString> rpathsUsed;
988
989 while (frameworks.isEmpty() == false) {
990 const FrameworkInfo framework = frameworks.takeFirst();
991 copiedFrameworks.append(framework.frameworkName);
992
993 // If a single dependency has the _debug suffix, we treat that as
994 // the whole deployment being a debug deployment, including deploying
995 // the debug version of plugins.
996 if (framework.isDebugLibrary())
997 deploymentInfo.isDebug = true;
998
999 if (deploymentInfo.qtPath.isNull())
1000 deploymentInfo.qtPath = QLibraryInfo::path(QLibraryInfo::PrefixPath);
1001
1002 if (framework.frameworkDirectory.startsWith(bundlePath)) {
1003 LogError() << framework.frameworkName << "already deployed, skipping.";
1004 continue;
1005 }
1006
1007 if (!framework.rpathUsed.isEmpty() && !rpathsUsed.contains(framework.rpathUsed)) {
1008 rpathsUsed.append(framework.rpathUsed);
1009 }
1010
1011 // Copy the framework/dylib to the app bundle.
1012 const QString deployedBinaryPath = framework.isDylib ? copyDylib(framework, bundlePath)
1013 : copyFramework(framework, bundlePath);
1014
1015 // Install_name_tool the new id into the binaries
1016 changeInstallName(bundlePath, framework, binaryPaths, useLoaderPath);
1017
1018 // Skip the rest if already was deployed.
1019 if (deployedBinaryPath.isNull())
1020 continue;
1021
1022 runStrip(deployedBinaryPath);
1023
1024 // Install_name_tool it a new id.
1025 if (!framework.rpathUsed.length()) {
1026 changeIdentification(framework.deployedInstallName, deployedBinaryPath);
1027 }
1028
1029 // Check for framework dependencies
1030 QList<FrameworkInfo> dependencies = getQtFrameworks(deployedBinaryPath, bundlePath, rpathsUsed, useDebugLibs);
1031
1032 for (const FrameworkInfo &dependency : dependencies) {
1033 if (dependency.rpathUsed.isEmpty()) {
1034 changeInstallName(bundlePath, dependency, QStringList() << deployedBinaryPath, useLoaderPath);
1035 } else {
1036 rpathsUsed.append(dependency.rpathUsed);
1037 }
1038
1039 // Deploy framework if necessary.
1040 if (copiedFrameworks.contains(dependency.frameworkName) == false && frameworks.contains(dependency) == false) {
1041 frameworks.append(dependency);
1042 }
1043 }
1044 }
1045 deploymentInfo.deployedFrameworks = copiedFrameworks;
1046 deployRPaths(bundlePath, rpathsUsed, binaryPaths, useLoaderPath);
1047 deploymentInfo.rpathsUsed += rpathsUsed;
1048 deploymentInfo.rpathsUsed.removeDuplicates();
1049 return deploymentInfo;
1050}
1051
1052DeploymentInfo deployQtFrameworks(const QString &appBundlePath, const QStringList &additionalExecutables, bool useDebugLibs)
1053{
1054 ApplicationBundleInfo applicationBundle;
1055 applicationBundle.path = appBundlePath;
1056 applicationBundle.binaryPath = findAppBinary(appBundlePath);
1057 applicationBundle.libraryPaths = findAppLibraries(appBundlePath);
1058 QStringList allBinaryPaths = QStringList() << applicationBundle.binaryPath << applicationBundle.libraryPaths
1059 << additionalExecutables;
1060
1061 QList<QString> allLibraryPaths = getBinaryRPaths(applicationBundle.binaryPath, true);
1062 allLibraryPaths.append(QLibraryInfo::path(QLibraryInfo::LibrariesPath));
1063 allLibraryPaths.removeDuplicates();
1064
1065 QList<FrameworkInfo> frameworks = getQtFrameworksForPaths(allBinaryPaths, appBundlePath, allLibraryPaths, useDebugLibs);
1066 if (frameworks.isEmpty() && !alwaysOwerwriteEnabled) {
1067 LogWarning();
1068 LogWarning() << "Could not find any external Qt frameworks to deploy in" << appBundlePath;
1069 LogWarning() << "Perhaps macdeployqt was already used on" << appBundlePath << "?";
1070 LogWarning() << "If so, you will need to rebuild" << appBundlePath << "before trying again.";
1071 return DeploymentInfo();
1072 } else {
1073 return deployQtFrameworks(frameworks, applicationBundle.path, allBinaryPaths, useDebugLibs, !additionalExecutables.isEmpty());
1074 }
1075}
1076
1077QString getLibInfix(const QStringList &deployedFrameworks)
1078{
1079 QString libInfix;
1080 for (const QString &framework : deployedFrameworks) {
1081 if (framework.startsWith(QStringLiteral("QtCore")) && framework.endsWith(QStringLiteral(".framework")) &&
1082 !framework.contains(QStringLiteral("5Compat"))) {
1083 Q_ASSERT(framework.length() >= 16);
1084 // 16 == "QtCore" + ".framework"
1085 const int lengthOfLibInfix = framework.length() - 16;
1086 if (lengthOfLibInfix)
1087 libInfix = framework.mid(6, lengthOfLibInfix);
1088 break;
1089 }
1090 }
1091 return libInfix;
1092}
1093
1094void deployPlugins(const ApplicationBundleInfo &appBundleInfo, const QString &pluginSourcePath,
1095 const QString pluginDestinationPath, DeploymentInfo deploymentInfo, bool useDebugLibs)
1096{
1097 LogNormal() << "Deploying plugins from" << pluginSourcePath;
1098
1099 if (!pluginSourcePath.contains(deploymentInfo.pluginPath))
1100 return;
1101
1102 // Plugin white list:
1103 QStringList pluginList;
1104
1105 const auto addPlugins = [&pluginSourcePath,&pluginList,useDebugLibs](const QString &subDirectory,
1106 const std::function<bool(QString)> &predicate = std::function<bool(QString)>()) {
1107 const QStringList libs = QDir(pluginSourcePath + u'/' + subDirectory)
1108 .entryList({QStringLiteral("*.dylib")});
1109 for (const QString &lib : libs) {
1110 if (lib.endsWith(QStringLiteral("_debug.dylib")) != useDebugLibs)
1111 continue;
1112 if (!predicate || predicate(lib))
1113 pluginList.append(subDirectory + u'/' + lib);
1114 }
1115 };
1116
1117 // Platform plugin:
1118 addPlugins(QStringLiteral("platforms"), [](const QString &lib) {
1119 // Ignore minimal and offscreen platform plugins
1120 if (!lib.contains(QStringLiteral("cocoa")))
1121 return false;
1122 return true;
1123 });
1124
1125 // Cocoa print support
1126 addPlugins(QStringLiteral("printsupport"));
1127
1128 // Styles
1129 addPlugins(QStringLiteral("styles"));
1130
1131 // Check if Qt was configured with -libinfix
1132 const QString libInfix = getLibInfix(deploymentInfo.deployedFrameworks);
1133
1134 // Network
1135 if (deploymentInfo.containsModule("Network", libInfix)) {
1136 addPlugins(QStringLiteral("tls"));
1137 addPlugins(QStringLiteral("networkinformation"));
1138 }
1139
1140 // All image formats (svg if QtSvg is used)
1141 const bool usesSvg = deploymentInfo.containsModule("Svg", libInfix);
1142 addPlugins(QStringLiteral("imageformats"), [usesSvg](const QString &lib) {
1143 if (lib.contains(QStringLiteral("qsvg")) && !usesSvg)
1144 return false;
1145 return true;
1146 });
1147
1148 addPlugins(QStringLiteral("iconengines"));
1149
1150 // Platforminputcontext plugins if QtGui is in use
1151 if (deploymentInfo.containsModule("Gui", libInfix)) {
1152 addPlugins(QStringLiteral("platforminputcontexts"), [&addPlugins](const QString &lib) {
1153 // Deploy the virtual keyboard plugins if we have deployed virtualkeyboard
1154 if (lib.startsWith(QStringLiteral("libqtvirtualkeyboard")))
1155 addPlugins(QStringLiteral("virtualkeyboard"));
1156 return true;
1157 });
1158 }
1159
1160 // Sql plugins if QtSql is in use
1161 if (deploymentInfo.containsModule("Sql", libInfix)) {
1162 addPlugins(QStringLiteral("sqldrivers"), [](const QString &lib) {
1163 if (lib.startsWith(QStringLiteral("libqsqlodbc")) || lib.startsWith(QStringLiteral("libqsqlpsql"))) {
1164 LogWarning() << "Plugin" << lib << "uses private API and is not Mac App store compliant.";
1165 if (appstoreCompliant) {
1166 LogWarning() << "Skip plugin" << lib;
1167 return false;
1168 }
1169 }
1170 return true;
1171 });
1172 }
1173
1174 // WebView plugins if QtWebView is in use
1175 if (deploymentInfo.containsModule("WebView", libInfix)) {
1176 addPlugins(QStringLiteral("webview"), [](const QString &lib) {
1177 if (lib.startsWith(QStringLiteral("libqtwebview_webengine"))) {
1178 LogWarning() << "Plugin" << lib << "uses QtWebEngine and is not Mac App store compliant.";
1179 if (appstoreCompliant) {
1180 LogWarning() << "Skip plugin" << lib;
1181 return false;
1182 }
1183 }
1184 return true;
1185 });
1186 }
1187
1188 // FIXME: Parse modules/Foo.json's plugin_types instead
1189 static const std::map<QString, std::vector<QString>> map {
1190 {QStringLiteral("Multimedia"), {QStringLiteral("multimedia")}},
1191 {QStringLiteral("3DRender"), {QStringLiteral("sceneparsers"), QStringLiteral("geometryloaders"), QStringLiteral("renderers")}},
1192 {QStringLiteral("3DQuickRender"), {QStringLiteral("renderplugins")}},
1193 {QStringLiteral("Positioning"), {QStringLiteral("position")}},
1194 {QStringLiteral("Location"), {QStringLiteral("geoservices")}},
1195 {QStringLiteral("TextToSpeech"), {QStringLiteral("texttospeech")}},
1196 {QStringLiteral("SerialBus"), {QStringLiteral("canbus")}},
1197 };
1198
1199 for (const auto &it : map) {
1200 if (deploymentInfo.containsModule(it.first, libInfix)) {
1201 for (const auto &pluginType : it.second) {
1202 addPlugins(pluginType);
1203 }
1204 }
1205 }
1206
1207 for (const QString &plugin : pluginList) {
1208 QString sourcePath = pluginSourcePath + "/" + plugin;
1209 const QString destinationPath = pluginDestinationPath + "/" + plugin;
1210 QDir dir;
1211 dir.mkpath(QFileInfo(destinationPath).path());
1212
1213 if (copyFilePrintStatus(sourcePath, destinationPath)) {
1214 runStrip(destinationPath);
1215 QList<FrameworkInfo> frameworks = getQtFrameworks(destinationPath, appBundleInfo.path, deploymentInfo.rpathsUsed, useDebugLibs);
1216 deployQtFrameworks(frameworks, appBundleInfo.path, QStringList() << destinationPath, useDebugLibs, deploymentInfo.useLoaderPath);
1217 }
1218 }
1219}
1220
1221void createQtConf(const QString &appBundlePath)
1222{
1223 // Set Plugins and imports paths. These are relative to App.app/Contents.
1224 QByteArray contents = "[Paths]\n"
1225 "Plugins = PlugIns\n"
1226 "Imports = Resources/qml\n"
1227 "QmlImports = Resources/qml\n";
1228
1229 QString filePath = appBundlePath + "/Contents/Resources/";
1230 QString fileName = filePath + "qt.conf";
1231
1232 QDir().mkpath(filePath);
1233
1234 if (QFile::exists(fileName) && !alwaysOwerwriteEnabled) {
1235 LogWarning();
1236 LogWarning() << fileName << "already exists, will not overwrite.";
1237 LogWarning() << "To make sure the plugins are loaded from the correct location,";
1238 LogWarning() << "please make sure qt.conf contains the following lines:";
1239 LogWarning() << "[Paths]";
1240 LogWarning() << " Plugins = PlugIns";
1241 return;
1242 }
1243
1244 if (QSaveFile qtconf(fileName); qtconf.open(QIODevice::WriteOnly)
1245 && qtconf.write(contents) != -1 && qtconf.commit()) {
1246 LogNormal() << "Created configuration file:" << fileName;
1247 LogNormal() << "This file sets the plugin search path to" << appBundlePath + "/Contents/PlugIns";
1248 }
1249}
1250
1251void deployPlugins(const QString &appBundlePath, DeploymentInfo deploymentInfo, bool useDebugLibs)
1252{
1253 ApplicationBundleInfo applicationBundle;
1254 applicationBundle.path = appBundlePath;
1255 applicationBundle.binaryPath = findAppBinary(appBundlePath);
1256
1257 const QString pluginDestinationPath = appBundlePath + "/" + "Contents/PlugIns";
1258 deployPlugins(applicationBundle, deploymentInfo.pluginPath, pluginDestinationPath, deploymentInfo, useDebugLibs);
1259}
1260
1261void deployQmlImport(const QString &appBundlePath, const QList<QString> &rpaths, const QString &importSourcePath, const QString &importName)
1262{
1263 QString importDestinationPath = appBundlePath + "/Contents/Resources/qml/" + importName;
1264
1265 // Skip already deployed imports. This can happen in cases like "QtQuick.Controls.Styles",
1266 // where deploying QtQuick.Controls will also deploy the "Styles" sub-import.
1267 if (QDir().exists(importDestinationPath))
1268 return;
1269
1270 recursiveCopyAndDeploy(appBundlePath, rpaths, importSourcePath, importDestinationPath);
1271}
1272
1273static bool importLessThan(const QVariant &v1, const QVariant &v2)
1274{
1275 QVariantMap import1 = v1.toMap();
1276 QVariantMap import2 = v2.toMap();
1277 QString path1 = import1["path"].toString();
1278 QString path2 = import2["path"].toString();
1279 return path1 < path2;
1280}
1281
1282// Scan qml files in qmldirs for import statements, deploy used imports from QmlImportsPath to Contents/Resources/qml.
1283bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInfo, QStringList &qmlDirs, QStringList &qmlImportPaths)
1284{
1285 LogNormal() << "";
1286 LogNormal() << "Deploying QML imports ";
1287 LogNormal() << "Application QML file path(s) is" << qmlDirs;
1288 LogNormal() << "QML module search path(s) is" << qmlImportPaths;
1289
1290 // Use qmlimportscanner from QLibraryInfo::LibraryExecutablesPath
1291 QString qmlImportScannerPath =
1292 QDir::cleanPath(QLibraryInfo::path(QLibraryInfo::LibraryExecutablesPath)
1293 + "/qmlimportscanner");
1294
1295 // Fallback: Look relative to the macdeployqt binary
1296 if (!QFile::exists(qmlImportScannerPath))
1297 qmlImportScannerPath = QCoreApplication::applicationDirPath() + "/qmlimportscanner";
1298
1299 // Verify that we found a qmlimportscanner binary
1300 if (!QFile::exists(qmlImportScannerPath)) {
1301 LogError() << "qmlimportscanner not found at" << qmlImportScannerPath;
1302 LogError() << "Rebuild qtdeclarative/tools/qmlimportscanner";
1303 return false;
1304 }
1305
1306 // build argument list for qmlimportsanner: "-rootPath foo/ -rootPath bar/ -importPath path/to/qt/qml"
1307 // ("rootPath" points to a directory containing app qml, "importPath" is where the Qt imports are installed)
1308 QStringList argumentList;
1309 for (const QString &qmlDir : qmlDirs) {
1310 argumentList.append("-rootPath");
1311 argumentList.append(qmlDir);
1312 }
1313 for (const QString &importPath : qmlImportPaths)
1314 argumentList << "-importPath" << importPath;
1315 QString qmlImportsPath = QLibraryInfo::path(QLibraryInfo::QmlImportsPath);
1316 argumentList.append( "-importPath");
1317 argumentList.append(qmlImportsPath);
1318
1319 // run qmlimportscanner
1320 QProcess qmlImportScanner;
1321 qmlImportScanner.start(qmlImportScannerPath, argumentList);
1322 if (!qmlImportScanner.waitForStarted()) {
1323 LogError() << "Could not start qmlimpoortscanner. Process error is" << qmlImportScanner.errorString();
1324 return false;
1325 }
1326 qmlImportScanner.waitForFinished(-1);
1327
1328 // log qmlimportscanner errors
1329 qmlImportScanner.setReadChannel(QProcess::StandardError);
1330 QByteArray errors = qmlImportScanner.readAll();
1331 if (!errors.isEmpty()) {
1332 LogWarning() << "QML file parse error (deployment will continue):";
1333 LogWarning() << errors;
1334 }
1335
1336 // parse qmlimportscanner json
1337 qmlImportScanner.setReadChannel(QProcess::StandardOutput);
1338 QByteArray json = qmlImportScanner.readAll();
1339 QJsonDocument doc = QJsonDocument::fromJson(json);
1340 if (!doc.isArray()) {
1341 LogError() << "qmlimportscanner output error. Expected json array, got:";
1342 LogError() << json;
1343 return false;
1344 }
1345
1346 // sort imports to deploy a module before its sub-modules (otherwise
1347 // deployQmlImports can consider the module deployed if it has already
1348 // deployed one of its sub-module)
1349 QVariantList array = doc.array().toVariantList();
1350 std::sort(array.begin(), array.end(), importLessThan);
1351
1352 // deploy each import
1353 for (const QVariant &importValue : array) {
1354 QVariantMap import = importValue.toMap();
1355 QString name = import["name"].toString();
1356 QString path = import["path"].toString();
1357 QString type = import["type"].toString();
1358
1359 LogNormal() << "Deploying QML import" << name;
1360
1361 // Skip imports with missing info - path will be empty if the import is not found.
1362 if (name.isEmpty() || path.isEmpty()) {
1363 LogNormal() << " Skip import: name or path is empty";
1364 LogNormal() << "";
1365 continue;
1366 }
1367
1368 // Deploy module imports only, skip directory (local/remote) and js imports. These
1369 // should be deployed as a part of the application build.
1370 if (type != QStringLiteral("module")) {
1371 LogNormal() << " Skip non-module import";
1372 LogNormal() << "";
1373 continue;
1374 }
1375
1376 // Create the destination path from the name
1377 // and version (grabbed from the source path)
1378 // ### let qmlimportscanner provide this.
1379 name.replace(u'.', u'/');
1380 int secondTolast = path.length() - 2;
1381 QString version = path.mid(secondTolast);
1382 if (version.startsWith(u'.'))
1383 name.append(version);
1384
1385 deployQmlImport(appBundlePath, deploymentInfo.rpathsUsed, path, name);
1386 LogNormal() << "";
1387 }
1388 return true;
1389}
1390
1391void codesignFile(const QString &identity, const QString &filePath)
1392{
1393 if (!runCodesign)
1394 return;
1395
1396 QString codeSignLogMessage = "codesign";
1397 if (hardenedRuntime)
1398 codeSignLogMessage += ", enable hardened runtime";
1399 if (secureTimestamp)
1400 codeSignLogMessage += ", include secure timestamp";
1401 LogNormal() << codeSignLogMessage << filePath;
1402
1403 QStringList codeSignOptions = { "--preserve-metadata=identifier,entitlements", "--force", "-s",
1404 identity, filePath };
1405 if (hardenedRuntime)
1406 codeSignOptions << "-o" << "runtime";
1407
1408 if (secureTimestamp)
1409 codeSignOptions << "--timestamp";
1410
1411 if (!extraEntitlements.isEmpty())
1412 codeSignOptions << "--entitlements" << extraEntitlements;
1413
1414 QProcess codesign;
1415 codesign.start("codesign", codeSignOptions);
1416 codesign.waitForFinished(-1);
1417
1418 QByteArray err = codesign.readAllStandardError();
1419 if (codesign.exitCode() > 0) {
1420 LogError() << "Codesign signing error:";
1421 LogError() << err;
1422 } else if (!err.isEmpty()) {
1423 LogDebug() << err;
1424 }
1425}
1426
1427QSet<QString> codesignBundle(const QString &identity,
1428 const QString &appBundlePath,
1429 QList<QString> additionalBinariesContainingRpaths)
1430{
1431 // Code sign all binaries in the app bundle. This needs to
1432 // be done inside-out, e.g sign framework dependencies
1433 // before the main app binary. The codesign tool itself has
1434 // a "--deep" option to do this, but usage when signing is
1435 // not recommended: "Signing with --deep is for emergency
1436 // repairs and temporary adjustments only."
1437
1438 LogNormal() << "";
1439 LogNormal() << "Signing" << appBundlePath << "with identity" << identity;
1440
1441 QStack<QString> pendingBinaries;
1442 QSet<QString> pendingBinariesSet;
1443 QSet<QString> signedBinaries;
1444
1445 // Create the root code-binary set. This set consists of the application
1446 // executable(s) and the plugins.
1447 QString appBundleAbsolutePath = QFileInfo(appBundlePath).absoluteFilePath();
1448 QString rootBinariesPath = appBundleAbsolutePath + "/Contents/MacOS/";
1449 QStringList foundRootBinaries = QDir(rootBinariesPath).entryList(QStringList() << "*", QDir::Files);
1450 for (const QString &binary : foundRootBinaries) {
1451 QString binaryPath = rootBinariesPath + binary;
1452 pendingBinaries.push(binaryPath);
1453 pendingBinariesSet.insert(binaryPath);
1454 additionalBinariesContainingRpaths.append(binaryPath);
1455 }
1456
1457 bool getAbsoltuePath = true;
1458 QStringList foundPluginBinaries = findAppBundleFiles(appBundlePath + "/Contents/PlugIns/", getAbsoltuePath);
1459 for (const QString &binary : foundPluginBinaries) {
1460 pendingBinaries.push(binary);
1461 pendingBinariesSet.insert(binary);
1462 }
1463
1464 // Add frameworks for processing.
1465 QStringList frameworkPaths = findAppFrameworkPaths(appBundlePath);
1466 for (const QString &frameworkPath : frameworkPaths) {
1467
1468 // Prioritise first to sign any additional inner bundles found in the Helpers folder (e.g
1469 // used by QtWebEngine).
1470 QDirIterator helpersIterator(frameworkPath, QStringList() << QString::fromLatin1("Helpers"), QDir::Dirs | QDir::NoSymLinks, QDirIterator::Subdirectories);
1471 while (helpersIterator.hasNext()) {
1472 helpersIterator.next();
1473 QString helpersPath = helpersIterator.filePath();
1474 QStringList innerBundleNames = QDir(helpersPath).entryList(QStringList() << "*.app", QDir::Dirs);
1475 for (const QString &innerBundleName : innerBundleNames)
1476 signedBinaries += codesignBundle(identity,
1477 helpersPath + "/" + innerBundleName,
1478 additionalBinariesContainingRpaths);
1479 }
1480
1481 // Also make sure to sign any libraries that will not be found by otool because they
1482 // are not linked and won't be seen as a dependency.
1483 QDirIterator librariesIterator(frameworkPath, QStringList() << QString::fromLatin1("Libraries"), QDir::Dirs | QDir::NoSymLinks, QDirIterator::Subdirectories);
1484 while (librariesIterator.hasNext()) {
1485 librariesIterator.next();
1486 QString librariesPath = librariesIterator.filePath();
1487 QStringList bundleFiles = findAppBundleFiles(librariesPath, getAbsoltuePath);
1488 for (const QString &binary : bundleFiles) {
1489 pendingBinaries.push(binary);
1490 pendingBinariesSet.insert(binary);
1491 }
1492 }
1493 }
1494
1495 // Sign all binaries; use otool to find and sign dependencies first.
1496 while (!pendingBinaries.isEmpty()) {
1497 QString binary = pendingBinaries.pop();
1498 if (signedBinaries.contains(binary))
1499 continue;
1500
1501 // Check if there are unsigned dependencies, sign these first.
1502 QStringList dependencies = getBinaryDependencies(rootBinariesPath, binary,
1503 additionalBinariesContainingRpaths);
1504 dependencies = QSet<QString>(dependencies.begin(), dependencies.end())
1505 .subtract(signedBinaries)
1506 .subtract(pendingBinariesSet)
1507 .values();
1508
1509 if (!dependencies.isEmpty()) {
1510 pendingBinaries.push(binary);
1511 pendingBinariesSet.insert(binary);
1512 int dependenciesSkipped = 0;
1513 for (const QString &dependency : std::as_const(dependencies)) {
1514 // Skip dependencies that are outside the current app bundle, because this might
1515 // cause a codesign error if the current bundle is part of the dependency (e.g.
1516 // a bundle is part of a framework helper, and depends on that framework).
1517 // The dependencies will be taken care of after the current bundle is signed.
1518 if (!dependency.startsWith(appBundleAbsolutePath)) {
1519 ++dependenciesSkipped;
1520 LogNormal() << "Skipping outside dependency: " << dependency;
1521 continue;
1522 }
1523 pendingBinaries.push(dependency);
1524 pendingBinariesSet.insert(dependency);
1525 }
1526
1527 // If all dependencies were skipped, make sure the binary is actually signed, instead
1528 // of going into an infinite loop.
1529 if (dependenciesSkipped == dependencies.size()) {
1530 pendingBinaries.pop();
1531 } else {
1532 continue;
1533 }
1534 }
1535
1536 // Look for an entitlements file in the bundle to include when signing
1537 extraEntitlements = findEntitlementsFile(appBundleAbsolutePath + "/Contents/Resources/");
1538
1539 // All dependencies are signed, now sign this binary.
1540 codesignFile(identity, binary);
1541 signedBinaries.insert(binary);
1542 pendingBinariesSet.remove(binary);
1543 }
1544
1545 LogNormal() << "Finished codesigning " << appBundlePath << "with identity" << identity;
1546
1547 // Verify code signature
1548 QProcess codesign;
1549 codesign.start("codesign", QStringList() << "--deep" << "-v" << appBundlePath);
1550 codesign.waitForFinished(-1);
1551 QByteArray err = codesign.readAllStandardError();
1552 if (codesign.exitCode() > 0) {
1553 LogError() << "codesign verification error:";
1554 LogError() << err;
1555 } else if (!err.isEmpty()) {
1556 LogDebug() << err;
1557 }
1558
1559 return signedBinaries;
1560}
1561
1562void codesign(const QString &identity, const QString &appBundlePath) {
1563 codesignBundle(identity, appBundlePath, QList<QString>());
1564}
1565
1566void createDiskImage(const QString &appBundlePath, const QString &filesystemType)
1567{
1568 QString appBaseName = appBundlePath;
1569 appBaseName.chop(4); // remove ".app" from end
1570
1571 QString dmgName = appBaseName + ".dmg";
1572
1573 QFile dmg(dmgName);
1574
1575 if (dmg.exists() && alwaysOwerwriteEnabled)
1576 dmg.remove();
1577
1578 if (dmg.exists()) {
1579 LogNormal() << "Disk image already exists, skipping .dmg creation for" << dmg.fileName();
1580 } else {
1581 LogNormal() << "Creating disk image (.dmg) for" << appBundlePath;
1582 }
1583
1584 LogNormal() << "Image will use" << filesystemType;
1585
1586 // More dmg options can be found in the hdiutil man page.
1587 QStringList options = QStringList()
1588 << "create" << dmgName
1589 << "-srcfolder" << appBundlePath
1590 << "-format" << "UDZO"
1591 << "-fs" << filesystemType
1592 << "-volname" << appBaseName;
1593
1594 QProcess hdutil;
1595 hdutil.start("hdiutil", options);
1596 hdutil.waitForFinished(-1);
1597 if (hdutil.exitCode() != 0) {
1598 LogError() << "Bundle creation error:" << hdutil.readAllStandardError();
1599 }
1600}
1601
1602void fixupFramework(const QString &frameworkName)
1603{
1604 // Expected framework name looks like "Foo.framework"
1605 QStringList parts = frameworkName.split(".");
1606 if (parts.count() < 2) {
1607 LogError() << "fixupFramework: Unexpected framework name" << frameworkName;
1608 return;
1609 }
1610
1611 // Assume framework binary path is Foo.framework/Foo
1612 QString frameworkBinary = frameworkName + QStringLiteral("/") + parts[0];
1613
1614 // Xcode expects to find Foo.framework/Versions/A when code
1615 // signing, while qmake typically generates numeric versions.
1616 // Create symlink to the actual version in the framework.
1617 linkFilePrintStatus("Current", frameworkName + "/Versions/A");
1618
1619 // Set up @rpath structure.
1620 changeIdentification("@rpath/" + frameworkBinary, frameworkBinary);
1621 addRPath("@loader_path/../../Contents/Frameworks/", frameworkBinary);
1622}
bool useLoaderPath
Definition shared.h:83
bool containsModule(const QString &module, const QString &libInFix) const
Definition shared.cpp:956
bool isDebug
Definition shared.h:85
bool isFramework
Definition shared.h:84
bool isDebugLibrary() const
Definition shared.h:38
bool isDylib
Definition shared.h:23
bool recursiveCopy(const QString &sourcePath, const QString &destinationPath, const QRegularExpression &ignoreRegExp=QRegularExpression())
Definition shared.cpp:643
bool runCodesign
Definition shared.cpp:31
void addRPath(const QString &rpath, const QString &binaryPath)
Definition shared.cpp:878
QStringList getBinaryDependencies(const QString executablePath, const QString &path, const QList< QString > &additionalBinariesContainingRpaths)
Definition shared.cpp:592
QString extraEntitlements
Definition shared.cpp:33
QStringList librarySearchPath
Definition shared.cpp:32
const QString bundleFrameworkDirectory
Definition shared.cpp:67
bool deployFramework
Definition shared.cpp:38
QStringList findAppBundleFiles(const QString &appBundlePath, bool absolutePath=false)
Definition shared.cpp:456
static bool importLessThan(const QVariant &v1, const QVariant &v2)
Definition shared.cpp:1273
QList< FrameworkInfo > getQtFrameworksForPaths(const QStringList &paths, const QString &appBundlePath, const QList< QString > &rpaths, bool useDebugLibs)
Definition shared.cpp:577
bool copyFilePrintStatus(const QString &from, const QString &to)
Definition shared.cpp:77
void deployRPaths(const QString &bundlePath, const QList< QString > &rpaths, const QString &binaryPath, bool useLoaderPath)
Definition shared.cpp:883
QString getLibInfix(const QStringList &deployedFrameworks)
Definition shared.cpp:1077
QList< QString > getBinaryRPaths(const QString &path, bool resolve=true, QString executablePath=QString())
Definition shared.cpp:530
void patch_debugInInfoPlist(const QString &infoPlistPath)
Definition shared.cpp:133
void runInstallNameTool(QStringList options)
Definition shared.cpp:832
bool appstoreCompliant
Definition shared.cpp:36
bool alwaysOwerwriteEnabled
Definition shared.cpp:30
void deployPlugins(const ApplicationBundleInfo &appBundleInfo, const QString &pluginSourcePath, const QString pluginDestinationPath, DeploymentInfo deploymentInfo, bool useDebugLibs)
Definition shared.cpp:1094
void deployQmlImport(const QString &appBundlePath, const QList< QString > &rpaths, const QString &importSourcePath, const QString &importName)
Definition shared.cpp:1261
void recursiveCopyAndDeploy(const QString &appBundlePath, const QList< QString > &rpaths, const QString &sourcePath, const QString &destinationPath)
Definition shared.cpp:670
QString resolveDyldPrefix(const QString &path, const QString &loaderPath, const QString &executablePath)
Definition shared.cpp:504
bool linkFilePrintStatus(const QString &file, const QString &link)
Definition shared.cpp:114
bool hardenedRuntime
Definition shared.cpp:34
void changeInstallName(const QString &bundlePath, const FrameworkInfo &framework, const QStringList &binaryPaths, bool useLoaderPath)
Definition shared.cpp:851
QString findEntitlementsFile(const QString &path)
Definition shared.cpp:473
bool secureTimestamp
Definition shared.cpp:35
QString copyDylib(const FrameworkInfo &framework, const QString path)
Definition shared.cpp:737
QStringList findAppLibraries(const QString &appBundlePath)
Definition shared.cpp:443
QDebug operator<<(QDebug debug, const ApplicationBundleInfo &info)
Definition shared.cpp:69
#define LogWarning()
Definition shared.h:14
QSet< QString > codesignBundle(const QString &identity, const QString &appBundlePath, QList< QString > additionalBinariesContainingRpaths)
Definition shared.cpp:1427
void codesignFile(const QString &identity, const QString &filePath)
Definition shared.cpp:1391
void changeInstallName(const QString &oldName, const QString &newName, const QString &binaryPath)
Definition shared.cpp:926
bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInfo, QStringList &qmlDirs, QStringList &qmlImportPaths)
Definition shared.cpp:1283
void createQtConf(const QString &appBundlePath)
Definition shared.cpp:1221
void runStrip(const QString &binaryPath)
Definition shared.cpp:935
QString findAppBinary(const QString &appBundlePath)
Definition shared.cpp:376
bool operator==(const FrameworkInfo &a, const FrameworkInfo &b)
Definition shared.cpp:44
void fixupFramework(const QString &appBundlePath)
Definition shared.cpp:1602
void deployPlugins(const QString &appBundlePath, DeploymentInfo deploymentInfo, bool useDebugLibs)
Definition shared.cpp:1251
void changeIdentification(const QString &id, const QString &binaryPath)
Definition shared.cpp:843
OtoolInfo findDependencyInfo(const QString &binaryPath)
Definition shared.cpp:155
DeploymentInfo deployQtFrameworks(const QString &appBundlePath, const QStringList &additionalExecutables, bool useDebugLibs)
Definition shared.cpp:1052
void createDiskImage(const QString &appBundlePath, const QString &filesystemType)
Definition shared.cpp:1566
QString copyFramework(const FrameworkInfo &framework, const QString path)
Definition shared.cpp:764
bool runStripEnabled
Definition shared.cpp:29
void stripAppBinary(const QString &bundlePath)
Definition shared.cpp:951
#define LogError()
Definition shared.h:13
QStringList findAppFrameworkPaths(const QString &appBundlePath)
Definition shared.cpp:429
DeploymentInfo deployQtFrameworks(QList< FrameworkInfo > frameworks, const QString &bundlePath, const QStringList &binaryPaths, bool useDebugLibs, bool useLoaderPath)
Definition shared.cpp:976
#define LogDebug()
Definition shared.h:16
QStringList findAppFrameworkNames(const QString &appBundlePath)
Definition shared.cpp:412
void codesign(const QString &identity, const QString &appBundlePath)
Definition shared.cpp:1562
FrameworkInfo parseOtoolLibraryLine(const QString &line, const QString &appBundlePath, const QList< QString > &rpaths, bool useDebugLibs)
Definition shared.cpp:219
QDebug operator<<(QDebug debug, const FrameworkInfo &info)
Definition shared.cpp:49
#define LogNormal()
Definition shared.h:15
QList< FrameworkInfo > getQtFrameworks(const QString &path, const QString &appBundlePath, const QList< QString > &rpaths, bool useDebugLibs)
Definition shared.cpp:569
int logLevel
Definition shared.cpp:37