8000 Feature/freetype by olymk2 · Pull Request #3 · olymk2/python-for-android · GitHub
[go: up one dir, main page]

Skip to content

Feature/freetype #3

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
diff -ur Python-2.7.2.orig/Lib/ctypes/util.py Python-2.7.2/Lib/ctypes/util.py > ctypes-find-library.diff
51 changes: 51 additions & 0 deletions recipes/freetype/recipe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

VERSION_freetype=${VERSION_freetype:-2.5.5}
DEPS_freetype=(harfbuzz)
URL_freetype=http://download.savannah.gnu.org/releases/freetype/freetype-2.5.5.tar.gz
MD5_freetype=7448edfbd40c7aa5088684b0a3edb2b8
BUILD_freetype=$BUILD_PATH/freetype/$(get_directory $URL_freetype)
RECIPE_freetype=$RECIPES_PATH/freetype

# function called for preparing source code if needed
# (you can apply patch etc here.)
function prebuild_freetype() {
true
}

#~ function shouldbuild_freetype() {
#~ if [ -f "$BUILD_freetype/libfreetype.so" ]; then
#~ DO_BUILD=0
#~ fi
#~ }

function build_freetype() {
cd $BUILD_freetype

push_arm
export LDFLAGS="$LDFLAGS -L$BUILD_harfbuzz/src/.libs/"
echo $SRC_PATH
echo $BUILD_harfbuzz
#return
#~ export CC="$CC -I$BUILD_libfreetype/include"
#~ export LDFLAGS="$LDFLAGS -L$LIBS_PATH"
#~ export LDSHARED="$LIBLINK"

#export LDSHARED="$LIBLINK"
# http://en.wikibooks.org/wiki/OpenGL_Programming/Installation/Android_NDK#FreeType


#try sh autogen.sh
try ./configure --build=i686-pc-linux-gnu --host=arm-linux-androideabi --prefix="$BUILD_PATH/python-install" --without-zlib --with-png=no --enable-shared
try make -j5
pop_arm
echo 'finished'
try cp -L $BUILD_freetype/objs/.libs/libfreetype.so $LIBS_PATH

}

# function called after all the compile have been done
function postbuild_freetype() {
true
}

35 changes: 35 additions & 0 deletions recipes/harfbuzz/recipe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

VERSION_harfbuzz=${VERSION_harfbuzz:-2.5.5}
URL_harfbuzz=http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-0.9.40.tar.bz2
MD5_harfbuzz=0e27e531f4c4acff601ebff0957755c2
BUILD_harfbuzz=$BUILD_PATH/harfbuzz/$(get_directory $URL_harfbuzz)
RECIPE_harfbuzz=$RECIPES_PATH/harfbuzz

# function called for preparing source code if needed
# (you can apply patch etc here.)
function prebuild_harfbuzz() {
true
}

function shouldbuild_harfbuzz() {
if [ -f "$BUILD_harfbuzz/src/.libs/libharfbuzz.so" ]; then
DO_BUILD=0
fi
}

function build_harfbuzz() {
cd $BUILD_harfbuzz

push_arm
try ./configure --build=i686-pc-linux-gnu --host=arm-linux-androideabi --prefix="$BUILD_PATH/python-install" --enable-shared --without-freetype --without-glib
try make -j5
pop_arm
try cp -L $BUILD_harfbuzz/src/.libs/libharfbuzz.so $LIBS_PATH
}

# function called after all the compile have been done
function postbuild_harfbuzz() {
true
}

