import SCons.Util, os.path def generate(env) : def createAppBundle(env, bundle, version = "1.0", resources = [], frameworks = [], info = {}, handlesXMPPURIs = False, sparklePublicDSAKey = None) : bundleDir = bundle + ".app" bundleContentsDir = bundleDir + "/Contents" resourcesDir = bundleContentsDir + "/Resources" frameworksDir = bundleContentsDir + "/Frameworks" env.Install(bundleContentsDir + "/MacOS", bundle) env.WriteVal(bundleContentsDir + "/PkgInfo", env.Value("APPL\77\77\77\77")) infoDict = { "CFBundleDevelopmentRegion" : "English", "CFBundleExecutable" : bundle, "CFBundleIdentifier" : "im.swift." + bundle, "CFBundleInfoDictionaryVersion" : "6.0", "CFBundleName" : bundle, "CFBundlePackageType" : "APPL", "CFBundleSignature": "\77\77\77\77", "CFBundleVersion" : version, "CFBundleIconFile" : bundle, "NSPrincipalClass" : "NSApplication", "NSHumanReadableCopyright" : "(c) 2010 Swift Development Team.\nAll Rights Reserved." } infoDict.update(info) plist = """ """ for key, value in infoDict.items() : plist += "" + key + "\n" plist += "" + value.encode("utf-8") + "\n" if handlesXMPPURIs : plist += """CFBundleURLTypes CFBundleURLName XMPP URL CFBundleURLSchemes xmpp \n""" if sparklePublicDSAKey : plist += "SUPublicDSAKeyFile" plist += "" + sparklePublicDSAKey.name.encode("utf-8") + "" env.Install(resourcesDir, sparklePublicDSAKey) plist += """ """ env.WriteVal(bundleContentsDir + "/Info.plist", env.Value(plist)) for (target, resource) in resources.items() : env.Install(os.path.join(resourcesDir, target), resource) for framework in frameworks : env.Install(frameworksDir, framework) return env.Dir(bundleDir) env.AddMethod(createAppBundle, "AppBundle") def exists(env) : return env["PLATFORM"] == "darwin"