Skip to content

Commit 712a0dd

Browse files
committed
Use get_include_dirs + black format
1 parent d5e2bcd commit 712a0dd

File tree

5 files changed

+91
-32
lines changed

5 files changed

+91
-32
lines changed

pythonforandroid/recipes/kivy/__init__.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,21 @@ def get_recipe_env(self, arch):
7575
*sdl2_mixer_recipe.get_include_dirs(arch),
7676
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'),
7777
])
78-
if 'sdl3' in self.ctx.recipe_build_order:
79-
env['USE_SDL3'] = '1'
80-
env['KIVY_SPLIT_EXAMPLES'] = '1'
81-
env['KIVY_SDL3_PATH'] = ':'.join([
82-
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include'),
83-
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL3_image', 'include'),
84-
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL3_mixer', 'include'),
85-
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL3_ttf', 'include'),
86-
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include', 'SDL3'),
87-
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL3_image', 'include', 'SDL3_image'),
88-
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL3_mixer', 'include', 'SDL3_mixer'),
89-
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL3_ttf', 'include', 'SDL3_ttf'),
90-
])
78+
if "sdl3" in self.ctx.recipe_build_order:
79+
sdl3_mixer_recipe = self.get_recipe("sdl3_mixer", self.ctx)
80+
sdl3_image_recipe = self.get_recipe("sdl3_image", self.ctx)
81+
sdl3_ttf_recipe = self.get_recipe("sdl3_ttf", self.ctx)
82+
sdl3_recipe = self.get_recipe("sdl3", self.ctx)
83+
env["USE_SDL3"] = "1"
84+
env["KIVY_SPLIT_EXAMPLES"] = "1"
85+
env["KIVY_SDL3_PATH"] = ":".join(
86+
[
87+
*sdl3_mixer_recipe.get_include_dirs(arch),
88+
*sdl3_image_recipe.get_include_dirs(arch),
89+
*sdl3_ttf_recipe.get_include_dirs(arch),
90+
*sdl3_recipe.get_include_dirs(arch),
91+
]
92+
)
9193

9294
return env
9395

pythonforandroid/recipes/sdl3/__init__.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,36 @@ class LibSDL3Recipe(BootstrapNDKRecipe):
1010
url = "https://github.com/libsdl-org/SDL/releases/download/release-{version}/SDL3-{version}.tar.gz"
1111
# md5sum = 'a344eb827a03045c9b399e99af4af13d'
1212

13-
dir_name = 'SDL'
13+
dir_name = "SDL"
1414

15-
depends = ['sdl3_image', 'sdl3_mixer', 'sdl3_ttf']
15+
depends = ["sdl3_image", "sdl3_mixer", "sdl3_ttf"]
1616

17-
def get_recipe_env(self, arch=None, with_flags_in_cc=True, with_python=True):
17+
def get_recipe_env(
18+
self, arch=None, with_flags_in_cc=True, with_python=True
19+
):
1820
env = super().get_recipe_env(
19-
arch=arch, with_flags_in_cc=with_flags_in_cc, with_python=with_python)
20-
env['APP_ALLOW_MISSING_DEPS'] = 'true'
21+
arch=arch,
22+
with_flags_in_cc=with_flags_in_cc,
23+
with_python=with_python,
24+
)
25+
env["APP_ALLOW_MISSING_DEPS"] = "true"
2126
return env
2227

28+
def get_include_dirs(self, arch):
29+
return [
30+
join(self.ctx.bootstrap.build_dir, "jni", "SDL", "include"),
31+
join(self.ctx.bootstrap.build_dir, "jni", "SDL", "include", "SDL3"),
32+
]
33+
2334
def should_build(self, arch):
2435
libdir = join(self.get_build_dir(arch.arch), "../..", "libs", arch.arch)
25-
libs = ['libmain.so', 'libSDL3.so', 'libSDL3_image.so', 'libSDL3_mixer.so', 'libSDL3_ttf.so']
36+
libs = [
37+
"libmain.so",
38+
"libSDL3.so",
39+
"libSDL3_image.so",
40+
"libSDL3_mixer.so",
41+
"libSDL3_ttf.so",
42+
]
2643
return not all(exists(join(libdir, x)) for x in libs)
2744

2845
def build_arch(self, arch):
@@ -33,7 +50,7 @@ def build_arch(self, arch):
3350
sh.Command(join(self.ctx.ndk_dir, "ndk-build")),
3451
"V=1",
3552
"NDK_DEBUG=" + ("1" if self.ctx.build_as_debuggable else "0"),
36-
_env=env
53+
_env=env,
3754
)
3855

3956

pythonforandroid/recipes/sdl3_image/__init__.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,30 @@
88
class LibSDL3Image(BootstrapNDKRecipe):
99
version = "3.2.4"
1010
url = "https://github.com/libsdl-org/SDL_image/releases/download/release-{version}/SDL3_image-{version}.tar.gz"
11-
dir_name = 'SDL3_image'
11+
dir_name = "SDL3_image"
1212

