Merge pull request #322 from kived/android-adb

add adb and p4a commands to android/android_new
This commit is contained in:
Akshay Arora 2016-04-24 00:23:16 +05:30
commit e58d89c7b7
3 changed files with 34 additions and 2 deletions

View file

@ -52,8 +52,13 @@ class Target(object):
result = []
last_command = []
for arg in args:
if not arg.startswith('--'):
while args:
arg = args.pop(0)
if arg == '--':
if last_command:
last_command += args
break
elif not arg.startswith('--'):
if last_command:
result.append(last_command)
last_command = []

View file

@ -34,6 +34,7 @@ from buildozer.libs.version import parse
class TargetAndroid(Target):
targetname = 'android'
p4a_branch = "old_toolchain"
p4a_directory = "python-for-android"
p4a_apk_cmd = "python build.py"
@ -839,6 +840,18 @@ class TargetAndroid(Target):
self._serials = serials
return serials
def cmd_adb(self, *args):
self.check_requirements()
self.install_platform()
args = args[0]
if args and args[0] == '--alias':
print('To set up ADB in this shell session, execute:')
print(' alias adb=$(buildozer {} adb --alias 2>&1 >/dev/null)'
.format(self.targetname))
sys.stderr.write(self.adb_cmd + '\n')
else:
self.buildozer.cmd(' '.join([self.adb_cmd] + args))
def cmd_deploy(self, *args):
super(TargetAndroid, self).cmd_deploy(*args)
state = self.buildozer.state

View file

@ -2,12 +2,14 @@
'''
Android target, based on python-for-android project (new toolchain)
'''
import sys
from buildozer.targets.android import TargetAndroid
from os.path import join, expanduser, realpath
class TargetAndroidNew(TargetAndroid):
targetname = 'android_new'
p4a_branch = "master"
p4a_directory = "python-for-android-master"
p4a_apk_cmd = "apk --bootstrap=sdl2"
@ -103,6 +105,18 @@ class TargetAndroidNew(TargetAndroid):
self.buildozer.config.set('app', 'android.entrypoint', 'org.kivy.android.PythonActivity')
return super(TargetAndroidNew, self).cmd_run(*args)
def cmd_p4a(self, *args):
self.check_requirements()
self.install_platform()
args = args[0]
if args and args[0] == '--alias':
print('To set up p4a in this shell session, execute:')
print(' alias p4a=$(buildozer {} p4a --alias 2>&1 >/dev/null)'
.format(self.targetname))
sys.stderr.write('PYTHONPATH={} {}\n'.format(self.pa_dir, self._p4a_cmd))
else:
self._p4a(' '.join(args) if args else '')
def get_target(buildozer):
buildozer.targetname = "android"