Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions recipes/boost/project-config.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Boost.Build Configuration
54 changes: 54 additions & 0 deletions recipes/boost/recipe.sh
Original file line number Diff line number Diff line change
@@ -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
try 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
}
47 changes: 47 additions & 0 deletions recipes/boost/user-config.jam
Original file line number Diff line number Diff line change
@@ -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++
:
<archiver>$(TOOLCHAIN_PREFIX)-ar
<compileflags>-fexceptions
<compileflags>-frtti
<compileflags>-fPIC
<compileflags>-ffunction-sections
<compileflags>-funwind-tables
<compileflags>-Wno-psabi
<compileflags>-mtune=xscale
<compileflags>-Os
<compileflags>-fomit-frame-pointer
<compileflags>-fno-strict-aliasing
<compileflags>-finline-limit=64
<compileflags>-I$(ANDROIDNDK)/platforms/android-$(ANDROIDAPI)/arch-arm/usr/include
<compileflags>-Wa,--noexecstack
<compileflags>-DANDROID
<compileflags>-D__ANDROID__
<compileflags>-DNDEBUG
<compileflags>-O2
<compileflags>-g
<compileflags>-I$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/include
<compileflags>-I$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(ARCH)/include
<architecture>arm
<compileflags>-fvisibility=hidden
<compileflags>-fvisibility-inlines-hidden
<compileflags>-fdata-sections
<cxxflags>-D__arm__
<cxxflags>-D_REENTRANT
<cxxflags>-DBOOST_SP_USE_PTHREADS
<cxxflags>-DBOOST_AC_USE_PTHREADS
<cxxflags>-D_GLIBCXX__PTHREADS
<compileflags>-I$(PYTHON_INSTALL)/include/python2.7
;
42 changes: 42 additions & 0 deletions recipes/libtorrent/recipe.sh
Original file line number Diff line number Diff line change
@@ -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
}