Skip to content

Commit 6ebd2ff

Browse files
committed
Fix bootstrap build for launcher
1 parent 7b8cfc8 commit 6ebd2ff

File tree

1 file changed

+37
-13
lines changed
  • pythonforandroid/bootstraps/sdl2/build

1 file changed

+37
-13
lines changed

pythonforandroid/bootstraps/sdl2/build/build.py

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,15 @@ def make_package(args):
222222
# print('Your PATH must include android tools.')
223223
# sys.exit(-1)
224224

225-
if not (exists(join(realpath(args.private), 'main.py')) or
226-
exists(join(realpath(args.private), 'main.pyo'))):
227-
print('''BUILD FAILURE: No main.py(o) found in your app directory. This
225+
# Ignore warning if the launcher is in args
226+
if not args.launcher:
227+
if not (exists(join(realpath(args.private), 'main.py')) or
228+
exists(join(realpath(args.private), 'main.pyo'))):
229+
print('''BUILD FAILURE: No main.py(o) found in your app directory. This
228230
file must exist to act as the entry point for you app. If your app is
229231
started by a file with a different name, rename it to main.py or add a
230232
main.py that loads it.''')
231-
exit(1)
233+
exit(1)
232234

233235
# Delete the old assets.
234236
if exists('assets/public.mp3'):
@@ -248,8 +250,13 @@ def make_package(args):
248250
tar_dirs.append('private')
249251
if exists('crystax_python'):
250252
tar_dirs.append('crystax_python')
253+
251254
if args.private:
252255
make_tar('assets/private.mp3', tar_dirs, args.ignore_path)
256+
elif args.launcher:
257+
# clean 'None's as a result of main.py path absence
258+
tar_dirs = [tdir for tdir in tar_dirs if tdir]
259+
make_tar('assets/private.mp3', tar_dirs, args.ignore_path)
253260
# else:
254261
# make_tar('assets/private.mp3', ['private'])
255262

@@ -267,12 +274,18 @@ def make_package(args):
267274
# sys.exit(-1)
268275

269276

270-
# Prepare some variables for templating process
277+
# folder name for launcher
278+
url_scheme = 'kivy'
271279

272-
default_icon = 'templates/kivy-icon.png'
280+
# Prepare some variables for templating process
281+
if args.launcher:
282+
default_icon = 'templates/launcher-icon.png'
283+
default_presplash = 'templates/launcher-presplash.jpg'
284+
else:
285+
default_icon = 'templates/kivy-icon.png'
286+
default_presplash = 'templates/kivy-presplash.jpg'
273287
shutil.copy(args.icon or default_icon, 'res/drawable/icon.png')
274288

275-
default_presplash = 'templates/kivy-presplash.jpg'
276289
shutil.copy(args.presplash or default_presplash,
277290
'res/drawable/presplash.jpg')
278291

@@ -312,9 +325,10 @@ def make_package(args):
312325
args.extra_source_dirs = []
313326

314327
service = False
315-
service_main = join(realpath(args.private), 'service', 'main.py')
316-
if exists(service_main) or exists(service_main + 'o'):
317-
service = True
328+
if args.private:
329+
service_main = join(realpath(args.private), 'service', 'main.py')
330+
if exists(service_main) or exists(service_main + 'o'):
331+
service = True
318332

319333
service_names = []
320334
for sid, spec in enumerate(args.services):
@@ -344,6 +358,7 @@ def make_package(args):
344358
args=args,
345359
service=service,
346360
service_names=service_names,
361+
url_scheme=url_scheme,
347362
)
348363

349364
render(
@@ -355,7 +370,9 @@ def make_package(args):
355370
render(
356371
'strings.tmpl.xml',
357372
'res/values/strings.xml',
358-
args=args)
373+
args=args,
374+
url_scheme=url_scheme,
375+
)
359376

360377
render(
361378
'custom_rules.tmpl.xml',
@@ -391,8 +408,9 @@ def parse_args(args=None):
391408
''')
392409

393410
ap.add_argument('--private', dest='private',
394-
help='the dir of user files',
395-
required=True)
411+
help='the dir of user files')
412+
# , required=True) for launcher, crashes in make_package
413+
# if not mentioned (and the check is there anyway)
396414
ap.add_argument('--package', dest='package',
397415
help=('The name of the java package the project will be'
398416
' packaged under.'),
@@ -414,6 +432,9 @@ def parse_args(args=None):
414432
help=('The orientation that the game will display in. '
415433
'Usually one of "landscape", "portrait" or '
416434
'"sensor"'))
435+
ap.add_argument('--launcher', dest='launcher', action='store_true',
436+
help=('Provide this argument to build a multi-app '
437+
'launcher, rather than a single app.'))
417438
ap.add_argument('--icon', dest='icon',
418439
help='A png file to use as the icon for the application.')
419440
ap.add_argument('--permission', dest='permissions', action='append',
@@ -499,6 +520,9 @@ def parse_args(args=None):
499520
PYTHON = None
500521
BLACKLIST_PATTERNS.remove('*.py')
501522

523+
if args.launcher:
524+
WHITELIST_PATTERNS += ['pyconfig.h']
525+
502526
if args.blacklist:
503527
with open(args.blacklist) as fd:
504528
patterns = [x.strip() for x in fd.read().splitlines()

0 commit comments

Comments
 (0)