20
20
from fnmatch import fnmatch
21
21
import jinja2
22
22
23
+ from pythonforandroid .bootstrap import SDL_BOOTSTRAPS
23
24
from pythonforandroid .util import rmdir , ensure_dir , max_build_tool_version
24
25
25
26
@@ -83,7 +84,7 @@ def get_bootstrap_name():
83
84
if PYTHON is not None and not exists (PYTHON ):
84
85
PYTHON = None
85
86
86
- if _bootstrap_name in ('sdl2' , 'webview' , 'service_only' , 'qt' ):
87
+ if _bootstrap_name in ('sdl2' , 'sdl3' , ' webview' , 'service_only' , 'qt' ):
87
88
WHITELIST_PATTERNS .append ('pyconfig.h' )
88
89
89
90
environment = jinja2 .Environment (loader = jinja2 .FileSystemLoader (
@@ -220,6 +221,10 @@ def compile_py_file(python_file, optimize_python=True):
220
221
return "." .join ([os .path .splitext (python_file )[0 ], "pyc" ])
221
222
222
223
224
+ def is_sdl_bootstrap ():
225
+ return get_bootstrap_name () in SDL_BOOTSTRAPS
226
+
227
+
223
228
def make_package (args ):
224
229
# If no launcher is specified, require a main.py/main.pyc:
225
230
if (get_bootstrap_name () != "sdl" or args .launcher is None ) and \
@@ -541,7 +546,7 @@ def make_package(args):
541
546
"debug" : "debug" in args .build_mode ,
542
547
"native_services" : args .native_services
543
548
}
544
- if get_bootstrap_name () == "sdl2" :
549
+ if is_sdl_bootstrap () :
545
550
render_args ["url_scheme" ] = url_scheme
546
551
547
552
render (
@@ -596,7 +601,7 @@ def make_package(args):
596
601
"args" : args ,
597
602
"private_version" : hashlib .sha1 (private_version .encode ()).hexdigest ()
598
603
}
599
- if get_bootstrap_name () == "sdl2" :
604
+ if is_sdl_bootstrap () :
600
605
render_args ["url_scheme" ] = url_scheme
601
606
render (
602
607
'strings.tmpl.xml' ,
@@ -769,7 +774,7 @@ def create_argument_parser():
769
774
ap .add_argument ('--private' , dest = 'private' ,
770
775
help = 'the directory with the app source code files' +
771
776
' (containing your main.py entrypoint)' ,
772
- required = (get_bootstrap_name () != "sdl2" ))
777
+ required = (not is_sdl_bootstrap () ))
773
778
ap .add_argument ('--package' , dest = 'package' ,
774
779
help = ('The name of the java package the project will be'
775
780
' packaged under.' ),
@@ -787,7 +792,7 @@ def create_argument_parser():
787
792
'same number of groups of numbers as previous '
788
793
'versions.' ),
789
794
required = True )
790
- if get_bootstrap_name () == "sdl2" :
795
+ if is_sdl_bootstrap () :
791
796
ap .add_argument ('--launcher' , dest = 'launcher' , action = 'store_true' ,
792
797
help = ('Provide this argument to build a multi-app '
793
798
'launcher, rather than a single app.' ))
@@ -1044,7 +1049,7 @@ def _read_configuration():
1044
1049
args .orientation , args .manifest_orientation
1045
1050
)
1046
1051
1047
- if get_bootstrap_name () == "sdl2" :
1052
+ if is_sdl_bootstrap () :
1048
1053
args .sdl_orientation_hint = get_sdl_orientation_hint (args .orientation )
1049
1054
1050
1055
if args .res_xmls and isinstance (args .res_xmls [0 ], list ):
@@ -1073,10 +1078,9 @@ def _read_configuration():
1073
1078
if x .strip () and not x .strip ().startswith ('#' )]
1074
1079
WHITELIST_PATTERNS += patterns
1075
1080
1076
- if args .private is None and \
1077
- get_bootstrap_name () == 'sdl2' and args .launcher is None :
1081
+ if args .private is None and is_sdl_bootstrap () and args .launcher is None :
1078
1082
print ('Need --private directory or ' +
1079
- '--launcher (SDL2 bootstrap only)' +
1083
+ '--launcher (SDL2/SDL3 bootstrap only)' +
1080
1084
'to have something to launch inside the .apk!' )
1081
1085
sys .exit (1 )
1082
1086
make_package (args )
0 commit comments