Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include paths for sdl2_mixer have changed. Added a method to return the right one. #2700

Merged
merged 1 commit into from
Nov 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pythonforandroid/recipes/audiostream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ class AudiostreamRecipe(CythonRecipe):
def get_recipe_env(self, arch):
env = super().get_recipe_env(arch)
sdl_include = 'SDL2'
sdl_mixer_include = 'SDL2_mixer'

env['USE_SDL2'] = 'True'
env['SDL2_INCLUDE_DIR'] = join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include')

env['CFLAGS'] += ' -I{jni_path}/{sdl_include}/include -I{jni_path}/{sdl_mixer_include}'.format(
env['CFLAGS'] += ' -I{jni_path}/{sdl_include}/include'.format(
jni_path=join(self.ctx.bootstrap.build_dir, 'jni'),
sdl_include=sdl_include,
sdl_mixer_include=sdl_mixer_include)
sdl_include=sdl_include)

sdl2_mixer_recipe = self.get_recipe('sdl2_mixer', self.ctx)
for include_dir in sdl2_mixer_recipe.get_include_dirs(arch):
env['CFLAGS'] += ' -I{include_dir}'.format(include_dir=include_dir)

# NDKPLATFORM is our switch for detecting Android platform, so can't be None
env['NDKPLATFORM'] = "NOTNONE"
env['LIBLINK'] = 'NOTNONE' # Hacky fix. Needed by audiostream setup.py
Expand Down
6 changes: 5 additions & 1 deletion pythonforandroid/recipes/ffpyplayer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ def get_recipe_env(self, arch, with_flags_in_cc=True):
env["SDL_LIB_DIR"] = join(self.ctx.bootstrap.build_dir, 'libs', arch.arch)

env["USE_SDL2_MIXER"] = '1'
env["SDL2_MIXER_INCLUDE_DIR"] = join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_mixer')

# ffpyplayer does not allow to pass more than one include dir for sdl2_mixer (and ATM is
# not needed), so we only pass the first one.
sdl2_mixer_recipe = self.get_recipe('sdl2_mixer', self.ctx)
env["SDL2_MIXER_INCLUDE_DIR"] = sdl2_mixer_recipe.get_include_dirs(arch)[0]

# NDKPLATFORM and LIBLINK are our switches for detecting Android platform, so can't be empty
# FIXME: We may want to introduce a cleaner approach to this?
Expand Down
3 changes: 2 additions & 1 deletion pythonforandroid/recipes/kivy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ def get_recipe_env(self, arch):
if 'sdl2' in self.ctx.recipe_build_order:
env['USE_SDL2'] = '1'
env['KIVY_SPLIT_EXAMPLES'] = '1'
sdl2_mixer_recipe = self.get_recipe('sdl2_mixer', self.ctx)
env['KIVY_SDL2_PATH'] = ':'.join([
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include'),
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_image'),
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_mixer', 'include'),
*sdl2_mixer_recipe.get_include_dirs(arch),
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'),
])

Expand Down
7 changes: 6 additions & 1 deletion pythonforandroid/recipes/pygame/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@ def prebuild_arch(self, arch):
jpeg = self.get_recipe('jpeg', self.ctx)
jpeg_inc_dir = jpeg_lib_dir = jpeg.get_build_dir(arch.arch)

sdl_mixer_includes = ""
sdl2_mixer_recipe = self.get_recipe('sdl2_mixer', self.ctx)
for include_dir in sdl2_mixer_recipe.get_include_dirs(arch):
sdl_mixer_includes += f"-I{include_dir} "

setup_file = setup_template.format(
sdl_includes=(
" -I" + join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include') +
" -L" + join(self.ctx.bootstrap.build_dir, "libs", str(arch)) +
" -L" + png_lib_dir + " -L" + jpeg_lib_dir + " -L" + arch.ndk_lib_dir_versioned),
sdl_ttf_includes="-I"+join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'),
sdl_image_includes="-I"+join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_image'),
sdl_mixer_includes="-I"+join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_mixer'),
sdl_mixer_includes=sdl_mixer_includes,
jpeg_includes="-I"+jpeg_inc_dir,
png_includes="-I"+png_inc_dir,
freetype_includes=""
Expand Down
7 changes: 7 additions & 0 deletions pythonforandroid/recipes/sdl2_mixer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from pythonforandroid.recipe import BootstrapNDKRecipe


Expand All @@ -6,5 +8,10 @@ class LibSDL2Mixer(BootstrapNDKRecipe):
url = 'https://github.com/libsdl-org/SDL_mixer/releases/download/release-{version}/SDL2_mixer-{version}.tar.gz'
dir_name = 'SDL2_mixer'

def get_include_dirs(self, arch):
return [
os.path.join(self.ctx.bootstrap.build_dir, "jni", "SDL2_mixer", "include")
]


recipe = LibSDL2Mixer()
14 changes: 14 additions & 0 deletions tests/recipes/test_sdl2_mixer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import unittest
from tests.recipes.recipe_lib_test import RecipeCtx


class TestSDL2MixerRecipe(RecipeCtx, unittest.TestCase):
"""
An unittest for recipe :mod:`~pythonforandroid.recipes.sdl2_mixer`
"""
recipe_name = "sdl2_mixer"

def test_get_include_dirs(self):
list_of_includes = self.recipe.get_include_dirs(self.arch)
self.assertIsInstance(list_of_includes, list)
self.assertTrue(list_of_includes[0].endswith("include"))