├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── env ├── mk ├── build_ndk.sh ├── build_single.sh ├── bzip2 │ └── 1.0.6 │ │ ├── build.sh │ │ ├── bzip2-1.0.6-makefile-env.patch │ │ └── sources.txt ├── gdbm │ └── 1.11 │ │ ├── build.sh │ │ ├── gdbm-1.11-android-winsize.patch │ │ └── sources.txt ├── ncurses │ └── 5.9 │ │ ├── build.sh │ │ ├── ncurses-5.9-android-locale-fixes.patch │ │ └── sources.txt ├── ndk_source.sh ├── openssl │ └── 1.0.2d │ │ ├── build.sh │ │ ├── openssl-1.0.2d-android-ndk-target.patch │ │ └── sources.txt ├── python │ └── 3.4.3 │ │ ├── build.sh │ │ ├── python-3.4.3-android-libmpdec.patch │ │ ├── python-3.4.3-android-locale.patch │ │ ├── python-3.4.3-android-misc.patch │ │ ├── python-3.4.3-android-missing-getdents64-definition.patch │ │ ├── python-3.4.3-cross-compile.patch │ │ ├── python-3.4.3-python-misc.patch │ │ └── sources.txt ├── readline │ └── 6.3 │ │ ├── build.sh │ │ └── sources.txt ├── sqlite │ └── 3.8.10.2 │ │ ├── build.sh │ │ └── sources.txt ├── test.sh ├── test_setup.sh └── xz │ └── 5.2.1 │ ├── build.sh │ ├── sources.txt │ └── xz-5.2.1-disable-so-versioning.patch ├── sdk └── .keep └── src └── .keep /.gitignore: -------------------------------------------------------------------------------- 1 | /mk/env.mk 2 | /build 3 | /build-tools 4 | /build-vm 5 | /src/* 6 | !/src/.keep 7 | /sdk/* 8 | !/sdk/.keep 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ## Setup. 2 | 3 | all: build 4 | 5 | # Get configuration. 6 | mk/env.mk: env 7 | @bash --noprofile --norc -c 'source ./env; set -o posix; set' | egrep '^(ANDROID|SDK|NDK|BUILD|TEST|PYTHON)_' > $@ 8 | -include mk/env.mk 9 | 10 | # A formula. 11 | define formula 12 | $1: $1-$2 13 | 14 | $1-$2: ndk $3 15 | $$(info Checking $1 $2 sources...) 16 | @wget -N -P "src/" -i "mk/$1/$2/sources.txt" 17 | ifeq ("$$(wildcard build/.built-$(BUILD_IDENTIFIER)/$1-$2)","") 18 | $$(info Building $1 $2...) 19 | @bash --noprofile --norc mk/build_single.sh $1 $2 20 | @touch build/.built-$(BUILD_IDENTIFIER)/$1-$2 21 | endif 22 | endef 23 | 24 | 25 | ## Building. 26 | 27 | build: python_modules python 28 | 29 | # Main Python. 30 | $(eval $(call formula,python,3.4.3)) 31 | 32 | # Optional Python modules. 33 | python_modules: $(foreach mod,$(subst ',,$(PYTHON_OPTIONAL_MODULES)),python_$(mod)) 34 | 35 | # Python lzma support. 36 | $(eval $(call formula,xz,5.2.1)) 37 | python_lzma: xz 38 | 39 | # Python bzip2 support. 40 | $(eval $(call formula,bzip2,1.0.6)) 41 | python_bz2: bzip2 42 | 43 | # Python readline support. 44 | $(eval $(call formula,readline,6.3)) 45 | python_readline: readline 46 | 47 | # Python SSL support. 48 | $(eval $(call formula,openssl,1.0.2d)) 49 | python_ssl: openssl 50 | 51 | # Python curses support. 52 | $(eval $(call formula,ncurses,5.9)) 53 | python_curses: ncurses 54 | 55 | # Python SQLite support. 56 | $(eval $(call formula,sqlite,3.8.10.2)) 57 | python_sqlite3: sqlite 58 | 59 | # Python (g)dbm support. 60 | $(eval $(call formula,gdbm,1.11)) 61 | python_gdbm: gdbm 62 | 63 | 64 | # Android NDK. 65 | ndk: 66 | $(info Checking NDK sources...) 67 | @wget -N -P "sdk/" $(shell bash mk/ndk_source.sh) 68 | ifeq ("$(wildcard build/.built-ndk-$(BUILD_IDENTIFIER))","") 69 | $(info Preparing NDK toolchain...) 70 | @bash --noprofile --norc mk/build_ndk.sh 71 | @touch build/.built-ndk-$(BUILD_IDENTIFIER) 72 | endif 73 | 74 | 75 | ## Cleaning. 76 | 77 | clean: clean_generated clean_builds 78 | @rm -rf "$(ANDROID_TEST_PREFIX)" 79 | @rm -rf "$(ANDROID_TOOL_PREFIX)" 80 | 81 | clean_generated: 82 | @find ./src -mindepth 1 -maxdepth 1 -type d -exec rm -rf "{}" \; 83 | 84 | clean_builds: 85 | @rm -rf "$(ANDROID_PREFIX)" 86 | 87 | 88 | ## Testing. 89 | 90 | test: test_setup 91 | @bash --noprofile --norc mk/test.sh 92 | 93 | test_setup: 94 | ifeq ("$(wildcard build-vm/$(TEST_IDENTIFIER))","") 95 | @bash --noprofile --norc mk/test_setup.sh 96 | endif 97 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Python 3 Android 2 | ================ 3 | 4 | This is an experimental set of build scripts that will crosscompile Python 3 for an ARM Android device. 5 | 6 | **This project is not maintained anymore. Do check out [@GRRedWing's](https://github.com/GRRedWings/python3-android) and [@yan12125's](https://github.com/yan12125/python3-android) forks for a continuation of development on Python 3 for Android.** 7 | 8 | Usage 9 | ------ 10 | 11 | 1. `make clean` for good measure. 12 | 2. For every NDK/API Level/Toolchain combination you wish to build for: 13 | * Edit `env` to match your (desired) configuration. 14 | * `make` to build everything! 15 | * (Optional) `make test` to setup an Android emulator and run automated Python regression tests. 16 | 17 | Requirements 18 | ------------ 19 | 20 | Building requires: 21 | 22 | 1. A working host toolchain that is able to compile Python (for hostpython). 23 | 2. Patience. 24 | 25 | Testing requires: 26 | 27 | 1. Java 6 to use the Android SDK manager. 28 | 2. `awk` and `tr` for some setup wizardry. 29 | 3. Even more patience. 30 | 31 | Both require: 32 | 33 | 1. A working `bash` and basic *nix utilities like `cp` and `touch`. 34 | 2. `wget` to fetch files. 35 | 2. `tar` to extract files. 36 | 37 | FAQ 38 | --- 39 | 40 | *The build is failing with something about license terms!* 41 | 42 | Read the license terms, edit `env` and set `ANDROID_AGREE_LICENSE_TERMS=y` if you agree with them, and re-run. 43 | -------------------------------------------------------------------------------- /env: -------------------------------------------------------------------------------- 1 | export BASE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 2 | 3 | # Directories. 4 | export ANDROID_PREFIX="${BASE}/build" 5 | export ANDROID_TOOL_PREFIX="${BASE}/build-tools" 6 | export ANDROID_TEST_PREFIX="${BASE}/build-vm" 7 | 8 | # SDKs and target platforms. 9 | export NDK_REL=android-ndk-r10d 10 | export SDK_REL=android-sdk-r24.0.2 11 | export NDK_REV=10d 12 | export SDK_REV=24.0.2 13 | export ANDROID_API_LEVEL=21 14 | export ANDROID_PLATFORM=arm 15 | export ANDROID_COMPILER=4.9 16 | export ANDROID_HOST=x86_64-pc-linux-gnu 17 | export ANDROID_AGREE_LICENSE_TERMS=n 18 | 19 | # Testing. 20 | export ANDROID_VM_NAME=PythonTesting 21 | export ANDROID_EMULATOR_TESTDIR="/data/py3" 22 | export ANDROID_EMULATOR_OPTIONS="" 23 | #-no-window -no-skin -no-boot-anim" 24 | 25 | # Compile flags. 26 | export CFLAGS_EXTRA="" 27 | export CPPFLAGS_EXTRA="" 28 | export CXXFLAGS_EXTRA="" 29 | export LDFLAGS_EXTRA="" 30 | export MAKEOPTS_EXTRA="" 31 | 32 | # Python optional modules. 33 | # Available: 34 | # bz2 - enable the bz2 module and the bzip2 codec (builds bzip2). 35 | # lzma - enable the lzma module and the lzma codec (builds xz). 36 | # ssl - enable the ssl module and SSL/TLS support for sockets (builds OpenSSL). 37 | # readline - enable the readline module and command history/the like in the REPL (builds Readline). 38 | # curses - enable the curses module (builds ncursesw). 39 | # sqlite3 - enable the sqlite3 module (builds SQLite). 40 | # gdbm - enable the dbm/gdbm modules (builds GDBM). 41 | export PYTHON_OPTIONAL_MODULES="bz2 lzma ssl" 42 | 43 | # Do no touch unless you know what you are doing. 44 | case "${ANDROID_PLATFORM}" in 45 | arm) 46 | export ANDROID_TARGET=arm-linux-androideabi 47 | export ANDROID_TOOLCHAIN="arm-linux-androideabi-${ANDROID_COMPILER}" 48 | ;; 49 | mips) 50 | export ANDROID_TARGET=mipsel-linux-android 51 | export ANDROID_TOOLCHAIN="mipsel-linu-android-${ANDROID_COMPILER}" 52 | ;; 53 | x86) 54 | export ANDROID_TARGET=i686-linux-android 55 | export ANDROID_TOOLCHAIN="x86-${ANDROID_COMPILER}" 56 | ;; 57 | *) 58 | echo "Unknown Android platform: ${ANDROID_PLATFORM}" 59 | exit 1 60 | ;; 61 | esac 62 | export BUILD_IDENTIFIER="${NDK_REV}-${ANDROID_API_LEVEL}-${ANDROID_TOOLCHAIN}" 63 | export TEST_IDENTIFIER="${SDK_REV}-${ANDROID_API_LEVEL}-${ANDROID_PLATFORM}" 64 | -------------------------------------------------------------------------------- /mk/build_ndk.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | source ./env 3 | 4 | # Stolen from https://github.com/rust-lang/rust/blob/2e2f53fad/configure#L345. 5 | case $(uname -m) in 6 | i386 | i486 | i686 | i786 | x86) 7 | NDK_ARCH="x86" 8 | ;; 9 | x86-64 | x86_64 | x64 | amd64) 10 | NDK_ARCH="x86_64" 11 | ;; 12 | *) 13 | echo "Unknown architecture: $(uname -m)." 14 | exit 1 15 | ;; 16 | esac 17 | 18 | [[ ! -d "${ANDROID_PREFIX}/.built-${BUILD_IDENTIFIER}" ]] && (mkdir -p "${ANDROID_PREFIX}/.built-${BUILD_IDENTIFIER}" || exit 1) 19 | [[ ! -d "${ANDROID_TOOL_PREFIX}/${BUILD_IDENTIFIER}" ]] && (mkdir -p "${ANDROID_TOOL_PREFIX}/${BUILD_IDENTIFIER}" || exit 1) 20 | 21 | 22 | case "${NDK_REV}" in 23 | 10*) 24 | NDK_ARCHIVE="${BASE}/sdk/android-ndk-r${NDK_REV}-$(uname -s | tr '[A-Z]' '[a-z]')-${NDK_ARCH}.bin" 25 | if [[ ! -d "${BASE}/sdk/${NDK_REL}" ]]; then 26 | chmod +x "${NDK_ARCHIVE}" || exit 1 27 | pushd "${BASE}/sdk" 28 | # Self-extracting binary. 29 | "${NDK_ARCHIVE}" || exit 1 30 | popd 31 | fi 32 | ;; 33 | *) 34 | NDK_ARCHIVE="$BASE/sdk/android-ndk-r${NDK_REV}-$(uname -s | tr '[A-Z]' '[a-z]')-${NDK_ARCH}.tar.bz2" 35 | if [[ ! -d "${BASE}/sdk/${NDK_REL}" ]]; then 36 | # Tar archive. 37 | tar -xf "${NDK_ARCHIVE}" -C "${BASE}/sdk" || exit 1 38 | fi 39 | ;; 40 | esac 41 | 42 | if [[ ! -f "${ANDROID_PREFIX}/.built-ndk-${BUILD_IDENTIFIER}" ]]; then 43 | ("${BASE}/sdk/${NDK_REL}/build/tools/make-standalone-toolchain.sh" --platform="android-${ANDROID_API_LEVEL}" --install-dir="${ANDROID_TOOL_PREFIX}/${BUILD_IDENTIFIER}" --toolchain="${ANDROID_TOOLCHAIN}" &&\ 44 | touch "${ANDROID_PREFIX}/.built-ndk-${BUILD_IDENTIFIER}") || exit 1 45 | fi 46 | -------------------------------------------------------------------------------- /mk/build_single.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | source ./env 3 | [[ ! -d "${ANDROID_PREFIX}/${BUILD_IDENTIFIER}" ]] && (mkdir -p "${ANDROID_PREFIX}/${BUILD_IDENTIFIER}" || exit 1) 4 | [[ ! -d "${ANDROID_PREFIX}/${BUILD_IDENTIFIER}/include" ]] && (mkdir "${ANDROID_PREFIX}/${BUILD_IDENTIFIER}/include" || exit 1) 5 | 6 | export PATH="${ANDROID_TOOL_PREFIX}/${BUILD_IDENTIFIER}/bin:${PATH}" 7 | export PREFIX="${ANDROID_PREFIX}/${BUILD_IDENTIFIER}" 8 | export TOOL_PREFIX="${ANDROID_TOOL_PREFIX}/${BUILD_IDENTIFIER}" 9 | export HOST="${ANDROID_HOST}" 10 | export TARGET="${ANDROID_TARGET}" 11 | 12 | export NDK_ROOT="${BASE}/sdk/${NDK_REL}" 13 | export SDK_ROOT="${BASE}/sdk/${SDK_REL}" 14 | export NDK_PLATFORM="android-${NDK_REV}" 15 | export SDK_PLATFORM="android-${SDK_REV}" 16 | export cross="${ANDROID_TARGET}-" 17 | 18 | export CFLAGS="--sysroot ${TOOL_PREFIX}/sysroot -I${PREFIX}/include -I${TOOL_PREFIX}/include -DANDROID -mandroid ${CFLAGS_EXTRA}" 19 | export CPPFLAGS="${CFLAGS} ${CPPFLAGS_EXTRA}" 20 | export CXXFLAGS="${CFLAGS} ${CXXFLAGS_EXTRA}" 21 | export LDFLAGS="--sysroot ${TOOL_PREFIX}/sysroot -L${PREFIX}/lib -L${TOOL_PREFIX}/lib ${LDFLAGS_EXTRA}" 22 | 23 | export CC="${ANDROID_TARGET}-gcc" 24 | export CXX="${ANDROID_TARGET}-g++" 25 | export CPP="${ANDROID_TARGET}-cpp" 26 | export AR="${ANDROID_TARGET}-ar" 27 | export AS="${ANDROID_TARGET}-ls" 28 | export LD="${ANDROID_TARGET}-ld" 29 | export OBJCOPY="${ANDROID_TARGET}-objcopy" 30 | export OBJDUMP="${ANDROID_TARGET}-objdump" 31 | export RANLIB="${ANDROID_TARGET}-ranlib" 32 | export STRIP="${ANDROID_TARGET}-strip" 33 | 34 | export NAME="$1" 35 | export VERSION="$2" 36 | export PACKAGE="${NAME}-${VERSION}" 37 | export FILESDIR="${BASE}/mk/${NAME}/${VERSION}" 38 | 39 | pushd "${BASE}" > /dev/null 40 | . "${FILESDIR}/build.sh" || exit 1 41 | popd > /dev/null 42 | -------------------------------------------------------------------------------- /mk/bzip2/1.0.6/build.sh: -------------------------------------------------------------------------------- 1 | pushd src >/dev/null 2 | 3 | rm -rf "${PACKAGE}" 4 | tar -xf "${PACKAGE}.tar.gz" || exit 1 5 | pushd "${PACKAGE}" >/dev/null 6 | 7 | patch -p1 < "${FILESDIR}/${PACKAGE}-makefile-env.patch" || exit 1 8 | make clean || exit 1 9 | make libbz2.a || exit 1 10 | make install_libbz2.a || exit 1 11 | 12 | popd >/dev/null 13 | popd >/dev/null 14 | -------------------------------------------------------------------------------- /mk/bzip2/1.0.6/bzip2-1.0.6-makefile-env.patch: -------------------------------------------------------------------------------- 1 | diff -ru bzip2-1.0.6/Makefile bzip2-1.0.6-p/Makefile 2 | --- bzip2-1.0.6/Makefile 2010-09-10 22:46:02.000000000 +0000 3 | +++ bzip2-1.0.6-p/Makefile 2014-01-20 01:35:53.252736910 +0000 4 | @@ -15,16 +15,16 @@ 5 | SHELL=/bin/sh 6 | 7 | # To assist in cross-compiling 8 | -CC=gcc 9 | -AR=ar 10 | -RANLIB=ranlib 11 | +CC?=gcc 12 | +AR?=ar 13 | +RANLIB?=ranlib 14 | LDFLAGS= 15 | 16 | BIGFILES=-D_FILE_OFFSET_BITS=64 17 | -CFLAGS=-Wall -Winline -O2 -g $(BIGFILES) 18 | +CFLAGS+=-Wall -Winline -O2 -g $(BIGFILES) 19 | 20 | # Where you want it installed when you do 'make install' 21 | -PREFIX=/usr/local 22 | +PREFIX?=/usr/local 23 | 24 | 25 | OBJS= blocksort.o \ 26 | @@ -69,12 +69,10 @@ 27 | cmp sample3.tst sample3.ref 28 | @cat words3 29 | 30 | -install: bzip2 bzip2recover 31 | +install: bzip2 bzip2recover install_libz2.a 32 | if ( test ! -d $(PREFIX)/bin ) ; then mkdir -p $(PREFIX)/bin ; fi 33 | - if ( test ! -d $(PREFIX)/lib ) ; then mkdir -p $(PREFIX)/lib ; fi 34 | if ( test ! -d $(PREFIX)/man ) ; then mkdir -p $(PREFIX)/man ; fi 35 | if ( test ! -d $(PREFIX)/man/man1 ) ; then mkdir -p $(PREFIX)/man/man1 ; fi 36 | - if ( test ! -d $(PREFIX)/include ) ; then mkdir -p $(PREFIX)/include ; fi 37 | cp -f bzip2 $(PREFIX)/bin/bzip2 38 | cp -f bzip2 $(PREFIX)/bin/bunzip2 39 | cp -f bzip2 $(PREFIX)/bin/bzcat 40 | @@ -85,10 +83,6 @@ 41 | chmod a+x $(PREFIX)/bin/bzip2recover 42 | cp -f bzip2.1 $(PREFIX)/man/man1 43 | chmod a+r $(PREFIX)/man/man1/bzip2.1 44 | - cp -f bzlib.h $(PREFIX)/include 45 | - chmod a+r $(PREFIX)/include/bzlib.h 46 | - cp -f libbz2.a $(PREFIX)/lib 47 | - chmod a+r $(PREFIX)/lib/libbz2.a 48 | cp -f bzgrep $(PREFIX)/bin/bzgrep 49 | ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzegrep 50 | ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzfgrep 51 | @@ -108,6 +102,14 @@ 52 | echo ".so man1/bzmore.1" > $(PREFIX)/man/man1/bzless.1 53 | echo ".so man1/bzdiff.1" > $(PREFIX)/man/man1/bzcmp.1 54 | 55 | +install_libbz2.a: libbz2.a 56 | + if ( test ! -d $(PREFIX)/inclue ) ; then mkdir -p $(PREFIX)/include ; fi 57 | + if ( test ! -d $(PREFIX)/lib ) ; then mkdir -p $(PREFIX)/lib ; fi 58 | + cp -f bzlib.h $(PREFIX)/include 59 | + chmod a+r $(PREFIX)/include/bzlib.h 60 | + cp -f libbz2.a $(PREFIX)/lib 61 | + chmod a+r $(PREFIX)/lib/libbz2.a 62 | + 63 | clean: 64 | rm -f *.o libbz2.a bzip2 bzip2recover \ 65 | sample1.rb2 sample2.rb2 sample3.rb2 \ 66 | 67 | -------------------------------------------------------------------------------- /mk/bzip2/1.0.6/sources.txt: -------------------------------------------------------------------------------- 1 | http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz 2 | -------------------------------------------------------------------------------- /mk/gdbm/1.11/build.sh: -------------------------------------------------------------------------------- 1 | pushd src >/dev/null 2 | 3 | rm -rf "${PACKAGE}" 4 | tar -xf "${PACKAGE}.tar.gz" || exit 1 5 | pushd "${PACKAGE}" >/dev/null 6 | 7 | patch -p1 < "${FILESDIR}/${PACKAGE}-android-winsize.patch" 8 | ./configure --prefix="${PREFIX}" --host="${TARGET}" --build="${HOST}" --enable-libgdbm-compat || exit 1 9 | make || exit 1 10 | make install || exit 1 11 | 12 | popd >/dev/null 13 | popd >/dev/null 14 | -------------------------------------------------------------------------------- /mk/gdbm/1.11/gdbm-1.11-android-winsize.patch: -------------------------------------------------------------------------------- 1 | diff -ru gdbm-1.11/src/gdbmtool.c gdbm-1.11-android/src/gdbmtool.c 2 | --- gdbm-1.11/src/gdbmtool.c 2013-05-21 21:48:31.000000000 +0200 3 | +++ gdbm-1.11-android/src/gdbmtool.c 2014-08-05 15:35:51.000000000 +0200 4 | @@ -302,7 +302,7 @@ 5 | int 6 | get_screen_lines () 7 | { 8 | -#ifdef TIOCGWINSZ 9 | +#if defined(TIOCGWINSZ) && !__ANDROID__ 10 | if (isatty (1)) 11 | { 12 | struct winsize ws; 13 | -------------------------------------------------------------------------------- /mk/gdbm/1.11/sources.txt: -------------------------------------------------------------------------------- 1 | https://ftp.gnu.org/gnu/gdbm/gdbm-1.11.tar.gz 2 | -------------------------------------------------------------------------------- /mk/ncurses/5.9/build.sh: -------------------------------------------------------------------------------- 1 | pushd src >/dev/null 2 | 3 | rm -rf "${PACKAGE}" 4 | tar -xf "${PACKAGE}.tar.gz" || exit 1 5 | pushd "${PACKAGE}" >/dev/null 6 | 7 | patch -p1 < "${FILESDIR}/${PACKAGE}-android-locale-fixes.patch" 8 | ./configure --prefix="${PREFIX}" --host="${TARGET}" --build="${HOST}" --without-ada --without-manpages --without-progs --without-tests --with-termlib --enable-termcap --enable-widec --disable-database --disable-home-terminfo || exit 1 9 | make || exit 1 10 | make install || exit 1 11 | # Fix symlinks for Python _curses and _curses_panel extensions. 12 | ln -s ncursesw/curses.h "${PREFIX}/include/curses.h" || exit 1 13 | ln -s ncursesw/panel.h "${PREFIX}/include/panel.h" || exit 1 14 | 15 | popd >/dev/null 16 | popd >/dev/null 17 | -------------------------------------------------------------------------------- /mk/ncurses/5.9/ncurses-5.9-android-locale-fixes.patch: -------------------------------------------------------------------------------- 1 | diff -ru ncurses-5.9/form/fty_num.c ncurses-5.9-android/form/fty_num.c 2 | --- ncurses-5.9/form/fty_num.c 2010-01-23 22:14:36.000000000 +0100 3 | +++ ncurses-5.9-android/form/fty_num.c 2014-08-04 23:04:23.000000000 +0200 4 | @@ -40,7 +40,7 @@ 5 | #include 6 | #endif 7 | 8 | -#if HAVE_LOCALE_H 9 | +#if HAVE_LOCALE_H && !__ANDROID__ 10 | #define isDecimalPoint(c) ((c) == ((L && L->decimal_point) ? *(L->decimal_point) : '.')) 11 | #else 12 | #define isDecimalPoint(c) ((c) == '.') 13 | -------------------------------------------------------------------------------- /mk/ncurses/5.9/sources.txt: -------------------------------------------------------------------------------- 1 | https://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz 2 | -------------------------------------------------------------------------------- /mk/ndk_source.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | source ./env 3 | 4 | # Stolen from https://github.com/rust-lang/rust/blob/2e2f53fad/configure#L345. 5 | case $(uname -m) in 6 | i386 | i486 | i686 | i786 | x86) 7 | NDK_ARCH="x86" 8 | ;; 9 | x86-64 | x86_64 | x64 | amd64) 10 | NDK_ARCH="x86_64" 11 | ;; 12 | *) 13 | echo "Unknown architecture: $(uname -m)." 14 | exit 1 15 | ;; 16 | esac 17 | 18 | case "${NDK_REV}" in 19 | 10*) 20 | NDK_EXT=bin 21 | ;; 22 | *) 23 | NDK_EXT=tar.bz2 24 | ;; 25 | esac 26 | 27 | echo http://dl.google.com/android/ndk/android-ndk-r${NDK_REV}-$(uname -s | tr '[A-Z]' '[a-z'])-${NDK_ARCH}.${NDK_EXT} 28 | -------------------------------------------------------------------------------- /mk/openssl/1.0.2d/build.sh: -------------------------------------------------------------------------------- 1 | pushd src >/dev/null 2 | 3 | rm -rf "${PACKAGE}" 4 | tar -xf "${PACKAGE}.tar.gz" || exit 1 5 | pushd "${PACKAGE}" >/dev/null 6 | 7 | [[ ! -d "${PREFIX}/share" ]] && (mkdir "${PREFIX}/share" || exit 1) 8 | patch -p1 < "${FILESDIR}/${PACKAGE}-android-ndk-target.patch" || exit 1 9 | ./Configure android-ndk --prefix="${PREFIX}" --openssldir="${PREFIX}/share" || exit 1 10 | make || exit 1 11 | make install_sw || exit 1 12 | 13 | # Remove binaries from premises. 14 | rm -f "${PREFIX}/bin/"{openssl,c_rehash} || exit 1 15 | 16 | popd >/dev/null 17 | popd >/dev/null 18 | -------------------------------------------------------------------------------- /mk/openssl/1.0.2d/openssl-1.0.2d-android-ndk-target.patch: -------------------------------------------------------------------------------- 1 | diff -ru openssl-1.0.2/Configure openssl-1.0.2-android/Configure 2 | --- openssl-1.0.2/Configure 2015-01-22 15:58:32.000000000 +0100 3 | +++ openssl-1.0.2-android/Configure 2015-03-02 11:23:58.000000000 +0100 4 | @@ -445,6 +445,7 @@ 5 | 6 | # Android: linux-* but without -DTERMIO and pointers to headers and libs. 7 | "android","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 8 | +"android-ndk","gcc:-O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so", 9 | "android-x86","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 10 | "android-armv7","gcc:-march=armv7-a -mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 11 | "android-mips","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 12 | 13 | -------------------------------------------------------------------------------- /mk/openssl/1.0.2d/sources.txt: -------------------------------------------------------------------------------- 1 | https://openssl.org/source/openssl-1.0.2d.tar.gz 2 | -------------------------------------------------------------------------------- /mk/python/3.4.3/build.sh: -------------------------------------------------------------------------------- 1 | pushd src >/dev/null 2 | 3 | rm -rf "Python-${VERSION}" 4 | tar -xf "Python-${VERSION}.tar.xz" || exit 1 5 | pushd "Python-${VERSION}" >/dev/null 6 | 7 | # Build host components. 8 | AR=ar AS=as CC=gcc CFLAGS= CPP=cpp CPPFLAGS= CXX=g++ CXXFLAGS= LD=ld LDFLAGS= RANLIB=ranlib ./configure || exit 1 9 | AR=ar AS=as CC=gcc CFLAGS= CPP=cpp CPPFLAGS= CXX=g++ CXXFLAGS= LD=ld LDFLAGS= RANLIB=ranlib make BUILDPYTHON=hostpython hostpython PGEN=Parser/hostpgen Parser/hostpgen || exit 1 10 | make distclean || exit 1 11 | 12 | # Apply patches and build target Python. 13 | cat > config.site <<-SITE 14 | ac_cv_file__dev_ptmx=no 15 | ac_cv_file__dev_ptc=no 16 | SITE 17 | ln -sf "${TOOL_PREFIX}/sysroot/usr/include/"{linux,sys}"/soundcard.h" 18 | patch -p1 < "${FILESDIR}/${PACKAGE}-cross-compile.patch" || exit 1 19 | patch -p1 < "${FILESDIR}/${PACKAGE}-python-misc.patch" || exit 1 20 | patch -p1 < "${FILESDIR}/${PACKAGE}-android-locale.patch" || exit 1 21 | patch -Ep1 < "${FILESDIR}/${PACKAGE}-android-libmpdec.patch" || exit 1 22 | [[ "${NDK_REV}" != 10* ]] && (patch -p1 < "${FILESDIR}/${PACKAGE}-android-missing-getdents64-definition.patch" || exit 1) 23 | patch -p1 < "${FILESDIR}/${PACKAGE}-android-misc.patch" || exit 1 24 | 25 | ./configure CROSS_COMPILE_TARGET=yes HOSTPYTHON="$(pwd)/hostpython" CONFIG_SITE=config.site --prefix="${PREFIX}" --host="${TARGET}" --build="${HOST}" --disable-ipv6 --enable-shared --without-ensurepip || exit 1 26 | make CROSS_COMPILE_TARGET=yes HOSTPYTHON="$(pwd)/hostpython" HOSTPGEN="$(pwd)/Parser/hostpgen" || exit 1 27 | make CROSS_COMPILE_TARGET=yes HOSTPYTHON="$(pwd)/hostpython" HOSTPGEN="$(pwd)/Parser/hostpgen" install || exit 1 28 | 29 | popd >/dev/null 30 | popd >/dev/null 31 | -------------------------------------------------------------------------------- /mk/python/3.4.3/python-3.4.3-android-libmpdec.patch: -------------------------------------------------------------------------------- 1 | diff -Nru Python-3.3.5/Modules/_decimal/libmpdec/basearith.c Python-3.3.5-android/Modules/_decimal/libmpdec/basearith.c 2 | --- Python-3.3.5/Modules/_decimal/libmpdec/basearith.c 2014-03-09 09:40:25.000000000 +0100 3 | +++ Python-3.3.5-android/Modules/_decimal/libmpdec/basearith.c 2014-08-05 16:11:29.000000000 +0200 4 | @@ -32,7 +32,7 @@ 5 | #include 6 | #include 7 | #include "constants.h" 8 | -#include "memory.h" 9 | +#include "mpmemory.h" 10 | #include "typearith.h" 11 | #include "basearith.h" 12 | 13 | diff -Nru Python-3.3.5/Modules/_decimal/libmpdec/io.c Python-3.3.5-android/Modules/_decimal/libmpdec/io.c 14 | --- Python-3.3.5/Modules/_decimal/libmpdec/io.c 2014-08-05 16:05:22.000000000 +0200 15 | +++ Python-3.3.5-android/Modules/_decimal/libmpdec/io.c 2014-08-05 16:11:42.000000000 +0200 16 | @@ -37,7 +37,7 @@ 17 | #include 18 | #include "bits.h" 19 | #include "constants.h" 20 | -#include "memory.h" 21 | +#include "mpmemory.h" 22 | #include "typearith.h" 23 | #include "io.h" 24 | 25 | diff -Nru Python-3.3.5/Modules/_decimal/libmpdec/memory.c Python-3.3.5-android/Modules/_decimal/libmpdec/memory.c 26 | --- Python-3.3.5/Modules/_decimal/libmpdec/memory.c 2014-03-09 09:40:25.000000000 +0100 27 | +++ Python-3.3.5-android/Modules/_decimal/libmpdec/memory.c 2014-08-05 16:11:52.000000000 +0200 28 | @@ -30,7 +30,7 @@ 29 | #include 30 | #include 31 | #include "typearith.h" 32 | -#include "memory.h" 33 | +#include "mpmemory.h" 34 | 35 | 36 | /* Guaranteed minimum allocation for a coefficient. May be changed once 37 | diff -Nru Python-3.3.5/Modules/_decimal/libmpdec/memory.h Python-3.3.5-android/Modules/_decimal/libmpdec/memory.h 38 | --- Python-3.3.5/Modules/_decimal/libmpdec/memory.h 2014-03-09 09:40:25.000000000 +0100 39 | +++ Python-3.3.5-android/Modules/_decimal/libmpdec/memory.h 1970-01-01 01:00:00.000000000 +0100 40 | @@ -1,51 +0,0 @@ 41 | -/* 42 | - * Copyright (c) 2008-2016 Stefan Krah. All rights reserved. 43 | - * 44 | - * Redistribution and use in source and binary forms, with or without 45 | - * modification, are permitted provided that the following conditions 46 | - * are met: 47 | - * 48 | - * 1. Redistributions of source code must retain the above copyright 49 | - * notice, this list of conditions and the following disclaimer. 50 | - * 51 | - * 2. Redistributions in binary form must reproduce the above copyright 52 | - * notice, this list of conditions and the following disclaimer in the 53 | - * documentation and/or other materials provided with the distribution. 54 | - * 55 | - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND 56 | - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 57 | - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 58 | - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 59 | - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 60 | - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 61 | - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 62 | - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 63 | - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 64 | - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 65 | - * SUCH DAMAGE. 66 | - */ 67 | - 68 | - 69 | -#ifndef MEMORY_H 70 | -#define MEMORY_H 71 | - 72 | - 73 | -#include "mpdecimal.h" 74 | - 75 | - 76 | -/* Internal header file: all symbols have local scope in the DSO */ 77 | -MPD_PRAGMA(MPD_HIDE_SYMBOLS_START) 78 | - 79 | - 80 | -int mpd_switch_to_dyn(mpd_t *result, mpd_ssize_t size, uint32_t *status); 81 | -int mpd_switch_to_dyn_zero(mpd_t *result, mpd_ssize_t size, uint32_t *status); 82 | -int mpd_realloc_dyn(mpd_t *result, mpd_ssize_t size, uint32_t *status); 83 | - 84 | - 85 | -MPD_PRAGMA(MPD_HIDE_SYMBOLS_END) /* restore previous scope rules */ 86 | - 87 | - 88 | -#endif 89 | - 90 | - 91 | - 92 | diff -Nru Python-3.3.5/Modules/_decimal/libmpdec/mpdecimal.c Python-3.3.5-android/Modules/_decimal/libmpdec/mpdecimal.c 93 | --- Python-3.3.5/Modules/_decimal/libmpdec/mpdecimal.c 2014-03-09 09:40:25.000000000 +0100 94 | +++ Python-3.3.5-android/Modules/_decimal/libmpdec/mpdecimal.c 2014-08-05 16:12:06.000000000 +0200 95 | @@ -36,7 +36,7 @@ 96 | #include "bits.h" 97 | #include "convolute.h" 98 | #include "crt.h" 99 | -#include "memory.h" 100 | +#include "mpmemory.h" 101 | #include "typearith.h" 102 | #include "umodarith.h" 103 | 104 | diff -Nru Python-3.3.5/Modules/_decimal/libmpdec/mpmemory.h Python-3.3.5-android/Modules/_decimal/libmpdec/mpmemory.h 105 | --- Python-3.3.5/Modules/_decimal/libmpdec/mpmemory.h 1970-01-01 01:00:00.000000000 +0100 106 | +++ Python-3.3.5-android/Modules/_decimal/libmpdec/mpmemory.h 2014-08-05 16:10:00.000000000 +0200 107 | @@ -0,0 +1,51 @@ 108 | +/* 109 | + * Copyright (c) 2008-2016 Stefan Krah. All rights reserved. 110 | + * 111 | + * Redistribution and use in source and binary forms, with or without 112 | + * modification, are permitted provided that the following conditions 113 | + * are met: 114 | + * 115 | + * 1. Redistributions of source code must retain the above copyright 116 | + * notice, this list of conditions and the following disclaimer. 117 | + * 118 | + * 2. Redistributions in binary form must reproduce the above copyright 119 | + * notice, this list of conditions and the following disclaimer in the 120 | + * documentation and/or other materials provided with the distribution. 121 | + * 122 | + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND 123 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 124 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 125 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 126 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 127 | + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 128 | + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 129 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 130 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 131 | + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 132 | + * SUCH DAMAGE. 133 | + */ 134 | + 135 | + 136 | +#ifndef MEMORY_H 137 | +#define MEMORY_H 138 | + 139 | + 140 | +#include "mpdecimal.h" 141 | + 142 | + 143 | +/* Internal header file: all symbols have local scope in the DSO */ 144 | +MPD_PRAGMA(MPD_HIDE_SYMBOLS_START) 145 | + 146 | + 147 | +int mpd_switch_to_dyn(mpd_t *result, mpd_ssize_t size, uint32_t *status); 148 | +int mpd_switch_to_dyn_zero(mpd_t *result, mpd_ssize_t size, uint32_t *status); 149 | +int mpd_realloc_dyn(mpd_t *result, mpd_ssize_t size, uint32_t *status); 150 | + 151 | + 152 | +MPD_PRAGMA(MPD_HIDE_SYMBOLS_END) /* restore previous scope rules */ 153 | + 154 | + 155 | +#endif 156 | + 157 | + 158 | + 159 | -------------------------------------------------------------------------------- /mk/python/3.4.3/python-3.4.3-android-locale.patch: -------------------------------------------------------------------------------- 1 | diff -ru Python-3.3.5/Modules/Setup.dist Python-3.3.5-android/Modules/Setup.dist 2 | --- Python-3.3.5/Modules/Setup.dist 2014-03-09 09:40:23.000000000 +0100 3 | +++ Python-3.3.5-android/Modules/Setup.dist 2014-08-04 22:16:29.000000000 +0200 4 | @@ -118,7 +118,7 @@ 5 | itertools itertoolsmodule.c # Functions creating iterators for efficient looping 6 | 7 | # access to ISO C locale support 8 | -_locale _localemodule.c # -lintl 9 | +#_locale _localemodule.c # -lintl 10 | 11 | # Standard I/O baseline 12 | _io -I$(srcdir)/Modules/_io _io/_iomodule.c _io/iobase.c _io/fileio.c _io/bytesio.c _io/bufferedio.c _io/textio.c _io/stringio.c 13 | diff -ru Python-3.3.5/Modules/_decimal/libmpdec/io.c Python-3.3.5-android/Modules/_decimal/libmpdec/io.c 14 | --- Python-3.3.5/Modules/_decimal/libmpdec/io.c 2014-03-09 09:40:25.000000000 +0100 15 | +++ Python-3.3.5-android/Modules/_decimal/libmpdec/io.c 2014-08-04 22:16:29.000000000 +0200 16 | @@ -868,10 +868,17 @@ 17 | } 18 | spec->type = *cp++; 19 | spec->type = (spec->type == 'N') ? 'G' : 'g'; 20 | +#ifdef __ANDROID__ 21 | + spec->dot = "."; 22 | + spec->sep = ","; 23 | + spec->grouping = "\3"; 24 | +#else 25 | lc = localeconv(); 26 | spec->dot = lc->decimal_point; 27 | spec->sep = lc->thousands_sep; 28 | spec->grouping = lc->grouping; 29 | +#endif 30 | + 31 | if (mpd_validate_lconv(spec) < 0) { 32 | return 0; /* GCOV_NOT_REACHED */ 33 | } 34 | diff -ru Python-3.3.5/Modules/_localemodule.c Python-3.3.5-android/Modules/_localemodule.c 35 | --- Python-3.3.5/Modules/_localemodule.c 2014-03-09 09:40:26.000000000 +0100 36 | +++ Python-3.3.5-android/Modules/_localemodule.c 2014-08-04 22:16:29.000000000 +0200 37 | @@ -38,6 +38,13 @@ 38 | #include 39 | #endif 40 | 41 | +#if __ANDROID__ 42 | +/* Android's locale support is pretty much unusable, it's better to have the 43 | + higher-level module fall back to C locale emulation. */ 44 | +#error "Android's locale support is too incomplete to create a usable module." 45 | +#endif 46 | + 47 | + 48 | PyDoc_STRVAR(locale__doc__, "Support for POSIX locales."); 49 | 50 | static PyObject *Error; 51 | @@ -141,6 +148,11 @@ 52 | if (!result) 53 | return NULL; 54 | 55 | +#ifdef __ANDROID__ 56 | + /* Don't even try on Android's broken locale.h. */ 57 | + goto failed; 58 | +#else 59 | + 60 | /* if LC_NUMERIC is different in the C library, use saved value */ 61 | l = localeconv(); 62 | 63 | @@ -189,6 +201,7 @@ 64 | RESULT_INT(p_sign_posn); 65 | RESULT_INT(n_sign_posn); 66 | return result; 67 | +#endif // __ANDROID__ 68 | 69 | failed: 70 | Py_XDECREF(result); 71 | diff -ru Python-3.3.5/Modules/main.c Python-3.3.5-android/Modules/main.c 72 | --- Python-3.3.5/Modules/main.c 2014-03-09 09:40:27.000000000 +0100 73 | +++ Python-3.3.5-android/Modules/main.c 2014-08-04 22:16:29.000000000 +0200 74 | @@ -522,7 +522,7 @@ 75 | oldloc = strdup(setlocale(LC_ALL, NULL)); 76 | setlocale(LC_ALL, ""); 77 | for (p = strtok(buf, ","); p != NULL; p = strtok(NULL, ",")) { 78 | -#ifdef __APPLE__ 79 | +#if defined(__APPLE__) || defined(__ANDROID__) 80 | /* Use utf-8 on Mac OS X */ 81 | unicode = PyUnicode_FromString(p); 82 | #else 83 | diff -ru Python-3.3.5/Objects/unicodeobject.c Python-3.3.5-android/Objects/unicodeobject.c 84 | --- Python-3.3.5/Objects/unicodeobject.c 2014-03-09 09:40:30.000000000 +0100 85 | +++ Python-3.3.5-android/Objects/unicodeobject.c 2014-08-04 22:16:29.000000000 +0200 86 | @@ -3295,13 +3295,22 @@ 87 | static int 88 | locale_error_handler(const char *errors, int *surrogateescape) 89 | { 90 | + 91 | if (errors == NULL) { 92 | +#ifdef __ANDROID__ 93 | + *surrogateescape = 1; 94 | +#else 95 | *surrogateescape = 0; 96 | +#endif 97 | return 0; 98 | } 99 | 100 | if (strcmp(errors, "strict") == 0) { 101 | +#ifdef __ANDROID__ 102 | + *surrogateescape = 1; 103 | +#else 104 | *surrogateescape = 0; 105 | +#endif 106 | return 0; 107 | } 108 | if (strcmp(errors, "surrogateescape") == 0) { 109 | @@ -3429,7 +3438,7 @@ 110 | { 111 | #ifdef HAVE_MBCS 112 | return PyUnicode_EncodeCodePage(CP_ACP, unicode, NULL); 113 | -#elif defined(__APPLE__) 114 | +#elif defined(__APPLE__) || defined(__ANDROID__) 115 | return _PyUnicode_AsUTF8String(unicode, "surrogateescape"); 116 | #else 117 | PyInterpreterState *interp = PyThreadState_GET()->interp; 118 | @@ -3709,7 +3718,7 @@ 119 | { 120 | #ifdef HAVE_MBCS 121 | return PyUnicode_DecodeMBCS(s, size, NULL); 122 | -#elif defined(__APPLE__) 123 | +#elif defined(__APPLE__) || defined(__ANDROID__) 124 | return PyUnicode_DecodeUTF8Stateful(s, size, "surrogateescape", NULL); 125 | #else 126 | PyInterpreterState *interp = PyThreadState_GET()->interp; 127 | @@ -4835,7 +4844,7 @@ 128 | return NULL; 129 | } 130 | 131 | -#ifdef __APPLE__ 132 | +#if defined(__APPLE__) || defined(__ANDROID__) 133 | 134 | /* Simplified UTF-8 decoder using surrogateescape error handler, 135 | used to decode the command line arguments on Mac OS X. 136 | diff -ru Python-3.3.5/Python/bltinmodule.c Python-3.3.5-android/Python/bltinmodule.c 137 | --- Python-3.3.5/Python/bltinmodule.c 2014-03-09 09:40:32.000000000 +0100 138 | +++ Python-3.3.5-android/Python/bltinmodule.c 2014-08-04 22:16:29.000000000 +0200 139 | @@ -24,7 +24,7 @@ 140 | #ifdef HAVE_MBCS 141 | const char *Py_FileSystemDefaultEncoding = "mbcs"; 142 | int Py_HasFileSystemDefaultEncoding = 1; 143 | -#elif defined(__APPLE__) 144 | +#elif defined(__APPLE__) || defined(__ANDROID__) 145 | const char *Py_FileSystemDefaultEncoding = "utf-8"; 146 | int Py_HasFileSystemDefaultEncoding = 1; 147 | #else 148 | diff -ru Python-3.3.5/Python/fileutils.c Python-3.3.5-android/Python/fileutils.c 149 | --- Python-3.3.5/Python/fileutils.c 2014-03-09 09:40:32.000000000 +0100 150 | +++ Python-3.3.5-android/Python/fileutils.c 2014-08-04 22:16:29.000000000 +0200 151 | @@ -10,7 +10,7 @@ 152 | #include 153 | #endif 154 | 155 | -#ifdef __APPLE__ 156 | +#if defined(__APPLE__) || defined(__ANDROID__) 157 | extern wchar_t* _Py_DecodeUTF8_surrogateescape(const char *s, Py_ssize_t size); 158 | #endif 159 | 160 | @@ -44,7 +44,7 @@ 161 | Py_RETURN_NONE; 162 | } 163 | 164 | -#if !defined(__APPLE__) && !defined(MS_WINDOWS) 165 | +#if !defined(__APPLE__) && !defined(__ANDROID__) && !defined(MS_WINDOWS) 166 | extern int _Py_normalize_encoding(const char *, char *, size_t); 167 | 168 | /* Workaround FreeBSD and OpenIndiana locale encoding issue with the C locale. 169 | @@ -194,7 +194,7 @@ 170 | } 171 | #endif /* !defined(__APPLE__) && !defined(MS_WINDOWS) */ 172 | 173 | -#if !defined(__APPLE__) && (!defined(MS_WINDOWS) || !defined(HAVE_MBRTOWC)) 174 | +#if !defined(__APPLE__) && !defined(__ANDROID__) && (!defined(MS_WINDOWS) || !defined(HAVE_MBRTOWC)) 175 | static wchar_t* 176 | decode_ascii_surrogateescape(const char *arg, size_t *size) 177 | { 178 | @@ -241,7 +241,7 @@ 179 | wchar_t* 180 | _Py_char2wchar(const char* arg, size_t *size) 181 | { 182 | -#ifdef __APPLE__ 183 | +#if defined(__APPLE__) || defined(__ANDROID__) 184 | wchar_t *wstr; 185 | wstr = _Py_DecodeUTF8_surrogateescape(arg, strlen(arg)); 186 | if (size != NULL) { 187 | @@ -384,7 +384,7 @@ 188 | char* 189 | _Py_wchar2char(const wchar_t *text, size_t *error_pos) 190 | { 191 | -#ifdef __APPLE__ 192 | +#if defined(__APPLE__) || defined(__ANDROID__) 193 | Py_ssize_t len; 194 | PyObject *unicode, *bytes = NULL; 195 | char *cpath; 196 | diff -ru Python-3.3.5/Python/formatter_unicode.c Python-3.3.5-android/Python/formatter_unicode.c 197 | --- Python-3.3.5/Python/formatter_unicode.c 2014-03-09 09:40:32.000000000 +0100 198 | +++ Python-3.3.5-android/Python/formatter_unicode.c 2014-08-04 22:16:29.000000000 +0200 199 | @@ -665,6 +665,7 @@ 200 | { 201 | switch (type) { 202 | case LT_CURRENT_LOCALE: { 203 | +#ifndef __ANDROID__ 204 | struct lconv *locale_data = localeconv(); 205 | locale_info->decimal_point = PyUnicode_DecodeLocale( 206 | locale_data->decimal_point, 207 | @@ -680,6 +681,7 @@ 208 | } 209 | locale_info->grouping = locale_data->grouping; 210 | break; 211 | +#endif // __ANDROID__ 212 | } 213 | case LT_DEFAULT_LOCALE: 214 | locale_info->decimal_point = PyUnicode_FromOrdinal('.'); 215 | diff -ru Python-3.3.5/Python/pystrtod.c Python-3.3.5-android/Python/pystrtod.c 216 | --- Python-3.3.5/Python/pystrtod.c 2014-03-09 09:40:33.000000000 +0100 217 | +++ Python-3.3.5-android/Python/pystrtod.c 2014-08-04 22:16:29.000000000 +0200 218 | @@ -177,8 +177,12 @@ 219 | 220 | fail_pos = NULL; 221 | 222 | +#ifdef __ANDROID__ 223 | + decimal_point = "."; 224 | +#else 225 | locale_data = localeconv(); 226 | decimal_point = locale_data->decimal_point; 227 | +#endif 228 | decimal_point_len = strlen(decimal_point); 229 | 230 | assert(decimal_point_len != 0); 231 | @@ -378,8 +382,12 @@ 232 | Py_LOCAL_INLINE(void) 233 | change_decimal_from_locale_to_dot(char* buffer) 234 | { 235 | +#ifdef __ANDROID__ 236 | + const char *decimal_point = "."; 237 | +#else 238 | struct lconv *locale_data = localeconv(); 239 | const char *decimal_point = locale_data->decimal_point; 240 | +#endif 241 | 242 | if (decimal_point[0] != '.' || decimal_point[1] != 0) { 243 | size_t decimal_point_len = strlen(decimal_point); 244 | diff -ru Python-3.3.5/Python/pythonrun.c Python-3.3.5-android/Python/pythonrun.c 245 | --- Python-3.3.5/Python/pythonrun.c 2014-03-09 09:40:33.000000000 +0100 246 | +++ Python-3.3.5-android/Python/pythonrun.c 2014-08-04 22:16:29.000000000 +0200 247 | @@ -188,6 +188,8 @@ 248 | return NULL; 249 | } 250 | return get_codec_name(codeset); 251 | +#elif __ANDROID__ 252 | + return get_codec_name("UTF-8"); 253 | #else 254 | PyErr_SetNone(PyExc_NotImplementedError); 255 | return NULL; 256 | -------------------------------------------------------------------------------- /mk/python/3.4.3/python-3.4.3-android-misc.patch: -------------------------------------------------------------------------------- 1 | diff -ru Python-3.3.5/Lib/platform.py Python-3.3.5-android/Lib/platform.py 2 | --- Python-3.3.5/Lib/platform.py 2014-03-09 09:40:13.000000000 +0100 3 | +++ Python-3.3.5-android/Lib/platform.py 2014-08-04 22:19:36.000000000 +0200 4 | @@ -368,6 +368,76 @@ 5 | supported_dists=supported_dists, 6 | full_distribution_name=0) 7 | 8 | +_android_environment_vars = ( 9 | + 'ANDROID_ROOT', 'ANDROID_ASSETS', 'ANDROID_STORAGE', 'ANDROID_DATA', 10 | + 'ANDROID_PROPERTY_WORKSPACE', 'ANDROID_BOOTLOGO') 11 | +_android_version_property = 'ro.build.version.release' 12 | +_android_buildstr_property = 'ro.build.version.full' 13 | + 14 | +def android_version(version='', buildstr=''): 15 | + """ Attempt to get the Android version number and build string. 16 | + 17 | + The function checks for the getprop binary to retrieve build info, 18 | + and falls back to manually reading /system/build.prop if available. 19 | + 20 | + Returns a (version, buildstr) tuple which defaults to the args given 21 | + as parameters. 22 | + """ 23 | + if not any(os.getenv(e) for e in _android_environment_vars): 24 | + # Probably not on Android... 25 | + return version, buildstr 26 | + 27 | + version_obtained = False 28 | + buildstr_obtained = False 29 | + 30 | + # Try the 'official' API tool first, since /system/build.prop might 31 | + # not be the only source for properties. 32 | + if os.access('/system/bin/getprop', os.X_OK): 33 | + def _getprop(prop): 34 | + android_property_fd = _get_android_property_fd() 35 | + pass_fds = (android_property_fd,) if android_property_fd else () 36 | + try: 37 | + result = subprocess.check_output(['/system/bin/getprop', prop], 38 | + pass_fds=pass_fds) 39 | + return result.decode('utf-8').strip() 40 | + except (subprocess.CalledProcessError, UnicodeDecodeError): 41 | + raise RuntimeError('getprop failed') 42 | + 43 | + try: 44 | + version = _getprop(_android_version_property) 45 | + version_obtained = True 46 | + except RuntimeError: 47 | + pass 48 | + 49 | + try: 50 | + buildstr = _getprop(_android_buildstr_property) 51 | + buildstr_obtained = True 52 | + except RuntimeError: 53 | + pass 54 | + done = version_obtained and buildstr_obtained 55 | + 56 | + # Fall back to parsing /system/build.prop manually. 57 | + if not done and os.path.isfile('/system/build.prop'): 58 | + for line in open('/system/build.prop', 'rb'): 59 | + if b'=' not in line: 60 | + continue 61 | + key, val = line.split(b'=', maxsplit=1) 62 | + key = key.strip().decode('utf-8') 63 | + 64 | + if not version_obtained and key == _android_version_property: 65 | + version = val.strip().decode('utf-8') 66 | + if not buildstr_obtained and key == _android_buildstr_property: 67 | + buildstr = val.strip().decode('utf-8') 68 | + 69 | + return version, buildstr 70 | + 71 | +def _get_android_property_fd(): 72 | + android_property_workspace = os.getenv('ANDROID_PROPERTY_WORKSPACE') 73 | + if android_property_workspace: 74 | + property_fd_str = android_property_workspace.split(',')[0] 75 | + if property_fd_str.isdigit(): 76 | + return int(property_fd_str) 77 | + 78 | def popen(cmd, mode='r', bufsize=-1): 79 | 80 | """ Portable popen() interface. 81 | diff -ru Python-3.3.5/Lib/subprocess.py Python-3.3.5-android/Lib/subprocess.py 82 | --- Python-3.3.5/Lib/subprocess.py 2014-03-09 09:40:13.000000000 +0100 83 | +++ Python-3.3.5-android/Lib/subprocess.py 2014-08-04 22:19:36.000000000 +0200 84 | @@ -1343,9 +1343,18 @@ 85 | args = list(args) 86 | 87 | if shell: 88 | - args = ["/bin/sh", "-c"] + args 89 | if executable: 90 | - args[0] = executable 91 | + main = executable 92 | + elif os.path.isfile('/bin/sh'): 93 | + main = '/bin/sh' 94 | + else: 95 | + import platform 96 | + if platform.android_version()[0]: 97 | + main = '/system/bin/sh' 98 | + else: 99 | + raise RuntimeError('Could not find system shell') 100 | + 101 | + args = [main, "-c"] + args 102 | 103 | if executable is None: 104 | executable = args[0] 105 | diff -ru Python-3.3.5/Lib/test/test_subprocess.py Python-3.3.5-android/Lib/test/test_subprocess.py 106 | --- Python-3.3.5/Lib/test/test_subprocess.py 2014-03-09 09:40:19.000000000 +0100 107 | +++ Python-3.3.5-android/Lib/test/test_subprocess.py 2014-08-04 22:19:36.000000000 +0200 108 | @@ -17,6 +17,7 @@ 109 | import shutil 110 | import gc 111 | import textwrap 112 | +import platform 113 | 114 | try: 115 | import resource 116 | @@ -1356,7 +1357,10 @@ 117 | fd, fname = mkstemp() 118 | # reopen in text mode 119 | with open(fd, "w", errors="surrogateescape") as fobj: 120 | - fobj.write("#!/bin/sh\n") 121 | + if platform.android_version()[0]: 122 | + fobj.write('#!/system/bin/sh\n') 123 | + else: 124 | + fobj.write("#!/bin/sh\n") 125 | fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" % 126 | sys.executable) 127 | os.chmod(fname, 0o700) 128 | @@ -1401,7 +1405,10 @@ 129 | fd, fname = mkstemp() 130 | # reopen in text mode 131 | with open(fd, "w", errors="surrogateescape") as fobj: 132 | - fobj.write("#!/bin/sh\n") 133 | + if platform.android_version()[0]: 134 | + fobj.write('#!/system/bin/sh\n') 135 | + else: 136 | + fobj.write("#!/bin/sh\n") 137 | fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" % 138 | sys.executable) 139 | os.chmod(fname, 0o700) 140 | diff -ru Python-3.4.2/Modules/pwdmodule.c Python-3.4.2-android/Modules/pwdmodule.c 141 | --- Python-3.4.2/Modules/pwdmodule.c 2015-02-24 23:06:31.000000000 +0100 142 | +++ Python-3.4.2-android/Modules/pwdmodule.c 2015-02-24 23:09:14.000000000 +0100 143 | @@ -72,7 +72,11 @@ 144 | SETS(setIndex++, p->pw_passwd); 145 | PyStructSequence_SET_ITEM(v, setIndex++, _PyLong_FromUid(p->pw_uid)); 146 | PyStructSequence_SET_ITEM(v, setIndex++, _PyLong_FromGid(p->pw_gid)); 147 | +#if !defined(__ANDROID__) 148 | SETS(setIndex++, p->pw_gecos); 149 | +#else 150 | + SETS(setIndex++, ""); 151 | +#endif 152 | SETS(setIndex++, p->pw_dir); 153 | SETS(setIndex++, p->pw_shell); 154 | 155 | diff -ru Python-3.3.5/Modules/socketmodule.c Python-3.3.5-android/Modules/socketmodule.c 156 | --- Python-3.3.5/Modules/socketmodule.c 2014-03-09 09:40:28.000000000 +0100 157 | +++ Python-3.3.5-android/Modules/socketmodule.c 2014-08-04 22:19:36.000000000 +0200 158 | @@ -150,7 +150,7 @@ 159 | On the other hand, not all Linux versions agree, so there the settings 160 | computed by the configure script are needed! */ 161 | 162 | -#ifndef linux 163 | +#if !defined(linux) || __ANDROID__ 164 | # undef HAVE_GETHOSTBYNAME_R_3_ARG 165 | # undef HAVE_GETHOSTBYNAME_R_5_ARG 166 | # undef HAVE_GETHOSTBYNAME_R_6_ARG 167 | @@ -169,7 +169,7 @@ 168 | # define HAVE_GETHOSTBYNAME_R_3_ARG 169 | # elif defined(__sun) || defined(__sgi) 170 | # define HAVE_GETHOSTBYNAME_R_5_ARG 171 | -# elif defined(linux) 172 | +# elif defined(linux) && !__ANDROID__ 173 | /* Rely on the configure script */ 174 | # else 175 | # undef HAVE_GETHOSTBYNAME_R 176 | diff -ru Python-3.3.5/Modules/posixmodule.c Python-3.3.5-android/Modules/posixmodule.c 177 | --- Python-3.3.5/Modules/posixmodule.c 2014-03-09 08:40:28.000000000 +0000 178 | +++ Python-3.3.5-android/Modules/posixmodule.c 2015-02-24 19:57:05.368843433 +0000 179 | @@ -403,6 +403,11 @@ 180 | #endif 181 | #endif 182 | 183 | +/* Android doesn't expose AT_EACCESS - manually define it. */ 184 | +#if !defined(AT_EACCESS) && defined(__ANDROID__) 185 | +#define AT_EACCESS 0x200 186 | +#endif 187 | + 188 | 189 | #ifdef MS_WINDOWS 190 | static int 191 | diff -ru Python-3.3.5/Python/pytime.c Python-3.3.5-android/Python/pytime.c 192 | --- Python-3.3.5/Python/pytime.c 2015-02-23 11:54:25.000000000 -0500 193 | +++ Python-3.3.5-android/Python/pytime.c 2015-02-23 11:55:19.000000000 -0500 194 | @@ -3,7 +3,7 @@ 195 | #include 196 | #endif 197 | 198 | -#if defined(__APPLE__) && defined(HAVE_GETTIMEOFDAY) && defined(HAVE_FTIME) 199 | +#if (defined(__APPLE__) || defined(__ANDROID__)) && defined(HAVE_GETTIMEOFDAY) && defined(HAVE_FTIME) 200 | /* 201 | * _PyTime_gettimeofday falls back to ftime when getttimeofday fails because the latter 202 | * might fail on some platforms. This fallback is unwanted on MacOSX because 203 | diff -ru Python-3.4.2/configure Python-3.4.2-android/configure 204 | --- Python-3.4.2/configure 2015-02-24 23:18:31.000000000 +0100 205 | +++ Python-3.4.2-android/configure 2015-03-01 20:15:02.000000000 +0100 206 | @@ -5406,6 +5406,34 @@ 207 | MULTIARCH=$($CC --print-multiarch 2>/dev/null) 208 | 209 | 210 | +# Test if we're running on Android. 211 | +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if target is Android-based" >&5 212 | +$as_echo_n "checking if target is Android-based... " >&6; } 213 | +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 214 | +/* end confdefs.h. */ 215 | + 216 | +#if __ANDROID__ 217 | +yes 218 | +#endif 219 | + 220 | +_ACEOF 221 | +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | 222 | + $EGREP "yes" >/dev/null 2>&1; then : 223 | + 224 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 225 | +$as_echo "yes" >&6; } 226 | + with_android=yes 227 | + 228 | +else 229 | + 230 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 231 | +$as_echo "no" >&6; } 232 | + with_android=no 233 | + 234 | + 235 | +fi 236 | +rm -f conftest* 237 | + 238 | 239 | 240 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking LIBRARY" >&5 241 | @@ -5650,7 +5678,14 @@ 242 | SOVERSION=`echo $SOVERSION|cut -d "." -f 1` 243 | ;; 244 | esac 245 | - INSTSONAME="$LDLIBRARY".$SOVERSION 246 | + 247 | + if test "$with_android" != yes 248 | + then 249 | + INSTSONAME="$LDLIBRARY".$SOVERSION 250 | + else 251 | + INSTSONAME="$LDLIBRARY" 252 | + fi 253 | + 254 | if test "$with_pydebug" != yes 255 | then 256 | PY3LIBRARY=libpython3.so 257 | diff -ru Python-3.4.2/configure.ac Python-3.4.2-android/configure.ac 258 | --- Python-3.4.2/configure.ac 2015-02-24 23:18:31.000000000 +0100 259 | +++ Python-3.4.2-android/configure.ac 2015-03-01 20:14:54.000000000 +0100 260 | @@ -796,6 +796,21 @@ 261 | MULTIARCH=$($CC --print-multiarch 2>/dev/null) 262 | AC_SUBST(MULTIARCH) 263 | 264 | +# Test if we're running on Android. 265 | +AC_MSG_CHECKING(if target is Android-based) 266 | +AC_EGREP_CPP(yes, 267 | +[ 268 | +#if __ANDROID__ 269 | +yes 270 | +#endif 271 | +], [ 272 | + AC_MSG_RESULT(yes) 273 | + with_android=yes 274 | + ], [ 275 | + AC_MSG_RESULT(no) 276 | + with_android=no 277 | + ] 278 | +) 279 | 280 | AC_SUBST(LIBRARY) 281 | AC_MSG_CHECKING(LIBRARY) 282 | @@ -970,7 +985,14 @@ 283 | SOVERSION=`echo $SOVERSION|cut -d "." -f 1` 284 | ;; 285 | esac 286 | - INSTSONAME="$LDLIBRARY".$SOVERSION 287 | + 288 | + if test "$with_android" != yes 289 | + then 290 | + INSTSONAME="$LDLIBRARY".$SOVERSION 291 | + else 292 | + INSTSONAME="$LDLIBRARY" 293 | + fi 294 | + 295 | if test "$with_pydebug" != yes 296 | then 297 | PY3LIBRARY=libpython3.so 298 | 299 | diff -ru Python-3.4.2/Makefile.pre.in Python-3.4.2-android/Makefile.pre.in 300 | --- Python-3.4.2/Makefile.pre.in 2015-03-04 16:25:36.000000000 +0100 301 | +++ Python-3.4.2-android/Makefile.pre.in 2015-03-04 16:27:27.000000000 +0100 302 | @@ -568,7 +568,7 @@ 303 | *\ -s*|s*) quiet="-q";; \ 304 | *) quiet="";; \ 305 | esac; \ 306 | - $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ 307 | + $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED) -lpython$(LDVERSION)' OPT='$(OPT)' \ 308 | _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \ 309 | $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build 310 | 311 | diff -Nru Python-3.4.2/Makefile.pre.in Python-3.4.2-android/Makefile.pre.in 312 | --- Python-3.4.2/Makefile.pre.in 2015-06-27 17:04:23.885777456 +0000 313 | +++ Python-3.4.2-android/Makefile.pre.in 2015-06-27 17:05:27.709777315 +0000 314 | @@ -585,11 +585,9 @@ 315 | $(RANLIB) $@ 316 | 317 | libpython$(LDVERSION).so: $(LIBRARY_OBJS) 318 | + $(BLDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \ 319 | if test $(INSTSONAME) != $(LDLIBRARY); then \ 320 | - $(BLDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \ 321 | $(LN) -f $(INSTSONAME) $@; \ 322 | - else \ 323 | - $(BLDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \ 324 | fi 325 | 326 | libpython3.so: libpython$(LDVERSION).so 327 | -------------------------------------------------------------------------------- /mk/python/3.4.3/python-3.4.3-android-missing-getdents64-definition.patch: -------------------------------------------------------------------------------- 1 | diff -ru Python-3.3.5/Modules/_posixsubprocess.c Python-3.3.5-android/Modules/_posixsubprocess.c 2 | --- Python-3.3.5/Modules/_posixsubprocess.c 2014-03-09 09:40:26.000000000 +0100 3 | +++ Python-3.3.5-android/Modules/_posixsubprocess.c 2014-08-04 22:19:36.000000000 +0200 4 | @@ -18,6 +18,12 @@ 5 | #include 6 | #endif 7 | 8 | +#if defined(__ANDROID__) 9 | +/* Android doesn't expose syscalls. Let's add the definition manually. */ 10 | +# include 11 | +# define SYS_getdents64 __NR_getdents64 12 | +#endif 13 | + 14 | #if defined(sun) 15 | /* readdir64 is used to work around Solaris 9 bug 6395699. */ 16 | # define readdir readdir64 17 | 18 | -------------------------------------------------------------------------------- /mk/python/3.4.3/python-3.4.3-cross-compile.patch: -------------------------------------------------------------------------------- 1 | diff -ru Python-3.3.5/Makefile.pre.in Python-3.3.5-android/Makefile.pre.in 2 | --- Python-3.3.5/Makefile.pre.in 2014-03-09 09:40:23.000000000 +0100 3 | +++ Python-3.3.5-android/Makefile.pre.in 2014-08-04 22:13:00.000000000 +0200 4 | @@ -674,7 +674,7 @@ 5 | $(GRAMMAR_H): $(GRAMMAR_INPUT) $(PGENSRCS) 6 | @$(MKDIR_P) Include 7 | $(MAKE) $(PGEN) 8 | - $(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) 9 | + $(HOSTPGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) 10 | $(GRAMMAR_C): $(GRAMMAR_H) $(GRAMMAR_INPUT) $(PGENSRCS) 11 | $(MAKE) $(GRAMMAR_H) 12 | touch $(GRAMMAR_C) 13 | @@ -1243,6 +1243,7 @@ 14 | # Install the dynamically loadable modules 15 | # This goes into $(exec_prefix) 16 | sharedinstall: sharedmods 17 | + CC='$(CC)' LDSHARED='$(BLDSHARED)' LDFLAGS='$(LDFLAGS)' OPT='$(OPT)' CROSS_COMPILE='$(CROSS_COMPILE)' \ 18 | $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \ 19 | --prefix=$(prefix) \ 20 | --install-scripts=$(BINDIR) \ 21 | diff -ru Python-3.3.5/configure Python-3.3.5-android/configure 22 | --- Python-3.3.5/configure 2014-03-09 09:40:34.000000000 +0100 23 | +++ Python-3.3.5-android/configure 2014-08-04 22:13:00.000000000 +0200 24 | @@ -2943,13 +2943,18 @@ 25 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for python interpreter for cross build" >&5 26 | $as_echo_n "checking for python interpreter for cross build... " >&6; } 27 | if test -z "$PYTHON_FOR_BUILD"; then 28 | - for interp in python$PACKAGE_VERSION python3 python; do 29 | - which $interp >/dev/null 2>&1 || continue 30 | - if $interp -c 'import sys;sys.exit(not sys.version_info[:2] >= (3,3))'; then 31 | - break 32 | - fi 33 | - interp= 34 | - done 35 | + if test ! -z "$HOSTPYTHON" && PYTHONPATH="$ac_abs_confdir/Lib" "$HOSTPYTHON" -S -c 'import sys;sys.exit(not sys.version_info[:2] >= (3,3))'; then 36 | + interp="$HOSTPYTHON" 37 | + else 38 | + for interp in python$PACKAGE_VERSION python3 python; do 39 | + which $interp >/dev/null 2>&1 || continue 40 | + if $interp -c 'import sys;sys.exit(not sys.version_info[:2] >= (3,3))'; then 41 | + break 42 | + fi 43 | + interp= 44 | + done 45 | + fi 46 | + 47 | if test x$interp = x; then 48 | as_fn_error $? "python$PACKAGE_VERSION interpreter not found" "$LINENO" 5 49 | fi 50 | diff -ru Python-3.3.5/configure.ac Python-3.3.5-android/configure.ac 51 | --- Python-3.3.5/configure.ac 2014-03-09 09:40:34.000000000 +0100 52 | +++ Python-3.3.5-android/configure.ac 2014-08-04 22:13:00.000000000 +0200 53 | @@ -56,13 +56,18 @@ 54 | if test "$cross_compiling" = yes; then 55 | AC_MSG_CHECKING([for python interpreter for cross build]) 56 | if test -z "$PYTHON_FOR_BUILD"; then 57 | - for interp in python$PACKAGE_VERSION python3 python; do 58 | - which $interp >/dev/null 2>&1 || continue 59 | - if $interp -c 'import sys;sys.exit(not sys.version_info@<:@:2@:>@ >= (3,3))'; then 60 | - break 61 | - fi 62 | - interp= 63 | - done 64 | + if test ! -z "$HOSTPYTHON" && PYTHONPATH="$ac_abs_confdir/Lib" "$HOSTPYTHON" -S -c 'import sys;sys.exit(not sys.version_info@<:@:2@:>@ >= (3,3))'; then 65 | + interp="$HOSTPYTHON" 66 | + else 67 | + for interp in python$PACKAGE_VERSION python3 python; do 68 | + which $interp >/dev/null 2>&1 || continue 69 | + if $interp -c 'import sys;sys.exit(not sys.version_info@<:@:2@:>@ >= (3,3))'; then 70 | + break 71 | + fi 72 | + interp= 73 | + done 74 | + fi 75 | + 76 | if test x$interp = x; then 77 | AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found]) 78 | fi 79 | -------------------------------------------------------------------------------- /mk/python/3.4.3/python-3.4.3-python-misc.patch: -------------------------------------------------------------------------------- 1 | diff -ru Python-3.3.5/Lib/test/test_pwd.py Python-3.3.5-android/Lib/test/test_pwd.py 2 | --- Python-3.3.5/Lib/test/test_pwd.py 2014-03-09 09:40:19.000000000 +0100 3 | +++ Python-3.3.5-android/Lib/test/test_pwd.py 2014-08-04 22:14:36.000000000 +0200 4 | @@ -6,6 +6,7 @@ 5 | 6 | class PwdTest(unittest.TestCase): 7 | 8 | + @unittest.skipUnless(hasattr(pwd, 'getpwall'), 'pwd module does not expose getpwall()') 9 | def test_values(self): 10 | entries = pwd.getpwall() 11 | 12 | @@ -52,6 +53,7 @@ 13 | self.assertIn(pwd.getpwnam(e.pw_name), entriesbyname[e.pw_name]) 14 | self.assertIn(pwd.getpwuid(e.pw_uid), entriesbyuid[e.pw_uid]) 15 | 16 | + @unittest.skipUnless(hasattr(pwd, 'getpwall'), 'pwd module does not expose getpwall()') 17 | def test_errors(self): 18 | self.assertRaises(TypeError, pwd.getpwuid) 19 | self.assertRaises(TypeError, pwd.getpwuid, 3.14) 20 | diff -ru Python-3.4.2/Modules/python.c Python-3.4.2-android/Modules/python.c 21 | --- Python-3.4.2/Modules/python.c 2015-02-24 22:42:37.000000000 +0100 22 | +++ Python-3.4.2-android/Modules/python.c 2015-02-24 23:04:27.000000000 +0100 23 | @@ -44,10 +44,13 @@ 24 | fpsetmask(m & ~FP_X_OFL); 25 | #endif 26 | 27 | - oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL)); 28 | - if (!oldloc) { 29 | - fprintf(stderr, "out of memory\n"); 30 | - return 1; 31 | + oldloc = setlocale(LC_ALL, NULL); 32 | + if (oldloc) { 33 | + oldloc = _PyMem_RawStrdup(oldloc); 34 | + if (!oldloc) { 35 | + fprintf(stderr, "out of memory\n"); 36 | + return 1; 37 | + } 38 | } 39 | 40 | setlocale(LC_ALL, ""); 41 | @@ -64,8 +67,11 @@ 42 | } 43 | argv_copy2[argc] = argv_copy[argc] = NULL; 44 | 45 | - setlocale(LC_ALL, oldloc); 46 | - PyMem_RawFree(oldloc); 47 | + if (oldloc) { 48 | + setlocale(LC_ALL, oldloc); 49 | + PyMem_RawFree(oldloc); 50 | + } 51 | + 52 | res = Py_Main(argc, argv_copy); 53 | for (i = 0; i < argc; i++) { 54 | PyMem_RawFree(argv_copy2[i]); 55 | diff -ru Python-3.3.5/setup.py Python-3.3.5-android/setup.py 56 | --- Python-3.3.5/setup.py 2014-03-09 09:40:35.000000000 +0100 57 | +++ Python-3.3.5-android/setup.py 2014-08-04 22:14:36.000000000 +0200 58 | @@ -562,7 +562,7 @@ 59 | libraries=math_libs) ) 60 | 61 | # time libraries: librt may be needed for clock_gettime() 62 | - time_libs = [] 63 | + time_libs = ['m'] 64 | lib = sysconfig.get_config_var('TIMEMODULE_LIB') 65 | if lib: 66 | time_libs.append(lib) 67 | @@ -631,7 +631,8 @@ 68 | missing.append('spwd') 69 | 70 | # select(2); not on ancient System V 71 | - exts.append( Extension('select', ['selectmodule.c']) ) 72 | + exts.append( Extension('select', ['selectmodule.c'], 73 | + libraries=['m']) ) 74 | 75 | # Fred Drake's interface to the Python parser 76 | exts.append( Extension('parser', ['parsermodule.c']) ) 77 | @@ -639,7 +639,8 @@ 78 | # Operations on audio samples 79 | # According to #993173, this one should actually work fine on 80 | # 64-bit platforms. 81 | - exts.append( Extension('audioop', ['audioop.c']) ) 82 | + exts.append( Extension('audioop', ['audioop.c'], 83 | + libraries=['m']) ) 84 | 85 | # readline 86 | do_readline = self.compiler.find_library_file(lib_dirs, 'readline') 87 | @@ -1904,7 +1905,8 @@ 88 | sources=sources, 89 | depends=depends) 90 | ext_test = Extension('_ctypes_test', 91 | - sources=['_ctypes/_ctypes_test.c']) 92 | + sources=['_ctypes/_ctypes_test.c'], 93 | + libraries=['m']) 94 | self.extensions.extend([ext, ext_test]) 95 | 96 | if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"): 97 | -------------------------------------------------------------------------------- /mk/python/3.4.3/sources.txt: -------------------------------------------------------------------------------- 1 | https://python.org/ftp/python/3.4.3/Python-3.4.3.tar.xz 2 | -------------------------------------------------------------------------------- /mk/readline/6.3/build.sh: -------------------------------------------------------------------------------- 1 | pushd src >/dev/null 2 | 3 | rm -rf "${PACKAGE}" 4 | tar -xf "${PACKAGE}.tar.gz" || exit 1 5 | pushd "${PACKAGE}" >/dev/null 6 | 7 | autoreconf -i 8 | ./configure --prefix="${PREFIX}" --host="${TARGET}" --build="${HOST}" --disable-shared || exit 1 9 | make || exit 1 10 | make install || exit 1 11 | 12 | popd >/dev/null 13 | popd >/dev/null 14 | -------------------------------------------------------------------------------- /mk/readline/6.3/sources.txt: -------------------------------------------------------------------------------- 1 | https://ftp.gnu.org/gnu/readline/readline-6.3.tar.gz 2 | -------------------------------------------------------------------------------- /mk/sqlite/3.8.10.2/build.sh: -------------------------------------------------------------------------------- 1 | pushd src >/dev/null 2 | 3 | rm -rf "${NAME}-autoconf-3081002" 4 | tar -xf "${NAME}-autoconf-3081002.tar.gz" || exit 1 5 | pushd "${NAME}-autoconf-3081002" >/dev/null 6 | 7 | ./configure --prefix="${PREFIX}" --host="${TARGET}" --build="${HOST}" --disable-shared || exit 1 8 | make || exit 1 9 | make install || exit 1 10 | 11 | # Remove binary from premises. 12 | rm -f "${PREFIX}/bin/sqlite3" || exit 1 13 | 14 | popd >/dev/null 15 | popd >/dev/null 16 | -------------------------------------------------------------------------------- /mk/sqlite/3.8.10.2/sources.txt: -------------------------------------------------------------------------------- 1 | https://www.sqlite.org/2015/sqlite-autoconf-3081002.tar.gz 2 | -------------------------------------------------------------------------------- /mk/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | source ./env 3 | 4 | pushd "$BASE/sdk/android-sdk-r${SDK_REV}" > /dev/null 5 | 6 | # TODO: Figure out an appropriate port number. 7 | PORT=5554 8 | 9 | # Boot the emulator, wait for it. 10 | ./tools/emulator -avd "${ANDROID_VM_NAME}-${TEST_IDENTIFIER}" -port "${PORT}" -no-snapshot-save ${ANDROID_EMULATOR_OPTIONS} & 11 | ./platform-tools/adb -s "emulator-${PORT}" wait-for-device 12 | 13 | # Copy the files over. 14 | ./platform-tools/adb -s "emulator-${PORT}" push "${ANDROID_PREFIX}/${BUILD_IDENTIFIER}" "${ANDROID_EMULATOR_TESTDIR}" 15 | # Run the tests! 16 | ./platform-tools/adb -s "emulator-${PORT}" shell <<-EOF 17 | cd "${ANDROID_EMULATOR_TESTDIR}" 18 | bin/python3.3 -m test 19 | exit 20 | EOF 21 | # Stop the emulator. 22 | ./platform-tools/adb -s "emulator-${PORT}" emu kill 23 | 24 | popd > /dev/null 25 | -------------------------------------------------------------------------------- /mk/test_setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | source ./env 3 | 4 | # Force license terms. 5 | if [[ "$ANDROID_AGREE_LICENSE_TERMS" != y ]]; then 6 | echo "You didn't agree to the Android SDK license terms! Read them and then set ANDROID_AGREE_LICENSE_TERMS=y in env." 7 | exit 1 8 | fi 9 | 10 | # Install the SDK manager. 11 | if [[ ! -d "$BASE/sdk/android-sdk-r${SDK_REV}" ]]; then 12 | case $(uname -s) in 13 | Darwin) 14 | [[ ! -f "$BASE/sdk/android-sdk-r${SDK_REV}.zip" ]] && (wget http://dl.google.com/android/android-sdk_r${SDK_REV}-macosx.zip -O "$BASE/sdk/android-sdk-r${SDK_REV}.zip" || exit 1) 15 | unzip -q "$BASE/sdk/android-sdk-r${SDK_REV}.zip" -d "$BASE/sdk" || exit 1 16 | mv "$BASE/sdk/android-sdk-macosx" "$BASE/sdk/android-sdk-r${SDK_REV}" || exit 1 17 | ;; 18 | Linux) 19 | [[ ! -f "$BASE/sdk/android-sdk-r4{SDK_REV}.zip" ]] && (wget http://dl.google.com/android/android-sdk_r${SDK_REV}-linux.tgz -O "$BASE/sdk/android-sdk-r${SDK_REV}.tgz" || exit 1) 20 | tar -xf "$BASE/sdk/android-sdk-r${SDK_REV}.tgz" -C "$BASE/sdk" || exit 1 21 | mv "$BASE/sdk/android-sdk-linux" "$BASE/sdk/android-sdk-r${SDK_REV}" || exit 1 22 | ;; 23 | esac 24 | fi 25 | 26 | pushd "$BASE/sdk/android-sdk-r${SDK_REV}" > /dev/null 27 | 28 | # Find SDK platform ID to use. 29 | SDK_ID=$(./tools/android -s list sdk -a |\ 30 | grep -F 'SDK Platform Android' |\ 31 | grep -Fm1 "API ${ANDROID_API_LEVEL}" |\ 32 | awk '{print $1}' | tr -d '-') 33 | if [[ -z "${SDK_ID}" ]]; then 34 | echo "Could not find SDK package for API level ${ANDROID_API_LEVEL}, make sure it's available using:" 35 | echo " $BASE/sdk/android-sdk-r${SDK_REV}/tools/android list sdk" 36 | echo "and check if it's in there." 37 | exit 1 38 | fi 39 | # Install base SDKs. 40 | echo "${ANDROID_AGREE_LICENSE_TERMS}" | ./tools/android -s update sdk --no-ui -a --filter "${SDK_ID},tool,platform-tool" || exit 1 41 | 42 | # Get SDK system image ID. 43 | case "${ANDROID_PLATFORM}" in 44 | arm) 45 | ABI_SEARCH_TERM="ARM EABI" 46 | ABI_OPT="armeabi-v7a" 47 | ;; 48 | mips) 49 | echo "Unsupported Android test platform: ${ANDROID_PLATFORM}" 50 | echo "This platform has no system images available to test with." 51 | exit 1 52 | ;; 53 | x86) 54 | ABI_SEARCH_TERM="Intel x86" 55 | ABI_OPT="x86" 56 | ;; 57 | *) 58 | echo "Unknown Android platform: ${ANDROID_PLATFORM}" 59 | exit 1 60 | ;; 61 | esac 62 | ABI_IMG_ID=$(./tools/android -s list sdk -a |\ 63 | grep -F 'System Image' |\ 64 | grep -F "${ABI_SEARCH_TERM}" |\ 65 | grep -Fm1 "API ${ANDROID_API_LEVEL}" |\ 66 | awk '{print $1}' | tr -d '-') 67 | if [[ -z "${ABI_IMG_ID}" ]]; then 68 | echo "Could not find ${ABI_SEARCH_TERM} system image for API level ${ANDROID_API_LEVEL}, make sure it's available using:" 69 | echo " $BASE/sdk/android-sdk-r${SDK_REV}/tools/android list sdk" 70 | echo "and check if it's in there." 71 | exit 1 72 | fi 73 | 74 | # Install SDK system image 75 | echo "${ANDROID_AGREE_LICENSE_TERMS}" | ./tools/android -s update sdk --no-ui -a --filter "${ABI_IMG_ID}" || exit 1 76 | 77 | # Make a VM. 78 | [[ ! -d "${ANDROID_TEST_PREFIX}" ]] && (mkdir "${ANDROID_TEST_PREFIX}" || exit 1) 79 | echo n | ./tools/android -s create avd -f \ 80 | -t "android-${ANDROID_API_LEVEL}" \ 81 | -n "${ANDROID_VM_NAME}-${TEST_IDENTIFIER}" \ 82 | -p "${ANDROID_TEST_PREFIX}/${TEST_IDENTIFIER}" \ 83 | -b "${ABI_OPT}" \ 84 | || exit 1 85 | 86 | # We're done here. 87 | popd > /dev/null 88 | -------------------------------------------------------------------------------- /mk/xz/5.2.1/build.sh: -------------------------------------------------------------------------------- 1 | pushd src >/dev/null 2 | 3 | rm -rf "${PACKAGE}" 4 | tar -xf "${PACKAGE}.tar.xz" || exit 1 5 | pushd "${PACKAGE}" >/dev/null 6 | 7 | patch -p1 < "${FILESDIR}/${PACKAGE}-disable-so-versioning.patch" || exit 1 8 | ./configure --prefix="${PREFIX}" --host="${TARGET}" --build="${HOST}" --disable-shared --disable-xz --disable-xzdec --disable-lzmadec --disable-lzmainfo --disable-lzma-links --disable-scripts || exit 1 9 | make || exit 1 10 | make install || exit 1 11 | # Remove documentation. 12 | rm -rf "${PREFIX}/share/doc" 13 | 14 | popd >/dev/null 15 | popd >/dev/null 16 | -------------------------------------------------------------------------------- /mk/xz/5.2.1/sources.txt: -------------------------------------------------------------------------------- 1 | http://tukaani.org/xz/xz-5.2.1.tar.xz 2 | -------------------------------------------------------------------------------- /mk/xz/5.2.1/xz-5.2.1-disable-so-versioning.patch: -------------------------------------------------------------------------------- 1 | diff -Nru xz-5.2.1-old/src/liblzma/Makefile.am xz-5.2.1/src/liblzma/Makefile.am 2 | --- xz-5.2.1-old/src/liblzma/Makefile.am 2015-07-21 14:35:24.124356586 +0000 3 | +++ xz-5.2.1/src/liblzma/Makefile.am 2015-07-21 14:36:25.768356450 +0000 4 | @@ -24,7 +24,7 @@ 5 | -I$(top_srcdir)/src/liblzma/simple \ 6 | -I$(top_srcdir)/src/common \ 7 | -DTUKLIB_SYMBOL_PREFIX=lzma_ 8 | -liblzma_la_LDFLAGS = -no-undefined -version-info 7:1:2 9 | +liblzma_la_LDFLAGS = -no-undefined -version-info 7:1:2 -avoid-version 10 | 11 | EXTRA_DIST += liblzma.map validate_map.sh 12 | if COND_SYMVERS 13 | diff -Nru xz-5.2.1-old/src/liblzma/Makefile.in xz-5.2.1/src/liblzma/Makefile.in 14 | --- xz-5.2.1-old/src/liblzma/Makefile.in 2015-07-21 14:35:24.124356586 +0000 15 | +++ xz-5.2.1/src/liblzma/Makefile.in 2015-07-21 14:37:15.412356340 +0000 16 | @@ -747,7 +747,7 @@ 17 | -I$(top_srcdir)/src/common \ 18 | -DTUKLIB_SYMBOL_PREFIX=lzma_ 19 | 20 | -liblzma_la_LDFLAGS = -no-undefined -version-info 7:1:2 $(am__append_1) \ 21 | +liblzma_la_LDFLAGS = -no-undefined -version-info 7:1:2 -avoid-version $(am__append_1) \ 22 | $(am__append_41) 23 | pkgconfigdir = $(libdir)/pkgconfig 24 | pkgconfig_DATA = liblzma.pc 25 | 26 | -------------------------------------------------------------------------------- /sdk/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rave-engine/python3-android/0ae21243524f9c0613555ac11e3a871a10c874a9/sdk/.keep -------------------------------------------------------------------------------- /src/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rave-engine/python3-android/0ae21243524f9c0613555ac11e3a871a10c874a9/src/.keep --------------------------------------------------------------------------------