Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions pythonforandroid/recipes/jpeg/Application.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
APP_OPTIM := release
APP_ABI := all # or armeabi
APP_MODULES := libjpeg
28 changes: 28 additions & 0 deletions pythonforandroid/recipes/jpeg/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from pythonforandroid.recipe import NDKRecipe
from pythonforandroid.logger import shprint
from os.path import join, exists
import sh


class JpegRecipe(NDKRecipe):
name = 'jpeg'
version = 'linaro-android'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I know this is an old one, but I came across it.
Is this version ever being picked up?
Also I had some connection refused issues recently while cloning git://git.linaro.org/people/tomgall/libjpeg-turbo/libjpeg-turbo.git perhaps we should use a release tar.gz archive, what do you guys think?

url = 'git://git.linaro.org/people/tomgall/libjpeg-turbo/libjpeg-turbo.git'

patches = ['build-static.patch']

generated_libraries = ['libjpeg.a']

def prebuild_arch(self, arch):
super(JpegRecipe, self).prebuild_arch(arch)

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)


recipe = JpegRecipe()
85 changes: 85 additions & 0 deletions pythonforandroid/recipes/jpeg/build-static.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
diff -Naur jpeg/Android.mk b/Android.mk
--- jpeg/Android.mk 2015-12-14 11:37:25.900190235 -0600
+++ b/Android.mk 2015-12-14 11:41:27.532182210 -0600
@@ -54,8 +54,7 @@

LOCAL_SRC_FILES:= $(libjpeg_SOURCES_DIST)

-LOCAL_SHARED_LIBRARIES := libcutils
-LOCAL_STATIC_LIBRARIES := libsimd
+LOCAL_STATIC_LIBRARIES := libsimd libcutils

LOCAL_C_INCLUDES := $(LOCAL_PATH)

@@ -68,7 +67,7 @@

LOCAL_MODULE := libjpeg

-include $(BUILD_SHARED_LIBRARY)
+include $(BUILD_STATIC_LIBRARY)

######################################################
### cjpeg ###
@@ -82,7 +81,7 @@

LOCAL_SRC_FILES:= $(cjpeg_SOURCES)

-LOCAL_SHARED_LIBRARIES := libjpeg
+LOCAL_STATIC_LIBRARIES := libjpeg

LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/android
@@ -110,7 +109,7 @@

LOCAL_SRC_FILES:= $(djpeg_SOURCES)

-LOCAL_SHARED_LIBRARIES := libjpeg
+LOCAL_STATIC_LIBRARIES := libjpeg

LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/android
@@ -137,7 +136,7 @@

LOCAL_SRC_FILES:= $(jpegtran_SOURCES)

-LOCAL_SHARED_LIBRARIES := libjpeg
+LOCAL_STATIC_LIBRARIES := libjpeg

LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/android
@@ -163,7 +162,7 @@

LOCAL_SRC_FILES:= $(tjunittest_SOURCES)

-LOCAL_SHARED_LIBRARIES := libjpeg
+LOCAL_STATIC_LIBRARIES := libjpeg

LOCAL_C_INCLUDES := $(LOCAL_PATH)

@@ -189,7 +188,7 @@

LOCAL_SRC_FILES:= $(tjbench_SOURCES)

-LOCAL_SHARED_LIBRARIES := libjpeg
+LOCAL_STATIC_LIBRARIES := libjpeg

LOCAL_C_INCLUDES := $(LOCAL_PATH)

@@ -215,7 +214,7 @@

LOCAL_SRC_FILES:= $(rdjpgcom_SOURCES)

-LOCAL_SHARED_LIBRARIES := libjpeg
+LOCAL_STATIC_LIBRARIES := libjpeg

LOCAL_C_INCLUDES := $(LOCAL_PATH)

@@ -240,7 +239,7 @@

LOCAL_SRC_FILES:= $(wrjpgcom_SOURCES)

-LOCAL_SHARED_LIBRARIES := libjpeg
+LOCAL_STATIC_LIBRARIES := libjpeg

LOCAL_C_INCLUDES := $(LOCAL_PATH)

41 changes: 41 additions & 0 deletions pythonforandroid/recipes/pil/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from os.path import join

from pythonforandroid.recipe import CompiledComponentsPythonRecipe


class PILRecipe(CompiledComponentsPythonRecipe):
name = 'pil'
version = '1.1.7'
url = 'http://effbot.org/downloads/Imaging-{version}.tar.gz'
depends = [('python2', 'python3'), 'png', 'jpeg']
site_packages_name = 'PIL'

patches = ['disable-tk.patch',
'fix-directories.patch']

def get_recipe_env(self, arch=None):
env = super(PILRecipe, self).get_recipe_env(arch)

png = self.get_recipe('png', self.ctx)
png_lib_dir = png.get_lib_dir(arch)
png_jni_dir = png.get_jni_dir(arch)
jpeg = self.get_recipe('jpeg', self.ctx)
jpeg_lib_dir = jpeg.get_lib_dir(arch)
jpeg_jni_dir = jpeg.get_jni_dir(arch)
env['JPEG_ROOT'] = '{}|{}'.format(jpeg_lib_dir, jpeg_jni_dir)

