lbry-android-sdk/p4a/pythonforandroid/recipes/jpeg/__init__.py

56 lines
2.1 KiB
Python
Raw Normal View History

from pythonforandroid.recipe import Recipe
2017-08-13 03:24:00 +02:00
from pythonforandroid.logger import shprint
from pythonforandroid.util import current_directory
2022-12-02 21:15:34 +01:00
from os.path import join
2017-08-13 03:24:00 +02:00
import sh
class JpegRecipe(Recipe):
'''
.. versionchanged:: 0.6.0
rewrote recipe to be build with clang and updated libraries to latest
version of the official git repo.
'''
name = 'jpeg'
version = '2.0.1'
url = 'https://github.com/libjpeg-turbo/libjpeg-turbo/archive/{version}.tar.gz' # noqa
2022-12-02 21:15:34 +01:00
built_libraries = {'libjpeg.a': '.', 'libturbojpeg.a': '.'}
# we will require this below patch to build the shared library
# patches = ['remove-version.patch']
2017-08-13 03:24:00 +02:00
def build_arch(self, arch):
build_dir = self.get_build_dir(arch.arch)
2017-08-13 03:24:00 +02:00
# TODO: Fix simd/neon
with current_directory(build_dir):
env = self.get_recipe_env(arch)
toolchain_file = join(self.ctx.ndk_dir,
'build/cmake/android.toolchain.cmake')
2017-08-13 03:24:00 +02:00
shprint(sh.rm, '-f', 'CMakeCache.txt', 'CMakeFiles/')
shprint(sh.cmake, '-G', 'Unix Makefiles',
'-DCMAKE_SYSTEM_NAME=Android',
'-DCMAKE_POSITION_INDEPENDENT_CODE=1',
'-DCMAKE_ANDROID_ARCH_ABI={arch}'.format(arch=arch.arch),
'-DCMAKE_ANDROID_NDK=' + self.ctx.ndk_dir,
2022-12-02 21:15:34 +01:00
'-DCMAKE_C_COMPILER={cc}'.format(cc=arch.get_clang_exe()),
'-DCMAKE_CXX_COMPILER={cc_plus}'.format(
cc_plus=arch.get_clang_exe(plus_plus=True)),
'-DCMAKE_BUILD_TYPE=Release',
'-DCMAKE_INSTALL_PREFIX=./install',
'-DCMAKE_TOOLCHAIN_FILE=' + toolchain_file,
2017-08-13 03:24:00 +02:00
'-DANDROID_ABI={arch}'.format(arch=arch.arch),
'-DANDROID_ARM_NEON=ON',
'-DENABLE_NEON=ON',
# '-DREQUIRE_SIMD=1',
# Force disable shared, with the static ones is enough
'-DENABLE_SHARED=0',
'-DENABLE_STATIC=1',
_env=env)
shprint(sh.make, _env=env)
2017-08-13 03:24:00 +02:00
recipe = JpegRecipe()