diff options
author | Jake Petroules <jake.petroules@theqtcompany.com> | 2015-09-20 01:11:22 -0700 |
---|---|---|
committer | Jake Petroules <jake.petroules@theqtcompany.com> | 2015-09-25 07:37:42 +0000 |
commit | 010637125b556223fbb70f5c8ab49cea07220fe7 (patch) | |
tree | 08a2b1a20168cfcefcda02622b715184bd514b24 /share/qbs/modules/xcode | |
parent | 8efec0f4a04058a728d18aac0ee8c34f1ba0f971 (diff) | |
download | qbs-010637125b556223fbb70f5c8ab49cea07220fe7.tar.gz |
Add support for entitlements to the code signing process.
Change-Id: I14111b46f0b0a864a27b86618ad716b35c074d64
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Diffstat (limited to 'share/qbs/modules/xcode')
-rw-r--r-- | share/qbs/modules/xcode/xcode.qbs | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/share/qbs/modules/xcode/xcode.qbs b/share/qbs/modules/xcode/xcode.qbs index 06e11c354..d1324bf3b 100644 --- a/share/qbs/modules/xcode/xcode.qbs +++ b/share/qbs/modules/xcode/xcode.qbs @@ -1,8 +1,10 @@ import qbs +import qbs.BundleTools import qbs.File import qbs.FileInfo import qbs.DarwinTools import qbs.ModUtils +import qbs.PropertyList import 'xcode.js' as Utils Module { @@ -60,6 +62,8 @@ Module { return _actualSigningIdentity[0][1]; } + property path signingEntitlements + property string provisioningProfile property path provisioningProfilePath: { var files = _availableProvisioningProfiles; @@ -205,4 +209,89 @@ Module { v.set(); } } + + Group { + name: "Provisioning Profile" + files: xcode.provisioningProfilePath + ? [xcode.provisioningProfilePath] + : [] + } + + FileTagger { + fileTags: ["xcode.provisioningprofile"] + patterns: ["*.mobileprovision", "*.provisionprofile"] + } + + Rule { + multiplex: true + inputs: ["xcode.provisioningprofile"] + + Artifact { + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.targetName + ".xcent") + fileTags: ["xcent"] + } + + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating entitlements"; + cmd.highlight = "codegen"; + cmd.bundleIdentifier = product.moduleProperty("bundle", "identifier"); + cmd.signingEntitlements = ModUtils.moduleProperty(product, "signingEntitlements"); + cmd.platformPath = ModUtils.moduleProperty(product, "platformPath"); + cmd.sdkPath = ModUtils.moduleProperty(product, "sdkPath"); + cmd.sourceCode = function() { + var provData = Utils.readProvisioningProfileData( + inputs["xcode.provisioningprofile"][0].filePath); + + var aggregateEntitlements = {}; + + // Start building up an aggregate entitlements plist from the files in the SDKs, + // which contain placeholders in the same manner as Info.plist + function entitlementsFileContents(path) { + return File.exists(path) ? BundleTools.infoPlistContents(path) : undefined; + } + var entitlementsSources = [ + entitlementsFileContents(FileInfo.joinPaths(platformPath, "Entitlements.plist")), + entitlementsFileContents(FileInfo.joinPaths(sdkPath, "Entitlements.plist")), + entitlementsFileContents(signingEntitlements) + ]; + + for (var i = 0; i < entitlementsSources.length; ++i) { + var contents = entitlementsSources[i]; + for (var key in contents) { + if (contents.hasOwnProperty(key)) + aggregateEntitlements[key] = contents[key]; + } + } + + contents = provData["Entitlements"]; + for (key in contents) { + if (contents.hasOwnProperty(key) && !aggregateEntitlements.hasOwnProperty(key)) + aggregateEntitlements[key] = contents[key]; + } + + // Expand entitlements variables with data from the provisioning profile + var env = { + "AppIdentifierPrefix": provData["ApplicationIdentifierPrefix"] + ".", + "CFBundleIdentifier": bundleIdentifier + }; + DarwinTools.expandPlistEnvironmentVariables(aggregateEntitlements, env, true); + + // Anything with an undefined or otherwise empty value should be removed + // Only JSON-formatted plists can have null values, other formats error out + // This also follows Xcode behavior + DarwinTools.cleanPropertyList(aggregateEntitlements); + + var plist = new PropertyList(); + try { + plist.readFromObject(aggregateEntitlements); + plist.writeToFile(outputs.xcent[0].filePath, "xml1"); + } finally { + plist.clear(); + } + }; + return [cmd]; + } + } } |