Skip to content

Commit

Permalink
fixes android reference for android_new + support for p4a hook
Browse files Browse the repository at this point in the history
  • Loading branch information
tito committed Jan 4, 2017
1 parent 11bac03 commit 9848996
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
5 changes: 4 additions & 1 deletion buildozer/default.spec
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ fullscreen = 1
#android.p4a_dir =

# (str) The directory in which python-for-android should look for your own build recipes (if any)
#p4a.local_recipes =
#p4a.local_recipes =

# (str) Filename to the hook for p4a
#p4a.hook =

# (list) python-for-android whitelist
#android.p4a_whitelist =
Expand Down
13 changes: 7 additions & 6 deletions buildozer/targets/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,11 @@ def _generate_whitelist(self, dist_dir):
def get_dist_dir(self, dist_name):
return join(self.pa_dir, 'dist', dist_name)

@property
def dist_dir(self):
dist_name = self.buildozer.config.get('app', 'package.name')
return self.get_dist_dir(dist_name)

def execute_build_package(self, build_cmd):
dist_name = self.buildozer.config.get('app', 'package.name')
cmd = [self.p4a_apk_cmd]
Expand Down Expand Up @@ -807,13 +812,9 @@ def _update_libraries_references(self, dist_dir):

# recreate the project.properties
with io.open(project_fn, 'w', encoding='utf-8') as fd:
for line in content:
if IS_PY3:
fd.write(line)
else:
fd.write(line.decode('utf-8'))
fd.writelines(content)
for index, ref in enumerate(references):
fd.write(u'android.library.reference.{}={}\n'.format(index + 1,
fd.write(u'\nandroid.library.reference.{}={}'.format(index + 1,
ref))

self.buildozer.debug('project.properties updated')
Expand Down
7 changes: 3 additions & 4 deletions buildozer/targets/android_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def __init__(self, buildozer):
color = 'always' if USE_COLOR else 'never'
self.extra_p4a_args = ' --color={} --storage-dir={}'.format(
color, self._build_dir)
hook = self.buildozer.config.getdefault("app", "p4a.hook", None)
if hook is not None:
self.extra_p4a_args += ' --hook={}'.format(realpath(hook))

def _p4a(self, cmd, **kwargs):
if not hasattr(self, "pa_dir"):
Expand Down Expand Up @@ -67,10 +70,6 @@ def compile_platform(self):
dist_name, self._p4a_bootstrap, requirements, " ".join(options)),
get_stdout=True)[0]

def _update_libraries_references(self, dist_dir):
# UNSUPPORTED YET
pass

def get_dist_dir(self, dist_name):
return join(self._build_dir, 'dists', dist_name)

Expand Down

0 comments on commit 9848996

Please sign in to comment.