-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework for Pillow/pil recipes & update jpeg and png (#1573)
* Force to build only static library for freetype/harfbuzz, format source code and fix imports We force to only build the static library to avoid that Pillow/pil gets linked with the shared library, plus we cannot use those libraries in his shared form because we will have conflicts with the ones distributed by android os...so no need to build those libraries unless properly versioned as we do with openssl libs * Update png version * Update jpeg and move to mainline Also add a patch that may allow us to build the libraries in his shared form...in case we need them * Rework Pillow - Fix compatibility for new jpeg - add freetype/harfbuzz support - move libraries from LDFLAGS to LIBS - format source code * Rework pil - Fix compatibility for new jpeg - add freetype/harfbuzz support - move libraries from LDFLAGS to LIBS - make it work with python2 and python2legacy * Add cmake reminder to quickstart.rst The recent rework of the jpeg recipe has introduced a new build dependency for us, so we add it to the section `Installing Dependencies` to no forgot about it. * Fix hardcoded url for png We set the last commit published for a version because the author of the github's repo never released/tagged it, despite He performed the necessary changes in master branch and notify about it in the README file...so this way we don't hardcode the url. Note: we should try to move the png repo to mainline because of the issue mentioned above and the fact that the last commit of the repo is more than one year old
- Loading branch information
1 parent
ce0a651
commit e3123f4
Showing
9 changed files
with
215 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,78 @@ | ||
from pythonforandroid.recipe import NDKRecipe | ||
from pythonforandroid.recipe import Recipe | ||
from pythonforandroid.logger import shprint | ||
from pythonforandroid.util import current_directory | ||
from os.path import join, exists | ||
from os import environ, uname | ||
from glob import glob | ||
import sh | ||
|
||
|
||
class JpegRecipe(NDKRecipe): | ||
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 = 'linaro-android' | ||
url = 'git+https://git.linaro.org/people/tomgall/libjpeg-turbo/libjpeg-turbo' | ||
version = '2.0.1' | ||
url = 'https://github.com/libjpeg-turbo/libjpeg-turbo/archive/{version}.tar.gz' # noqa | ||
# we will require this below patch to build the shared library | ||
# patches = ['remove-version.patch'] | ||
|
||
patches = ['build-static.patch'] | ||
def should_build(self, arch): | ||
return not exists(join(self.get_build_dir(arch.arch), | ||
'libturbojpeg.a')) | ||
|
||
generated_libraries = ['libjpeg.a'] | ||
def build_arch(self, arch): | ||
super(JpegRecipe, self).build_arch(arch) | ||
build_dir = self.get_build_dir(arch.arch) | ||
|
||
def prebuild_arch(self, arch): | ||
super(JpegRecipe, self).prebuild_arch(arch) | ||
# 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') | ||
|
||
build_dir = self.get_build_dir(arch.arch) | ||
app_mk = join(build_dir, 'Application.mk') | ||
if not exists(app_mk): | ||
shprint(sh.cp, join(self.get_recipe_dir(), 'Application.mk'), app_mk) | ||
jni_ln = join(build_dir, 'jni') | ||
if not exists(jni_ln): | ||
shprint(sh.ln, '-s', build_dir, jni_ln) | ||
shprint(sh.rm, '-f', 'CMakeCache.txt', 'CMakeFiles/') | ||
shprint(sh.cmake, '-G', 'Unix Makefiles', | ||
'-DCMAKE_SYSTEM_NAME=Android', | ||
'-DCMAKE_SYSTEM_PROCESSOR={cpu}'.format(cpu='arm'), | ||
'-DCMAKE_POSITION_INDEPENDENT_CODE=1', | ||
'-DCMAKE_ANDROID_ARCH_ABI={arch}'.format(arch=arch.arch), | ||
'-DCMAKE_ANDROID_NDK=' + self.ctx.ndk_dir, | ||
'-DCMAKE_C_COMPILER={toolchain}/bin/clang'.format( | ||
toolchain=env['TOOLCHAIN']), | ||
'-DCMAKE_CXX_COMPILER={toolchain}/bin/clang++'.format( | ||
toolchain=env['TOOLCHAIN']), | ||
'-DCMAKE_BUILD_TYPE=Release', | ||
'-DCMAKE_INSTALL_PREFIX=./install', | ||
'-DCMAKE_TOOLCHAIN_FILE=' + toolchain_file, | ||
|
||
def build_arch(self, arch): | ||
super(JpegRecipe, self).build_arch(arch) | ||
with current_directory(self.get_lib_dir(arch)): | ||
shprint(sh.mv, 'libjpeg.a', 'libjpeg-orig.a') | ||
shprint(sh.ar, '-rcT', 'libjpeg.a', 'libjpeg-orig.a', 'libsimd.a') | ||
'-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) | ||
|
||
# copy static libs to libs collection | ||
for lib in glob(join(build_dir, '*.a')): | ||
shprint(sh.cp, '-L', lib, self.ctx.libs_dir) | ||
|
||
def get_recipe_env(self, arch=None, with_flags_in_cc=False, clang=True): | ||
env = environ.copy() | ||
|
||
build_platform = '{system}-{machine}'.format( | ||
system=uname()[0], machine=uname()[-1]).lower() | ||
env['TOOLCHAIN'] = join(self.ctx.ndk_dir, 'toolchains/llvm/' | ||
'prebuilt/{build_platform}'.format( | ||
build_platform=build_platform)) | ||
|
||
return env | ||
|
||
|
||
recipe = JpegRecipe() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- jpeg/CMakeLists.txt.orig 2018-11-12 20:20:28.000000000 +0100 | ||
+++ jpeg/CMakeLists.txt 2018-12-14 12:43:45.338704504 +0100 | ||
@@ -573,6 +573,9 @@ | ||
add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES}) | ||
set_property(TARGET turbojpeg PROPERTY COMPILE_FLAGS | ||
"-DBMP_SUPPORTED -DPPM_SUPPORTED") | ||
+ set_property(TARGET jpeg PROPERTY NO_SONAME 1) | ||
+ set_property(TARGET turbojpeg PROPERTY NO_SONAME 1) | ||
+ set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "") | ||
if(WIN32) | ||
set_target_properties(turbojpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE) | ||
endif() |
Oops, something went wrong.