Skip to content

Commit

Permalink
Merge pull request #1 from SBGSports/foc-2532-macdeploy-for-crosscompile
Browse files Browse the repository at this point in the history
FOC-2532: macdeployqt for cross compiled bundle
  • Loading branch information
oleksandrlynda authored Jan 18, 2024
2 parents 6f4e11d + 529ba71 commit 482ac0b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
Binary file removed bin/macdeployqt
Binary file not shown.
7 changes: 6 additions & 1 deletion macdeployqt_src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int main(int argc, char **argv)
appBundlePath = QString::fromLocal8Bit(argv[1]);

if (argc < 2 || appBundlePath.startsWith("-")) {
qDebug() << "Usage: macdeployqt app-bundle [options]";
qDebug() << "Usage: custom macdeployqt app-bundle [options]";
qDebug() << "";
qDebug() << "Options:";
qDebug() << " -verbose=<0-3> : 0 = no output, 1 = error/warning (default), 2 = normal, 3 = debug";
Expand All @@ -60,6 +60,7 @@ int main(int argc, char **argv)
qDebug() << " -appstore-compliant : Skip deployment of components that use private API";
qDebug() << " -libpath=<path> : Add the given path to the library search path";
qDebug() << " -fs=<filesystem> : Set the filesystem used for the .dmg disk image (defaults to HFS+)";
qDebug() << " -qtdir=<path> : Path for your custom Qt where default macdeployqt is invalid";
qDebug() << "";
qDebug() << "macdeployqt takes an application bundle as input and makes it";
qDebug() << "self-contained by copying in the Qt frameworks and plugins that";
Expand All @@ -77,6 +78,10 @@ int main(int argc, char **argv)
qDebug() << "";
qDebug() << "See the \"Deploying Applications on OS X\" topic in the";
qDebug() << "documentation for more information about deployment on OS X.";
qDebug() << "";
qDebug() << "Note:";
qDebug() << "Tested only for Focus.app -verbose=1 -qtdir=/.../qt-arm -qmldir=/.../SBGSource";
qDebug() << "";

return 1;
}
Expand Down
38 changes: 34 additions & 4 deletions macdeployqt_src/shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,30 @@ bool deployFramework = false;
using std::cout;
using std::endl;

namespace LibraryInfo {
QString location(QLibraryInfo::LibraryLocation loc)
{
switch(loc)
{
case QLibraryInfo::PrefixPath: return customQtPath;
case QLibraryInfo::DocumentationPath: return customQtPath + "/doc";
case QLibraryInfo::HeadersPath: return customQtPath + "/include";
case QLibraryInfo::LibrariesPath: return customQtPath + "/lib";
case QLibraryInfo::LibraryExecutablesPath: return customQtPath + "/libexec";
case QLibraryInfo::BinariesPath: return customQtPath + "/bin";
case QLibraryInfo::PluginsPath: return customQtPath + "/plugins";
case QLibraryInfo::ImportsPath: return customQtPath + "/imports";
case QLibraryInfo::Qml2ImportsPath: return customQtPath + "/qml";
case QLibraryInfo::ArchDataPath: return customQtPath;
case QLibraryInfo::DataPath: return customQtPath;
case QLibraryInfo::TranslationsPath: return customQtPath + "/translations";
case QLibraryInfo::ExamplesPath: return customQtPath + "examples";
case QLibraryInfo::TestsPath: return customQtPath + "/tests";
case QLibraryInfo::SettingsPath: return "/Library/Preferences/Qt";
}
}
};

bool operator==(const FrameworkInfo &a, const FrameworkInfo &b)
{
return ((a.frameworkPath == b.frameworkPath) && (a.binaryPath == b.binaryPath));
Expand Down Expand Up @@ -1034,8 +1058,9 @@ DeploymentInfo deployQtFrameworks(const QString &appBundlePath, const QStringLis
QStringList allBinaryPaths = QStringList() << applicationBundle.binaryPath << applicationBundle.libraryPaths
<< additionalExecutables;
QSet<QString> allLibraryPaths = getBinaryRPaths(applicationBundle.binaryPath, true);
allLibraryPaths.insert(QLibraryInfo::location(QLibraryInfo::LibrariesPath));
allLibraryPaths.insert(LibraryInfo::location(QLibraryInfo::LibrariesPath));
QList<FrameworkInfo> frameworks = getQtFrameworksForPaths(allBinaryPaths, appBundlePath, allLibraryPaths, useDebugLibs);

if (frameworks.isEmpty() && !alwaysOwerwriteEnabled) {
LogWarning();
LogWarning() << "Could not find any external Qt frameworks to deploy in" << appBundlePath;
Expand Down Expand Up @@ -1257,11 +1282,16 @@ bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInf
LogNormal() << "QML module search path(s) is" << qmlImportPaths;

// Use qmlimportscanner from QLibraryInfo::BinariesPath
QString qmlImportScannerPath = QDir::cleanPath(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlimportscanner");
QString qmlImportScannerPath = QDir::cleanPath(LibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlimportscanner");
qDebug() << "Looking for qmlimportscanner in: " << qmlImportScannerPath;


// Fallback: Look relative to the macdeployqt binary
if (!QFile(qmlImportScannerPath).exists())
if (!QFile(qmlImportScannerPath).exists()) {
qmlImportScannerPath = QCoreApplication::applicationDirPath() + "/qmlimportscanner";
qInfo() << "Failed, looking for qmlimportscanner in macdeployqt dir path" << qmlImportScannerPath;
}


// Verify that we found a qmlimportscanner binary
if (!QFile(qmlImportScannerPath).exists()) {
Expand All @@ -1279,7 +1309,7 @@ bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInf
}
for (const QString &importPath : qmlImportPaths)
argumentList << "-importPath" << importPath;
QString qmlImportsPath = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
QString qmlImportsPath = LibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
argumentList.append( "-importPath");
argumentList.append(qmlImportsPath);

Expand Down

0 comments on commit 482ac0b

Please sign in to comment.