class Builder(object): type2variantCpu = {'simulator' : ('o-g', 'x86'), 'device' : ('o.le-v7-g', 'arm'), 'deploy' : ('o.le-v7', 'arm'), 'distribute' : ('o.le-v7', 'arm')} def __init__(self, project_dir, type, ndk, useLogFile = False): self.top_dir = project_dir.rstrip(os.sep) self.type = type (self.variant, self.cpu) = Builder.type2variantCpu[type] self.ndk = ndk self.project_tiappxml = os.path.join(self.top_dir, 'tiapp.xml') self.tiappxml = TiAppXML(self.project_tiappxml) self.name = self.tiappxml.properties['name'] self.id = self.tiappxml.properties['id'] self.buildDir = os.path.join(self.top_dir, 'build', 'blackberry') self.blackberryResources = os.path.join(self.top_dir, 'Resources', 'blackberry') self.project_deltafy = Deltafy(self.top_dir) if useLogFile: self.tiappxml = TiAppXML(self.project_tiappxml) else: # hide property output with open(os.devnull, 'w') as nul: oldStdout = sys.stdout sys.stdout = nul self.tiappxml = TiAppXML(self.project_tiappxml) sys.stdout = oldStdout self.name = self.tiappxml.properties['name'] self.buildDir = os.path.join(self.top_dir, 'build', 'blackberry') def getPackage(self): return os.path.join(self.buildDir, self.cpu, self.variant, '%s.bar' % self.name) def run(self, ipAddress = None, password = None, debugToken = None, storePass = None, outputDir = None): # TODO Mac: V8 runtime should be added and possibly a lot of other stuff retCode = self.build() if retCode != 0: return retCode info('Running') templates = os.path.join(template_dir,'templates') # Check if tiapp.xml changed since last run bar_descriptor_exists = os.path.exists(os.path.join(self.buildDir, 'bar-descriptor.xml')) tiapp_delta = self.project_deltafy.scan_single_file(self.project_tiappxml) tiapp_changed = tiapp_delta is not None # Discover any splash images that follow this pattern: # splash-widthxheight.[png|jpg] resources = os.listdir(self.blackberryResources) splashScreens = [r for r in resources if re.match('splash-[0-9]*x[0-9]*.png|jpg', r)] if (tiapp_changed or not bar_descriptor_exists): # regenerate bar-descriptor.xml # TODO MAC: Add blackberry specific properties. Needs update in tiapp.py script print 'Creating bar-descriptor.xml' shutil.copy2(os.path.join(templates,'bar-descriptor.xml'), self.buildDir) newConfig = { 'id':self.tiappxml.properties['id'], 'appname':self.tiappxml.properties['name'], 'platformversion':self.ndk.version, 'description':(self.tiappxml.properties['description'] or 'not specified'), 'version':(self.tiappxml.properties['version'] or '1.0'), 'author':(self.tiappxml.properties['publisher'] or 'not specified'), 'category':'core.games', 'icon':'assets/%s' %(self.tiappxml.properties['icon'] or 'appicon.png'), 'splashScreens':splashScreens } try: Blackberry.renderTemplate(os.path.join(self.buildDir,'bar-descriptor.xml'), newConfig) except Exception, e: print >>sys.stderr, e sys.exit(1) # Change current directory to do relative operations os.chdir("%s" % self.buildDir) barPath = self.getPackage() savePath = os.path.join(self.buildDir, self.cpu, self.variant, self.name) retCode = self.ndk.package(barPath, savePath, self.name, self.type, debugToken) if retCode != 0: return retCode if self.type != 'distribute': retCode = self.ndk.deploy(ipAddress, barPath, password) retCode = self.ndk.appLog(ipAddress, barPath, password) else: retCode = self.ndk.distribute(self.name, savePath, storePass, outputDir) if retCode != 0: log.info ( 'Distribution has failed. Please check that the buildID inside your\n' + 'project/Resources/blackberry/Ti.Manifest is a higher value then the\n' + 'the last time you ran distribute.') return retCode
class Builder(object): type2variantCpu = { 'simulator': ('o-g', 'x86'), 'device': ('o.le-v7-g', 'arm'), 'deploy': ('o.le-v7', 'arm') } def __init__(self, project_dir, type, ndk, useLogFile=False): self.top_dir = project_dir.rstrip(os.sep) self.type = type (self.variant, self.cpu) = Builder.type2variantCpu[type] self.ndk = ndk self.project_tiappxml = os.path.join(self.top_dir, 'tiapp.xml') self.tiappxml = TiAppXML(self.project_tiappxml) self.name = self.tiappxml.properties['name'] self.buildDir = os.path.join(self.top_dir, 'build', 'blackberry') self.project_deltafy = Deltafy(self.top_dir) if useLogFile: self.tiappxml = TiAppXML(self.project_tiappxml) else: # hide property output with open(os.devnull, 'w') as nul: oldStdout = sys.stdout sys.stdout = nul self.tiappxml = TiAppXML(self.project_tiappxml) sys.stdout = oldStdout self.name = self.tiappxml.properties['name'] self.buildDir = os.path.join(self.top_dir, 'build', 'blackberry') def getPackage(self): return os.path.join(self.buildDir, self.cpu, self.variant, '%s.bar' % self.name) def run(self, ipAddress, password=None, debugToken=None): # TODO Mac: V8 runtime should be added and possibly a lot of other stuff retCode = self.build() if retCode != 0: return retCode info('Running') # Check if tiapp.xml changed since last run tiapp_delta = self.project_deltafy.scan_single_file( self.project_tiappxml) tiapp_changed = tiapp_delta is not None if (tiapp_changed): # regenerate bar-descriptor.xml # TODO MAC: Add blackberry specific properties. Needs update in tiapp.py script templates = os.path.join(template_dir, 'templates') shutil.copy2(os.path.join(templates, 'bar-descriptor.xml'), self.buildDir) newConfig = { 'id': self.tiappxml.properties['id'], 'appname': self.tiappxml.properties['name'], 'platformversion': self.ndk.version, 'description': (self.tiappxml.properties['description'] or 'not specified'), 'version': (self.tiappxml.properties['version'] or '1.0'), 'author': (self.tiappxml.properties['publisher'] or 'not specified'), 'category': 'core.games', 'icon': 'assets/%s' % (self.tiappxml.properties['icon'] or 'appicon.png'), 'splashscreen': 'assets/default.png' } try: Blackberry.renderTemplate( os.path.join(self.buildDir, 'bar-descriptor.xml'), newConfig) except Exception, e: print >> sys.stderr, e sys.exit(1) # Change current directory to do relative operations os.chdir("%s" % self.buildDir) barPath = self.getPackage() savePath = os.path.join(self.buildDir, self.cpu, self.variant, self.name) retCode = self.ndk.package(barPath, savePath, self.name, self.type, debugToken) if retCode != 0: return retCode retCode = self.ndk.deploy(ipAddress, barPath, password) return retCode
class Builder(object): type2variantCpu = {'simulator' : ('o-g', 'x86'), 'device' : ('o.le-v7-g', 'arm'), 'deploy' : ('o.le-v7', 'arm')} def __init__(self, project_dir, type, ndk, useLogFile = False): self.top_dir = project_dir.rstrip(os.sep) self.type = type (self.variant, self.cpu) = Builder.type2variantCpu[type] self.ndk = ndk self.project_tiappxml = os.path.join(self.top_dir, 'tiapp.xml') self.tiappxml = TiAppXML(self.project_tiappxml) self.name = self.tiappxml.properties['name'] self.buildDir = os.path.join(self.top_dir, 'build', 'blackberry') self.project_deltafy = Deltafy(self.top_dir) if useLogFile: self.tiappxml = TiAppXML(self.project_tiappxml) else: # hide property output with open(os.devnull, 'w') as nul: oldStdout = sys.stdout sys.stdout = nul self.tiappxml = TiAppXML(self.project_tiappxml) sys.stdout = oldStdout self.name = self.tiappxml.properties['name'] self.buildDir = os.path.join(self.top_dir, 'build', 'blackberry') def getPackage(self): return os.path.join(self.buildDir, self.cpu, self.variant, '%s.bar' % self.name) def run(self, ipAddress, password = None, debugToken = None): # TODO Mac: V8 runtime should be added and possibly a lot of other stuff retCode = self.build() if retCode != 0: return retCode info('Running') # Check if tiapp.xml changed since last run tiapp_delta = self.project_deltafy.scan_single_file(self.project_tiappxml) tiapp_changed = tiapp_delta is not None if (tiapp_changed): # regenerate bar-descriptor.xml # TODO MAC: Add blackberry specific properties. Needs update in tiapp.py script templates = os.path.join(template_dir,'templates') shutil.copy2(os.path.join(templates,'bar-descriptor.xml'), self.buildDir) newConfig = { 'id':self.tiappxml.properties['id'], 'appname':self.tiappxml.properties['name'], 'platformversion':self.ndk.version, 'description':(self.tiappxml.properties['description'] or 'not specified'), 'version':(self.tiappxml.properties['version'] or '1.0'), 'author':(self.tiappxml.properties['publisher'] or 'not specified'), 'category':'core.games', 'icon':'assets/%s' %(self.tiappxml.properties['icon'] or 'appicon.png'), 'splashscreen':'assets/default.png' } try: Blackberry.renderTemplate(os.path.join(self.buildDir,'bar-descriptor.xml'), newConfig) except Exception, e: print >>sys.stderr, e sys.exit(1) # Change current directory to do relative operations os.chdir("%s" % self.buildDir) barPath = self.getPackage() savePath = os.path.join(self.buildDir, self.cpu, self.variant, self.name) retCode = self.ndk.package(barPath, savePath, self.name, self.type, debugToken) if retCode != 0: return retCode retCode = self.ndk.deploy(ipAddress, barPath, password) return retCode
class Builder(object): type2variantCpu = {'simulator' : ('o-g', 'x86'), 'device' : ('o.le-v7-g', 'arm'), 'deploy' : ('o.le-v7', 'arm'), 'distribute' : ('o.le-v7', 'arm')} def __init__(self, project_dir, type, ndk, useLogFile = False): self.top_dir = project_dir.rstrip(os.sep) self.type = type (self.variant, self.cpu) = Builder.type2variantCpu[type] self.ndk = ndk self.project_tiappxml = os.path.join(self.top_dir, 'tiapp.xml') self.tiappxml = TiAppXML(self.project_tiappxml) self.name = self.tiappxml.properties['name'] self.id = self.tiappxml.properties['id'] self.buildDir = os.path.join(self.top_dir, 'build', 'blackberry') self.blackberryResources = os.path.join(self.top_dir, 'Resources', 'blackberry') self.project_deltafy = Deltafy(self.top_dir) if useLogFile: self.tiappxml = TiAppXML(self.project_tiappxml) else: # hide property output with open(os.devnull, 'w') as nul: oldStdout = sys.stdout sys.stdout = nul self.tiappxml = TiAppXML(self.project_tiappxml) sys.stdout = oldStdout self.name = self.tiappxml.properties['name'] self.buildDir = os.path.join(self.top_dir, 'build', 'blackberry') def getPackage(self): return os.path.join(self.buildDir, self.cpu, self.variant, '%s.bar' % self.name) def run(self, ipAddress = None, password = None, debugToken = None, storePass = None, outputDir = None): # TODO Mac: V8 runtime should be added and possibly a lot of other stuff retCode = self.build() if retCode != 0: return retCode info('Running') templates = os.path.join(template_dir,'templates') # Check if tiapp.xml changed since last run bar_descriptor_exists = os.path.exists(os.path.join(self.buildDir, 'bar-descriptor.xml')) tiapp_delta = self.project_deltafy.scan_single_file(self.project_tiappxml) tiapp_changed = tiapp_delta is not None # Discover any splash images that follow this pattern: # splash-widthxheight.[png|jpg] resources = os.listdir(self.blackberryResources) splashScreens = [r for r in resources if re.match('splash-[0-9]*x[0-9]*.png|jpg', r)] if (tiapp_changed or not bar_descriptor_exists): # regenerate bar-descriptor.xml # TODO MAC: Add blackberry specific properties. Needs update in tiapp.py script print 'Creating bar-descriptor.xml' shutil.copy2(os.path.join(templates,'bar-descriptor.xml'), self.buildDir) newConfig = { 'id':self.tiappxml.properties['id'], 'appname':self.tiappxml.properties['name'], 'platformversion':self.ndk.version, 'description':(self.tiappxml.properties['description'] or 'not specified'), 'version':(self.tiappxml.properties['version'] or '1.0'), 'author':(self.tiappxml.properties['publisher'] or 'not specified'), 'category':'core.games', 'icon':'assets/%s' %(self.tiappxml.properties['icon'] or 'appicon.png'), 'splashScreens':splashScreens, 'orientation': self.tiappxml.blackberry.get('orientation', 'default') } try: Blackberry.renderTemplate(os.path.join(self.buildDir,'bar-descriptor.xml'), newConfig) except Exception, e: print >>sys.stderr, e sys.exit(1) # Write application properties to INI file. write_app_properties( self.tiappxml.app_properties.items(), os.path.join(self.buildDir, 'app_properties.ini')) # Change current directory to do relative operations os.chdir("%s" % self.buildDir) barPath = self.getPackage() savePath = os.path.join(self.buildDir, self.cpu, self.variant, self.name) retCode = self.ndk.package(barPath, savePath, self.name, self.type, debugToken) if retCode != 0: return retCode if self.type != 'distribute': retCode = self.ndk.deploy(ipAddress, barPath, password) retCode = self.ndk.appLog(ipAddress, barPath, password) else: retCode = self.ndk.distribute(self.name, savePath, storePass, outputDir) if retCode != 0: log.info ( 'Distribution has failed. Please check that the buildID inside your\n' + 'project/Resources/blackberry/Ti.Manifest is a higher value then the\n' + 'the last time you ran distribute.') return retCode