cflags = ' -I{} -L{} -I{} -L{}'.format(png_jni_dir, png_lib_dir, jpeg_jni_dir, jpeg_lib_dir)
env['CFLAGS'] += cflags
env['CXXFLAGS'] += cflags
env['CC'] += cflags
env['CXX'] += cflags

ndk_dir = self.ctx.ndk_platform
ndk_lib_dir = join(ndk_dir, 'usr', 'lib')
ndk_include_dir = join(ndk_dir, 'usr', 'include')
env['ZLIB_ROOT'] = '{}|{}'.format(ndk_lib_dir, ndk_include_dir)

return env


recipe = PILRecipe()
12 changes: 12 additions & 0 deletions pythonforandroid/recipes/pil/disable-tk.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--- Imaging-1.1.7/setup.py.orig 2012-08-31 12:52:25.000000000 +0200
+++ Imaging-1.1.7/setup.py 2012-08-31 12:53:04.000000000 +0200
@@ -322,7 +322,7 @@
"_imagingcms", ["_imagingcms.c"], libraries=["lcms"] + extra
))

- if sys.platform == "darwin":
+ if False: #sys.platform == "darwin":
# locate Tcl/Tk frameworks
frameworks = []
framework_roots = [

79 changes: 79 additions & 0 deletions pythonforandroid/recipes/pil/fix-directories.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
diff -Naur pil/setup.py b/setup.py
--- pil/setup.py 2015-12-11 16:42:40.817701332 -0600
+++ b/setup.py 2015-12-11 17:07:34.778477132 -0600
@@ -34,10 +34,10 @@
# TIFF_ROOT = libinclude("/opt/tiff")

TCL_ROOT = None
-JPEG_ROOT = None
-ZLIB_ROOT = None
+JPEG_ROOT = tuple(os.environ['JPEG_ROOT'].split('|')) if 'JPEG_ROOT' in os.environ else None
+ZLIB_ROOT = tuple(os.environ['ZLIB_ROOT'].split('|')) if 'ZLIB_ROOT' in os.environ else None
TIFF_ROOT = None
-FREETYPE_ROOT = None
+FREETYPE_ROOT = tuple(os.environ['FREETYPE_ROOT'].split('|')) if 'FREETYPE_ROOT' in os.environ else None
LCMS_ROOT = None

# FIXME: add mechanism to explicitly *disable* the use of a library
@@ -127,29 +127,6 @@

add_directory(include_dirs, "libImaging")

- #
- # add platform directories
-
- if sys.platform == "cygwin":
- # pythonX.Y.dll.a is in the /usr/lib/pythonX.Y/config directory
- add_directory(library_dirs, os.path.join(
- "/usr/lib", "python%s" % sys.version[:3], "config"
- ))
-
- elif sys.platform == "darwin":
- # attempt to make sure we pick freetype2 over other versions
- add_directory(include_dirs, "/sw/include/freetype2")
- add_directory(include_dirs, "/sw/lib/freetype2/include")
- # fink installation directories
- add_directory(library_dirs, "/sw/lib")
- add_directory(include_dirs, "/sw/include")
- # darwin ports installation directories
- add_directory(library_dirs, "/opt/local/lib")
- add_directory(include_dirs, "/opt/local/include")
-
- add_directory(library_dirs, "/usr/local/lib")
- # FIXME: check /opt/stuff directories here?
-
prefix = sysconfig.get_config_var("prefix")
if prefix:
add_directory(library_dirs, os.path.join(prefix, "lib"))
@@ -199,22 +176,6 @@
add_directory(include_dirs, include_root)

#
- # add standard directories
-
- # look for tcl specific subdirectory (e.g debian)
- if _tkinter:
- tcl_dir = "/usr/include/tcl" + TCL_VERSION
- if os.path.isfile(os.path.join(tcl_dir, "tk.h")):
- add_directory(include_dirs, tcl_dir)
-
- # standard locations
- add_directory(library_dirs, "/usr/local/lib")
- add_directory(include_dirs, "/usr/local/include")
-
- add_directory(library_dirs, "/usr/lib")
- add_directory(include_dirs, "/usr/include")
-
- #
# insert new dirs *before* default libs, to avoid conflicts
# between Python PYD stub libs and real libraries

@@ -299,8 +260,6 @@
defs.append(("HAVE_LIBZ", None))
if sys.platform == "win32":
libs.extend(["kernel32", "user32", "gdi32"])
- if struct.unpack("h", "\0\1")[0] == 1:
- defs.append(("WORDS_BIGENDIAN", None))

exts = [(Extension(
"_imaging", files, libraries=libs, define_macros=defs
13 changes: 13 additions & 0 deletions pythonforandroid/recipes/png/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from pythonforandroid.recipe import NDKRecipe


class PngRecipe(NDKRecipe):
name = 'png'
version = '1.6.15'
url = 'https://github.com/julienr/libpng-android/archive/{version}.zip'

generated_libraries = ['libpng.a']


recipe = PngRecipe()