Skip to content

Commit 27b95a3

Browse files
authored
Merge pull request kivy#1541 from opacam/python-core-bootstraps
[CORE UPDATE - PART II] Fix bootstraps for webview and service_only
2 parents 6735c6f + 2be9ca0 commit 27b95a3

File tree

78 files changed

+3250
-3933
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+3250
-3933
lines changed

pythonforandroid/bootstraps/common/build/build.py

Lines changed: 48 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def get_bootstrap_name():
6868
BLACKLIST_PATTERNS.append('*.py')
6969

7070
WHITELIST_PATTERNS = []
71-
if get_bootstrap_name() == "sdl2":
72-
WHITELIST_PATTERNS.append("pyconfig.h")
71+
if get_bootstrap_name() in ('sdl2', 'webview', 'service_only'):
72+
WHITELIST_PATTERNS.append('pyconfig.h')
7373

7474
python_files = []
7575

@@ -263,8 +263,6 @@ def make_package(args):
263263
sys.exit(1)
264264

265265
assets_dir = "src/main/assets"
266-
if get_bootstrap_name() != "sdl2":
267-
assets_dir = "assets"
268266

269267
# Delete the old assets.
270268
try_unlink(join(assets_dir, 'public.mp3'))
@@ -291,15 +289,13 @@ def make_package(args):
291289

