Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
probonopd committed May 26, 2017
2 parents a3a6376 + 195b793 commit 01056fa
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ These projects are already using [Travis CI](http://travis-ci.org/) and linuxdep
- https://github.com/crapp/labpowerqt/
- https://github.com/probonopd/linuxdeployqt/ obviously ;-)
- https://github.com/xdgurl/xdgurl
- https://github.com/QNapi/qnapi

This project is already using linuxdeployqt in a custom Jenkins workflow:
- https://github.com/appimage-packages/
Expand Down
1 change: 1 addition & 0 deletions linuxdeployqt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ int main(int argc, char **argv)
if (deploymentInfo.pluginPath.isEmpty())
deploymentInfo.pluginPath = QDir::cleanPath(deploymentInfo.qtPath + "/../plugins");
deployPlugins(appDirPath, deploymentInfo);
createQtConf(appDirPath);
}

if (runStripEnabled)
Expand Down
80 changes: 77 additions & 3 deletions shared/shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ bool alwaysOwerwriteEnabled = false;
QStringList librarySearchPath;
bool appstoreCompliant = false;
int logLevel = 1;
int qtDetected = 0;
bool deployLibrary = false;

using std::cout;
Expand Down Expand Up @@ -889,7 +890,6 @@ DeploymentInfo deployQtLibraries(const QString &appDirPath, const QStringList &a
LogDebug() << "applicationBundle.binaryPath:" << applicationBundle.binaryPath;

// Find out whether Qt is a dependency of the application to be bundled
int qtDetected = 0;
LddInfo lddInfo = findDependencyInfo(appBinaryPath);
foreach (const DylibInfo dep, lddInfo.dependencies) {
LogDebug() << "dep.binaryPath" << dep.binaryPath;
Expand Down Expand Up @@ -933,6 +933,7 @@ DeploymentInfo deployQtLibraries(const QString &appDirPath, const QStringList &a
}

QString output = captureOutput(qmakePath + " -query");
LogDebug() << "-query output from qmake:" << output;

QStringList outputLines = output.split("\n", QString::SkipEmptyParts);
foreach (const QString &outputLine, outputLines) {
Expand Down Expand Up @@ -1107,6 +1108,8 @@ void deployPlugins(const AppDirInfo &appDirInfo, const QString &pluginSourcePath
sourcePath = QDir::cleanPath(qtLibexecPath + "/QtWebEngineProcess");
destinationPath = QDir::cleanPath(dstLibexec + "/QtWebEngineProcess");
copyFilePrintStatus(sourcePath, destinationPath);
// put qt.conf file next to browser process so it can also make use of our local Qt resources
createQtConfForQtWebEngineProcess(dstLibexec);
// Resources:
sourcePath = QDir::cleanPath(qtDataPath + "/resources/qtwebengine_resources.pak");
destinationPath = QDir::cleanPath(dstResources + "/qtwebengine_resources.pak");
Expand Down Expand Up @@ -1152,6 +1155,72 @@ void deployPlugins(const AppDirInfo &appDirInfo, const QString &pluginSourcePath
}
}

void createQtConf(const QString &appDirPath)
{
// Set Plugins and imports paths. These are relative to QCoreApplication::applicationDirPath()
// which is where the main executable resides; see http://doc.qt.io/qt-5/qt-conf.html
// See https://github.com/probonopd/linuxdeployqt/issues/ 75, 98, 99
QByteArray contents;
if(fhsLikeMode){
contents = "# Generated by linuxdeployqt\n"
"# https://github.com/probonopd/linuxdeployqt/\n"
"[Paths]\n"
"Prefix = ../\n"
"Plugins = plugins\n"
"Imports = qml\n"
"Qml2Imports = qml\n";
} else {
contents = "# Generated by linuxdeployqt\n"
"# https://github.com/probonopd/linuxdeployqt/\n"
"[Paths]\n"
"Prefix = ./\n"
"Plugins = plugins\n"
"Imports = qml\n"
"Qml2Imports = qml\n";
}

QString filePath = appDirPath + "/"; // Is picked up when placed next to the main executable
QString fileName = QDir::cleanPath(appBinaryPath + "/../qt.conf");

QDir().mkpath(filePath);

QFile qtconf(fileName);
if (qtconf.exists() && !alwaysOwerwriteEnabled) {

LogWarning() << fileName << "already exists, will not overwrite.";
return;
}

qtconf.open(QIODevice::WriteOnly);
if (qtconf.write(contents) != -1) {
LogNormal() << "Created configuration file:" << fileName;
}
}

void createQtConfForQtWebEngineProcess(const QString &appDirPath)
{
QByteArray contents = "# Generated by linuxdeployqt\n"
"# https://github.com/probonopd/linuxdeployqt/\n"
"[Paths]\n"
"Prefix = ../\n";
QString filePath = appDirPath + "/";
QString fileName = filePath + "qt.conf";

QDir().mkpath(filePath);

QFile qtconf(fileName);
if (qtconf.exists() && !alwaysOwerwriteEnabled) {
LogWarning() << fileName << "already exists, will not overwrite.";
return;
}

qtconf.open(QIODevice::WriteOnly);
if (qtconf.write(contents) != -1) {
LogNormal() << "Created configuration file for Qt WebEngine process:" << fileName;
LogNormal() << "This file sets the prefix option to parent directory of browser process executable";
}
}

void deployPlugins(const QString &appDirPath, DeploymentInfo deploymentInfo)
{
AppDirInfo applicationBundle;
Expand Down Expand Up @@ -1195,6 +1264,11 @@ void deployQmlImport(const QString &appDirPath, const QSet<QString> &rpaths, con
// Scan qml files in qmldirs for import statements, deploy used imports from Qml2ImportsPath to ./qml.
bool deployQmlImports(const QString &appDirPath, DeploymentInfo deploymentInfo, QStringList &qmlDirs)
{
if(!qtDetected){
LogDebug() << "Skipping QML imports since no Qt detected";
return false;
}

LogNormal() << "";
LogNormal() << "Deploying QML imports ";
LogNormal() << "Application QML file search path(s) is" << qmlDirs;
Expand All @@ -1212,8 +1286,8 @@ bool deployQmlImports(const QString &appDirPath, DeploymentInfo deploymentInfo,
// Verify that we found a qmlimportscanner binary
if (!QFile(qmlImportScannerPath).exists()) {
LogError() << "qmlimportscanner not found at" << qmlImportScannerPath;
LogError() << "Rebuild qtdeclarative/tools/qmlimportscanner";
return false;
LogError() << "Please install it if you want to bundle QML based applications.";
return true;
}

// build argument list for qmlimportsanner: "-rootPath foo/ -rootPath bar/ -importPath path/to/qt/qml"
Expand Down
2 changes: 2 additions & 0 deletions shared/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ DeploymentInfo deployQtLibraries(const QString &appDirPath,
const QStringList &additionalExecutables,
const QString &qmake);
DeploymentInfo deployQtLibraries(QList<LibraryInfo> libraries,const QString &bundlePath, const QStringList &binaryPaths, bool useLoaderPath);
void createQtConf(const QString &appDirPath);
void createQtConfForQtWebEngineProcess(const QString &appDirPath);
void deployPlugins(const QString &appDirPath, DeploymentInfo deploymentInfo);
bool deployQmlImports(const QString &appDirPath, DeploymentInfo deploymentInfo, QStringList &qmlDirs);
void changeIdentification(const QString &id, const QString &binaryPath);
Expand Down
2 changes: 1 addition & 1 deletion tests/tests-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
sudo add-apt-repository --yes ppa:beineri/opt-qt58-trusty
sudo apt-get update -qq

git clone https://github.com/NixOS/patchelf.git
git clone -o 44b7f95 https://github.com/NixOS/patchelf.git
cd patchelf
bash ./bootstrap.sh
./configure
Expand Down

0 comments on commit 01056fa

Please sign in to comment.