aboutsummaryrefslogtreecommitdiffstats
path: root/share/qbs/modules/cpp
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@petroules.com>2013-05-30 16:14:05 -0400
committerJoerg Bornemann <joerg.bornemann@digia.com>2013-05-31 17:16:48 +0200
commit187658847cedd62ae0a3f9ef407a8b59020364b4 (patch)
tree676a60e04b421687f34bb1e762bb5dd19e6e66e5 /share/qbs/modules/cpp
parent487d42f9b22a2990335ed1d5255115525a6fa5ba (diff)
Centralize Info.plist/bundle handling code.
The differences in plist/bundle handling between OS X and iOS are extremely minimal, so there is no reason to duplicate such a large block of code between their respective module files. As a side effect, this implements support for dictionaries and arrays in OS X plists as well as the defaults handling that already existed for iOS. As an additional side effect, QBS-272 is no longer an issue. Change-Id: I39be5681f4d4fba7369d55da720ff8130ff52cba Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'share/qbs/modules/cpp')
-rw-r--r--share/qbs/modules/cpp/DarwinGCC.qbs96
-rw-r--r--share/qbs/modules/cpp/ios-gcc.qbs84
-rw-r--r--share/qbs/modules/cpp/mac-gcc.qbs95
3 files changed, 112 insertions, 163 deletions
diff --git a/share/qbs/modules/cpp/DarwinGCC.qbs b/share/qbs/modules/cpp/DarwinGCC.qbs
index 413c91274..e5b76003a 100644
--- a/share/qbs/modules/cpp/DarwinGCC.qbs
+++ b/share/qbs/modules/cpp/DarwinGCC.qbs
@@ -45,6 +45,74 @@ UnixGCC {
}
Rule {
+ multiplex: true
+ inputs: ["qbs"]
+
+ Artifact {
+ fileName: product.targetName + ".app/" +
+ (product.moduleProperty("qbs", "targetOS") === "mac" ? "Contents/" : "") +
+ "Info.plist"
+ fileTags: ["infoplist"]
+ }
+
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = "generating Info.plist";
+ cmd.highlight = "codegen";
+ cmd.infoPlist = ModUtils.moduleProperty(product, "infoPlist") || {};
+ cmd.platformPath = product.moduleProperty("cpp", "platformPath");
+ cmd.sourceCode = function() {
+ var defaultValues = ModUtils.moduleProperty(product, "defaultInfoPlist");
+ var key;
+ for (key in defaultValues) {
+ if (defaultValues.hasOwnProperty(key) && !(key in infoPlist))
+ infoPlist[key] = defaultValues[key];
+ }
+
+ var process;
+ if (platformPath) {
+ process = new Process();
+ process.start("plutil", ["-convert", "json", "-o", "-",
+ platformPath + "/Info.plist"]);
+ process.waitForFinished();
+ platformInfo = JSON.parse(process.readAll());
+
+ var additionalProps = platformInfo["AdditionalInfo"];
+ for (key in additionalProps) {
+ if (additionalProps.hasOwnProperty(key) && !(key in infoPlist)) // override infoPlist?
+ infoPlist[key] = defaultValues[key];
+ }
+
+ if (product.moduleProperty("qbs", "targetOS") === "ios") {
+ key = "UIDeviceFamily";
+ if (key in platformInfo && !(key in infoPlist))
+ infoPlist[key] = platformInfo[key];
+ }
+ } else {
+ print("Missing platformPath property");
+ }
+
+ process = new Process();
+ process.start("sw_vers", ["-buildVersion"]);
+ process.waitForFinished();
+ infoPlist["BuildMachineOSBuild"] = process.readAll().trim();
+
+ var infoplist = new TextFile(outputs.infoplist[0].fileName, TextFile.WriteOnly);
+ infoplist.write(JSON.stringify(infoPlist));
+ infoplist.close();
+
+ process = new Process();
+ process.start("plutil", ["-convert",
+ product.moduleProperty("qbs", "targetOS") === "ios"
+ ? "binary1" : "xml1",
+ outputs.infoplist[0].fileName]);
+ process.waitForFinished();
+ }
+ return cmd;
+ }
+ }
+
+ Rule {
condition: product.moduleProperty("cpp", "buildDsym")
inputs: ["application"]
@@ -60,4 +128,32 @@ UnixGCC {
return cmd;
}
}
+
+ Rule {
+ multiplex: true
+ inputs: {
+ var res = ["application", "infoplist", "pkginfo"];
+ // if (product.moduleProperty("cpp", "buildDsym")) // should work like that in the future
+ res.push("dsym");
+ if (product.moduleProperty("qbs", "targetOS") === "ios") {
+ res.push("resourcerules");
+ // if (ModUtils.moduleProperty(product, "buildIpa")) // ditto
+ res.push("ipa");
+ }
+ return res;
+ }
+
+ Artifact {
+ fileName: product.targetName + ".app"
+ fileTags: ["applicationbundle"]
+ }
+
+ prepare: {
+ // This command is intentionally empty; it just lets the user know a bundle has been made
+ var cmd = new JavaScriptCommand();
+ cmd.description = "creating app bundle";
+ cmd.highlight = "codegen";
+ return cmd;
+ }
+ }
}
diff --git a/share/qbs/modules/cpp/ios-gcc.qbs b/share/qbs/modules/cpp/ios-gcc.qbs
index bba09d469..f67d967f9 100644
--- a/share/qbs/modules/cpp/ios-gcc.qbs
+++ b/share/qbs/modules/cpp/ios-gcc.qbs
@@ -54,66 +54,6 @@ DarwinGCC {
inputs: ["qbs"]
Artifact {
- fileName: product.targetName + ".app/Info.plist"
- fileTags: ["infoplist"]
- }
-
- prepare: {
- var cmd = new JavaScriptCommand();
- cmd.description = "generating Info.plist";
- cmd.highlight = "codegen";
- cmd.infoPlist = ModUtils.moduleProperty(product, "infoPlist") || {};
- cmd.platformPath = product.moduleProperty("cpp","platformPath");
- cmd.sourceCode = function() {
- var defaultValues = ModUtils.moduleProperty(product, "defaultInfoPlist");
- var key;
- for (key in defaultValues) {
- if (defaultValues.hasOwnProperty(key) && !(key in infoPlist))
- infoPlist[key] = defaultValues[key];
- }
-
- var process;
- if (platformPath) {
- process = new Process();
- process.start("plutil", ["-convert", "json", "-o", "-",
- platformPath + "/Info.plist"]);
- process.waitForFinished();
- platformInfo = JSON.parse(process.readAll());
-
- var additionalProps = platformInfo["AdditionalInfo"];
- for (key in additionalProps) {
- if (additionalProps.hasOwnProperty(key) && !(key in infoPlist)) // override infoPlist?
- infoPlist[key] = defaultValues[key];
- }
- key = "UIDeviceFamily";
- if (key in platformInfo && !(key in infoPlist))
- infoPlist[key] = platformInfo[key];
- } else {
- print("Missing platformPath property");
- }
-
- process = new Process();
- process.start("sw_vers", ["-buildVersion"]);
- process.waitForFinished();
- infoPlist["BuildMachineOSBuild"] = process.readAll().trim();
-
- var infoplist = new TextFile(outputs.infoplist[0].fileName, TextFile.WriteOnly);
- infoplist.write(JSON.stringify(infoPlist));
- infoplist.close();
-
- process = new Process();
- process.start("plutil", ["-convert", "binary1", outputs.infoplist[0].fileName]);
- process.waitForFinished();
- }
- return cmd;
- }
- }
-
- Rule {
- multiplex: true
- inputs: ["qbs"]
-
- Artifact {
fileName: product.targetName + ".app/ResourceRules.plist"
fileTags: ["resourcerules"]
}
@@ -166,28 +106,4 @@ DarwinGCC {
return cmd;
}
}
-
- Rule {
- multiplex: true
- inputs: {
- var res = ["application", "infoplist", "pkginfo", "resourcerules"];
- // if (product.moduleProperty("cpp", "buildDsym")) // should work like that in the future
- res.push("dsym");
- // if (ModUtils.moduleProperty(product, "buildIpa")) // ditto
- res.push("ipa");
- return res;
- }
-
- Artifact {
- fileName: product.targetName + ".app"
- fileTags: ["applicationbundle"]
- }
-
- prepare: {
- var cmd = new JavaScriptCommand();
- cmd.description = "creating app bundle";
- cmd.highlight = "codegen";
- return cmd;
- }
- }
}
diff --git a/share/qbs/modules/cpp/mac-gcc.qbs b/share/qbs/modules/cpp/mac-gcc.qbs
index 89f239047..83f483c14 100644
--- a/share/qbs/modules/cpp/mac-gcc.qbs
+++ b/share/qbs/modules/cpp/mac-gcc.qbs
@@ -5,85 +5,22 @@ import 'darwin-tools.js' as Tools
DarwinGCC {
condition: qbs.hostOS === 'mac' && qbs.targetOS === 'mac' && qbs.toolchain === 'gcc'
- Rule {
- multiplex: true
- inputs: ["qbs"]
-
- Artifact {
- fileName: product.targetName + ".app/Contents/Info.plist"
- fileTags: ["infoplist"]
- }
-
- prepare: {
- var cmd = new JavaScriptCommand();
- cmd.description = "generating Info.plist";
- cmd.highlight = "codegen";
- cmd.infoPlist = ModUtils.moduleProperty(product, "infoPlist") || {
- CFBundleDisplayName: product.targetName,
- CFBundleExecutable: product.targetName,
- CFBundleIconFile: product.targetName + ".icns",
- CFBundleInfoDictionaryVersion: "6.0",
- CFBundleName: product.targetName,
- CFBundlePackageType: "APPL",
- CFBundleSignature: "????"
- };
- cmd.sourceCode = function() {
- var infoplist = new TextFile(outputs.infoplist[0].fileName, TextFile.WriteOnly);
- infoplist.writeLine('<?xml version="1.0" encoding="UTF-8"?>');
- infoplist.writeLine('<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">');
- infoplist.writeLine('<plist version="1.0">');
- infoplist.writeLine('<dict>');
- for (var key in infoPlist) {
- infoplist.writeLine(' <key>' + key + '</key>');
- var value = infoPlist[key];
- // Plist files depends on variable types
- var type = typeof(value);
- if (type === "string") {
- // It's already ok
- } else if (type === "boolean") {
- if (value)
- type = "true";
- else
- type = "false";
- value = undefined;
- } else if (type === "number") {
- // Is there better way?
- if (value % 1 === 0)
- type = "integer";
- else
- type = "real";
- } else {
- // FIXME: Add Dict support:
- throw "Unsupported type '" + type + "'";
- }
- if (value === undefined)
- infoplist.writeLine(' <' + type + '/>');
- else
- infoplist.writeLine(' <' + type + '>' + value + '</' + type + '>');
- }
- infoplist.writeLine('</dict>');
- infoplist.writeLine('</plist>');
- infoplist.close();
- }
- return cmd;
- }
- }
-
- Rule {
- multiplex: true
- inputs: ["application", "infoplist", "pkginfo", "dsym"]
-
- Artifact {
- fileName: product.targetName + ".app"
- fileTags: ["applicationbundle"]
- }
-
- prepare: {
- // This command is intentionally empty; it just lets the user know a bundle has been made
- var cmd = new JavaScriptCommand();
- cmd.description = "creating app bundle";
- cmd.highlight = "codegen";
- return cmd;
+ defaultInfoPlist: {
+ var baseName = String(product.targetName).substring(product.targetName.lastIndexOf('/') + 1);
+ var baseNameRfc1034 = Tools.rfc1034(baseName);
+ var defaultVal = {
+ CFBundleName: baseName,
+ CFBundleIdentifier: "org.example." + baseNameRfc1034,
+ CFBundleInfoDictionaryVersion: "6.0",
+ CFBundleVersion: "1.0", // version of the app
+ CFBundleShortVersionString: "1.0", // user visible version of the app
+ CFBundleExecutable: baseName,
+ CFBundleDisplayName: baseName,
+ CFBundleIconFile: baseName + ".icns",
+ CFBundlePackageType: "APPL",
+ CFBundleSignature: "????", // legacy creator code in macOS Classic, can be ignored
+ CFBundleDevelopmentRegion: "en" // default localization
}
+ return defaultVal
}
}