aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@petroules.com>2013-06-18 11:44:52 -0400
committerJoerg Bornemann <joerg.bornemann@digia.com>2013-06-19 12:08:50 +0200
commit42a1b4f3e0047688ad34cda3a8628a6a9ff1af1a (patch)
treefc0765986bc8b6d9188e7737d2574b2e86b35319
parentcc1d95bb7ded0337ab27fd1b6c6206452d6dcd14 (diff)
Implement the infoPlistFormat property.
Task-number: QBS-329 Change-Id: I749123ba13e537e476dc76767254bc9029a1c1cc Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
-rw-r--r--doc/qbs.qdoc12
-rw-r--r--share/qbs/modules/cpp/DarwinGCC.qbs20
-rw-r--r--share/qbs/modules/cpp/bundle-tools.js38
3 files changed, 66 insertions, 4 deletions
diff --git a/doc/qbs.qdoc b/doc/qbs.qdoc
index 4d35c6b16..0520ab406 100644
--- a/doc/qbs.qdoc
+++ b/doc/qbs.qdoc
@@ -1292,6 +1292,18 @@
Finally, variable expansions will be performed such that substrings of the form ${VAR} will be
replaced with their corresponding environment variables.
+ \section2 infoPlistFormat
+
+ \table
+ \row \li \b{Type:} \li \c{string}
+ \row \li \b{Allowed Values:} \li \c{"xml1"}, \c{"binary1"}, \c{"json"}, \c{"same-as-input"}
+ \row \li \b{Default:} \li \c{"binary1"} for iOS; \c{"same-as-input"} or \c{"xml1"}
+ for OS X depending on whether \c{infoPlistFile} is
+ specified; undefined for all other operating systems.
+ \endtable
+
+ The file format to write the product's resulting Info.plist in.
+
\section1 Properties Specific to iOS
diff --git a/share/qbs/modules/cpp/DarwinGCC.qbs b/share/qbs/modules/cpp/DarwinGCC.qbs
index 296644d97..497afda72 100644
--- a/share/qbs/modules/cpp/DarwinGCC.qbs
+++ b/share/qbs/modules/cpp/DarwinGCC.qbs
@@ -13,6 +13,12 @@ UnixGCC {
property path infoPlistFile
property var infoPlist
property bool processInfoPlist: true
+ property string infoPlistFormat: {
+ if (qbs.targetOS.contains("osx"))
+ return infoPlistFile ? "same-as-input" : "xml1"
+ else if (qbs.targetOS.contains("ios"))
+ return "binary1"
+ }
property bool buildDsym: qbs.buildVariant === "release"
property var buildEnv: {
var env = {
@@ -131,6 +137,7 @@ UnixGCC {
cmd.infoPlistFile = ModUtils.moduleProperty(product, "infoPlistFile");
cmd.infoPlist = ModUtils.moduleProperty(product, "infoPlist") || {};
cmd.processInfoPlist = ModUtils.moduleProperty(product, "processInfoPlist");
+ cmd.infoPlistFormat = ModUtils.moduleProperty(product, "infoPlistFormat");
cmd.platformPath = product.moduleProperty("cpp", "platformPath");
cmd.toolchainInstallPath = product.moduleProperty("cpp", "toolchainInstallPath");
cmd.sysroot = product.moduleProperty("qbs", "sysroot");
@@ -234,12 +241,17 @@ UnixGCC {
infoplist.write(JSON.stringify(aggregatePlist));
infoplist.close();
+ if (infoPlistFormat === "same-as-input" && infoPlistFile)
+ infoPlistFormat = BundleTools.infoPlistFormat(infoPlistFile);
+
+ var validFormats = [ "xml1", "binary1", "json" ];
+ if (!validFormats.contains(infoPlistFormat))
+ throw("Invalid Info.plist format " + infoPlistFormat + ". " +
+ "Must be in [xml1, binary1, json].");
+
// Convert the written file to the format appropriate for the current platform
process = new Process();
- process.start("plutil", ["-convert",
- product.moduleProperty("qbs", "targetOS").contains("ios")
- ? "binary1" : "xml1",
- outputs.infoplist[0].fileName]);
+ process.start("plutil", ["-convert", infoPlistFormat, outputs.infoplist[0].fileName]);
process.waitForFinished();
}
return cmd;
diff --git a/share/qbs/modules/cpp/bundle-tools.js b/share/qbs/modules/cpp/bundle-tools.js
index 31a336b0b..25fb8dcb6 100644
--- a/share/qbs/modules/cpp/bundle-tools.js
+++ b/share/qbs/modules/cpp/bundle-tools.js
@@ -33,6 +33,44 @@ function infoPlistContents(infoPlistFilePath)
return JSON.parse(process.readAll());
}
+function infoPlistFormat(infoPlistFilePath)
+{
+ if (infoPlistFilePath === undefined)
+ return undefined;
+
+ // Verify that the Info.plist format is actually valid in the first place
+ var process = new Process();
+ process.start("plutil", ["-lint", infoPlistFilePath]);
+ process.waitForFinished();
+ var lint = process.readAll().trim();
+ if (lint.indexOf(infoPlistFilePath + ": ") !== 0)
+ throw("Unexpected output from plutil command: " + lint);
+
+ lint = lint.slice(infoPlistFilePath.length + 2);
+
+ if (lint !== "OK")
+ throw("Info.plist was in an invalid format: " + lint);
+
+ process = new Process();
+ process.start("file", [infoPlistFilePath]);
+ process.waitForFinished();
+ var magic = process.readAll().trim();
+
+ if (magic.indexOf(infoPlistFilePath + ": ") !== 0)
+ throw("Unexpected output from file command: " + magic);
+
+ magic = magic.slice(infoPlistFilePath.length + 2);
+
+ if (magic === "Apple binary property list")
+ return "binary1";
+ else if (magic.indexOf("XML") === 0)
+ return "xml1";
+ else if (magic.indexOf("UTF-8 Unicode text") === 0)
+ return "json";
+
+ return undefined;
+}
+
// CONTENTS_FOLDER_PATH
// Main bundle directory
// the version parameter is only used for framework bundles