292290
# Prepare some variables for templating process
293291
res_dir = "src/main/res"
294-
if get_bootstrap_name() == "webview":
295-
res_dir = "res"
296292
default_icon = 'templates/kivy-icon.png'
297293
default_presplash = 'templates/kivy-presplash.jpg'
294+
shutil.copy(
295+
args.icon or default_icon,
296+
join(res_dir, 'drawable/icon.png')
297+
)
298298
if get_bootstrap_name() != "service_only":
299-
shutil.copy(
300-
args.icon or default_icon,
301-
join(res_dir, 'drawable/icon.png')
302-
)
303299
shutil.copy(
304300
args.presplash or default_presplash,
305301
join(res_dir, 'drawable/presplash.jpg')
@@ -340,9 +336,9 @@ def make_package(args):
340336
with open(args.intent_filters) as fd:
341337
args.intent_filters = fd.read()
342338

343-
if get_bootstrap_name() == "sdl2":
344-
args.add_activity = args.add_activity or []
345-
args.activity_launch_mode = args.activity_launch_mode or ''
339+
# if get_bootstrap_name() == "sdl2":
340+
args.add_activity = args.add_activity or []
341+
args.activity_launch_mode = args.activity_launch_mode or ''
346342

347343
if args.extra_source_dirs:
348344
esd = []
@@ -374,17 +370,11 @@ def make_package(args):
374370
sticky = 'sticky' in options
375371

376372
service_names.append(name)
377-
service_target_path = ""
378-
if get_bootstrap_name() != "sdl2":
379-
service_target_path =\
380-
'src/{}/Service{}.java'.format(args.package.replace(".", "/"),
381-
name.capitalize())
382-
else:
383-
service_target_path =\
384-
'src/main/java/{}/Service{}.java'.format(
385-
args.package.replace(".", "/"),
386-
name.capitalize()
387-
)
373+
service_target_path =\
374+
'src/main/java/{}/Service{}.java'.format(
375+
args.package.replace(".", "/"),
376+
name.capitalize()
377+
)
388378
render(
389379
'Service.tmpl.java',
390380
service_target_path,
@@ -424,8 +414,6 @@ def make_package(args):
424414

425415
# Render out android manifest:
426416
manifest_path = "src/main/AndroidManifest.xml"
427-
if get_bootstrap_name() != "sdl2":
428-
manifest_path = "AndroidManifest.xml"
429417
render_args = {
430418
"args": args,
431419
"service": service,
@@ -441,45 +429,39 @@ def make_package(args):
441429

442430
# Copy the AndroidManifest.xml to the dist root dir so that ant
443431
# can also use it
444-
if get_bootstrap_name() == "sdl2":
445-
if exists('AndroidManifest.xml'):
446-
remove('AndroidManifest.xml')
447-
shutil.copy(manifest_path, 'AndroidManifest.xml')
432+
if exists('AndroidManifest.xml'):
433+
remove('AndroidManifest.xml')
434+
shutil.copy(manifest_path, 'AndroidManifest.xml')
448435

449436
# gradle build templates
450-
if get_bootstrap_name() != "webview":
451-
# HISTORICALLY NOT SUPPORTED FOR WEBVIEW. Needs review? -JonasT
452-
render(
453-
'build.tmpl.gradle',
454-
'build.gradle',
455-
args=args,
456-
aars=aars,
457-
jars=jars,
458-
android_api=android_api,
459-
build_tools_version=build_tools_version)
437+
render(
438+
'build.tmpl.gradle',
439+
'build.gradle',
440+
args=args,
441+
aars=aars,
442+
jars=jars,
443+
android_api=android_api,
444+
build_tools_version=build_tools_version
445+
)
460446

461447
# ant build templates
462-
if get_bootstrap_name() != "service_only":
463-
# Historically, service_only doesn't support ant anymore.
464-
# Maybe we should also drop this for the others? -JonasT
465-
render(
466-
'build.tmpl.xml',
467-
'build.xml',
468-
args=args,
469-
versioned_name=versioned_name)
448+
render(
449+
'build.tmpl.xml',
450+
'build.xml',
451+
args=args,
452+
versioned_name=versioned_name)
470453

471454
# String resources:
472-
if get_bootstrap_name() != "service_only":
473-
render_args = {
474-
"args": args,
475-
"private_version": str(time.time())
476-
}
477-
if get_bootstrap_name() == "sdl2":
478-
render_args["url_scheme"] = url_scheme
479-
render(
480-
'strings.tmpl.xml',
481-
join(res_dir, 'values/strings.xml'),
482-
**render_args)
455+
render_args = {
456+
"args": args,
457+
"private_version": str(time.time())
458+
}
459+
if get_bootstrap_name() == "sdl2":
460+
render_args["url_scheme"] = url_scheme
461+
render(
462+
'strings.tmpl.xml',
463+
join(res_dir, 'values/strings.xml'),
464+
**render_args)
483465

484466
if exists(join("templates", "custom_rules.tmpl.xml")):
485467
render(
@@ -489,7 +471,7 @@ def make_package(args):
489471

490472
if get_bootstrap_name() == "webview":
491473
render('WebViewLoader.tmpl.java',
492-
'src/org/kivy/android/WebViewLoader.java',
474+
'src/main/java/org/kivy/android/WebViewLoader.java',
493475
args=args)
494476

495477
if args.sign:
@@ -551,6 +533,9 @@ def parse_args(args=None):
551533
help='The permissions to give this app.', nargs='+')
552534
ap.add_argument('--meta-data', dest='meta_data', action='append',
553535
help='Custom key=value to add in application metadata')
536+
ap.add_argument('--icon', dest='icon',
537+
help=('A png file to use as the icon for '
538+
'the application.'))
554539
if get_bootstrap_name() != "service_only":
555540
ap.add_argument('--presplash', dest='presplash',
556541
help=('A jpeg file to use as a screen while the '
@@ -566,9 +551,6 @@ def parse_args(args=None):
566551
ap.add_argument('--window', dest='window', action='store_true',
567552
default=False,
568553
help='Indicate if the application will be windowed')
569-
ap.add_argument('--icon', dest='icon',
570-
help=('A png file to use as the icon for '
571-
'the application.'))
572554
ap.add_argument('--orientation', dest='orientation',
573555
default='portrait',
574556
help=('The orientation that the game will '
@@ -626,9 +608,6 @@ def parse_args(args=None):
626608
'directory'))
627609
ap.add_argument('--with-billing', dest='billing_pubkey',
628610
help='If set, the billing service will be added (not implemented)')
629-
ap.add_argument('--service', dest='services', action='append',
630-
help='Declare a new service entrypoint: '
631-
'NAME:PATH_TO_PY[:foreground]')
632611
ap.add_argument('--add-source', dest='extra_source_dirs', action='append',
633612
help='Include additional source dirs in Java build')
634613
if get_bootstrap_name() == "webview":
@@ -708,7 +687,7 @@ def _read_configuration():
708687
if args.meta_data is None:
709688
args.meta_data = []
710689

711-
if args.services is None:
690+
if (not hasattr(args, 'services')) or args.services is None:
712691
args.services = []
713692

714693
if args.try_system_python_compile:
@@ -739,10 +718,8 @@ def _read_configuration():
739718
if x.strip() and not x.strip().startswith('#')]
740719
WHITELIST_PATTERNS += patterns
741720

742-
if args.private is None and (
743-
get_bootstrap_name() != "sdl2" or
744-
args.launcher is None
745-
):
721+
if args.private is None and \
722+
get_bootstrap_name() == 'sdl2' and args.launcher is None:
746723
print('Need --private directory or ' +
747724
'--launcher (SDL2 bootstrap only)' +
748725
'to have something to launch inside the .apk!')
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,90 @@
1-
@if "%DEBUG%" == "" @echo off
2-
@rem ##########################################################################
3-
@rem
4-
@rem Gradle startup script for Windows
5-
@rem
6-
@rem ##########################################################################
7-
8-
@rem Set local scope for the variables with windows NT shell
9-
if "%OS%"=="Windows_NT" setlocal
10-
11-
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12-
set DEFAULT_JVM_OPTS=
13-
14-
set DIRNAME=%~dp0
15-
if "%DIRNAME%" == "" set DIRNAME=.
16-
set APP_BASE_NAME=%~n0
17-
set APP_HOME=%DIRNAME%
18-
19-
@rem Find java.exe
20-
if defined JAVA_HOME goto findJavaFromJavaHome
21-
22-
set JAVA_EXE=java.exe
23-
%JAVA_EXE% -version >NUL 2>&1
24-
if "%ERRORLEVEL%" == "0" goto init
25-
26-
echo.
27-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28-
echo.
29-
echo Please set the JAVA_HOME variable in your environment to match the
30-
echo location of your Java installation.
31-
32-
goto fail
33-
34-
:findJavaFromJavaHome
35-
set JAVA_HOME=%JAVA_HOME:"=%
36-
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37-
38-
if exist "%JAVA_EXE%" goto init
39-
40-
echo.
41-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42-
echo.
43-
echo Please set the JAVA_HOME variable in your environment to match the
44-
echo location of your Java installation.
45-
46-
goto fail
47-
48-
:init
49-
@rem Get command-line arguments, handling Windowz variants
50-
51-
if not "%OS%" == "Windows_NT" goto win9xME_args
52-
if "%@eval[2+2]" == "4" goto 4NT_args
53-
54-
:win9xME_args
55-
@rem Slurp the command line arguments.
56-
set CMD_LINE_ARGS=
57-
set _SKIP=2
58-
59-
:win9xME_args_slurp
60-
if "x%~1" == "x" goto execute
61-
62-
set CMD_LINE_ARGS=%*
63-
goto execute
64-
65-
:4NT_args
66-
@rem Get arguments from the 4NT Shell from JP Software
67-
set CMD_LINE_ARGS=%$
68-
69-
:execute
70-
@rem Setup the command line
71-
72-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73-
74-
@rem Execute Gradle
75-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76-
77-
:end
78-
@rem End local scope for the variables with windows NT shell
79-
if "%ERRORLEVEL%"=="0" goto mainEnd
80-
81-
:fail
82-
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83-
rem the _cmd.exe /c_ return code!
84-
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85-
exit /b 1
86-
87-
:mainEnd
88-
if "%OS%"=="Windows_NT" endlocal
89-
90-
:omega
1+
@if "%DEBUG%" == "" @echo off
2+
@rem ##########################################################################
3+
@rem
4+
@rem Gradle startup script for Windows
5+
@rem
6+
@rem ##########################################################################
7+
8+
@rem Set local scope for the variables with windows NT shell
9+
if "%OS%"=="Windows_NT" setlocal
10+
11+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12+
set DEFAULT_JVM_OPTS=
13+
14+
set DIRNAME=%~dp0
15+
if "%DIRNAME%" == "" set DIRNAME=.
16+
set APP_BASE_NAME=%~n0
17+
set APP_HOME=%DIRNAME%
18+
19+
@rem Find java.exe
20+
if defined JAVA_HOME goto findJavaFromJavaHome
21+
22+
set JAVA_EXE=java.exe
23+
%JAVA_EXE% -version >NUL 2>&1
24+
if "%ERRORLEVEL%" == "0" goto init
25+
26+
echo.
27+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28+
echo.
29+
echo Please set the JAVA_HOME variable in your environment to match the
30+
echo location of your Java installation.
31+
32+
goto fail
33+
34+
:findJavaFromJavaHome
35+
set JAVA_HOME=%JAVA_HOME:"=%
36+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37+
38+
if exist "%JAVA_EXE%" goto init
39+
40+
echo.
41+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42+
echo.
43+
echo Please set the JAVA_HOME variable in your environment to match the
44+
echo location of your Java installation.
45+
46+
goto fail
47+
48+
:init
49+
@rem Get command-line arguments, handling Windowz variants
50+
51+
if not "%OS%" == "Windows_NT" goto win9xME_args
52+
if "%@eval[2+2]" == "4" goto 4NT_args
53+
54+
:win9xME_args
55+
@rem Slurp the command line arguments.
56+
set CMD_LINE_ARGS=
57+
set _SKIP=2
58+
59+
:win9xME_args_slurp
60+
if "x%~1" == "x" goto execute
61+
62+
set CMD_LINE_ARGS=%*
63+
goto execute
64+
65+
:4NT_args
66+
@rem Get arguments from the 4NT Shell from JP Software
67+
set CMD_LINE_ARGS=%$
68+
69+
:execute
70+
@rem Setup the command line
71+
72+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73+
74+
@rem Execute Gradle
75+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76+
77+
:end
78+
@rem End local scope for the variables with windows NT shell
79+
if "%ERRORLEVEL%"=="0" goto mainEnd
80+
81+
:fail
82+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83+
rem the _cmd.exe /c_ return code!
84+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85+
exit /b 1
86+
87+
:mainEnd
88+
if "%OS%"=="Windows_NT" endlocal
89+
90+
:omega

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy