Skip to content

Commit 8fcc632

Browse files
committed
Added audiostream recipe. Works with SDL only. audiostream library needs to be tweaked to know when it should link against SDL2 instead of SDL
1 parent ce4f76f commit 8fcc632

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
from pythonforandroid.toolchain import CythonRecipe, shprint, ArchAndroid, current_directory, info
3+
import sh
4+
import glob
5+
from os.path import join, exists
6+
7+
8+
class AudiostreamRecipe(CythonRecipe):
9+
version = 'master'
10+
url = 'https://github.com/kivy/audiostream/archive/{version}.zip'
11+
name = 'audiostream'
12+
depends = ['python2', ('sdl', 'sdl2'), 'pyjnius']
13+
14+
def get_recipe_env(self, arch):
15+
if 'sdl' in self.ctx.recipe_build_order:
16+
sdl_include = 'sdl'
17+
sdl_mixer_include = 'sdl_mixer'
18+
elif 'sdl2' in self.ctx.recipe_build_order:
19+
sdl_include = 'SDL'
20+
sdl_mixer_include = 'SDL2_mixer'
21+
22+
#note: audiostream library is not yet able to judge whether it is being used with sdl or with sdl2.
23+
#this causes linking to fail against SDL2 (compiling against SDL2 works)
24+
#need to find a way to fix this in audiostream's setup.py
25+
26+
env = super(AudiostreamRecipe, self).get_recipe_env(arch)
27+
env['CFLAGS'] += ' -I{jni_path}/{sdl_include}/include -I{jni_path}/{sdl_mixer_include}'.format(
28+
jni_path = join(self.ctx.bootstrap.build_dir, 'jni'),
29+
sdl_include = sdl_include,
30+
sdl_mixer_include = sdl_mixer_include)
31+
return env
32+
33+
34+
35+
recipe = AudiostreamRecipe()
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
VERSION_audiostream=${VERSION_audiostream:-master}
4+
URL_audiostream=https://github.com/kivy/audiostream/archive/$VERSION_audiostream.zip
5+
DEPS_audiostream=(python sdl pyjnius)
6+
MD5_audiostream=
7+
BUILD_audiostream=$BUILD_PATH/audiostream/$(get_directory $URL_audiostream)
8+
RECIPE_audiostream=$RECIPES_PATH/audiostream
9+
10+
function prebuild_audiostream() {
11+
cd $BUILD_audiostream
12+
}
13+
14+
function shouldbuild_audiostream() {
15+
if [ -d "$SITEPACKAGES_PATH/audiostream" ]; then
16+
DO_BUILD=0
17+
fi
18+
}
19+
20+
function build_audiostream() {
21+
cd $BUILD_audiostream
22+
23+
push_arm
24+
25+
# build python extension
26+
export JNI_PATH=$JNI_PATH
27+
export CFLAGS="$CFLAGS -I$JNI_PATH/sdl/include -I$JNI_PATH/sdl_mixer/"
28+
export LDFLAGS="$LDFLAGS -lm -L$LIBS_PATH"
29+
try cd $BUILD_audiostream
30+
$HOSTPYTHON setup.py build_ext &>/dev/null
31+
try find . -iname '*.pyx' -exec $CYTHON {} \;
32+
try $HOSTPYTHON setup.py build_ext -v
33+
try $HOSTPYTHON setup.py install -O2
34+
try cp -a audiostream/platform/android/org $JAVACLASS_PATH
35+
36+
pop_arm
37+
}
38+
39+
function postbuild_audiostream() {
40+
true
41+
}

0 commit comments

Comments
 (0)