1+ from __future__ import unicode_literals
12from pythonforandroid .recipe import CythonRecipe , IncludedFilesBehaviour
23from pythonforandroid .util import current_directory
34from pythonforandroid .patching import will_build
45from pythonforandroid import logger
56
67from os .path import join
7- from sys import version_info
88
99
1010class AndroidRecipe (IncludedFilesBehaviour , CythonRecipe ):
@@ -26,27 +26,35 @@ def get_recipe_env(self, arch):
2626
2727 def prebuild_arch (self , arch ):
2828 super (AndroidRecipe , self ).prebuild_arch (arch )
29+ ctx_bootstrap = self .ctx .bootstrap .name
2930
31+ # define macros for Cython, C, Python
3032 tpxi = 'DEF {} = {}\n '
3133 th = '#define {} {}\n '
3234 tpy = '{} = {}\n '
3335
34- bootstrap = self .ctx .bootstrap .name
35- bootstrap = bootstrap_name = bootstrap if version_info >= (3 , ) else bootstrap .decode ('utf-8' )
36+ # make sure bootstrap name is in unicode
37+ if isinstance (ctx_bootstrap , bytes ):
38+ ctx_bootstrap = ctx_bootstrap .decode ('utf-8' )
39+ bootstrap = bootstrap_name = ctx_bootstrap
40+
3641 is_sdl2 = bootstrap_name in ('sdl2' , 'sdl2python3' , 'sdl2_gradle' )
3742 is_pygame = bootstrap_name in ('pygame' ,)
3843 is_webview = bootstrap_name in ('webview' ,)
3944
4045 if is_sdl2 or is_webview :
4146 if is_sdl2 :
4247 bootstrap = 'sdl2'
43- java_ns = u 'org.kivy.android'
44- jni_ns = u 'org/kivy/android'
48+ java_ns = 'org.kivy.android'
49+ jni_ns = 'org/kivy/android'
4550 elif is_pygame :
46- java_ns = 'org.renpy.android'
47- jni_ns = 'org/renpy/android'
51+ java_ns = b 'org.renpy.android'
52+ jni_ns = b 'org/renpy/android'
4853 else :
49- logger .error ('unsupported bootstrap for android recipe: {}' .format (bootstrap_name ))
54+ logger .error ((
55+ 'unsupported bootstrap for android recipe: {}'
56+ '' .format (bootstrap_name )
57+ ))
5058 exit (1 )
5159
5260 config = {
@@ -58,22 +66,28 @@ def prebuild_arch(self, arch):
5866 'JNI_NAMESPACE' : jni_ns ,
5967 }
6068
69+ # create config files for Cython, C and Python
6170 with (
6271 current_directory (self .get_build_dir (arch .arch ))), (
6372 open (join ('android' , 'config.pxi' ), 'w' )) as fpxi , (
6473 open (join ('android' , 'config.h' ), 'w' )) as fh , (
6574 open (join ('android' , 'config.py' ), 'w' )) as fpy :
75+
6676 for key , value in config .items ():
6777 fpxi .write (tpxi .format (key , repr (value )))
6878 fpy .write (tpy .format (key , repr (value )))
69- fh .write (th .format (key ,
70- value if isinstance (value , int )
71- else '"{}"' .format (value )))
79+
80+ fh .write (th .format (
81+ key ,
82+ value if isinstance (value , int ) else '"{}"' .format (value )
83+ ))
7284 self .config_env [key ] = str (value )
7385
7486 if is_sdl2 :
7587 fh .write ('JNIEnv *SDL_AndroidGetJNIEnv(void);\n ' )
76- fh .write ('#define SDL_ANDROID_GetJNIEnv SDL_AndroidGetJNIEnv\n ' )
88+ fh .write (
89+ '#define SDL_ANDROID_GetJNIEnv SDL_AndroidGetJNIEnv\n '
90+ )
7791 elif is_pygame :
7892 fh .write ('JNIEnv *SDL_ANDROID_GetJNIEnv(void);\n ' )
7993
0 commit comments