Skip to content

Commit

Permalink
migrate tokens. Closes #499
Browse files Browse the repository at this point in the history
  • Loading branch information
tito committed May 14, 2017
1 parent f55147e commit 48ea268
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ config, along with the environment variables that would override them.

- ``title`` -> ``$APP_TITLE``
- ``package.name`` -> ``$APP_PACKAGE_NAME``
- ``android.p4a_dir`` -> ``$APP_ANDROID_P4A_DIR``
- ``p4a.source_dir`` -> ``$APP_P4A_SOURCE_DIR``

Buildozer Virtual Machine
-------------------------
Expand Down
20 changes: 20 additions & 0 deletions buildozer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ def check_configuration_tokens(self):
'''Ensure the spec file is 'correct'.
'''
self.info('Check configuration tokens')
self.migrate_configuration_tokens()
get = self.config.getdefault
errors = []
adderror = errors.append
Expand Down Expand Up @@ -417,6 +418,25 @@ def check_configuration_tokens(self):
print(error)
exit(1)

def migrate_configuration_tokens(self):
config = self.config
if config.has_section("app"):
migration = (
("android.p4a_dir", "p4a.source_dir"),
("android.p4a_whitelist", "android.whitelist"),
("android.bootstrap", "p4a.bootstrap"),
("android.branch", "p4a.branch"),
("android.p4a_whitelist_src", "android.whitelist_src"),
("android.p4a_blacklist_src", "android.blacklist_src")
)
for entry_old, entry_new in migration:
if not config.has_option("app", entry_old):
continue
value = config.get("app", entry_old)
config.set("app", entry_new, value)
config.remove_option("app", entry_old)
self.error("In section [app]: {} is deprecated, rename to {}!".format(
entry_old, entry_new))

def check_build_layout(self):
'''Ensure the build (local and global) directory layout and files are
Expand Down
46 changes: 28 additions & 18 deletions buildozer/default.spec
Original file line number Diff line number Diff line change
Expand Up @@ -111,29 +111,23 @@ fullscreen = 0
# (str) ANT directory (if empty, it will be automatically downloaded.)
#android.ant_path =

# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
#android.p4a_dir =

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

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

# (list) python-for-android whitelist
#android.p4a_whitelist =

# (bool) If True, then skip trying to update the Android sdk
# This can be useful to avoid excess Internet downloads or save time
# when an update is due and you just want to test/build your package
# android.skip_update = False

# (str) Bootstrap to use for android builds (android_new only)
# android.bootstrap = sdl2

# (str) Android entry point, default is ok for Kivy-based app
#android.entrypoint = org.renpy.android.PythonActivity

# (list) Pattern to whitelist for the whole project
#android.whitelist =

# (str) Path to a custom whitelist file
#android.whitelist_src =

# (str) Path to a custom blacklist file
#android.blacklist_src =

# (list) List of Java .jar files to add to the libs so that pyjnius can access
# their classes. Don't add jars that you do not need, since extra jars can slow
# down the build process. Allows wildcards matching, for example:
Expand All @@ -152,9 +146,8 @@ fullscreen = 0
# bootstrap)
#android.gradle_dependencies =

# (str) python-for-android branch to use, if not master, useful to try
# not yet merged features.
#android.branch = master
# (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
Expand Down Expand Up @@ -192,6 +185,23 @@ fullscreen = 0
# (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86
android.arch = armeabi-v7a

#
# Python for android (p4a) specific
#

# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
#p4a.source_dir =

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

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

# (str) Bootstrap to use for android builds (android_new only)
# p4a.bootstrap = sdl2


#
# iOS specific
#
Expand Down
8 changes: 4 additions & 4 deletions buildozer/targets/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,17 +462,17 @@ def _check_aidl(self, v_build_tools):

def install_platform(self):
cmd = self.buildozer.cmd
source = self.buildozer.config.getdefault('app', 'android.branch',
source = 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',
'android.p4a_dir')
'p4a.source_dir')
if system_p4a_dir:
self.pa_dir = pa_dir = expanduser(system_p4a_dir)
if not self.buildozer.file_exists(pa_dir):
self.buildozer.error(
'Path for android.p4a_dir does not exist')
'Path for p4a.source_dir does not exist')
self.buildozer.error('')
raise BuildozerException()
else:
Expand Down Expand Up @@ -594,7 +594,7 @@ def _get_package(self):

def _generate_whitelist(self, dist_dir):
p4a_whitelist = self.buildozer.config.getlist(
'app', 'android.p4a_whitelist') or []
'app', 'android.whitelist') or []
whitelist_fn = join(dist_dir, 'whitelist.txt')
with open(whitelist_fn, 'w') as fd:
for wl in p4a_whitelist:
Expand Down
6 changes: 3 additions & 3 deletions buildozer/targets/android_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, *args, **kwargs):
executable = sys.executable or 'python'
self._p4a_cmd = '{} -m pythonforandroid.toolchain '.format(executable)
self._p4a_bootstrap = self.buildozer.config.getdefault(
'app', 'android.bootstrap', 'sdl2')
'app', 'p4a.bootstrap', 'sdl2')
self.p4a_apk_cmd += self._p4a_bootstrap
color = 'always' if USE_COLOR else 'never'
self.extra_p4a_args = ' --color={} --storage-dir={}'.format(
Expand Down Expand Up @@ -124,8 +124,8 @@ def execute_build_package(self, build_cmd):
cmd.append(local_recipes)

# support for blacklist/whitelist filename
whitelist_src = self.buildozer.config.getdefault('app', 'android.p4a_whitelist_src', None)
blacklist_src = self.buildozer.config.getdefault('app', 'android.p4a_blacklist_src', None)
whitelist_src = self.buildozer.config.getdefault('app', 'android.whitelist_src', None)
blacklist_src = self.buildozer.config.getdefault('app', 'android.blacklist_src', None)
if whitelist_src:
cmd.append('--whitelist')
cmd.append(realpath(whitelist_src))
Expand Down
2 changes: 1 addition & 1 deletion docs/source/contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ To test your own recipe via Buildozer, you need to:

#. Change your `buildozer.spec` to reference your version::

android.p4a_dir = /path/to/your/python-for-android
p4a.source_dir = /path/to/your/python-for-android

#. Copy your recipe into `python-for-android/recipes/YOURLIB/recipe.sh`

Expand Down

0 comments on commit 48ea268

Please sign in to comment.