-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Rework for Pillow/pil recipes & update jpeg and png #1573
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
80c1add
Force to build only static library for freetype/harfbuzz, format sour…
opacam 4b0fafd
Update png version
opacam 2f5e45a
Update jpeg and move to mainline
opacam 23e4335
Rework Pillow
opacam 987fd51
Rework pil
opacam 2372edb
Add cmake reminder to quickstart.rst
opacam 36703e3
Fix hardcoded url for png
opacam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor, why don't you use the same format string syntax as before/after for consistency? |
||
'-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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would
rm -f
work on a directory without the-r
flag?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got the bug report on Discord 2 years later 🤯
https://discord.com/channels/423249981340778496/678695971164520523/876867985355186228