summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@theqtcompany.com>2016-02-22 09:50:33 +0100
committerMorten Johan Sørvig <morten.sorvig@theqtcompany.com>2016-02-22 09:40:21 +0000
commitd63a58095f3d43a69bfb16d3d064455da8a8a6ab (patch)
tree92227f1193b4490e0c8a61cb82af6c7d3645cd39
parent6c2f485638a1c91fe4bfc4ff552db81fbc807499 (diff)
nacldeployqt: add “compress” option
Runs pnacl-compress. Change-Id: Ia5a1ccefcc879b7df27b8a8cb4fa7ccec2bd544f Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
-rw-r--r--src/tools/nacldeployqt/main.cpp37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/tools/nacldeployqt/main.cpp b/src/tools/nacldeployqt/main.cpp
index aa86fd9a0f..fac933972e 100644
--- a/src/tools/nacldeployqt/main.cpp
+++ b/src/tools/nacldeployqt/main.cpp
@@ -22,6 +22,7 @@ public:
bool print;
bool run;
bool debug;
+ bool compress;
bool testlibMode;
QString binary;
QString qtBaseDir;
@@ -41,6 +42,8 @@ private:
QString stdoutCaptureFile;
QString stderrCaptureFile;
+
+ QString findPNaClTool(const QString &sdkRoot, const QString &toolName);
QList<QByteArray> quote(const QList<QByteArray> &list);
void runCommand(const QString &command);
bool copyRecursively(const QString &srcFilePath, const QString &tgtFilePath);
@@ -111,7 +114,7 @@ int QtNaclDeployer::deploy()
return 0;
}
- // Get the location of the deployment scripts in the nacl sdk:
+ // Get the location of the deployment scripts and tools in the nacl sdk:
QString createNmf = naclSdkRoot + "/tools/create_nmf.py";
if (!QFile(createNmf).exists()) {
qDebug() << "create_nmf.py not found at" << createNmf;
@@ -122,14 +125,19 @@ int QtNaclDeployer::deploy()
qDebug() << "create_html.py not found at" << createHtml;
return 0;
}
- QString pnaclFinalize = naclSdkRoot + "/toolchain/mac_pnacl/bin/pnacl-finalize";
- if (!QFile(pnaclFinalize).exists())
- pnaclFinalize = naclSdkRoot + "/toolchain/linux_pnacl/bin/pnacl-finalize";
- if (!QFile(pnaclFinalize).exists()) {
+
+ QString pnaclFinalize = findPNaClTool(naclSdkRoot, "pnacl-finalize");
+ if (deploymentType == PNaCl && !QFile(pnaclFinalize).exists()) {
qDebug() << "pnacl-finalize not found at" << pnaclFinalize;
return 0;
}
+ QString pnaclCompress = findPNaClTool(naclSdkRoot, "pnacl-compress");
+ if (deploymentType == PNaCl && compress && !QFile(pnaclCompress).exists()) {
+ qDebug() << "pnacl-compress not found at" << pnaclCompress;
+ return 0;
+ }
+
QString qtLibDir = qtBaseDir + "/lib";
QString qtBinDir = qtBaseDir + "/bin";
QString qtImportsDir = qtBaseDir + "/qml";
@@ -173,6 +181,7 @@ int QtNaclDeployer::deploy()
// On PNaCl, the output from "make" is a bitcode .bc file. Create
// a .pexe suitable for distribution using "pnacl-finalize".
if (deploymentType == PNaCl) {
+ qDebug() << "pnacl-finalize" << binary;
finalBinary.replace(".bc", ".pexe");
QString finalizeCommand = pnaclFinalize + " -o " + outDir + finalBinary + " " + binary;
runCommand(finalizeCommand);
@@ -182,6 +191,13 @@ int QtNaclDeployer::deploy()
const QString finalBinaryPath = outDir + finalBinary;
+ // Compress PNaCl binary using panacl-compress.
+ if (deploymentType == PNaCl && compress) {
+ qDebug() << "pnacl-compress" << finalBinaryPath;
+ QString compressCommand = pnaclCompress + " " + finalBinaryPath;
+ runCommand(compressCommand.toLatin1().constData());
+ }
+
// create the .nmf manifest file
if (deploymentType != Emscripten) {
QString nmfCommand = QStringLiteral("python ") + createNmf
@@ -346,6 +362,15 @@ int QtNaclDeployer::deploy()
return 0;
}
+// Look up executable in the mac and linux bin dirs.
+QString QtNaclDeployer::findPNaClTool(const QString &sdkRoot, const QString &toolName)
+{
+ QString pnaclFinalize = sdkRoot + "/toolchain/mac_pnacl/bin/" + toolName;
+ if (!QFile(pnaclFinalize).exists())
+ pnaclFinalize = sdkRoot + "/toolchain/linux_pnacl/bin/" + toolName;
+ return pnaclFinalize;
+}
+
QList<QByteArray> QtNaclDeployer::quote(const QList<QByteArray> &list)
{
QList<QByteArray> result;
@@ -440,6 +465,7 @@ int main(int argc, char **argv)
parser.addOption(QCommandLineOption(QStringList() << "p" << "print", "Print Chrome and debugging help."));
parser.addOption(QCommandLineOption(QStringList() << "r" << "run", "Run the application in Chrome."));
parser.addOption(QCommandLineOption(QStringList() << "d" << "debug", "Debug the application in Chrome [OS X only]."));
+ parser.addOption(QCommandLineOption(QStringList() << "c" << "compress", "Compress the application binary with pnacl-compress [PNaCl only]."));
parser.addOption(QCommandLineOption(QStringList() << "e" << "testlib", "Run in QTestLib mode"));
parser.process(app);
@@ -453,6 +479,7 @@ int main(int argc, char **argv)
deployer.print = parser.isSet("print");
deployer.run = parser.isSet("run");
deployer.debug = parser.isSet("debug");
+ deployer.compress = parser.isSet("compress");
deployer.testlibMode = parser.isSet("testlib");
#ifdef Q_OS_LINUX