From 8fcc6324193ac1363ae08e35c69e5eef4ea2d5cf Mon Sep 17 00:00:00 2001 From: Hottwaj Date: Sat, 5 Dec 2015 15:24:34 +0000 Subject: [PATCH 1/2] Added audiostream recipe. Works with SDL only. audiostream library needs to be tweaked to know when it should link against SDL2 instead of SDL --- .../recipes/audiostream/__init__.py | 35 ++++++++++++++++ .../recipes/audiostream/recipe.sh | 41 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 pythonforandroid/recipes/audiostream/__init__.py create mode 100644 pythonforandroid/recipes/audiostream/recipe.sh diff --git a/pythonforandroid/recipes/audiostream/__init__.py b/pythonforandroid/recipes/audiostream/__init__.py new file mode 100644 index 0000000000..3edb0da033 --- /dev/null +++ b/pythonforandroid/recipes/audiostream/__init__.py @@ -0,0 +1,35 @@ + +from pythonforandroid.toolchain import CythonRecipe, shprint, ArchAndroid, current_directory, info +import sh +import glob +from os.path import join, exists + + +class AudiostreamRecipe(CythonRecipe): + version = 'master' + url = 'https://github.com/kivy/audiostream/archive/{version}.zip' + name = 'audiostream' + depends = ['python2', ('sdl', 'sdl2'), 'pyjnius'] + + def get_recipe_env(self, arch): + if 'sdl' in self.ctx.recipe_build_order: + sdl_include = 'sdl' + sdl_mixer_include = 'sdl_mixer' + elif 'sdl2' in self.ctx.recipe_build_order: + sdl_include = 'SDL' + sdl_mixer_include = 'SDL2_mixer' + + #note: audiostream library is not yet able to judge whether it is being used with sdl or with sdl2. + #this causes linking to fail against SDL2 (compiling against SDL2 works) + #need to find a way to fix this in audiostream's setup.py + + env = super(AudiostreamRecipe, self).get_recipe_env(arch) + env['CFLAGS'] += ' -I{jni_path}/{sdl_include}/include -I{jni_path}/{sdl_mixer_include}'.format( + jni_path = join(self.ctx.bootstrap.build_dir, 'jni'), + sdl_include = sdl_include, + sdl_mixer_include = sdl_mixer_include) + return env + + + +recipe = AudiostreamRecipe() diff --git a/pythonforandroid/recipes/audiostream/recipe.sh b/pythonforandroid/recipes/audiostream/recipe.sh new file mode 100644 index 0000000000..1cf22e738c --- /dev/null +++ b/pythonforandroid/recipes/audiostream/recipe.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +VERSION_audiostream=${VERSION_audiostream:-master} +URL_audiostream=https://github.com/kivy/audiostream/archive/$VERSION_audiostream.zip +DEPS_audiostream=(python sdl pyjnius) +MD5_audiostream= +BUILD_audiostream=$BUILD_PATH/audiostream/$(get_directory $URL_audiostream) +RECIPE_audiostream=$RECIPES_PATH/audiostream + +function prebuild_audiostream() { + cd $BUILD_audiostream +} + +function shouldbuild_audiostream() { + if [ -d "$SITEPACKAGES_PATH/audiostream" ]; then + DO_BUILD=0 + fi +} + +function build_audiostream() { + cd $BUILD_audiostream + + push_arm + + # build python extension + export JNI_PATH=$JNI_PATH + export CFLAGS="$CFLAGS -I$JNI_PATH/sdl/include -I$JNI_PATH/sdl_mixer/" + export LDFLAGS="$LDFLAGS -lm -L$LIBS_PATH" + try cd $BUILD_audiostream + $HOSTPYTHON setup.py build_ext &>/dev/null + try find . -iname '*.pyx' -exec $CYTHON {} \; + try $HOSTPYTHON setup.py build_ext -v + try $HOSTPYTHON setup.py install -O2 + try cp -a audiostream/platform/android/org $JAVACLASS_PATH + + pop_arm +} + +function postbuild_audiostream() { + true +} From 015f00019169b640c7f67ce401331c174e0617ae Mon Sep 17 00:00:00 2001 From: Hottwaj Date: Sat, 5 Dec 2015 15:50:10 +0000 Subject: [PATCH 2/2] Because audiostream can't link against audiostream yet, raise an error with more helpful message --- pythonforandroid/recipes/audiostream/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pythonforandroid/recipes/audiostream/__init__.py b/pythonforandroid/recipes/audiostream/__init__.py index 3edb0da033..dcee1f9e3f 100644 --- a/pythonforandroid/recipes/audiostream/__init__.py +++ b/pythonforandroid/recipes/audiostream/__init__.py @@ -18,11 +18,12 @@ def get_recipe_env(self, arch): elif 'sdl2' in self.ctx.recipe_build_order: sdl_include = 'SDL' sdl_mixer_include = 'SDL2_mixer' + + #note: audiostream library is not yet able to judge whether it is being used with sdl or with sdl2. + #this causes linking to fail against SDL2 (compiling against SDL2 works) + #need to find a way to fix this in audiostream's setup.py + raise RuntimeError('Audiostream library is not yet able to configure itself to link against SDL2. Patch on audiostream library needed - any help much appreciated!') - #note: audiostream library is not yet able to judge whether it is being used with sdl or with sdl2. - #this causes linking to fail against SDL2 (compiling against SDL2 works) - #need to find a way to fix this in audiostream's setup.py - env = super(AudiostreamRecipe, self).get_recipe_env(arch) env['CFLAGS'] += ' -I{jni_path}/{sdl_include}/include -I{jni_path}/{sdl_mixer_include}'.format( jni_path = join(self.ctx.bootstrap.build_dir, 'jni'),