First stab at Universal Python

This commit is contained in:
Brian Hammond 2013-02-04 15:57:33 -05:00
parent d67552a703
commit 952bffcebd
2 changed files with 83 additions and 21 deletions

View file

@ -26,15 +26,15 @@ try patch -p1 < $KIVYIOSROOT/src/python_files/Python-$PYTHON_VERSION-static-_sql
try cp $KIVYIOSROOT/src/python_files/ModulesSetup Modules/Setup.local
try cp $KIVYIOSROOT/src/python_files/_scproxy.py Lib/_scproxy.py
# echo "Building for native machine ============================================"
echo "Building for native machine ============================================"
try ./configure CC="$CCACHE clang -Qunused-arguments -fcolor-diagnostics" LDFLAGS="-lsqlite3"
try make python.exe Parser/pgen
try mv python.exe hostpython
try mv Parser/pgen Parser/hostpgen
try make distclean
if [ -e hostpython ]; then
try ./configure CC="$CCACHE clang -Qunused-arguments -fcolor-diagnostics" LDFLAGS="-lsqlite3"
try make python.exe Parser/pgen
try mv python.exe hostpython
try mv Parser/pgen Parser/hostpgen
try make distclean
fi
echo "Building for iOS ======================================================="
@ -54,19 +54,55 @@ ln -s "$SDKROOT/usr/lib/libgcc_s.1.dylib" extralibs/libgcc_s.10.4.dylib || echo
try cp $KIVYIOSROOT/src/python_files/ModulesSetup Modules/Setup.local
try cp $KIVYIOSROOT/src/python_files/_scproxy.py Lib/_scproxy.py
try ./configure CC="$ARM_CC" LD="$ARM_LD" \
CFLAGS="$ARM_CFLAGS" \
LDFLAGS="$ARM_LDFLAGS -Lextralibs/ -lsqlite3" \
--disable-toolbox-glue \
--host=armv7-apple-darwin \
--prefix=/python \
--without-doc-strings
if [ ! -e $BUILDROOT/lib/libpython2.7-armv7.a ]; then
try ./configure CC="$ARM_CC" LD="$ARM_LD" \
CFLAGS="$ARM_CFLAGS" \
LDFLAGS="$ARM_LDFLAGS -Lextralibs/ -lsqlite3" \
--disable-toolbox-glue \
--host=armv7-apple-darwin \
--prefix=/python \
--without-doc-strings
try make HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen \
CROSS_COMPILE_TARGET=yes
try make HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen \
CROSS_COMPILE_TARGET=yes
try make install HOSTPYTHON=./hostpython CROSS_COMPILE_TARGET=yes prefix="$BUILDROOT/python"
try make install HOSTPYTHON=./hostpython CROSS_COMPILE_TARGET=yes prefix="$BUILDROOT/python"
try mv -f $BUILDROOT/python/lib/libpython2.7.a $BUILDROOT/lib/
try mv -f $BUILDROOT/python/lib/libpython2.7.a \
$BUILDROOT/lib/libpython2.7-armv7.a
deduplicate $BUILDROOT/lib/libpython2.7-armv7.a
fi
# build for i386 (simulator)
if [ ! -e $BUILDROOT/lib/libpython2.7-i386.a ]; then
export CPPFLAGS="-I$SIMULATOR_SDKROOT/usr/include/"
echo "*************************"
echo CPPFLAGS=$CPPFLAGS
echo "*************************"
try ./configure CC="$i386_CC" LD="$i386_LD" \
CFLAGS="$i386_CFLAGS" \
LDFLAGS="$i386_LDFLAGS -Lextralibs/ -lsqlite3" \
--disable-toolbox-glue \
--prefix=/python \
--without-doc-strings
try make -j4 install prefix="$BUILDROOT/python"
try mv -f $BUILDROOT/python/lib/libpython2.7.a \
$BUILDROOT/lib/libpython2.7-i386.a
deduplicate $BUILDROOT/lib/libpython2.7-i386.a
fi
# combine the libs into a Universal lib
if [ -e $BUILDROOT/lib/libpython2.7-i386.a ] && [ -e $BUILDROOT/lib/libpython2.7-armv7.a ]; then
try lipo -create -output $BUILDROOT/lib/libpython2.7.a \
$BUILDROOT/lib/libpython2.7-i386.a \
$BUILDROOT/lib/libpython2.7-armv7.a
fi
deduplicate $BUILDROOT/lib/libpython2.7.a

View file

@ -23,6 +23,21 @@ if [ ! -d $DEVROOT ]; then
exit 1
fi
# iOS SDK Environmnent for the simulator
export SIMULATOR_SDKVER=`xcodebuild -showsdks | fgrep "iphonesimulator" | tail -n 1 | awk '{print $2}'`
export SIMULATOR_DEVROOT=`xcode-select -print-path`/Platforms/iPhoneSimulator.platform/Developer
export SIMULATOR_SDKROOT=$SIMULATOR_DEVROOT/SDKs/iPhoneSimulator$SDKVER.sdk
if [ ! -d $SIMULATOR_DEVROOT ]; then
echo "Unable to found the Xcode iPhoneSimulator.platform"
echo
echo "The path is automatically set from 'xcode-select -print-path'"
echo " + /Platforms/iPhoneSimulator.platform/Developer"
echo
echo "Ensure 'xcode-select -print-path' is set."
exit 1
fi
# version of packages
export PYTHON_VERSION=2.7.1
export SDLTTF_VERSION=2.0.10
@ -45,7 +60,7 @@ export PKG_CONFIG_PATH="$BUILDROOT/pkgconfig:$PKG_CONFIG_PATH"
# some tools
export CCACHE=$(which ccache)
# flags for arm compilation
# flags for arm (device) 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"
@ -60,6 +75,17 @@ export ARM_LDFLAGS="$ARM_LDFLAGS -miphoneos-version-min=$SDKVER"
export ARM_CFLAGS="$ARM_CFLAGS -O3"
#export ARM_CFLAGS="$ARM_CFLAGS -O0 -g"
# flags for i386 (simulator) compilation
export i386_CC="$CCACHE $SIMULATOR_DEVROOT/usr/bin/i686-apple-darwin11-llvm-gcc-4.2"
export i386_AR="$SIMULATOR_DEVROOT/usr/bin/ar"
export i386_LD="$SIMULATOR_DEVROOT/usr/bin/ld"
export i386_CFLAGS="-isysroot $SIMULATOR_SDKROOT"
export i386_LDFLAGS="-isysroot $SIMULATOR_SDKROOT"
# uncomment this line if you want debugging stuff
export i386_CFLAGS="$i386_CFLAGS -O3"
#export i386_CFLAGS="$i386_CFLAGS -O0 -g"
# create build directory if not found
try mkdir -p $BUILDROOT
try mkdir -p $BUILDROOT/include