diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..27ab723 --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ + +all: iphoneos iphonesimulator + echo "Building fat lib"; + +iphoneos: + mkdir -p build/armv7; \ + cp -r tools build/armv7/tools; \ + cp -r src build/armv7/src; \ + export TARGET_SDK=iphoneos; \ + TARGET_SDK=iphoneos build/armv7/tools/build-all.sh; + +iphonesimulator: + mkdir -p build/i386; \ + cp -r tools build/i386/tools; \ + cp -r src build/i386/src; \ + export TARGET_SDK=iphonesimulator; \ + TARGET_SDK=iphonesimulator build/i386/tools/build-all.sh; + +clean: + rm -rf ./build diff --git a/src/python_files/Python-2.7.1-ctypes_duplicate.armv7.patch b/src/python_files/Python-2.7.1-ctypes_duplicate.armv7.patch new file mode 100644 index 0000000..c895dc5 --- /dev/null +++ b/src/python_files/Python-2.7.1-ctypes_duplicate.armv7.patch @@ -0,0 +1,34 @@ +--- Python2.7-old/Modules/_ctypes/cfield.c 2010-05-09 16:46:46.000000000 +0200 ++++ Python2.7-new/Modules/_ctypes/cfield.c 2013-08-27 00:21:15.000000000 +0200 +@@ -1747,24 +1747,6 @@ + } ffi_type; + */ + +-/* align and size are bogus for void, but they must not be zero */ +-ffi_type ffi_type_void = { 1, 1, FFI_TYPE_VOID }; +- +-ffi_type ffi_type_uint8 = { 1, 1, FFI_TYPE_UINT8 }; +-ffi_type ffi_type_sint8 = { 1, 1, FFI_TYPE_SINT8 }; +- +-ffi_type ffi_type_uint16 = { 2, 2, FFI_TYPE_UINT16 }; +-ffi_type ffi_type_sint16 = { 2, 2, FFI_TYPE_SINT16 }; +- +-ffi_type ffi_type_uint32 = { 4, 4, FFI_TYPE_UINT32 }; +-ffi_type ffi_type_sint32 = { 4, 4, FFI_TYPE_SINT32 }; +- +-ffi_type ffi_type_uint64 = { 8, LONG_LONG_ALIGN, FFI_TYPE_UINT64 }; +-ffi_type ffi_type_sint64 = { 8, LONG_LONG_ALIGN, FFI_TYPE_SINT64 }; +- +-ffi_type ffi_type_float = { sizeof(float), FLOAT_ALIGN, FFI_TYPE_FLOAT }; +-ffi_type ffi_type_double = { sizeof(double), DOUBLE_ALIGN, FFI_TYPE_DOUBLE }; +- + #ifdef ffi_type_longdouble + #undef ffi_type_longdouble + #endif +@@ -1772,6 +1754,4 @@ + ffi_type ffi_type_longdouble = { sizeof(long double), LONGDOUBLE_ALIGN, + FFI_TYPE_LONGDOUBLE }; + +-ffi_type ffi_type_pointer = { sizeof(void *), VOID_P_ALIGN, FFI_TYPE_POINTER }; +- + /*---------------- EOF ----------------*/ diff --git a/src/python_files/Python-2.7.1-ctypes_duplicate.patch b/src/python_files/Python-2.7.1-ctypes_duplicate.i386.patch similarity index 100% rename from src/python_files/Python-2.7.1-ctypes_duplicate.patch rename to src/python_files/Python-2.7.1-ctypes_duplicate.i386.patch diff --git a/tools/build-libffi.sh b/tools/build-libffi.sh index 0d3abc8..a6b3c96 100755 --- a/tools/build-libffi.sh +++ b/tools/build-libffi.sh @@ -7,13 +7,13 @@ echo "Building libffi =============================" if [ ! -f $CACHEROOT/libffi-$FFI_VERSION.tar.gz ]; then try curl -L ftp://sourceware.org/pub/libffi/libffi-$FFI_VERSION.tar.gz > $CACHEROOT/libffi-$FFI_VERSION.tar.gz fi -if [ ! -d $TMPROOT/libffi-$FFI_VERSION ]; then - try rm -rf $TMPROOT/libffi-$FFI_VERSION - try tar xvf $CACHEROOT/libffi-$FFI_VERSION.tar.gz - try mv libffi-$FFI_VERSION $TMPROOT -fi -if [ -f $TMPROOT/libffi-$FFI_VERSION/build/Release-iphoneos/libffi.a ]; then +#get rid of old build +rm -rf $TMPROOT/libffi-$FFI_VERSION +try tar xvf $CACHEROOT/libffi-$FFI_VERSION.tar.gz +try mv libffi-$FFI_VERSION $TMPROOT + +if [ -f $TMPROOT/libffi-$FFI_VERSION/build/Release-${TARGET_SDK}/libffi.a ]; then exit 0; fi @@ -21,6 +21,8 @@ fi pushd $TMPROOT/libffi-$FFI_VERSION try patch -p1 < $KIVYIOSROOT/src/ffi_files/ffi-$FFI_VERSION-sysv.S.patch + + try xcodebuild $XCODEBUILD_FLAGS OTHER_CFLAGS="-no-integrated-as" -project libffi.xcodeproj -target "libffi iOS" try cp build/Release-${TARGET_SDK}/libffi.a $BUILDROOT/lib/libffi.a try cp -a build/Release-${TARGET_SDK}/usr/local/include $BUILDROOT/include/ffi diff --git a/tools/build-python.sh b/tools/build-python.sh index 5a635b0..d9308a2 100755 --- a/tools/build-python.sh +++ b/tools/build-python.sh @@ -66,7 +66,7 @@ try ./configure CC="$ARM_CC" LD="$ARM_LD" \ # with undefined lookup, checks in configure just failed :( try patch -p1 < $KIVYIOSROOT/src/python_files/Python-$IOS_PYTHON_VERSION-pyconfig.patch -try patch -p1 < $KIVYIOSROOT/src/python_files/Python-$IOS_PYTHON_VERSION-ctypes_duplicate.patch +try patch -p1 < $KIVYIOSROOT/src/python_files/Python-$IOS_PYTHON_VERSION-ctypes_duplicate.${CPU_ARCHITECHTURE}.patch try make -j4 HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen \ CROSS_COMPILE_TARGET=yes diff --git a/tools/environment.sh b/tools/environment.sh index 502eda0..a43f093 100755 --- a/tools/environment.sh +++ b/tools/environment.sh @@ -8,28 +8,6 @@ try () { "$@" || exit -1 } -#KIVY_IOS_SDK=iphoneos -export TARGET_SDK="iphonesimulator" -export CPU_ARCHITECHTURE="i386" -export XCODEBUILD_FLAGS="ONLY_ACTIVE_ARCH=NO ARCHS=$CPU_ARCHITECHTURE -configuration Release -sdk ${TARGET_SDK} --arch=$CPU_ARCHITECHTURE" - - - -# iOS SDK Environmnent (don't use name "SDKROOT"!!! it will break the compilation) -#export SDKVER=`xcodebuild -showsdks | fgrep "$KIVY_IOS_SDK" | tail -n 1 | awk '{print $2}'` -#export DEVROOT=`xcode-select -print-path`/Platforms/iPhoneOS.platform/Developer -export SDKVER=`xcrun --sdk $TARGET_SDK --show-sdk-version` -export IOSSDKROOT=`xcrun --sdk $TARGET_SDK --show-sdk-path` - -# Xcode doesn't include /usr/local/bin -export PATH="$PATH":/usr/local/bin - -if [ ! -d $IOSSDKROOT ]; then - echo "Unable to found the target $TARGET_SDK SDK " - echo - echo "The path is automatically set from 'xcrun --sdk $TARGET_SDK --show-sdk-path'" - exit 1 -fi # version of packages export IOS_PYTHON_VERSION=2.7.1 @@ -40,16 +18,74 @@ export XSLT_VERSION=1.1.26 export LXML_VERSION=2.3.1 export FFI_VERSION=3.0.13 -# where the build will be located +# Xcode doesn't include /usr/local/bin +export PATH="$PATH":/usr/local/bin + +# ensure byte-compiling is working +export PYTHONDONTWRITEBYTECODE= + + + + +# set TARGET_SDK to iphonos by default if not specified +if [ "X$TARGET_SDK" == "X" ]; then + export TARGET_SDK="iphoneos" +fi + +#set architechuture based on which target we compiling for +export CPU_ARCHITECHTURE="armv7" +if [ "X$TARGET_SDK" == "Xiphonesimulator" ]; then + export CPU_ARCHITECHTURE="i386" +fi + +# where our built is located export KIVYIOSROOT="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )" export BUILDROOT="$KIVYIOSROOT/build" export TMPROOT="$KIVYIOSROOT/tmp" export DESTROOT="$KIVYIOSROOT/tmp/root" export CACHEROOT="$KIVYIOSROOT/.cache" -# pkg-config for SDL and futures -try mkdir -p $BUILDROOT/pkgconfig -export PKG_CONFIG_PATH="$BUILDROOT/pkgconfig:$PKG_CONFIG_PATH" +# iOS SDK Environmnent (don't use name "SDKROOT"!!! it will break the compilation) +export SDKVER=`xcrun --sdk $TARGET_SDK --show-sdk-version` +export IOSSDKROOT=`xcrun --sdk $TARGET_SDK --show-sdk-path` + + + +#find the right compiler and linker +export ARM_CC=$(xcrun -find -sdk $TARGET_SDK clang) +export ARM_AR=$(xcrun -find -sdk $TARGET_SDK ar) +export ARM_LD=$(xcrun -find -sdk $TARGET_SDK ld) + +# flags for arm compilation +# (not really arm if building for simlator...but it's all the stuff we're cross comiling for iOS) +export ARM_CFLAGS="-arch $CPU_ARCHITECHTURE" +export ARM_CFLAGS="$ARM_CFLAGS -pipe -no-cpp-precomp" +export ARM_CFLAGS="$ARM_CFLAGS -isysroot $IOSSDKROOT" +export ARM_CFLAGS="$ARM_CFLAGS -miphoneos-version-min=$SDKVER" + + +# flags for linker +export ARM_LDFLAGS="-arch $CPU_ARCHITECHTURE -isysroot $IOSSDKROOT" +export ARM_LDFLAGS="$ARM_LDFLAGS -miphoneos-version-min=$SDKVER" + +# uncomment this line if you want debugging stuff +export ARM_CFLAGS="$ARM_CFLAGS -O3" +#export ARM_CFLAGS="$ARM_CFLAGS -O0 -g" + +#general xcode build settings +export XCODEBUILD_FLAGS="ONLY_ACTIVE_ARCH=NO ARCHS=$CPU_ARCHITECHTURE -configuration Release -sdk ${TARGET_SDK} --arch=$CPU_ARCHITECHTURE" + + + + +##CHECK sanity of configuration +if [ ! -d $IOSSDKROOT ]; then + echo "Unable to found the target $TARGET_SDK SDK " + echo + echo "The path is automatically set from 'xcrun --sdk $TARGET_SDK --show-sdk-path'" + exit 1 +fi + # some tools export CCACHE=$(which ccache) @@ -83,29 +119,12 @@ if [ $CONFIGURATION_OK -eq 0 ]; then fi +#now do some setup... +# pkg-config for SDL and futures +try mkdir -p $BUILDROOT/pkgconfig +export PKG_CONFIG_PATH="$BUILDROOT/pkgconfig:$PKG_CONFIG_PATH" -# flags for arm compilation -#export ARM_CC="$CCACHE $DEVROOT/usr/bin/arm-apple-darwin10-llvm-gcc-4.2" -#export ARM_AR="$DEVROOT/usr/bin/ar" -#export ARM_LD="$DEVROOT/usr/bin/ld" -export ARM_CC=$(xcrun -find -sdk $TARGET_SDK clang) -export ARM_AR=$(xcrun -find -sdk $TARGET_SDK ar) -export ARM_LD=$(xcrun -find -sdk $TARGET_SDK ld) - -export ARM_CFLAGS="-arch $CPU_ARCHITECHTURE" -export ARM_CFLAGS="$ARM_CFLAGS -pipe -no-cpp-precomp" -export ARM_CFLAGS="$ARM_CFLAGS -isysroot $IOSSDKROOT" -export ARM_CFLAGS="$ARM_CFLAGS -miphoneos-version-min=$SDKVER" -export ARM_LDFLAGS="-arch $CPU_ARCHITECHTURE -isysroot $IOSSDKROOT" -export ARM_LDFLAGS="$ARM_LDFLAGS -miphoneos-version-min=$SDKVER" - -# uncomment this line if you want debugging stuff -export ARM_CFLAGS="$ARM_CFLAGS -O3" -#export ARM_CFLAGS="$ARM_CFLAGS -O0 -g" - -# ensure byte-compiling is working -export PYTHONDONTWRITEBYTECODE= # create build directory if not found try mkdir -p $BUILDROOT diff --git a/tools/populate-project.sh b/tools/populate-project.sh index 223ea0e..a5b2fbe 100755 --- a/tools/populate-project.sh +++ b/tools/populate-project.sh @@ -6,6 +6,8 @@ try () { . $(dirname $0)/environment.sh +export PYTHONDONTWRITEBYTECODE= + APPNAME=$1 APPID=$(echo $APPNAME | tr '[A-Z]' '[a-z]') APPDIR=$KIVYIOSROOT/app-$APPID