Skip to content

Commit d7ef97a

Browse files
committed
wip, python finally compile without gethostbyaddr_r missing.
1 parent 6ca248c commit d7ef97a

File tree

15 files changed

+84
-42
lines changed

15 files changed

+84
-42
lines changed

README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,11 @@ Related project
119119
- PGS4A: http://pygame.renpy.org/
120120
- Android scripting: http://code.google.com/p/android-scripting/
121121
- Python on a chip: http://code.google.com/p/python-on-a-chip/
122+
123+
124+
TODO
125+
----
126+
127+
- Make Android API configurable (defined in src/default.properties => shoudl be generated)
128+
- jni/Android.mk must not include ttf/image/mixer if not asked by the user
129+
- application should be automatically generated (Android.mk etc...)

configure.sh

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ CBLUE="\x1b[34;01m"
2323
CGRAY="\x1b[30;01m"
2424
CRESET="\x1b[39;49;00m"
2525

26-
# Initial enviromnent
27-
export NDKPLATFORM="$ANDROIDNDK/platforms/android-5/arch-arm"
28-
export ARCH="armeabi"
29-
#export ARCH="armeabi-v7a" # not tested yet.
26+
# Use ccache ?
27+
which ccache &>/dev/null
28+
if [ $? -eq 0 ]; then
29+
export CC="ccache gcc"
30+
export CXX="ccache g++"
31+
fi
3032

3133
#set -x
3234

