• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kivy / python-for-android / 14420258271

12 Apr 2025 01:55PM UTC coverage: 59.141% (+0.03%) from 59.111%
14420258271

push

github

web-flow
Add `SDL3` bootstrap (alongside `SDL3`, `SDL3_ttf`, `SDL3_mixer`, `SDL3_image` recipes) for Kivy `3.0.0` (#3125)

* Add SDL3 bootstrap

* Avoid some DRY issues + minor fixes + version bump

1054 of 2383 branches covered (44.23%)

Branch coverage included in aggregate %.

112 of 160 new or added lines in 14 files covered. (70.0%)

1 existing line in 1 file now uncovered.

4960 of 7786 relevant lines covered (63.7%)

2.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

23.21
/pythonforandroid/recipes/android/__init__.py
1
from pythonforandroid.recipe import CythonRecipe, IncludedFilesBehaviour
4✔
2
from pythonforandroid.util import current_directory
4✔
3
from pythonforandroid import logger
4✔
4

5
from os.path import join
4✔
6

7

8
class AndroidRecipe(IncludedFilesBehaviour, CythonRecipe):
4✔
9
    # name = 'android'
10
    version = None
4✔
11
    url = None
4✔
12

13
    src_filename = 'src'
4✔
14

15
    depends = [('sdl3', 'sdl2', 'genericndkbuild'), 'pyjnius']
4✔
16

17
    config_env = {}
4✔
18

19
    def get_recipe_env(self, arch):
4✔
20
        env = super().get_recipe_env(arch)
×
21
        env.update(self.config_env)
×
22
        return env
×
23

24
    def prebuild_arch(self, arch):
4✔
25
        super().prebuild_arch(arch)
×
26
        ctx_bootstrap = self.ctx.bootstrap.name
×
27

28
        # define macros for Cython, C, Python
29
        tpxi = 'DEF {} = {}\n'
×
30
        th = '#define {} {}\n'
×
31
        tpy = '{} = {}\n'
×
32

33
        # make sure bootstrap name is in unicode
34
        if isinstance(ctx_bootstrap, bytes):
×
35
            ctx_bootstrap = ctx_bootstrap.decode('utf-8')
×
36
        bootstrap = bootstrap_name = ctx_bootstrap
×
NEW
37
        if bootstrap_name in ["sdl2", "sdl3", "webview", "service_only", "service_library", "qt"]:
×
38
            java_ns = u'org.kivy.android'
×
39
            jni_ns = u'org/kivy/android'
×
40
        else:
41
            logger.error((
×
42
                'unsupported bootstrap for android recipe: {}'
43
                ''.format(bootstrap_name)
44
            ))
45
            exit(1)
×
46

47
        config = {
×
48
            'BOOTSTRAP': bootstrap,
49
            'IS_SDL2': int(bootstrap_name == "sdl2"),
50
            'IS_SDL3': int(bootstrap_name == "sdl3"),
51
            'PY2': 0,
52
            'JAVA_NAMESPACE': java_ns,
53
            'JNI_NAMESPACE': jni_ns,
54
            'ACTIVITY_CLASS_NAME': self.ctx.activity_class_name,
55
            'ACTIVITY_CLASS_NAMESPACE': self.ctx.activity_class_name.replace('.', '/'),
56
            'SERVICE_CLASS_NAME': self.ctx.service_class_name,
57
        }
58

59
        # create config files for Cython, C and Python
60
        with (
×
61
                current_directory(self.get_build_dir(arch.arch))), (
62
                open(join('android', 'config.pxi'), 'w')) as fpxi, (
63
                open(join('android', 'config.h'), 'w')) as fh, (
64
                open(join('android', 'config.py'), 'w')) as fpy:
65

66
            for key, value in config.items():
×
67
                fpxi.write(tpxi.format(key, repr(value)))
×
68
                fpy.write(tpy.format(key, repr(value)))
×
69

70
                fh.write(th.format(
×
71
                    key,
72
                    value if isinstance(value, int) else '"{}"'.format(value)
73
                ))
74
                self.config_env[key] = str(value)
×
75

NEW
76
            if bootstrap_name == "sdl2":
×
77
                fh.write('JNIEnv *SDL_AndroidGetJNIEnv(void);\n')
×
78
                fh.write(
×
79
                    '#define SDL_ANDROID_GetJNIEnv SDL_AndroidGetJNIEnv\n'
80
                )
NEW
81
            elif bootstrap_name == "sdl3":
×
NEW
82
                fh.write('JNIEnv *SDL_GetAndroidJNIEnv(void);\n')
×
NEW
83
                fh.write(
×
84
                    '#define SDL_ANDROID_GetJNIEnv SDL_GetAndroidJNIEnv\n'
85
                )
86
            else:
87
                fh.write('JNIEnv *WebView_AndroidGetJNIEnv(void);\n')
×
88
                fh.write(
×
89
                    '#define SDL_ANDROID_GetJNIEnv WebView_AndroidGetJNIEnv\n'
90
                )
91

92

93
recipe = AndroidRecipe()
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc