def main(args): argc = len(args) if argc < 5 or args[1]=='--help': print "Usage: %s <name> <id> <directory> [iphone,android,mobileweb] [android_sdk]" % os.path.basename(args[0]) sys.exit(1) name = args[1].decode("utf-8") appid = args[2].decode("utf-8") directory = os.path.abspath(os.path.expanduser(args[3].decode("utf-8"))) iphone = False android = False android_sdk = None sdk = None mobileweb = False if args[4] == 'iphone' or (argc > 5 and args[5] == 'iphone') or (argc > 6 and args[6] == 'iphone'): iphone = True if args[4] == 'android' or (argc > 5 and args[5] == 'android') or (argc > 6 and args[6] == 'android'): android = True if args[4] == 'mobileweb' or (argc > 5 and args[5] == 'mobileweb') or (argc > 6 and args[6] == 'mobileweb'): mobileweb = True if android: sys.path.append(os.path.join(os.path.dirname(args[0]), "android")) from androidsdk import AndroidSDK android_sdk = args[argc-1].decode("utf-8") try: sdk = AndroidSDK(android_sdk) except Exception, e: print >>sys.stderr, e sys.exit(1)
def main(args, update_platforms=False): argc = len(args) if argc < 5 or args[1]=='--help': parser.print_help() sys.exit(1) name = args[1].decode("utf-8") appid = args[2].decode("utf-8") directory = os.path.abspath(os.path.expanduser(args[3].decode("utf-8"))) iphone = False android = False android_sdk = None sdk = None mobileweb = False blackberry = False blackberry_ndk = None if is_iphone(args[4]) or (argc > 5 and is_iphone(args[5])) or (argc > 6 and is_iphone(args[6])): iphone = True if args[4] == 'android' or (argc > 5 and args[5] == 'android') or (argc > 6 and args[6] == 'android'): android = True if args[4] == 'mobileweb' or (argc > 5 and args[5] == 'mobileweb') or (argc > 6 and args[6] == 'mobileweb'): mobileweb = True if args[4] == 'blackberry' or (argc > 5 and args[5] == 'blackberry') or (argc > 6 and args[6] == 'blackberry'): blackberry = True if android: sys.path.append(os.path.join(os.path.dirname(args[0]), "android")) from androidsdk import AndroidSDK android_sdk = args[argc-1].decode("utf-8") try: sdk = AndroidSDK(android_sdk) except Exception, e: print >>sys.stderr, e sys.exit(1)
def main(args): global android_sdk # command platform project_dir command = args[1] platform = args[2] project_dir = os.path.expanduser(args[3]) manifest = Manifest(os.path.join(project_dir, 'manifest')) error = False if is_android(platform): build_properties = read_properties( open(os.path.join(project_dir, 'build.properties'))) android_sdk_path = os.path.dirname( os.path.dirname(build_properties['android.platform'])) android_sdk = AndroidSDK(android_sdk_path) if command == 'run': def run_callback(gen_project_dir): script = os.path.abspath( os.path.join(template_dir, '..', platform, 'builder.py')) script_args = [script, 'run', gen_project_dir] if is_android(platform): script_args.append(android_sdk.get_android_sdk()) rc = run_python(script_args) # run the project if rc == 1: if is_ios(platform): error = os.path.join(gen_project_dir, 'build', 'iphone', 'build', 'build.log') print "[ERROR] Build Failed. See: %s" % os.path.abspath( error) else: print "[ERROR] Build Failed." stage(platform, project_dir, manifest, run_callback) elif command == 'run-emulator': if is_android(platform): def run_emulator_callback(gen_project_dir): script = os.path.abspath( os.path.join(template_dir, '..', platform, 'builder.py')) run_python([ script, 'run-emulator', gen_project_dir, android_sdk.get_android_sdk() ]) stage(platform, project_dir, manifest, run_emulator_callback) elif command == 'docgen': if is_android(platform): dest_dir = args[4] docgen(project_dir, dest_dir) if error: sys.exit(1) else: sys.exit(0)
def main(args): global android_sdk # command platform project_dir command = args[1] platform = args[2] project_dir = os.path.expanduser(args[3]) manifest = Manifest(os.path.join(project_dir, 'manifest')) error = False if is_android(platform): build_properties = read_properties(open(os.path.join(project_dir, 'build.properties'))) android_sdk_path = os.path.dirname(os.path.dirname(build_properties['android.platform'])) android_sdk = AndroidSDK(android_sdk_path) if command == 'run': def run_callback(gen_project_dir): script = os.path.abspath(os.path.join(template_dir, '..', platform,'builder.py')) script_args = [script, 'run', gen_project_dir] if is_android(platform): script_args.append(android_sdk.get_android_sdk()) rc = run_python(script_args) # run the project if rc==1: if is_ios(platform): error = os.path.join(gen_project_dir, 'build', 'iphone', 'build', 'build.log') print "[ERROR] Build Failed. See: %s" % os.path.abspath(error) else: print "[ERROR] Build Failed." stage(platform, project_dir, manifest, run_callback) elif command == 'install': def install_callback(gen_project_dir): if is_ios(platform): print "[ERROR] Build Failed. Install module to device not supported on iOS." return tiapp_xml = os.path.join(gen_project_dir, 'tiapp.xml') script = os.path.abspath(os.path.join(template_dir, '..', platform, 'builder.py')) script_args = [script, "install", manifest.name, android_sdk.get_android_sdk(), gen_project_dir, manifest.moduleid, "Necessary argument, but unused."] rc = run_python(script_args) # install the project if rc != 0: if is_ios(platform): error = os.path.join(gen_project_dir, 'build', 'iphone', 'build', 'build.log') print "[ERROR] Build Failed. See: %s" % os.path.abspath(error) else: print "[ERROR] Build Failed." stage(platform, project_dir, manifest, install_callback) elif command == 'run-emulator': if is_android(platform): def run_emulator_callback(gen_project_dir): script = os.path.abspath(os.path.join(template_dir, '..', platform, 'builder.py')) run_python([script, 'run-emulator', gen_project_dir, android_sdk.get_android_sdk()]) stage(platform, project_dir, manifest, run_emulator_callback) elif command == 'docgen': if is_android(platform): dest_dir = args[4] docgen(project_dir, dest_dir) if error: sys.exit(1) else: sys.exit(0)
if f is not None: f.close() # Don't override a pre-existing .gitignore in case users have their own preferences # for what should be in it. (LH #2446) if not os.path.exists(os.path.join(app_dir, '.gitignore')): self.render(template_dir, 'gitignore', app_dir, '.gitignore') else: print "[TRACE] Skipping copying gitignore -> .gitignore because already exists" android_project_resources = os.path.join(project_dir, 'Resources', 'android') if build_time == False and os.path.exists(android_project_resources): shutil.rmtree(android_project_resources) if not os.path.exists(android_project_resources): copy_resources(os.path.join(template_dir, 'resources'), android_project_resources) if __name__ == '__main__': # this is for testing only for the time being if len(sys.argv) != 5 or sys.argv[1] == '--help': print "Usage: %s <name> <id> <directory> <sdk>" % os.path.basename( sys.argv[0]) sys.exit(1) sdk = AndroidSDK(sys.argv[4]) android = Android(sys.argv[1], sys.argv[2], sdk, None, 'java') android.create(sys.argv[3])
name = None theid = None for line in run.run([sdk.get_android(),'list','target'],debug=False).split("\n"): line = line.strip() if line.find("id: ")!=-1: theid = line[4:] theid = theid[0:theid.find('or ')-1] if line.find("Name:")!=-1: name = line[6:] elif line.find("Based on ")!=-1: version = line[9:] version = version[0:version.find('(')-1] name = "%s %s" % (name,version) elif line.find("Skins: ")!=-1: skins = line[7:].replace(' (default)','').strip().split(", ") avds.append({'name':name,'id':theid,'skins':skins}) return avds if __name__ == '__main__': if len(sys.argv) != 2: print "Usage: %s <directory>" % os.path.basename(sys.argv[0]) sys.exit(1) sdk = AndroidSDK(os.path.expanduser(dequote(sys.argv[1])), 7) print get_avds(sdk)