Skip to content

Commit e84b951

Browse files
authored
Merge pull request kivy#2255 from opacam/feature-libwebp-support
✨ Add libwebp recipe
2 parents 5ae7676 + e028801 commit e84b951

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from multiprocessing import cpu_count
2+
from os.path import join
3+
4+
import sh
5+
6+
from pythonforandroid.util import current_directory, ensure_dir
7+
from pythonforandroid.toolchain import shprint
8+
from pythonforandroid.recipe import Recipe
9+
10+
11+
class LibwebpRecipe(Recipe):
12+
version = '1.1.0'
13+
url = 'https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-{version}.tar.gz' # noqa
14+
depends = []
15+
built_libraries = {
16+
'libwebp.so': 'installation/lib',
17+
'libwebpdecoder.so': 'installation/lib',
18+
'libwebpdemux.so': 'installation/lib',
19+
'libwebpmux.so': 'installation/lib',
20+
}
21+
22+
def build_arch(self, arch):
23+
source_dir = self.get_build_dir(arch.arch)
24+
build_dir = join(source_dir, 'build')
25+
install_dir = join(source_dir, 'installation')
26+
toolchain_file = join(
27+
self.ctx.ndk_dir, 'build', 'cmake', 'android.toolchain.cmake',
28+
)
29+
30+
ensure_dir(build_dir)
31+
with current_directory(build_dir):
32+
env = self.get_recipe_env(arch)
33+
shprint(sh.cmake, source_dir,
34+
f'-DANDROID_ABI={arch.arch}',
35+
f'-DANDROID_NATIVE_API_LEVEL={self.ctx.ndk_api}',
36+
37+
f'-DCMAKE_TOOLCHAIN_FILE={toolchain_file}',
38+
f'-DCMAKE_INSTALL_PREFIX={install_dir}',
39+
'-DCMAKE_BUILD_TYPE=Release',
40+
41+
'-DBUILD_SHARED_LIBS=1',
42+
43+
_env=env)
44+
shprint(sh.make, '-j' + str(cpu_count()), _env=env)
45+
# We make the install because this way we will have
46+
# all the includes and libraries in one place
47+
shprint(sh.make, 'install', _env=env)
48+
49+
50+
recipe = LibwebpRecipe()

0 commit comments

Comments
 (0)