Skip to content

Commit 446a8df

Browse files
committed
Merge pull request kivy#389 from mathewvermeer/libtorrent
add boost & libtorrent recipes
2 parents cbb43df + 8f19c26 commit 446a8df

File tree

4 files changed

+144
-0
lines changed

4 files changed

+144
-0
lines changed

recipes/boost/project-config.jam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Boost.Build Configuration

recipes/boost/recipe.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
# This recipe only downloads Boost and builds Boost.Build
3+
# Since Boost by default uses version numbers in the library names, it makes linking to them harder (as Android does not accept version numbers)
4+
# This is used in the libtorrent recipe and Boost.Build is used to (recursivly) compile Boost from the source here
5+
VERSION_boost=${VERSION_boost:-1.58.0}
6+
DEPS_boost=(python)
7+
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
8+
MD5_boost=5a5d5614d9a07672e1ab2a250b5defc5
9+
BUILD_boost=$BUILD_PATH/boost/$(get_directory $URL_boost)
10+
RECIPE_boost=$RECIPES_PATH/boost
11+
12+
function prebuild_boost() {
13+
cd $BUILD_boost
14+
15+
# Boost config locations
16+
RECIPECONFIG=${RECIPE_boost}/user-config.jam
17+
BOOSTCONFIG=${BUILD_boost}/tools/build/src/user-config.jam
18+
19+
# Make Boost.Build
20+
./bootstrap.sh --with-python=$HOSTPYTHON --with-python-root=$BUILD_PATH/python-install --with-python-version=2.7
21+
22+
# 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
23+
if [ -e ${BOOSTCONFIG} ]; then
24+
try rm ${BOOSTCONFIG}
25+
fi
26+
try cp ${RECIPECONFIG} ${BOOSTCONFIG}
27+
28+
# Replace the generated project-config with our own
29+
try rm $BUILD_boost/project-config.jam*
30+
try cp $RECIPE_boost/project-config.jam $BUILD_boost
31+
32+
# Create Android case for library linking when building Boost.Python
33+
#FIXME: Not idempotent
34+
try sed -i "622i\ \ \ \ \ \ \ \ case * : return ;" tools/build/src/tools/python.jam
35+
}
36+
37+
function build_boost() {
38+
cd $BUILD_boost
39+
40+
# Export the Boost location to other recipes that want to know where to find Boost
41+
export BOOST_ROOT=$BUILD_boost
42+
# Export PYTHON_INSTALL as it is used in user-config
43+
export PYTHON_INSTALL="$BUILD_PATH/python-install"
44+
45+
# Also copy libgnustl
46+
try cp $ANDROIDNDK/sources/cxx-stl/gnu-libstdc++/$TOOLCHAIN_VERSION/libs/$ARCH/libgnustl_shared.so $LIBS_PATH
47+
48+
pop_arm
49+
}
50+
51+
function postbuild_boost() {
52+
unset BOOST_ROOT
53+
unset PYTHONINSTALL
54+
}

recipes/boost/user-config.jam

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import os ;
2+
3+
local ANDROIDNDK = [ os.environ ANDROIDNDK ] ;
4+
local ANDROIDAPI = [ os.environ ANDROIDAPI ] ;
5+
local TOOLCHAIN_VERSION = [ os.environ TOOLCHAIN_VERSION ] ;
6+
local TOOLCHAIN_PREFIX = [ os.environ TOOLCHAIN_PREFIX ] ;
7+
local ARCH = [ os.environ ARCH ] ;
8+
local PYTHON_INSTALL = [ os.environ PYTHON_INSTALL ] ;
9+
10+
using python : 2.7 : : : : ;
11+
12+
using gcc : android
13+
:
14+
$(TOOLCHAIN_PREFIX)-g++
15+
:
16+
<archiver>$(TOOLCHAIN_PREFIX)-ar
17+
<compileflags>-fexceptions
18+
<compileflags>-frtti
19+
<compileflags>-fPIC
20+
<compileflags>-ffunction-sections
21+
<compileflags>-funwind-tables
22+
<compileflags>-Wno-psabi
23+
<compileflags>-mtune=xscale
24+
<compileflags>-Os
25+
<compileflags>-fomit-frame-pointer
26+
<compileflags>-fno-strict-aliasing
27+
<compileflags>-finline-limit=64
28+
<compileflags>-I$(ANDROIDNDK)/platforms/android-$(ANDROIDAPI)/arch-arm/usr/include
29+
<compileflags>-Wa,--noexecstack
30+
<compileflags>-DANDROID
31+
<compileflags>-D__ANDROID__
32+
<compileflags>-DNDEBUG
33+
<compileflags>-O2
34+
<compileflags>-g
35+
<compileflags>-I$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/include
36+
<compileflags>-I$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(ARCH)/include
37+
<architecture>arm
38+
<compileflags>-fvisibility=hidden
39+
<compileflags>-fvisibility-inlines-hidden
40+
<compileflags>-fdata-sections
41+
<cxxflags>-D__arm__
42+
<cxxflags>-D_REENTRANT
43+
<cxxflags>-DBOOST_SP_USE_PTHREADS
44+
<cxxflags>-DBOOST_AC_USE_PTHREADS
45+
<cxxflags>-D_GLIBCXX__PTHREADS
46+
<compileflags>-I$(PYTHON_INSTALL)/include/python2.7
47+
;

recipes/libtorrent/recipe.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
# This recipe builds libtorrent-rasterbat with it's Python bindings
3+
# It depends on Boost.Build and the source of several Boost libraries present in BOOST_ROOT, which is all provided by the boost recipe
4+
VERSION_libtorrent=${VERSION_libtorrent:-1.0.5}
5+
DEPS_libtorrent=(boost python)
6+
URL_libtorrent=http://downloads.sourceforge.net/project/libtorrent/libtorrent/libtorrent-rasterbar-${VERSION_libtorrent}.tar.gz
7+
MD5_libtorrent=d09521d34092ba430f430572c9e2b3d3
8+
BUILD_libtorrent=$BUILD_PATH/libtorrent/$(get_directory $URL_libtorrent)
9+
RECIPE_libtorrent=$RECIPES_PATH/libtorrent
10+
11+
function prebuild_libtorrent() {
12+
true
13+
}
14+
15+
function shouldbuild_libtorrent() {
16+
if [ -f "$SITEPACKAGES_PATH/libtorrent.so" ]; then
17+
DO_BUILD=0
18+
fi
19+
}
20+
21+
function build_libtorrent() {
22+
cd $BUILD_libtorrent/bindings/python
23+
24+
push_arm
25+
26+
# Some flags and stuff that I don't want here, but in user-config, but doesn't work otherwise
27+
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"
28+
29+
# Build the Python bindings with Boost.Build and some dependencies recursively (libtorrent-rasterbar, Boost.*)
30+
# Also link to openssl
31+
# Hardcoded on -j5 because P4A does it too
32+
$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
33+
34+
# Copy the module
35+
try cp -L libtorrent.so $SITEPACKAGES_PATH
36+
37+
pop_arm
38+
}
39+
40+
function postbuild_libtorrent() {
41+
true
42+
}

0 commit comments

Comments
 (0)