aboutsummaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@petroules.com>2014-01-16 13:27:48 -0500
committerJoerg Bornemann <joerg.bornemann@digia.com>2014-03-04 14:55:04 +0100
commitb13126f71d0b70dab117821903d9dc632b2c7ca6 (patch)
treefcdf1bfba1fa5954d5b6f8fb6886bfe92b5ffdd5 /share
parent1c20be2f88f9f539eb0fb8b3e76d03cebeb3f5d2 (diff)
Use PropertyList instead of plutil for increased performance.
Change-Id: I8ff5b11ed06bb2817e47a973d1a8043c5bcd3237 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'share')
-rw-r--r--share/qbs/modules/cpp/DarwinGCC.qbs56
-rw-r--r--share/qbs/modules/cpp/bundle-tools.js38
-rw-r--r--share/qbs/modules/ib/IBModule.qbs20
3 files changed, 51 insertions, 63 deletions
diff --git a/share/qbs/modules/cpp/DarwinGCC.qbs b/share/qbs/modules/cpp/DarwinGCC.qbs
index 7a4470533..0e368a294 100644
--- a/share/qbs/modules/cpp/DarwinGCC.qbs
+++ b/share/qbs/modules/cpp/DarwinGCC.qbs
@@ -1,6 +1,7 @@
import qbs 1.0
import qbs.File
import qbs.Process
+import qbs.PropertyList
import qbs.TextFile
import qbs.ModUtils
import "bundle-tools.js" as BundleTools
@@ -169,7 +170,7 @@ UnixGCC {
cmd.osBuildVersion = product.moduleProperty("qbs", "hostOSBuildVersion");
cmd.sourceCode = function() {
- var process, key;
+ var plist, process, key;
// Contains the combination of default, file, and in-source keys and values
// Start out with the contents of this file as the "base", if given
@@ -196,11 +197,13 @@ UnixGCC {
var platformInfo = {};
if (platformPath) {
if (File.exists(platformInfoPlist)) {
- process = new Process();
- process.exec("plutil", ["-convert", "json", "-o", "-",
- platformInfoPlist], true);
- platformInfo = JSON.parse(process.readStdOut());
- process.close();
+ plist = new PropertyList();
+ try {
+ plist.readFromFile(platformInfoPlist);
+ platformInfo = JSON.parse(plist.toJSONString());
+ } finally {
+ plist.clear();
+ }
var additionalProps = platformInfo["AdditionalInfo"];
for (key in additionalProps) {
@@ -227,11 +230,13 @@ UnixGCC {
var sdkSettings = {};
if (sysroot) {
if (File.exists(sdkSettingsPlist)) {
- process = new Process();
- process.exec("plutil", ["-convert", "json", "-o", "-",
- sdkSettingsPlist], true);
- sdkSettings = JSON.parse(process.readStdOut());
- process.close();
+ plist = new PropertyList();
+ try {
+ plist.readFromFile(sdkSettingsPlist);
+ sdkSettings = JSON.parse(plist.toJSONString());
+ } finally {
+ plist.clear();
+ }
} else {
print("warning: sysroot (SDK path) given but no SDKSettings.plist found");
}
@@ -241,11 +246,13 @@ UnixGCC {
var toolchainInfo = {};
if (toolchainInstallPath && File.exists(toolchainInfoPlist)) {
- process = new Process();
- process.exec("plutil", ["-convert", "json", "-o", "-",
- toolchainInfoPlist], true);
- toolchainInfo = JSON.parse(process.readStdOut());
- process.close();
+ plist = new PropertyList();
+ try {
+ plist.readFromFile(toolchainInfoPlist);
+ toolchainInfo = JSON.parse(plist.toJSONString());
+ } finally {
+ plist.clear();
+ }
} else {
print("could not find a ToolchainInfo.plist near the toolchain install path");
}
@@ -269,11 +276,6 @@ UnixGCC {
DarwinTools.doRepl(aggregatePlist, env, true);
}
- // Write the plist contents as JSON
- var infoplist = new TextFile(outputs.infoplist[0].filePath, TextFile.WriteOnly);
- infoplist.write(JSON.stringify(aggregatePlist));
- infoplist.close();
-
if (infoPlistFormat === "same-as-input" && infoPlistFile)
infoPlistFormat = BundleTools.infoPlistFormat(infoPlistFile);
@@ -282,10 +284,14 @@ UnixGCC {
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.exec("plutil", ["-convert", infoPlistFormat, outputs.infoplist[0].filePath], true);
- process.close();
+ // Write the plist contents in the format appropriate for the current platform
+ plist = new PropertyList();
+ try {
+ plist.readFromString(JSON.stringify(aggregatePlist));
+ plist.writeToFile(outputs.infoplist[0].filePath, infoPlistFormat);
+ } finally {
+ plist.clear();
+ }
}
return cmd;
}
diff --git a/share/qbs/modules/cpp/bundle-tools.js b/share/qbs/modules/cpp/bundle-tools.js
index 2de50308d..74d9b3417 100644
--- a/share/qbs/modules/cpp/bundle-tools.js
+++ b/share/qbs/modules/cpp/bundle-tools.js
@@ -27,16 +27,12 @@ function infoPlistContents(infoPlistFilePath)
if (infoPlistFilePath === undefined)
return undefined;
- var process = new Process();
+ var plist = new PropertyList();
try {
- process.start("plutil", ["-convert", "json", "-o", "-", infoPlistFilePath]);
- process.waitForFinished();
- if (process.exitCode() !== 0)
- throw("plutil: " + (process.readStdErr().trim() || process.readStdOut().trim()));
-
- return JSON.parse(process.readStdOut());
+ plist.readFromFile(infoPlistFilePath);
+ return JSON.parse(plist.toJSONString());
} finally {
- process.close();
+ plist.clear();
}
}
@@ -45,31 +41,13 @@ 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();
+ var plist = new PropertyList();
try {
- process.start("plutil", ["-lint", infoPlistFilePath]);
- process.waitForFinished();
- if (process.exitCode() !== 0)
- throw("plutil: " + (process.readStdErr().trim() || process.readStdOut().trim()));
+ plist.readFromFile(infoPlistFilePath);
+ return plist.format();
} finally {
- process.close();
+ plist.clear();
}
-
- process = new Process();
- process.start("file", ["-bI", infoPlistFilePath]);
- process.waitForFinished();
- var magic = process.readStdOut().trim();
- process.close();
-
- if (magic.indexOf("application/octet-stream;") === 0)
- return "binary1";
- else if (magic.indexOf("application/xml;") === 0)
- return "xml1";
- else if (magic.indexOf("text/plain;") === 0)
- return "json";
-
- return undefined;
}
// CONTENTS_FOLDER_PATH
diff --git a/share/qbs/modules/ib/IBModule.qbs b/share/qbs/modules/ib/IBModule.qbs
index 0a0049733..21117103d 100644
--- a/share/qbs/modules/ib/IBModule.qbs
+++ b/share/qbs/modules/ib/IBModule.qbs
@@ -87,14 +87,18 @@ Module {
if (process.exec("ibtool", ["--version"], true) !== 0)
print(process.readStdErr());
- var plist = new PropertyList();
- plist.readFromString(process.readStdOut());
-
- plist = JSON.parse(plist.toJSONString());
- if (plist)
- plist = plist["com.apple.ibtool.version"];
- if (plist)
- version = plist["short-bundle-version"];
+ var propertyList = new PropertyList();
+ try {
+ propertyList.readFromString(process.readStdOut());
+
+ var plist = JSON.parse(propertyList.toJSONString());
+ if (plist)
+ plist = plist["com.apple.ibtool.version"];
+ if (plist)
+ version = plist["short-bundle-version"];
+ } finally {
+ propertyList.clear();
+ }
} finally {
process.close();
}