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 // To properly find all dependencies of the current framework / library further down in
1012 // getQtFrameworks, we need to get its rpaths, resolve them in the context of its original
1013 // location before it is copied, and add them as candidate rpaths.
1014 //
1015 // This is necessary to handle cases like
1016 // (1) QtNetwork.framework -> (2) libbrotlidec.dylib -> (3) libbrotlicommon.1.dylib
1017 // to correctly resolve the path to (3) when it is referenced as
1018 // '@rpath/libbrotlicommon.1.dylib' and (2) has an LC_RPATH of '@loader_path/../lib', and
1019 // no other absolute rpaths. So the '@loader_path/../lib' will be resolved relative
1020 // to (2)'s original location and its LC_RPATH.
1021 //
1022 // Otherwise we'd only have the Qt prefix and the current bundle app dir as rpath
1023 // candidates, and once (2) is copied into the app bundle, there's no way
1024 // '@rpath/libbrotlicommon.1.dylib' could resolve to the real path on disk from the two
1025 // candidates above.
1026 if (!framework.sourceFilePath.isEmpty()) {
1027 const QList<QString> sourceRPaths = getBinaryRPaths(framework.sourceFilePath, true);
1028 for (const QString &sourceRPath : sourceRPaths) {
1029 const QDir sourceRPathDir(sourceRPath);
1030 if (sourceRPathDir.exists() && !rpathsUsed.contains(sourceRPath)) {
1031 rpathsUsed.append(sourceRPath);
1032 }
1033 }
1034 }
1035
1036 // Copy the framework/dylib to the app bundle.
1037 const QString deployedBinaryPath = framework.isDylib ? copyDylib(framework, bundlePath)
1038 : copyFramework(framework, bundlePath);
1039
1040 // Install_name_tool the new id into the binaries
1041 changeInstallName(bundlePath, framework, binaryPaths, useLoaderPath);
1042
1043 // Skip the rest if already was deployed.
1044 if (deployedBinaryPath.isNull())
1045 continue;
1046
1047 runStrip(deployedBinaryPath);
1048
1049 // Install_name_tool it a new id.
1050 if (!framework.rpathUsed.length()) {
1051 changeIdentification(framework.deployedInstallName, deployedBinaryPath);
1052 }
1053
1054 // Check for framework dependencies
1055 QList<FrameworkInfo> dependencies = getQtFrameworks(deployedBinaryPath, bundlePath, rpathsUsed, useDebugLibs);
1056
1057 for (const FrameworkInfo &dependency : dependencies) {
1058 if (dependency.rpathUsed.isEmpty()) {
1059 changeInstallName(bundlePath, dependency, QStringList() << deployedBinaryPath, useLoaderPath);
1060 } else if (!rpathsUsed.contains(dependency.rpathUsed)) {
1061 rpathsUsed.append(dependency.rpathUsed);
1062 }
1063
1064 // Deploy framework if necessary.
1065 if (copiedFrameworks.contains(dependency.frameworkName) == false && frameworks.contains(dependency) == false) {
1066 frameworks.append(dependency);
1067 }
1068 }
1069 }
1070 deploymentInfo.deployedFrameworks = copiedFrameworks;
1071 deployRPaths(bundlePath, rpathsUsed, binaryPaths, useLoaderPath);
1072 deploymentInfo.rpathsUsed += rpathsUsed;
1073 deploymentInfo.rpathsUsed.removeDuplicates();
1074 return deploymentInfo;
1075}
1076
1077DeploymentInfo deployQtFrameworks(const QString &appBundlePath, const QStringList &additionalExecutables, bool useDebugLibs)
1078{
1079 ApplicationBundleInfo applicationBundle;
1080 applicationBundle.path = appBundlePath;
1081 applicationBundle.binaryPath = findAppBinary(appBundlePath);
1082 applicationBundle.libraryPaths = findAppLibraries(appBundlePath);
1083 QStringList allBinaryPaths = QStringList() << applicationBundle.binaryPath << applicationBundle.libraryPaths
1084 << additionalExecutables;
1085
1086 QList<QString> allLibraryPaths = getBinaryRPaths(applicationBundle.binaryPath, true);
1087 allLibraryPaths.append(QLibraryInfo::path(QLibraryInfo::LibrariesPath));
1088 allLibraryPaths.removeDuplicates();
1089
1090 QList<FrameworkInfo> frameworks = getQtFrameworksForPaths(allBinaryPaths, appBundlePath, allLibraryPaths, useDebugLibs);
1091 if (frameworks.isEmpty() && !alwaysOwerwriteEnabled) {
1092 LogWarning();
1093 LogWarning() << "Could not find any external Qt frameworks to deploy in" << appBundlePath;
1094 LogWarning() << "Perhaps macdeployqt was already used on" << appBundlePath << "?";
1095 LogWarning() << "If so, you will need to rebuild" << appBundlePath << "before trying again.";
1096 return DeploymentInfo();
1097 } else {
1098 return deployQtFrameworks(frameworks, applicationBundle.path, allBinaryPaths, useDebugLibs, !additionalExecutables.isEmpty());
1099 }
1100}
1101
1102QString getLibInfix(const QStringList &deployedFrameworks)
1103{
1104 QString libInfix;
1105 for (const QString &framework : deployedFrameworks) {
1106 if (framework.startsWith(QStringLiteral("QtCore")) && framework.endsWith(QStringLiteral(".framework")) &&
1107 !framework.contains(QStringLiteral("5Compat"))) {
1108 Q_ASSERT(framework.length() >= 16);
1109 // 16 == "QtCore" + ".framework"
1110 const int lengthOfLibInfix = framework.length() - 16;
1111 if (lengthOfLibInfix)
1112 libInfix = framework.mid(6, lengthOfLibInfix);
1113 break;
1114 }
1115 }
1116 return libInfix;
1117}
1118
1119void deployPlugins(const ApplicationBundleInfo &appBundleInfo, const QString &pluginSourcePath,
1120 const QString pluginDestinationPath, DeploymentInfo deploymentInfo, bool useDebugLibs)
1121{
1122 LogNormal() << "Deploying plugins from" << pluginSourcePath;
1123
1124 if (!pluginSourcePath.contains(deploymentInfo.pluginPath))
1125 return;
1126
1127 // Plugin white list:
1128 QStringList pluginList;
1129
1130 const auto addPlugins = [&pluginSourcePath,&pluginList,useDebugLibs](const QString &subDirectory,
1131 const std::function<bool(QString)> &predicate = std::function<bool(QString)>()) {
1132 const QStringList libs = QDir(pluginSourcePath + u'/' + subDirectory)
1133 .entryList({QStringLiteral("*.dylib")});
1134 for (const QString &lib : libs) {
1135 if (lib.endsWith(QStringLiteral("_debug.dylib")) != useDebugLibs)
1136 continue;
1137 if (!predicate || predicate(lib))
1138 pluginList.append(subDirectory + u'/' + lib);
1139 }
1140 };
1141
1142 // Platform plugin:
1143 addPlugins(QStringLiteral("platforms"), [](const QString &lib) {
1144 // Ignore minimal and offscreen platform plugins
1145 if (!lib.contains(QStringLiteral("cocoa")))
1146 return false;
1147 return true;
1148 });
1149
1150 // Cocoa print support
1151 addPlugins(QStringLiteral("printsupport"));
1152
1153 // Styles
1154 addPlugins(QStringLiteral("styles"));
1155
1156 // Check if Qt was configured with -libinfix
1157 const QString libInfix = getLibInfix(deploymentInfo.deployedFrameworks);
1158
1159 // Network
1160 if (deploymentInfo.containsModule("Network", libInfix)) {
1161 addPlugins(QStringLiteral("tls"));
1162 addPlugins(QStringLiteral("networkinformation"));
1163 }
1164
1165 // All image formats (svg if QtSvg is used)
1166 const bool usesSvg = deploymentInfo.containsModule("Svg", libInfix);
1167 addPlugins(QStringLiteral("imageformats"), [usesSvg](const QString &lib) {
1168 if (lib.contains(QStringLiteral("qsvg")) && !usesSvg)
1169 return false;
1170 return true;
1171 });
1172
1173 addPlugins(QStringLiteral("iconengines"));
1174
1175 // Platforminputcontext plugins if QtGui is in use
1176 if (deploymentInfo.containsModule("Gui", libInfix)) {
1177 addPlugins(QStringLiteral("platforminputcontexts"), [&addPlugins](const QString &lib) {
1178 // Deploy the virtual keyboard plugins if we have deployed virtualkeyboard
1179 if (lib.startsWith(QStringLiteral("libqtvirtualkeyboard")))
1180 addPlugins(QStringLiteral("virtualkeyboard"));
1181 return true;
1182 });
1183 }
1184
1185 // Sql plugins if QtSql is in use
1186 if (deploymentInfo.containsModule("Sql", libInfix)) {
1187 addPlugins(QStringLiteral("sqldrivers"), [](const QString &lib) {
1188 if (lib.startsWith(QStringLiteral("libqsqlodbc")) || lib.startsWith(QStringLiteral("libqsqlpsql"))) {
1189 LogWarning() << "Plugin" << lib << "uses private API and is not Mac App store compliant.";
1190 if (appstoreCompliant) {
1191 LogWarning() << "Skip plugin" << lib;
1192 return false;
1193 }
1194 }
1195 return true;
1196 });
1197 }
1198
1199 // WebView plugins if QtWebView is in use
1200 if (deploymentInfo.containsModule("WebView", libInfix)) {
1201 addPlugins(QStringLiteral("webview"), [](const QString &lib) {
1202 if (lib.startsWith(QStringLiteral("libqtwebview_webengine"))) {
1203 LogWarning() << "Plugin" << lib << "uses QtWebEngine and is not Mac App store compliant.";
1204 if (appstoreCompliant) {
1205 LogWarning() << "Skip plugin" << lib;
1206 return false;
1207 }
1208 }
1209 return true;
1210 });
1211 }
1212
1213 // FIXME: Parse modules/Foo.json's plugin_types instead
1214 static const std::map<QString, std::vector<QString>> map {
1215 {QStringLiteral("Multimedia"), {QStringLiteral("multimedia")}},
1216 {QStringLiteral("3DRender"), {QStringLiteral("sceneparsers"), QStringLiteral("geometryloaders"), QStringLiteral("renderers")}},
1217 {QStringLiteral("3DQuickRender"), {QStringLiteral("renderplugins")}},
1218 {QStringLiteral("Positioning"), {QStringLiteral("position")}},
1219 {QStringLiteral("Location"), {QStringLiteral("geoservices")}},
1220 {QStringLiteral("TextToSpeech"), {QStringLiteral("texttospeech")}},
1221 {QStringLiteral("SerialBus"), {QStringLiteral("canbus")}},
1222 };
1223
1224 for (const auto &it : map) {
1225 if (deploymentInfo.containsModule(it.first, libInfix)) {
1226 for (const auto &pluginType : it.second) {
1227 addPlugins(pluginType);
1228 }
1229 }
1230 }
1231
1232 for (const QString &plugin : pluginList) {
1233 QString sourcePath = pluginSourcePath + "/" + plugin;
1234 const QString destinationPath = pluginDestinationPath + "/" + plugin;
1235 QDir dir;
1236 dir.mkpath(QFileInfo(destinationPath).path());
1237
1238 if (copyFilePrintStatus(sourcePath, destinationPath)) {
1239 runStrip(destinationPath);
1240 QList<FrameworkInfo> frameworks = getQtFrameworks(destinationPath, appBundleInfo.path, deploymentInfo.rpathsUsed, useDebugLibs);
1241 deployQtFrameworks(frameworks, appBundleInfo.path, QStringList() << destinationPath, useDebugLibs, deploymentInfo.useLoaderPath);
1242 }
1243 }
1244}
1245
1246void createQtConf(const QString &appBundlePath)
1247{
1248 // Set Plugins and imports paths. These are relative to App.app/Contents.
1249 QByteArray contents = "[Paths]\n"
1250 "Plugins = PlugIns\n"
1251 "Imports = Resources/qml\n"
1252 "QmlImports = Resources/qml\n";
1253
1254 QString filePath = appBundlePath + "/Contents/Resources/";
1255 QString fileName = filePath + "qt.conf";
1256
1257 QDir().mkpath(filePath);
1258
1259 if (QFile::exists(fileName) && !alwaysOwerwriteEnabled) {
1260 LogWarning();
1261 LogWarning() << fileName << "already exists, will not overwrite.";
1262 LogWarning() << "To make sure the plugins are loaded from the correct location,";
1263 LogWarning() << "please make sure qt.conf contains the following lines:";
1264 LogWarning() << "[Paths]";
1265 LogWarning() << " Plugins = PlugIns";
1266 return;
1267 }
1268
1269 if (QSaveFile qtconf(fileName); qtconf.open(QIODevice::WriteOnly)
1270 && qtconf.write(contents) != -1 && qtconf.commit()) {
1271 LogNormal() << "Created configuration file:" << fileName;
1272 LogNormal() << "This file sets the plugin search path to" << appBundlePath + "/Contents/PlugIns";
1273 }
1274}
1275
1276void deployPlugins(const QString &appBundlePath, DeploymentInfo deploymentInfo, bool useDebugLibs)
1277{
1278 ApplicationBundleInfo applicationBundle;
1279 applicationBundle.path = appBundlePath;
1280 applicationBundle.binaryPath = findAppBinary(appBundlePath);
1281
1282 const QString pluginDestinationPath = appBundlePath + "/" + "Contents/PlugIns";
1283 deployPlugins(applicationBundle, deploymentInfo.pluginPath, pluginDestinationPath, deploymentInfo, useDebugLibs);
1284}
1285
1286void deployQmlImport(const QString &appBundlePath, const QList<QString> &rpaths, const QString &importSourcePath, const QString &importName)
1287{
1288 QString importDestinationPath = appBundlePath + "/Contents/Resources/qml/" + importName;
1289
1290 // Skip already deployed imports. This can happen in cases like "QtQuick.Controls.Styles",
1291 // where deploying QtQuick.Controls will also deploy the "Styles" sub-import.
1292 if (QDir().exists(importDestinationPath))
1293 return;
1294
1295 recursiveCopyAndDeploy(appBundlePath, rpaths, importSourcePath, importDestinationPath);
1296}
1297
1298static bool importLessThan(const QVariant &v1, const QVariant &v2)
1299{
1300 QVariantMap import1 = v1.toMap();
1301 QVariantMap import2 = v2.toMap();
1302 QString path1 = import1["path"].toString();
1303 QString path2 = import2["path"].toString();
1304 return path1 < path2;
1305}
1306
1307// Scan qml files in qmldirs for import statements, deploy used imports from QmlImportsPath to Contents/Resources/qml.
1308bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInfo, QStringList &qmlDirs, QStringList &qmlImportPaths)
1309{
1310 LogNormal() << "";
1311 LogNormal() << "Deploying QML imports ";
1312 LogNormal() << "Application QML file path(s) is" << qmlDirs;
1313 LogNormal() << "QML module search path(s) is" << qmlImportPaths;
1314
1315 // Use qmlimportscanner from QLibraryInfo::LibraryExecutablesPath
1316 QString qmlImportScannerPath =
1317 QDir::cleanPath(QLibraryInfo::path(QLibraryInfo::LibraryExecutablesPath)
1318 + "/qmlimportscanner");
1319
1320 // Fallback: Look relative to the macdeployqt binary
1321 if (!QFile::exists(qmlImportScannerPath))
1322 qmlImportScannerPath = QCoreApplication::applicationDirPath() + "/qmlimportscanner";
1323
1324 // Verify that we found a qmlimportscanner binary
1325 if (!QFile::exists(qmlImportScannerPath)) {
1326 LogError() << "qmlimportscanner not found at" << qmlImportScannerPath;
1327 LogError() << "Rebuild qtdeclarative/tools/qmlimportscanner";
1328 return false;
1329 }
1330
1331 // build argument list for qmlimportsanner: "-rootPath foo/ -rootPath bar/ -importPath path/to/qt/qml"
1332 // ("rootPath" points to a directory containing app qml, "importPath" is where the Qt imports are installed)
1333 QStringList argumentList;
1334 for (const QString &qmlDir : qmlDirs) {
1335 argumentList.append("-rootPath");
1336 argumentList.append(qmlDir);
1337 }
1338 for (const QString &importPath : qmlImportPaths)
1339 argumentList << "-importPath" << importPath;
1340 QString qmlImportsPath = QLibraryInfo::path(QLibraryInfo::QmlImportsPath);
1341 argumentList.append( "-importPath");
1342 argumentList.append(qmlImportsPath);
1343
1344 // run qmlimportscanner
1345 QProcess qmlImportScanner;
1346 qmlImportScanner.start(qmlImportScannerPath, argumentList);
1347 if (!qmlImportScanner.waitForStarted()) {
1348 LogError() << "Could not start qmlimpoortscanner. Process error is" << qmlImportScanner.errorString();
1349 return false;
1350 }
1351 qmlImportScanner.waitForFinished(-1);
1352
1353 // log qmlimportscanner errors
1354 qmlImportScanner.setReadChannel(QProcess::StandardError);
1355 QByteArray errors = qmlImportScanner.readAll();
1356 if (!errors.isEmpty()) {
1357 LogWarning() << "QML file parse error (deployment will continue):";
1358 LogWarning() << errors;
1359 }
1360
1361 // parse qmlimportscanner json
1362 qmlImportScanner.setReadChannel(QProcess::StandardOutput);
1363 QByteArray json = qmlImportScanner.readAll();
1364 QJsonDocument doc = QJsonDocument::fromJson(json);
1365 if (!doc.isArray()) {
1366 LogError() << "qmlimportscanner output error. Expected json array, got:";
1367 LogError() << json;
1368 return false;
1369 }
1370
1371 // sort imports to deploy a module before its sub-modules (otherwise
1372 // deployQmlImports can consider the module deployed if it has already
1373 // deployed one of its sub-module)
1374 QVariantList array = doc.array().toVariantList();
1375 std::sort(array.begin(), array.end(), importLessThan);
1376
1377 // deploy each import
1378 for (const QVariant &importValue : array) {
1379 QVariantMap import = importValue.toMap();
1380 QString name = import["name"].toString();
1381 QString path = import["path"].toString();
1382 QString type = import["type"].toString();
1383
1384 LogNormal() << "Deploying QML import" << name;
1385
1386 // Skip imports with missing info - path will be empty if the import is not found.
1387 if (name.isEmpty() || path.isEmpty()) {
1388 LogNormal() << " Skip import: name or path is empty";
1389 LogNormal() << "";
1390 continue;
1391 }
1392
1393 // Deploy module imports only, skip directory (local/remote) and js imports. These
1394 // should be deployed as a part of the application build.
1395 if (type != QStringLiteral("module")) {
1396 LogNormal() << " Skip non-module import";
1397 LogNormal() << "";
1398 continue;
1399 }
1400
1401 // Create the destination path from the name
1402 // and version (grabbed from the source path)
1403 // ### let qmlimportscanner provide this.
1404 name.replace(u'.', u'/');
1405 int secondTolast = path.length() - 2;
1406 QString version = path.mid(secondTolast);
1407 if (version.startsWith(u'.'))
1408 name.append(version);
1409
1410 deployQmlImport(appBundlePath, deploymentInfo.rpathsUsed, path, name);
1411 LogNormal() << "";
1412 }
1413 return true;
1414}
1415
1416void codesignFile(const QString &identity, const QString &filePath)
1417{
1418 if (!runCodesign)
1419 return;
1420
1421 QString codeSignLogMessage = "codesign";
1422 if (hardenedRuntime)
1423 codeSignLogMessage += ", enable hardened runtime";
1424 if (secureTimestamp)
1425 codeSignLogMessage += ", include secure timestamp";
1426 LogNormal() << codeSignLogMessage << filePath;
1427
1428 QStringList codeSignOptions = { "--preserve-metadata=identifier,entitlements", "--force", "-s",
1429 identity, filePath };
1430 if (hardenedRuntime)
1431 codeSignOptions << "-o" << "runtime";
1432
1433 if (secureTimestamp)
1434 codeSignOptions << "--timestamp";
1435
1436 if (!extraEntitlements.isEmpty())
1437 codeSignOptions << "--entitlements" << extraEntitlements;
1438
1439 QProcess codesign;
1440 codesign.start("codesign", codeSignOptions);
1441 codesign.waitForFinished(-1);
1442
1443 QByteArray err = codesign.readAllStandardError();
1444 if (codesign.exitCode() > 0) {
1445 LogError() << "Codesign signing error:";
1446 LogError() << err;
1447 } else if (!err.isEmpty()) {
1448 LogDebug() << err;
1449 }
1450}
1451
1452QSet<QString> codesignBundle(const QString &identity,
1453 const QString &appBundlePath,
1454 QList<QString> additionalBinariesContainingRpaths)
1455{
1456 // Code sign all binaries in the app bundle. This needs to
1457 // be done inside-out, e.g sign framework dependencies
1458 // before the main app binary. The codesign tool itself has
1459 // a "--deep" option to do this, but usage when signing is
1460 // not recommended: "Signing with --deep is for emergency
1461 // repairs and temporary adjustments only."
1462
1463 LogNormal() << "";
1464 LogNormal() << "Signing" << appBundlePath << "with identity" << identity;
1465
1466 QStack<QString> pendingBinaries;
1467 QSet<QString> pendingBinariesSet;
1468 QSet<QString> signedBinaries;
1469
1470 // Create the root code-binary set. This set consists of the application
1471 // executable(s) and the plugins.
1472 QString appBundleAbsolutePath = QFileInfo(appBundlePath).absoluteFilePath();
1473 QString rootBinariesPath = appBundleAbsolutePath + "/Contents/MacOS/";
1474 QStringList foundRootBinaries = QDir(rootBinariesPath).entryList(QStringList() << "*", QDir::Files);
1475
1476 // The app binary must be signed last.
1477 QString appBinary = findAppBinary(appBundleAbsolutePath);
1478 QString appBinaryName = QFileInfo(appBinary).fileName();
1479 if (int appBinaryIdx = foundRootBinaries.indexOf(appBinaryName); appBinaryIdx > 0) {
1480 foundRootBinaries.swapItemsAt(0, appBinaryIdx);
1481 LogDebug() << "swapped appBinary to start of list";
1482 }
1483 LogDebug() << "App binary is" << appBinaryName;
1484 LogDebug() << "Binaries in" << rootBinariesPath << "are" << foundRootBinaries;
1485
1486 for (const QString &binary : foundRootBinaries) {
1487 QString binaryPath = rootBinariesPath + binary;
1488 pendingBinaries.push(binaryPath);
1489 pendingBinariesSet.insert(binaryPath);
1490 additionalBinariesContainingRpaths.append(binaryPath);
1491 }
1492
1493 bool getAbsoltuePath = true;
1494 QStringList foundPluginBinaries = findAppBundleFiles(appBundlePath + "/Contents/PlugIns/", getAbsoltuePath);
1495 for (const QString &binary : foundPluginBinaries) {
1496 pendingBinaries.push(binary);
1497 pendingBinariesSet.insert(binary);
1498 }
1499
1500 // Add frameworks for processing.
1501 QStringList frameworkPaths = findAppFrameworkPaths(appBundlePath);
1502 for (const QString &frameworkPath : frameworkPaths) {
1503
1504 // Prioritise first to sign any additional inner bundles found in the Helpers folder (e.g
1505 // used by QtWebEngine).
1506 QDirIterator helpersIterator(frameworkPath, QStringList() << QString::fromLatin1("Helpers"), QDir::Dirs | QDir::NoSymLinks, QDirIterator::Subdirectories);
1507 while (helpersIterator.hasNext()) {
1508 helpersIterator.next();
1509 QString helpersPath = helpersIterator.filePath();
1510 QStringList innerBundleNames = QDir(helpersPath).entryList(QStringList() << "*.app", QDir::Dirs);
1511 for (const QString &innerBundleName : innerBundleNames)
1512 signedBinaries += codesignBundle(identity,
1513 helpersPath + "/" + innerBundleName,
1514 additionalBinariesContainingRpaths);
1515 }
1516
1517 // Also make sure to sign any libraries that will not be found by otool because they
1518 // are not linked and won't be seen as a dependency.
1519 QDirIterator librariesIterator(frameworkPath, QStringList() << QString::fromLatin1("Libraries"), QDir::Dirs | QDir::NoSymLinks, QDirIterator::Subdirectories);
1520 while (librariesIterator.hasNext()) {
1521 librariesIterator.next();
1522 QString librariesPath = librariesIterator.filePath();
1523 QStringList bundleFiles = findAppBundleFiles(librariesPath, getAbsoltuePath);
1524 for (const QString &binary : bundleFiles) {
1525 pendingBinaries.push(binary);
1526 pendingBinariesSet.insert(binary);
1527 }
1528 }
1529 }
1530
1531 // Sign all binaries; use otool to find and sign dependencies first.
1532 while (!pendingBinaries.isEmpty()) {
1533 QString binary = pendingBinaries.pop();
1534 if (signedBinaries.contains(binary))
1535 continue;
1536
1537 // Check if there are unsigned dependencies, sign these first.
1538 QStringList dependencies = getBinaryDependencies(rootBinariesPath, binary,
1539 additionalBinariesContainingRpaths);
1540 dependencies = QSet<QString>(dependencies.begin(), dependencies.end())
1541 .subtract(signedBinaries)
1542 .subtract(pendingBinariesSet)
1543 .values();
1544
1545 if (!dependencies.isEmpty()) {
1546 pendingBinaries.push(binary);
1547 pendingBinariesSet.insert(binary);
1548 int dependenciesSkipped = 0;
1549 for (const QString &dependency : std::as_const(dependencies)) {
1550 // Skip dependencies that are outside the current app bundle, because this might
1551 // cause a codesign error if the current bundle is part of the dependency (e.g.
1552 // a bundle is part of a framework helper, and depends on that framework).
1553 // The dependencies will be taken care of after the current bundle is signed.
1554 if (!dependency.startsWith(appBundleAbsolutePath)) {
1555 ++dependenciesSkipped;
1556 LogNormal() << "Skipping outside dependency: " << dependency;
1557 continue;
1558 }
1559 pendingBinaries.push(dependency);
1560 pendingBinariesSet.insert(dependency);
1561 }
1562
1563 // If all dependencies were skipped, make sure the binary is actually signed, instead
1564 // of going into an infinite loop.
1565 if (dependenciesSkipped == dependencies.size()) {
1566 pendingBinaries.pop();
1567 } else {
1568 continue;
1569 }
1570 }
1571
1572 // Look for an entitlements file in the bundle to include when signing
1573 extraEntitlements = findEntitlementsFile(appBundleAbsolutePath + "/Contents/Resources/");
1574
1575 // All dependencies are signed, now sign this binary.
1576 codesignFile(identity, binary);
1577 signedBinaries.insert(binary);
1578 pendingBinariesSet.remove(binary);
1579 }
1580
1581 LogNormal() << "Finished codesigning " << appBundlePath << "with identity" << identity;
1582
1583 // Verify code signature
1584 QProcess codesign;
1585 codesign.start("codesign", QStringList() << "--deep" << "-v" << appBundlePath);
1586 codesign.waitForFinished(-1);
1587 QByteArray err = codesign.readAllStandardError();
1588 if (codesign.exitCode() > 0) {
1589 LogError() << "codesign verification error:";
1590 LogError() << err;
1591 } else if (!err.isEmpty()) {
1592 LogDebug() << err;
1593 }
1594
1595 return signedBinaries;
1596}
1597
1598void codesign(const QString &identity, const QString &appBundlePath) {
1599 codesignBundle(identity, appBundlePath, QList<QString>());
1600}
1601
1602void createDiskImage(const QString &appBundlePath, const QString &filesystemType)
1603{
1604 QString appBaseName = appBundlePath;
1605 appBaseName.chop(4); // remove ".app" from end
1606
1607 QString dmgName = appBaseName + ".dmg";
1608
1609 QFile dmg(dmgName);
1610
1611 if (dmg.exists() && alwaysOwerwriteEnabled)
1612 dmg.remove();
1613
1614 if (dmg.exists()) {
1615 LogNormal() << "Disk image already exists, skipping .dmg creation for" << dmg.fileName();
1616 } else {
1617 LogNormal() << "Creating disk image (.dmg) for" << appBundlePath;
1618 }
1619
1620 LogNormal() << "Image will use" << filesystemType;
1621
1622 // More dmg options can be found in the hdiutil man page.
1623 QStringList options = QStringList()
1624 << "create" << dmgName
1625 << "-srcfolder" << appBundlePath
1626 << "-format" << "UDZO"
1627 << "-fs" << filesystemType
1628 << "-volname" << appBaseName;
1629
1630 QProcess hdutil;
1631 hdutil.start("hdiutil", options);
1632 hdutil.waitForFinished(-1);
1633 if (hdutil.exitCode() != 0) {
1634 LogError() << "Bundle creation error:" << hdutil.readAllStandardError();
1635 }
1636}
1637
1638void fixupFramework(const QString &frameworkName)
1639{
1640 // Expected framework name looks like "Foo.framework"
1641 QStringList parts = frameworkName.split(".");
1642 if (parts.count() < 2) {
1643 LogError() << "fixupFramework: Unexpected framework name" << frameworkName;
1644 return;
1645 }
1646
1647 // Assume framework binary path is Foo.framework/Foo
1648 QString frameworkBinary = frameworkName + QStringLiteral("/") + parts[0];
1649
1650 // Xcode expects to find Foo.framework/Versions/A when code
1651 // signing, while qmake typically generates numeric versions.
1652 // Create symlink to the actual version in the framework.
1653 linkFilePrintStatus("Current", frameworkName + "/Versions/A");
1654
1655 // Set up @rpath structure.
1656 changeIdentification("@rpath/" + frameworkBinary, frameworkBinary);
1657 addRPath("@loader_path/../../Contents/Frameworks/", frameworkBinary);
1658}
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:1298
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:1102
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:1119
void deployQmlImport(const QString &appBundlePath, const QList< QString > &rpaths, const QString &importSourcePath, const QString &importName)
Definition shared.cpp:1286
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:1452
void codesignFile(const QString &identity, const QString &filePath)
Definition shared.cpp:1416
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:1308
void createQtConf(const QString &appBundlePath)
Definition shared.cpp:1246
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:1638
void deployPlugins(const QString &appBundlePath, DeploymentInfo deploymentInfo, bool useDebugLibs)
Definition shared.cpp:1276
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:1077
void createDiskImage(const QString &appBundlePath, const QString &filesystemType)
Definition shared.cpp:1602
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:1598
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