8000 Add openal, pyopenal, pyogg, libogg, libvorbis recipes · bb33bb/python-for-android@13f7a97 · GitHub
[go: up one dir, main page]

Skip to content

Commit 13f7a97

Browse files
author
Kim Rinnewitz
committed
Add openal, pyopenal, pyogg, libogg, libvorbis recipes
1 parent 333a323 commit 13f7a97

File tree

7 files changed

+156
-0
lines changed

7 files changed

+156
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from pythonforandroid.recipe import NDKRecipe
2+
from pythonforandroid.toolchain import current_directory, shprint
3+
from os.path import join
4+
import sh
5+
6+
7+
class OggRecipe(NDKRecipe):
8+
version = '1.3.3'
9+
url = 'http://downloads.xiph.org/releases/ogg/libogg-{version}.tar.gz'
10+
11+
generated_libraries = ['libogg.so']
12+
13+
def build_arch(self, arch):
14+
with current_directory(self.get_build_dir(arch.arch)):
15+
env = self.get_recipe_env(arch)
16+
flags = [
17+
'--with-sysroot=' + self.ctx.ndk_platform,
18+
'--host=' + arch.toolchain_prefix,
19+
]
20+
configure = sh.Command('./configure')
21+
shprint(configure, *flags, _env=env)
22+
shprint(sh.make, _env=env)
23+
self.install_libs(arch, join('src', '.libs', 'libogg.so'))
24+
25+
26+
recipe = OggRecipe()
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from pythonforandroid.recipe import NDKRecipe
2+
from pythonforandroid.toolchain import current_directory, shprint
3+
from os.path import join
4+
import sh
5+
6+
7+
class VorbisRecipe(NDKRecipe):
8+
version = '1.3.6'
9+
url = 'http://downloads.xiph.org/releases/vorbis/libvorbis-{version}.tar.gz'
10+
opt_depends = ['libogg']
11+
12+
generated_libraries = ['libvorbis.so', 'libvorbisfile.so', 'libvorbisenc.so']
13+
14+
def get_recipe_env(self, arch=None):
15+
env = super(VorbisRecipe, self).get_recipe_env(arch)
16+
ogg = self.get_recipe('libogg', self.ctx)
17+
env['CFLAGS'] += ' -I{}'.format(join(ogg.get_build_dir(arch.arch), 'include'))
18+
return env
19+
20+
def build_arch(self, arch):
21+
with current_directory(self.get_build_dir(arch.arch)):
22+
env = self.get_recipe_env(arch)
23+
flags = [
24+
'--with-sysroot=' + self.ctx.ndk_platform,
25+
'--host=' + arch.toolchain_prefix,
26+
]
27+
configure = sh.Command('./configure')
28+
shprint(configure, *flags, _env=env)
29+
shprint(sh.make, _env=env)
30+
self.install_libs(arch,
31+
join('lib', '.libs', 'libvorbis.so'),
32+
join('lib', '.libs', 'libvorbisfile.so'),
33+
join('lib', '.libs', 'libvorbisenc.so')
34+
)
35+
36+
37+
recipe = VorbisRecipe()
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from pythonforandroid.recipe import NDKRecipe
2+
from pythonforandroid.toolchain import current_directory, shprint
3+
from os.path import join
4+
import os
5+
import sh
6+
7+
8+
class OpenALRecipe(NDKRecipe):
9+
version = '1.18.2'
10+
url = 'https://github.com/kcat/openal-soft/archive/openal-soft-{version}.tar.gz'
11+
12+
generated_libraries = ['libopenal.so']
13+
14+
def prebuild_arch(self, arch):
15+
# we need to build native tools for host system architecture
16+
with current_directory(join(self.get_build_dir(arch.arch), 'native-tools')):
17+
shprint(sh.cmake, '.', _env=os.environ)
18+
shprint(sh.make, _env=os.environ)
19+
20+
def build_arch(self, arch):
21+
with current_directory(self.get_build_dir(arch.arch)):
22+
env = self.get_recipe_env(arch)
23+
cmake_args = [
24+
'-DCMAKE_TOOLCHAIN_FILE={}'.format('XCompile-Android.txt'),
25+
'-DHOST={}'.format(self.ctx.toolchain_prefix)
26+
]
27+
if self.ctx.ndk == 'crystax':
28+
# avoids a segfault in libcrystax when calling lrintf
29+
cmake_args += ['-DHAVE_LRINTF=0']
30+
shprint(
31+
sh.cmake, '.',
32+
*cmake_args,
33+
_env=env
34+
)
35+
shprint(sh.make, _env=env)
36+
self.install_libs(arch, 'libopenal.so')
37+
38+
39+
recipe = OpenALRecipe()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from pythonforandroid.recipe import PythonRecipe
2+
from os.path import join
3+
4+
5+
class PyOggRecipe(PythonRecipe):
6+
version = '0.6.4a1'
7+
url = 'https://files.pythonhosted.org/packages/source/p/pyogg/PyOgg-{version}.tar.gz'
8+
depends = [('python2', 'python3crystax'), 'libogg', 'libvorbis', 'setuptools']
9+
patches = [join('patches', 'fix-find-lib.patch')]
10+
11+
call_hostpython_via_targetpython = False
12+
13+
14+
recipe = PyOggRecipe()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/pyogg/library_loader.py b/pyogg/library_loader.py
2+
index c2ba36c..383331a 100644
3+
--- a/pyogg/library_loader.py
4+
+++ b/pyogg/library_loader.py
5+
@@ -54,7 +54,7 @@ def load_other(name, paths = None):
6+
except:
7+
pass
8+
else:
9+
- for path in [os.getcwd(), _here]:
10+
+ for path in [os.path.join(os.environ['ANDROID_PRIVATE'], '..', 'lib')]:
11+
for style in other_styles:
12+
candidate = os.path.join(path, style.format(name))
13+
if os.path.exists(candidate):
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from pythonforandroid.recipe import PythonRecipe
2+
from os.path import join
3+
4+
5+
class PyOpenALRecipe(PythonRecipe):
6+
version = '0.7.3a1'
7+
url = 'https://files.pythonhosted.org/packages/source/p/pyopenal/PyOpenAL-{version}.tar.gz'
8+
depends = [('python2', 'python3crystax'), 'openal', 'numpy', 'setuptools']
9+
patches = [join('patches', 'fix-find-lib.patch')]
10+
11+
call_hostpython_via_targetpython = False
12+
13+
14+
recipe = PyOpenALRecipe()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/openal/library_loader.py b/openal/library_loader.py
2+
index be2485c..e8c6cd2 100644
3+
--- a/openal/library_loader.py
4+
+++ b/openal/library_loader.py
5+
@@ -56,7 +56,7 @@ class ExternalLibrary:
6+
except:
7+
pass
8+
else:
9+
- for path in [os.getcwd(), _here]:
10+
+ for path in [os.path.join(os.environ['ANDROID_PRIVATE'], '..', 'lib')]:
11+
for style in ExternalLibrary.other_styles:
12+
candidate = os.path.join(path, style.format(name))
13+
if os.path.exists(candidate) and os.path.isfile(candidate):

0 commit comments

Comments
 (0)
0