1 change: 0 additions & 1 deletion recipes/libxslt/recipe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ function build_libxslt() {
cd $BUILD_libxslt

push_arm

try ./configure --build=i686-pc-linux-gnu --host=arm-linux-eabi \
--without-plugins --without-debug --without-python --without-crypto \
--with-libxml-src=$BUILD_libxml2
Expand Down
59 changes: 56 additions & 3 deletions recipes/python/patches/Python-2.7.2-ctypes-disable-wchar.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff -uNr Python-2.7.2.orig/Lib/ctypes/__init__.py Python-2.7.2/Lib/ctypes/__init__.py
--- Python-2.7.2.orig/Lib/ctypes/__init__.py 2011-06-11 17:46:24.000000000 +0200
+++ Python-2.7.2/Lib/ctypes/__init__.py 2012-08-30 13:40:38.837698797 +0200
diff -ur '--exclude=*~' Python-2.7.2.orig/Lib/ctypes/__init__.py Python-2.7.2/Lib/ctypes/__init__.py
--- Python-2.7.2.orig/Lib/ctypes/__init__.py 2011-06-11 16:46:24.000000000 +0100
+++ Python-2.7.2/Lib/ctypes/__init__.py 2015-03-19 12:32:45.747723687 +0000
@@ -272,31 +272,34 @@
else:
set_conversion_mode("ascii", "strict")
Expand Down Expand Up @@ -61,3 +61,56 @@ diff -uNr Python-2.7.2.orig/Lib/ctypes/__init__.py Python-2.7.2/Lib/ctypes/__ini

POINTER(c_char).from_param = c_char_p.from_param #_SimpleCData.c_char_p_from_param

diff -ur '--exclude=*~' Python-2.7.2.orig/Modules/_ctypes/callproc.c Python-2.7.2/Modules/_ctypes/callproc.c
--- Python-2.7.2.orig/Modules/_ctypes/callproc.c 2015-03-19 11:56:40.668159317 +0000
+++ Python-2.7.2/Modules/_ctypes/callproc.c 2015-03-19 11:45:45.898288000 +0000
@@ -1423,7 +1423,7 @@
mode |= RTLD_NOW;
handle = ctypes_dlopen(name, mode);
if (!handle) {
- char *errmsg = ctypes_dlerror();
+ const char *errmsg = ctypes_dlerror();
if (!errmsg)
errmsg = "dlopen() error";
PyErr_SetString(PyExc_OSError,
diff -ur '--exclude=*~' Python-2.7.2.orig/Modules/_ctypes/libffi/src/dlmalloc.c Python-2.7.2/Modules/_ctypes/libffi/src/dlmalloc.c
--- Python-2.7.2.orig/Modules/_ctypes/libffi/src/dlmalloc.c 2015-03-19 13:26:58.928438829 +0000
+++ Python-2.7.2/Modules/_ctypes/libffi/src/dlmalloc.c 2015-03-19 15:32:19.042396376 +0000
@@ -614,18 +614,6 @@
#include "/usr/include/malloc.h"
#else /* HAVE_USR_INCLUDE_MALLOC_H */

-struct mallinfo {
- MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */
- MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */
- MALLINFO_FIELD_TYPE smblks; /* always 0 */
- MALLINFO_FIELD_TYPE hblks; /* always 0 */
- MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */
- MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */
- MALLINFO_FIELD_TYPE fsmblks; /* always 0 */
- MALLINFO_FIELD_TYPE uordblks; /* total allocated space */
- MALLINFO_FIELD_TYPE fordblks; /* total free space */
- MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */
-};

#endif /* HAVE_USR_INCLUDE_MALLOC_H */
#endif /* NO_MALLINFO */
@@ -966,7 +954,7 @@
p = malloc(n);
assert(malloc_usable_size(p) >= 256);
*/
-size_t dlmalloc_usable_size(void*);
+size_t dlmalloc_usable_size(const void*);

/*
malloc_stats();
@@ -4384,7 +4372,7 @@
internal_malloc_stats(gm);
}

-size_t dlmalloc_usable_size(void* mem) {
+size_t dlmalloc_usable_size(const void* mem) {
if (mem != 0) {
mchunkptr p = mem2chunk(mem);
if (cinuse(p))

21 changes: 21 additions & 0 deletions recipes/python/patches/ctypes-find-library.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--- Python-2.7.2.orig/Lib/ctypes/util.py 2011-06-11 16:46:24.000000000 +0100
+++ Python-2.7.2/Lib/ctypes/util.py 2015-03-26 13:45:33.322172603 +0000
@@ -83,7 +83,17 @@
except ValueError:
continue
return None
-
+elif os.name == "posix" and sys.platform == "linux3":
+ def find_library(name):
+ """ hack to find librarys for kivy and android
+ split the path and get the first parts which will give us
+ the app path something like /data/data/org.app.foo/"""
+ app_root = os.path.abspath('./').split(os.path.sep)[0:4]
+ lib_search = os.path.sep.join(app_root) + os.path.sep + 'lib'
+ for filename in os.listdir(lib_search):
+ if filename.endswith('.so') and name in filename:
+ return lib_search + os.path.sep + filename
+ return None
elif os.name == "posix":
# Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump
import re, tempfile, errno
3 changes: 2 additions & 1 deletion recipes/python/recipe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function prebuild_python() {
try patch -p1 < $RECIPE_python/patches/fix-remove-corefoundation.patch
try patch -p1 < $RECIPE_python/patches/fix-dynamic-lookup.patch
try patch -p1 < $RECIPE_python/patches/fix-dlfcn.patch
try patch -p1 < $RECIPE_python/patches/ctypes-find-library.diff

system=$(uname -s)
if [ "X$system" == "XDarwin" ]; then
Expand Down Expand Up @@ -94,7 +95,7 @@ function build_python() {
fi

# CFLAGS for python ctypes library
export CFLAGS="$CFLAGS -DNO_MALLINFO"
#export CFLAGS="$CFLAGS -DNO_MALLINFO"
export BUILDARCH=x86_64-linux-gnu
export HOSTARCH=arm-eabi

Expand Down
10 changes: 8 additions & 2 deletions src/src/org/renpy/android/PythonService.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,17 @@ public void run(){
System.loadLibrary("python2.7");
System.loadLibrary("application");
System.loadLibrary("sdl_main");
System.loadLibrary("ctypes");
System.loadLibrary("ctypes");

System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_io.so");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/unicodedata.so");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_ctypes.so");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_ctypes.so");

try {
System.loadLibrary("freetype");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/freetype.so");
} catch(UnsatisfiedLinkError e) {
}

try {
System.loadLibrary("sqlite3");
Expand Down
0