Skip to content

Commit 48ea268

Browse files
committed
migrate tokens. Closes #499
1 parent f55147e commit 48ea268

File tree

6 files changed

+57
-27
lines changed

6 files changed

+57
-27
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ config, along with the environment variables that would override them.
162162

163163
- ``title`` -> ``$APP_TITLE``
164164
- ``package.name`` -> ``$APP_PACKAGE_NAME``
165-
- ``android.p4a_dir`` -> ``$APP_ANDROID_P4A_DIR``
165+
- ``p4a.source_dir`` -> ``$APP_P4A_SOURCE_DIR``
166166

167167
Buildozer Virtual Machine
168168
-------------------------

buildozer/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ def check_configuration_tokens(self):
381381
'''Ensure the spec file is 'correct'.
382382
'''
383383
self.info('Check configuration tokens')
384+
self.migrate_configuration_tokens()
384385
get = self.config.getdefault
385386
errors = []
386387
adderror = errors.append
@@ -417,6 +418,25 @@ def check_configuration_tokens(self):
417418
print(error)
418419
exit(1)
419420

421+
def migrate_configuration_tokens(self):
422+
config = self.config
423+
if config.has_section("app"):
424+
migration = (
425+
("android.p4a_dir", "p4a.source_dir"),
426+
("android.p4a_whitelist", "android.whitelist"),
427+
("android.bootstrap", "p4a.bootstrap"),
428+
("android.branch", "p4a.branch"),
429+
("android.p4a_whitelist_src", "android.whitelist_src"),
430+
("android.p4a_blacklist_src", "android.blacklist_src")
431+
)
432+
for entry_old, entry_new in migration:
433+
if not config.has_option("app", entry_old):
434+
continue
435+
value = config.get("app", entry_old)
436+
config.set("app", entry_new, value)
437+
config.remove_option("app", entry_old)
438+
self.error("In section [app]: {} is deprecated, rename to {}!".format(
439+
entry_old, entry_new))
420440

421441
def check_build_layout(self):
422442
'''Ensure the build (local and global) directory layout and files are

buildozer/default.spec

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -111,29 +111,23 @@ fullscreen = 0
111111
# (str) ANT directory (if empty, it will be automatically downloaded.)
112112
#android.ant_path =
113113

114-
# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
115-
#android.p4a_dir =
116-
117-
# (str) The directory in which python-for-android should look for your own build recipes (if any)
118-
#p4a.local_recipes =
119-
120-
# (str) Filename to the hook for p4a
121-
#p4a.hook =
122-
123-
# (list) python-for-android whitelist
124-
#android.p4a_whitelist =
125-
126114
# (bool) If True, then skip trying to update the Android sdk
127115
# This can be useful to avoid excess Internet downloads or save time
128116
# when an update is due and you just want to test/build your package
129117
# android.skip_update = False
130118

131-
# (str) Bootstrap to use for android builds (android_new only)
132-
# android.bootstrap = sdl2
133-
134119
# (str) Android entry point, default is ok for Kivy-based app
135120
#android.entrypoint = org.renpy.android.PythonActivity
136121

122+
# (list) Pattern to whitelist for the whole project
123+
#android.whitelist =
124+
125+
# (str) Path to a custom whitelist file
126+
#android.whitelist_src =
127+
128+
# (str) Path to a custom blacklist file
129+
#android.blacklist_src =
130+
137131
# (list) List of Java .jar files to add to the libs so that pyjnius can access
138132
# their classes. Don't add jars that you do not need, since extra jars can slow
139133
# down the build process. Allows wildcards matching, for example:
@@ -152,9 +146,8 @@ fullscreen = 0
152146
# bootstrap)
153147
#android.gradle_dependencies =
154148

155-
# (str) python-for-android branch to use, if not master, useful to try
156-
# not yet merged features.
157-
#android.branch = master
149+
# (str) python-for-android branch to use, defaults to master
150+
#p4a.branch = master
158151

159152
# (str) OUYA Console category. Should be one of GAME or APP
160153
# If you leave this blank, OUYA support will not be enabled
@@ -192,6 +185,23 @@ fullscreen = 0
192185
# (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86
193186
android.arch = armeabi-v7a
194187

188+
#
189+
# Python for android (p4a) specific
190+
#
191+
192+
# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
193+
#p4a.source_dir =
194+
195+
# (str) The directory in which python-for-android should look for your own build recipes (if any)
196+
#p4a.local_recipes =
197+
198+
# (str) Filename to the hook for p4a
199+
#p4a.hook =
200+
201+
# (str) Bootstrap to use for android builds (android_new only)
202+
# p4a.bootstrap = sdl2
203+
204+
195205
#
196206
# iOS specific
197207
#

buildozer/targets/android.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,17 +462,17 @@ def _check_aidl(self, v_build_tools):
462462

463463
def install_platform(self):
464464
cmd = self.buildozer.cmd
465-
source = self.buildozer.config.getdefault('app', 'android.branch',
465+
source = self.buildozer.config.getdefault('app', 'p4a.branch',
466466
self.p4a_branch)
467467
self.pa_dir = pa_dir = join(self.buildozer.platform_dir,
468468
self.p4a_directory)
469469
system_p4a_dir = self.buildozer.config.getdefault('app',
470-
'android.p4a_dir')
470+
'p4a.source_dir')
471471
if system_p4a_dir:
472472
self.pa_dir = pa_dir = expanduser(system_p4a_dir)
473473
if not self.buildozer.file_exists(pa_dir):
474474
self.buildozer.error(
475-
'Path for android.p4a_dir does not exist')
475+
'Path for p4a.source_dir does not exist')
476476
self.buildozer.error('')
477477
raise BuildozerException()
478478
else:
@@ -594,7 +594,7 @@ def _get_package(self):
594594

595595
def _generate_whitelist(self, dist_dir):
596596
p4a_whitelist = self.buildozer.config.getlist(
597-
'app', 'android.p4a_whitelist') or []
597+
'app', 'android.whitelist') or []
598598
whitelist_fn = join(dist_dir, 'whitelist.txt')
599599
with open(whitelist_fn, 'w') as fd:
600600
for wl in p4a_whitelist:

buildozer/targets/android_new.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self, *args, **kwargs):
2222
executable = sys.executable or 'python'
2323
self._p4a_cmd = '{} -m pythonforandroid.toolchain '.format(executable)
2424
self._p4a_bootstrap = self.buildozer.config.getdefault(
25-
'app', 'android.bootstrap', 'sdl2')
25+
'app', 'p4a.bootstrap', 'sdl2')
2626
self.p4a_apk_cmd += self._p4a_bootstrap
2727
color = 'always' if USE_COLOR else 'never'
2828
self.extra_p4a_args = ' --color={} --storage-dir={}'.format(
@@ -124,8 +124,8 @@ def execute_build_package(self, build_cmd):
124124
cmd.append(local_recipes)
125125

126126
# support for blacklist/whitelist filename
127-
whitelist_src = self.buildozer.config.getdefault('app', 'android.p4a_whitelist_src', None)
128-
blacklist_src = self.buildozer.config.getdefault('app', 'android.p4a_blacklist_src', None)
127+
whitelist_src = self.buildozer.config.getdefault('app', 'android.whitelist_src', None)
128+
blacklist_src = self.buildozer.config.getdefault('app', 'android.blacklist_src', None)
129129
if whitelist_src:
130130
cmd.append('--whitelist')
131131
cmd.append(realpath(whitelist_src))

docs/source/contribute.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ To test your own recipe via Buildozer, you need to:
2222

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

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

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

0 commit comments

Comments
 (0)