13-
patches = ['enable-webp.patch']
13+
patches = ["enable-webp.patch"]
1414

1515
def get_include_dirs(self, arch):
1616
return [
17-
os.path.join(self.ctx.bootstrap.build_dir, "jni", "SDL3_image", "include")
17+
os.path.join(
18+
self.ctx.bootstrap.build_dir, "jni", "SDL3_image", "include"
19+
),
20+
os.path.join(
21+
self.ctx.bootstrap.build_dir,
22+
"jni",
23+
"SDL3_image",
24+
"include",
25+
"SDL3_image",
26+
),
1827
]
1928

2029
def prebuild_arch(self, arch):
2130
# We do not have a folder for each arch on BootstrapNDKRecipe, so we
2231
# need to skip the external deps download if we already have done it.
23-
external_deps_dir = os.path.join(self.get_build_dir(arch.arch), "external")
32+
external_deps_dir = os.path.join(
33+
self.get_build_dir(arch.arch), "external"
34+
)
2435
if not os.path.exists(os.path.join(external_deps_dir, "libwebp")):
2536
with current_directory(external_deps_dir):
2637
shprint(sh.Command("./download.sh"))

pythonforandroid/recipes/sdl3_mixer/__init__.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,34 @@ class LibSDL3Mixer(BootstrapNDKRecipe):
99
version = "72a73339731a12c1002f9caca64f1ab924938102"
1010
# url = "https://github.com/libsdl-org/SDL_ttf/releases/download/release-{version}/SDL3_ttf-{version}.tar.gz"
1111
url = "https://github.com/libsdl-org/SDL_mixer/archive/{version}.tar.gz"
12-
dir_name = 'SDL3_mixer'
12+
dir_name = "SDL3_mixer"
1313

14-
patches = ['disable-libgme.patch']
14+
patches = ["disable-libgme.patch"]
1515

1616
def get_include_dirs(self, arch):
1717
return [
18-
os.path.join(self.ctx.bootstrap.build_dir, "jni", "SDL3_mixer", "include")
18+
os.path.join(
19+
self.ctx.bootstrap.build_dir, "jni", "SDL3_mixer", "include"
20+
),
21+
os.path.join(
22+
self.ctx.bootstrap.build_dir,
23+
"jni",
24+
"SDL3_mixer",
25+
"include",
26+
"SDL3_mixer",
27+
),
1928
]
2029

2130
def prebuild_arch(self, arch):
2231
# We do not have a folder for each arch on BootstrapNDKRecipe, so we
2332
# need to skip the external deps download if we already have done it.
24-
external_deps_dir = os.path.join(self.get_build_dir(arch.arch), "external")
33+
external_deps_dir = os.path.join(
34+
self.get_build_dir(arch.arch), "external"
35+
)
2536

26-
if not os.path.exists(os.path.join(external_deps_dir, "libgme", "Android.mk")):
37+
if not os.path.exists(
38+
os.path.join(external_deps_dir, "libgme", "Android.mk")
39+
):
2740
with current_directory(external_deps_dir):
2841
shprint(sh.Command("./download.sh"))
2942
super().prebuild_arch(arch)

pythonforandroid/recipes/sdl3_ttf/__init__.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,30 @@
66

77

88
class LibSDL3TTF(BootstrapNDKRecipe):
9-
version = '3.2.0'
9+
version = "3.2.0"
1010
url = "https://github.com/libsdl-org/SDL_ttf/releases/download/release-{version}/SDL3_ttf-{version}.tar.gz"
11-
dir_name = 'SDL3_ttf'
11+
dir_name = "SDL3_ttf"
12+
13+
def get_include_dirs(self, arch):
14+
return [
15+
os.path.join(
16+
self.ctx.bootstrap.build_dir, "jni", "SDL3_ttf", "include"
17+
),
18+
os.path.join(
19+
self.ctx.bootstrap.build_dir,
20+
"jni",
21+
"SDL3_ttf",
22+
"include",
23+
"SDL3_ttf",
24+
),
25+
]
1226

1327
def prebuild_arch(self, arch):
1428
# We do not have a folder for each arch on BootstrapNDKRecipe, so we
1529
# need to skip the external deps download if we already have done it.
16-
external_deps_dir = os.path.join(self.get_build_dir(arch.arch), "external")
30+
external_deps_dir = os.path.join(
31+
self.get_build_dir(arch.arch), "external"
32+
)
1733
if not os.path.exists(os.path.join(external_deps_dir, "harfbuzz")):
1834
with current_directory(external_deps_dir):
1935
shprint(sh.Command("./download.sh"))

0 commit comments

Comments
 (0)