Skip to content

✨ Add libwebp recipe #2255

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

Merged
merged 1 commit into from
Aug 22, 2020
Merged
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
50 changes: 50 additions & 0 deletions pythonforandroid/recipes/libwebp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from multiprocessing import cpu_count
from os.path import join

import sh

from pythonforandroid.util import current_directory, ensure_dir
from pythonforandroid.toolchain import shprint
from pythonforandroid.recipe import Recipe


class LibwebpRecipe(Recipe):
version = '1.1.0'
url = 'https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-{version}.tar.gz' # noqa
depends = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not simply omitting?

built_libraries = {
'libwebp.so': 'installation/lib',
'libwebpdecoder.so': 'installation/lib',
'libwebpdemux.so': 'installation/lib',
'libwebpmux.so': 'installation/lib',
}

def build_arch(self, arch):
source_dir = self.get_build_dir(arch.arch)
build_dir = join(source_dir, 'build')
install_dir = join(source_dir, 'installation')
toolchain_file = join(
self.ctx.ndk_dir, 'build', 'cmake', 'android.toolchain.cmake',
)

ensure_dir(build_dir)
with current_directory(build_dir):
env = self.get_recipe_env(arch)
shprint(sh.cmake, source_dir,
f'-DANDROID_ABI={arch.arch}',
f'-DANDROID_NATIVE_API_LEVEL={self.ctx.ndk_api}',

f'-DCMAKE_TOOLCHAIN_FILE={toolchain_file}',
f'-DCMAKE_INSTALL_PREFIX={install_dir}',
'-DCMAKE_BUILD_TYPE=Release',

'-DBUILD_SHARED_LIBS=1',

_env=env)
shprint(sh.make, '-j' + str(cpu_count()), _env=env)
# We make the install because this way we will have
# all the includes and libraries in one place
shprint(sh.make, 'install', _env=env)


recipe = LibwebpRecipe()