Merge pull request #940 from opacam/feature-allow-p4a-forks
New feature: allow to use a p4a fork
This commit is contained in:
commit
7a0ef4f10c
2 changed files with 47 additions and 13 deletions
|
@ -158,9 +158,6 @@ fullscreen = 0
|
|||
# (list) Java classes to add as activities to the manifest.
|
||||
#android.add_activites = com.example.ExampleActivity
|
||||
|
||||
# (str) python-for-android branch to use, defaults to master
|
||||
#p4a.branch = master
|
||||
|
||||
# (str) OUYA Console category. Should be one of GAME or APP
|
||||
# If you leave this blank, OUYA support will not be enabled
|
||||
#android.ouya.category = GAME
|
||||
|
@ -208,6 +205,12 @@ android.arch = armeabi-v7a
|
|||
# Python for android (p4a) specific
|
||||
#
|
||||
|
||||
# (str) python-for-android fork to use, defaults to upstream (kivy)
|
||||
#p4a.fork = kivy
|
||||
|
||||
# (str) python-for-android branch to use, defaults to master
|
||||
#p4a.branch = master
|
||||
|
||||
# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
|
||||
#p4a.source_dir =
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ from buildozer.target import Target
|
|||
from os import environ
|
||||
from os.path import exists, join, realpath, expanduser, basename, relpath
|
||||
from platform import architecture
|
||||
from shutil import copyfile
|
||||
from shutil import copyfile, rmtree
|
||||
from glob import glob
|
||||
|
||||
from buildozer.libs.version import parse
|
||||
|
@ -47,9 +47,11 @@ DEPRECATED_TOKENS = (('app', 'android.sdk'), )
|
|||
# does.
|
||||
DEFAULT_SDK_TAG = '4333796'
|
||||
|
||||
|
||||
class TargetAndroid(Target):
|
||||
targetname = 'android'
|
||||
p4a_directory = "python-for-android"
|
||||
p4a_fork = 'kivy'
|
||||
p4a_branch = 'master'
|
||||
p4a_apk_cmd = "apk --debug --bootstrap="
|
||||
extra_p4a_args = ''
|
||||
|
@ -614,8 +616,12 @@ class TargetAndroid(Target):
|
|||
|
||||
def _install_p4a(self):
|
||||
cmd = self.buildozer.cmd
|
||||
source = self.buildozer.config.getdefault('app', 'p4a.branch',
|
||||
self.p4a_branch)
|
||||
p4a_fork = self.buildozer.config.getdefault(
|
||||
'app', 'p4a.fork', self.p4a_fork
|
||||
)
|
||||
p4a_branch = self.buildozer.config.getdefault(
|
||||
'app', 'p4a.branch', self.p4a_branch
|
||||
)
|
||||
self.pa_dir = pa_dir = join(self.buildozer.platform_dir,
|
||||
self.p4a_directory)
|
||||
system_p4a_dir = self.buildozer.config.getdefault('app',
|
||||
|
@ -628,22 +634,47 @@ class TargetAndroid(Target):
|
|||
self.buildozer.error('')
|
||||
raise BuildozerException()
|
||||
else:
|
||||
# check that fork/branch has not been changed
|
||||
if self.buildozer.file_exists(pa_dir):
|
||||
cur_fork = cmd(
|
||||
'git config --get remote.origin.url',
|
||||
get_stdout=True,
|
||||
cwd=pa_dir,
|
||||
)[0].split('/')[3]
|
||||
cur_branch = cmd(
|
||||
'git branch -vv', get_stdout=True, cwd=pa_dir
|
||||
)[0].split()[1]
|
||||
if any([cur_fork != p4a_fork, cur_branch != p4a_branch]):
|
||||
self.buildozer.info(
|
||||
"Detected old fork/branch ({}/{}), deleting...".format(
|
||||
cur_fork, cur_branch
|
||||
)
|
||||
)
|
||||
rmtree(pa_dir)
|
||||
|
||||
if not self.buildozer.file_exists(pa_dir):
|
||||
cmd(
|
||||
('git clone -b {} --single-branch '
|
||||
'https://github.com/kivy/python-for-android.git '
|
||||
'{}').format(source, self.p4a_directory),
|
||||
cwd=self.buildozer.platform_dir)
|
||||
(
|
||||
'git clone -b {p4a_branch} --single-branch '
|
||||
'https://github.com/{p4a_fork}/python-for-android.git '
|
||||
'{p4a_dir}'
|
||||
).format(
|
||||
p4a_branch=p4a_branch,
|
||||
p4a_fork=p4a_fork,
|
||||
p4a_dir=self.p4a_directory,
|
||||
),
|
||||
cwd=self.buildozer.platform_dir,
|
||||
)
|
||||
elif self.platform_update:
|
||||
cmd('git clean -dxf', cwd=pa_dir)
|
||||
current_branch = cmd('git rev-parse --abbrev-ref HEAD',
|
||||
get_stdout=True, cwd=pa_dir)[0].strip()
|
||||
if current_branch == source:
|
||||
if current_branch == p4a_branch:
|
||||
cmd('git pull', cwd=pa_dir)
|
||||
else:
|
||||
cmd('git fetch --tags origin {0}:{0}'.format(source),
|
||||
cmd('git fetch --tags origin {0}:{0}'.format(p4a_branch),
|
||||
cwd=pa_dir)
|
||||
cmd('git checkout {}'.format(source), cwd=pa_dir)
|
||||
cmd('git checkout {}'.format(p4a_branch), cwd=pa_dir)
|
||||
|
||||
# also install dependencies (currently, only setup.py knows about it)
|
||||
# let's extract them.
|
||||
|
|
Loading…
Add table
Reference in a new issue