1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the tools applications of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 #ifndef MAC_DEPLOMYMENT_SHARED_H
29 #define MAC_DEPLOMYMENT_SHARED_H
30 
31 #include <QString>
32 #include <QStringList>
33 #include <QDebug>
34 #include <QSet>
35 #include <QVersionNumber>
36 
37 extern int logLevel;
38 #define LogError()      if (logLevel < 0) {} else qDebug() << "ERROR:"
39 #define LogWarning()    if (logLevel < 1) {} else qDebug() << "WARNING:"
40 #define LogNormal()     if (logLevel < 2) {} else qDebug() << "Log:"
41 #define LogDebug()      if (logLevel < 3) {} else qDebug() << "Log:"
42 
43 extern bool runStripEnabled;
44 
45 class FrameworkInfo
46 {
47 public:
48     bool isDylib;
49     QString frameworkDirectory;
50     QString frameworkName;
51     QString frameworkPath;
52     QString binaryDirectory;
53     QString binaryName;
54     QString binaryPath;
55     QString rpathUsed;
56     QString version;
57     QString installName;
58     QString deployedInstallName;
59     QString sourceFilePath;
60     QString frameworkDestinationDirectory;
61     QString binaryDestinationDirectory;
62 
isDebugLibrary()63     bool isDebugLibrary() const
64     {
65         return binaryName.contains(QLatin1String("_debug"));
66     }
67 };
68 
69 class DylibInfo
70 {
71 public:
72     QString binaryPath;
73     QVersionNumber currentVersion;
74     QVersionNumber compatibilityVersion;
75 };
76 
77 class OtoolInfo
78 {
79 public:
80     QString installName;
81     QString binaryPath;
82     QVersionNumber currentVersion;
83     QVersionNumber compatibilityVersion;
84     QList<DylibInfo> dependencies;
85 };
86 
87 bool operator==(const FrameworkInfo &a, const FrameworkInfo &b);
88 QDebug operator<<(QDebug debug, const FrameworkInfo &info);
89 
90 class ApplicationBundleInfo
91 {
92     public:
93     QString path;
94     QString binaryPath;
95     QStringList libraryPaths;
96 };
97 
98 class DeploymentInfo
99 {
100 public:
101     QString qtPath;
102     QString pluginPath;
103     QStringList deployedFrameworks;
104     QSet<QString> rpathsUsed;
105     bool useLoaderPath;
106     bool isFramework;
107     bool isDebug;
108 
109     bool containsModule(const QString &module, const QString &libInFix) const;
110 };
111 
112 inline QDebug operator<<(QDebug debug, const ApplicationBundleInfo &info);
113 
114 void changeQtFrameworks(const QString appPath, const QString &qtPath, bool useDebugLibs);
115 void changeQtFrameworks(const QList<FrameworkInfo> frameworks, const QStringList &binaryPaths, const QString &qtPath);
116 
117 OtoolInfo findDependencyInfo(const QString &binaryPath);
118 FrameworkInfo parseOtoolLibraryLine(const QString &line, const QString &appBundlePath, const QSet<QString> &rpaths, bool useDebugLibs);
119 QString findAppBinary(const QString &appBundlePath);
120 QList<FrameworkInfo> getQtFrameworks(const QString &path, const QString &appBundlePath, const QSet<QString> &rpaths, bool useDebugLibs);
121 QList<FrameworkInfo> getQtFrameworks(const QStringList &otoolLines, const QString &appBundlePath, const QSet<QString> &rpaths, bool useDebugLibs);
122 QString copyFramework(const FrameworkInfo &framework, const QString path);
123 DeploymentInfo deployQtFrameworks(const QString &appBundlePath, const QStringList &additionalExecutables, bool useDebugLibs);
124 DeploymentInfo deployQtFrameworks(QList<FrameworkInfo> frameworks,const QString &bundlePath, const QStringList &binaryPaths, bool useDebugLibs, bool useLoaderPath);
125 void createQtConf(const QString &appBundlePath);
126 void deployPlugins(const QString &appBundlePath, DeploymentInfo deploymentInfo, bool useDebugLibs);
127 bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInfo, QStringList &qmlDirs, QStringList &qmlImportPaths);
128 void changeIdentification(const QString &id, const QString &binaryPath);
129 void changeInstallName(const QString &oldName, const QString &newName, const QString &binaryPath);
130 void runStrip(const QString &binaryPath);
131 void stripAppBinary(const QString &bundlePath);
132 QString findAppBinary(const QString &appBundlePath);
133 QStringList findAppFrameworkNames(const QString &appBundlePath);
134 QStringList findAppFrameworkPaths(const QString &appBundlePath);
135 void codesignFile(const QString &identity, const QString &filePath);
136 QSet<QString> codesignBundle(const QString &identity,
137                              const QString &appBundlePath,
138                              QList<QString> additionalBinariesContainingRpaths);
139 void codesign(const QString &identity, const QString &appBundlePath);
140 void createDiskImage(const QString &appBundlePath, const QString &filesystemType);
141 void fixupFramework(const QString &appBundlePath);
142 
143 
144 #endif
145