migrate tokens. Closes #499

This commit is contained in:
Mathieu Virbel 2017-05-15 01:09:35 +02:00
parent f55147e300
commit 48ea268636
6 changed files with 57 additions and 27 deletions

View file

@ -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
-------------------------

View file

@ -381,6 +381,7 @@ class Buildozer(object):
'''Ensure the spec file is 'correct'.
'''
self.info('Check configuration tokens')
self.migrate_configuration_tokens()
get = self.config.getdefault
errors = []
adderror = errors.append
@ -417,6 +418,25 @@ class Buildozer(object):
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

View file

@ -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:
@ -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
@ -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
#

View file

@ -462,17 +462,17 @@ class TargetAndroid(Target):
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:
@ -594,7 +594,7 @@ class TargetAndroid(Target):
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:

View file

@ -22,7 +22,7 @@ class TargetAndroidNew(TargetAndroid):
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(
@ -124,8 +124,8 @@ class TargetAndroidNew(TargetAndroid):
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))

View file

@ -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`