From c1c2931c3fe421f3b7236a3f6ab79f57d9622d40 Mon Sep 17 00:00:00 2001 From: Mathew Date: Fri, 12 Jun 2015 11:08:55 +0200 Subject: [PATCH 1/2] add boost & libtorrent recipes --- recipes/boost/project-config.jam | 1 + recipes/boost/recipe.sh | 54 ++++++++++++++++++++++++++++++++ recipes/boost/user-config.jam | 47 +++++++++++++++++++++++++++ recipes/libtorrent/recipe.sh | 42 +++++++++++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 recipes/boost/project-config.jam create mode 100644 recipes/boost/recipe.sh create mode 100644 recipes/boost/user-config.jam create mode 100644 recipes/libtorrent/recipe.sh diff --git a/recipes/boost/project-config.jam b/recipes/boost/project-config.jam new file mode 100644 index 0000000000..a082201b46 --- /dev/null +++ b/recipes/boost/project-config.jam @@ -0,0 +1 @@ +# Boost.Build Configuration diff --git a/recipes/boost/recipe.sh b/recipes/boost/recipe.sh new file mode 100644 index 0000000000..7d81929e6d --- /dev/null +++ b/recipes/boost/recipe.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# This recipe only downloads Boost and builds Boost.Build +# Since Boost by default uses version numbers in the library names, it makes linking to them harder (as Android does not accept version numbers) +# This is used in the libtorrent recipe and Boost.Build is used to (recursivly) compile Boost from the source here +VERSION_boost=${VERSION_boost:-1.58.0} +DEPS_boost=(python) +URL_boost=http://downloads.sourceforge.net/project/boost/boost/${VERSION_boost}/boost_1_58_0.tar.gz # Don't forget to change the URL when changing the version +MD5_boost=5a5d5614d9a07672e1ab2a250b5defc5 +BUILD_boost=$BUILD_PATH/boost/$(get_directory $URL_boost) +RECIPE_boost=$RECIPES_PATH/boost + +function prebuild_boost() { + cd $BUILD_boost + + # Boost config locations + RECIPECONFIG=${RECIPE_boost}/user-config.jam + BOOSTCONFIG=${BUILD_boost}/tools/build/src/user-config.jam + + # Make Boost.Build + ./bootstrap.sh --with-python=$HOSTPYTHON --with-python-root=$BUILD_PATH/python-install --with-python-version=2.7 + + # Place our own user-config in Boost.Build and set the PYTHON_INSTALL variable, delete any previous copy first, so that is can be modified when the build directory still exists + if [ -e ${BOOSTCONFIG} ]; then + try rm ${BOOSTCONFIG} + fi + try cp ${RECIPECONFIG} ${BOOSTCONFIG} + + # Replace the generated project-config with our own + try rm $BUILD_boost/project-config.jam* + try cp $RECIPE_boost/project-config.jam $BUILD_boost + + # Create Android case for library linking when building Boost.Python + #FIXME: Not idempotent + sed -i "622i\ \ \ \ \ \ \ \ case * : return ;" tools/build/src/tools/python.jam +} + +function build_boost() { + cd $BUILD_boost + + # Export the Boost location to other recipes that want to know where to find Boost + export BOOST_ROOT=$BUILD_boost + # Export PYTHON_INSTALL as it is used in user-config + export PYTHON_INSTALL="$BUILD_PATH/python-install" + + # Also copy libgnustl + try cp $ANDROIDNDK/sources/cxx-stl/gnu-libstdc++/$TOOLCHAIN_VERSION/libs/$ARCH/libgnustl_shared.so $LIBS_PATH + + pop_arm +} + +function postbuild_boost() { + unset BOOST_ROOT + unset PYTHONINSTALL +} diff --git a/recipes/boost/user-config.jam b/recipes/boost/user-config.jam new file mode 100644 index 0000000000..c389e065bc --- /dev/null +++ b/recipes/boost/user-config.jam @@ -0,0 +1,47 @@ +import os ; + +local ANDROIDNDK = [ os.environ ANDROIDNDK ] ; +local ANDROIDAPI = [ os.environ ANDROIDAPI ] ; +local TOOLCHAIN_VERSION = [ os.environ TOOLCHAIN_VERSION ] ; +local TOOLCHAIN_PREFIX = [ os.environ TOOLCHAIN_PREFIX ] ; +local ARCH = [ os.environ ARCH ] ; +local PYTHON_INSTALL = [ os.environ PYTHON_INSTALL ] ; + +using python : 2.7 : : : : ; + +using gcc : android +: +$(TOOLCHAIN_PREFIX)-g++ +: +$(TOOLCHAIN_PREFIX)-ar +-fexceptions +-frtti +-fPIC +-ffunction-sections +-funwind-tables +-Wno-psabi +-mtune=xscale +-Os +-fomit-frame-pointer +-fno-strict-aliasing +-finline-limit=64 +-I$(ANDROIDNDK)/platforms/android-$(ANDROIDAPI)/arch-arm/usr/include +-Wa,--noexecstack +-DANDROID +-D__ANDROID__ +-DNDEBUG +-O2 +-g +-I$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/include +-I$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(ARCH)/include +arm +-fvisibility=hidden +-fvisibility-inlines-hidden +-fdata-sections +-D__arm__ +-D_REENTRANT +-DBOOST_SP_USE_PTHREADS +-DBOOST_AC_USE_PTHREADS +-D_GLIBCXX__PTHREADS +-I$(PYTHON_INSTALL)/include/python2.7 +; diff --git a/recipes/libtorrent/recipe.sh b/recipes/libtorrent/recipe.sh new file mode 100644 index 0000000000..379a7bec74 --- /dev/null +++ b/recipes/libtorrent/recipe.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# This recipe builds libtorrent-rasterbat with it's Python bindings +# It depends on Boost.Build and the source of several Boost libraries present in BOOST_ROOT, which is all provided by the boost recipe +VERSION_libtorrent=${VERSION_libtorrent:-1.0.5} +DEPS_libtorrent=(boost python) +URL_libtorrent=http://downloads.sourceforge.net/project/libtorrent/libtorrent/libtorrent-rasterbar-${VERSION_libtorrent}.tar.gz +MD5_libtorrent=d09521d34092ba430f430572c9e2b3d3 +BUILD_libtorrent=$BUILD_PATH/libtorrent/$(get_directory $URL_libtorrent) +RECIPE_libtorrent=$RECIPES_PATH/libtorrent + +function prebuild_libtorrent() { + true +} + +function shouldbuild_libtorrent() { + if [ -f "$SITEPACKAGES_PATH/libtorrent.so" ]; then + DO_BUILD=0 + fi +} + +function build_libtorrent() { + cd $BUILD_libtorrent/bindings/python + + push_arm + + # Some flags and stuff that I don't want here, but in user-config, but doesn't work otherwise + BOOSTSTUFF="--sysroot=$ANDROIDNDK/platforms/android-$ANDROIDAPI/arch-arm -L$ANDROIDNDK/sources/cxx-stl/gnu-libstdc++/$TOOLCHAIN_VERSION/libs/$ARCH -L$BUILD_PATH/python-install/lib -lpython2.7 -lgnustl_shared" + + # Build the Python bindings with Boost.Build and some dependencies recursively (libtorrent-rasterbar, Boost.*) + # Also link to openssl + # Hardcoded on -j5 because P4A does it too + $BOOST_ROOT/b2 -q -j5 target-os=android link=static boost-link=static boost=source threading=multi toolset=gcc-android geoip=off encryption=tommath linkflags="$BOOSTSTUFF" release + + # Copy the module + try cp -L libtorrent.so $SITEPACKAGES_PATH + + pop_arm +} + +function postbuild_libtorrent() { + true +} From 8f19c26878b9fdfd725fab5ab526585dd35a7bbd Mon Sep 17 00:00:00 2001 From: Mathew Date: Fri, 12 Jun 2015 12:07:56 +0200 Subject: [PATCH 2/2] add 'try' before sed command --- recipes/boost/recipe.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/boost/recipe.sh b/recipes/boost/recipe.sh index 7d81929e6d..5193b970ec 100644 --- a/recipes/boost/recipe.sh +++ b/recipes/boost/recipe.sh @@ -31,7 +31,7 @@ function prebuild_boost() { # Create Android case for library linking when building Boost.Python #FIXME: Not idempotent - sed -i "622i\ \ \ \ \ \ \ \ case * : return ;" tools/build/src/tools/python.jam + try sed -i "622i\ \ \ \ \ \ \ \ case * : return ;" tools/build/src/tools/python.jam } function build_boost() {