@@ -75,7 +77,6 @@ function push_arm() {
7577
export OLD_STRIP=$STRIP
7678
export OLD_MAKE=$MAKE
7779

78-
export PATH="$ANDROIDNDK/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/:$ANDROIDNDK:$ANDROIDSDK/tools:$PATH"
7980
# to override the default optimization, set OFLAG
8081
#export OFLAG="-Os"
8182
#export OFLAG="-O2"
@@ -86,11 +87,25 @@ function push_arm() {
8687
fi
8788
export CXXFLAGS="$CFLAGS"
8889

89-
export CC="arm-eabi-gcc $CFLAGS"
90-
export CXX="arm-eabi-g++ $CXXFLAGS"
91-
export AR="arm-eabi-ar"
92-
export RANLIB="arm-eabi-ranlib"
93-
export STRIP="arm-eabi-strip --strip-unneeded"
90+
# this must be something depending of the API level of Android
91+
export PATH="$ANDROIDNDK/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/:$ANDROIDNDK:$ANDROIDSDK/tools:$PATH"
92+
if [ "X$ANDROIDNDKVER" == "Xr7" ]; then
93+
export TOOLCHAIN_PREFIX=arm-linux-androideabi
94+
export TOOLCHAIN_VERSION=4.4.3
95+
elif [ "X$ANDROIDNDKVER" == "Xr5b" ]; then
96+
export TOOLCHAIN_PREFIX=arm-eabi
97+
export TOOLCHAIN_VERSION=4.4.0
98+
else
99+
error "Unable to configure NDK toolchain for NDK $ANDROIDNDKVER"
100+
exit -1
101+
fi
102+
103+
export PATH="$ANDROIDNDK/toolchains/$TOOLCHAIN_PREFIX-$TOOLCHAIN_VERSION/prebuilt/linux-x86/bin/:$ANDROIDNDK:$ANDROIDSDK/tools:$PATH"
104+
export CC="$TOOLCHAIN_PREFIX-gcc $CFLAGS"
105+
export CXX="$TOOLCHAIN_PREFIX-g++ $CXXFLAGS"
106+
export AR="$TOOLCHAIN_PREFIX-ar"
107+
export RANLIB="$TOOLCHAIN_PREFIX-ranlib"
108+
export STRIP="$TOOLCHAIN_PREFIX-strip --strip-unneeded"
94109
export MAKE="make -j5"
95110

96111
# Use ccache ?
@@ -120,11 +135,31 @@ function run_prepare() {
120135
error "No ANDROIDSDK environment set, abort"
121136
exit -1
122137
fi
138+
123139
if [ "X$ANDROIDNDK" == "X" ]; then
124140
error "No ANDROIDNDK environment set, abort"
125141
exit -1
126142
fi
127143

144+
if [ "X$ANDROIDAPI" == "X" ]; then
145+
export ANDROIDAPI=14
146+
fi
147+
148+
if [ "X$ANDROIDNDKVER" == "X" ]; then
149+
error "No ANDROIDNDKVER enviroment set, abort"
150+
error "(Must be something like 'r5b', 'r7'...)"
151+
exit -1
152+
fi
153+
154+
debug "SDK located at $ANDROIDSDK"
155+
debug "NDK located at $ANDROIDNDK"
156+
debug "NDK version is $ANDROIDNDKVER"
157+
debug "API level set to $ANDROIDAPI"
158+
159+
export NDKPLATFORM="$ANDROIDNDK/platforms/android-$ANDROIDAPI/arch-arm"
160+
export ARCH="armeabi"
161+
#export ARCH="armeabi-v7a" # not tested yet.
162+
128163
info "Check mandatory tools"
129164
# ensure that some tools are existing
130165
for tool in md5sum tar bzip2 unzip make gcc g++; do
@@ -140,8 +175,12 @@ function run_prepare() {
140175
mkdir -p $BUILD_PATH
141176
mkdir -p $PACKAGES_PATH
142177
fi
178+
179+
# create initial files
180+
echo "target=android-$ANDROIDAPI" > $SRC_PATH/default.properties
181+
echo "sdk.dir=$ANDROIDSDK" > $SRC_PATH/local.properties
143182
}
144-
183+
145184
function run_source_modules() {
146185
needed=(hostpython python $MODULES)
147186
declare -A processed

recipes/python/patches/disable-modules.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# This global variable is used to hold the list of modules to be disabled.
77
-disabled_module_list = []
8-
+disabled_module_list = ['_ctypes','bz2','ossaudiodev','_curses','_curses_panel','readline','_locale','_bsddb','gdbm','dbm','nis','linuxaudiodev','crypt','_multiprocessing']
8+
+disabled_module_list = ['spwd', '_ctypes','bz2','ossaudiodev','_curses','_curses_panel','readline','_locale','_bsddb','gdbm','dbm','nis','linuxaudiodev','crypt','_multiprocessing']
99

1010
def add_dir_to_list(dirlist, dir):
1111
"""Add the directory 'dir' to the list 'dirlist' (at the front) if
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--- Python-2.7.2/Modules/socketmodule.c.orig 2012-01-06 01:40:09.915694810 +0100
2+
+++ Python-2.7.2/Modules/socketmodule.c 2012-01-06 01:40:36.967694486 +0100
3+
@@ -146,6 +146,9 @@
4+
On the other hand, not all Linux versions agree, so there the settings
5+
computed by the configure script are needed! */
6+
7+
+/* Android hack, same reason are what is described above */
8+
+#undef HAVE_GETHOSTBYNAME_R
9+
+
10+
#ifndef linux
11+
# undef HAVE_GETHOSTBYNAME_R_3_ARG
12+
# undef HAVE_GETHOSTBYNAME_R_5_ARG

recipes/python/recipe.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function prebuild_python() {
2121
try patch -p1 < $RECIPE_python/patches/Python-$VERSION_python-xcompile.patch
2222
try patch -p1 < $RECIPE_python/patches/disable-modules.patch
2323
try patch -p1 < $RECIPE_python/patches/fix-locale.patch
24+
try patch -p1 < $RECIPE_python/patches/fix-gethostbyaddr.patch
2425
try patch -p1 < $RECIPE_python/patches/custom-loader.patch
2526

2627
# everything done, touch the marker !
@@ -41,7 +42,7 @@ function build_python() {
4142

4243
push_arm
4344
try ./configure --host=arm-eabi --prefix="$BUILD_PATH/python-install" --enable-shared
44-
try $MAKE HOSTPYTHON=$BUILD_hostpython/hostpython HOSTPGEN=$BUILD_hostpython/hostpgen CROSS_COMPILE=arm-eabi- CROSS_COMPILE_TARGET=yes INSTSONAME=libpython2.7.so
45+
try $MAKE HOSTPYTHON=$BUILD_hostpython/hostpython HOSTPGEN=$BUILD_hostpython/hostpgen CROSS_COMPILE=arm-eabi- CROSS_COMPILE_TARGET=yes INSTSONAME=libpython2.7.so
4546
try $MAKE install HOSTPYTHON=$BUILD_hostpython/hostpython HOSTPGEN=$BUILD_hostpython/hostpgen CROSS_COMPILE=arm-eabi- CROSS_COMPILE_TARGET=yes INSTSONAME=libpython2.7.so
4647
pop_arm
4748

recipes/sdl/recipe.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ function prebuild_sdl() {
1717

1818
function build_sdl() {
1919
cd $SRC_PATH/jni
20+
push_arm
2021
ndk-build V=1
22+
pop_arm
2123
}
2224

2325
function postbuild_sdl() {

src/build.xml

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/jni/application/Android.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ LOCAL_SRC_FILES := $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wil
3030
# Uncomment to also add C sources
3131
LOCAL_SRC_FILES += $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wildcard $(LOCAL_PATH)/$(F)/*.c))))
3232

33-
LOCAL_SHARED_LIBRARIES := sdl $(COMPILED_LIBRARIES)
33+
LOCAL_SHARED_LIBRARIES := SDL $(COMPILED_LIBRARIES)
3434

3535
LOCAL_STATIC_LIBRARIES := jpeg png
3636

3737
LOCAL_LDLIBS := -lpython2.7 -lGLESv1_CM -ldl -llog -lz
3838

39-
LOCAL_LDFLAGS += -L$(LOCAL_PATH)/../../python-install/lib $(APPLICATION_ADDITIONAL_LDFLAGS)
39+
LOCAL_LDFLAGS += -L$(LOCAL_PATH)/../../../build/python-install/lib $(APPLICATION_ADDITIONAL_LDFLAGS)
4040

4141
LIBS_WITH_LONG_SYMBOLS := $(strip $(shell \
4242
for f in $(LOCAL_PATH)/../../libs/$ARCH/*.so ; do \

src/jni/sdl_blitpool/Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LOCAL_CPP_EXTENSION := .cpp
1010

1111
LOCAL_SRC_FILES := SDL_blitpool.c
1212

13-
LOCAL_SHARED_LIBRARIES := sdl
13+
LOCAL_SHARED_LIBRARIES := SDL
1414
LOCAL_STATIC_LIBRARIES :=
1515
LOCAL_LDLIBS :=
1616

src/jni/sdl_gfx/Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ LOCAL_CPP_EXTENSION := .cpp
1212
# Note this simple makefile var substitution, you can find even simpler examples in different Android projects
1313
LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
1414

15-
LOCAL_SHARED_LIBRARIES := sdl
15+
LOCAL_SHARED_LIBRARIES := SDL
1616

1717
include $(BUILD_SHARED_LIBRARY)
1818

0 commit comments

Comments
 (0)