11from pythonforandroid .toolchain import Recipe , shprint , shutil , current_directory
22from os .path import join , exists
3+ from os import environ
34import sh
45
56"""
910
1011
1112class BoostRecipe (Recipe ):
12- version = '1.60.0'
13- # Don't forget to change the URL when changing the version
14- url = 'http://downloads.sourceforge.net/project/boost/boost/{version}/boost_1_60_0.tar.bz2'
15- depends = ['python2' ]
16- patches = ['disable-so-version.patch' , 'use-android-libs.patch' ]
13+ # Todo: make recipe compatible with all p4a architectures
14+ '''
15+ .. note:: This recipe can be built only against API 21+ and arch armeabi-v7a
16+
17+ .. versionchanged:: 0.6.0
18+ Rewrote recipe to support clang's build. The following changes has
19+ been made:
20+
21+ - Bumped version number to 1.68.0
22+ - Better version handling for url
23+ - Added python 3 compatibility
24+ - Default compiler for ndk's toolchain set to clang
25+ - Python version will be detected via user-config.jam
26+ - Changed stl's lib from ``gnustl_shared`` to ``c++_shared``
27+ '''
28+ version = '1.68.0'
29+ url = 'http://downloads.sourceforge.net/project/boost/' \
30+ 'boost/{version}/boost_{version_underscore}.tar.bz2'
31+ depends = [('python2' , 'python3' )]
32+ patches = ['disable-so-version.patch' ,
33+ 'use-android-libs.patch' ,
34+ 'fix-android-issues.patch' ]
35+
36+ @property
37+ def versioned_url (self ):
38+ if self .url is None :
39+ return None
40+ return self .url .format (
41+ version = self .version ,
42+ version_underscore = self .version .replace ('.' , '_' ))
1743
1844 def should_build (self , arch ):
1945 return not exists (join (self .get_build_dir (arch .arch ), 'b2' ))
@@ -28,41 +54,50 @@ def prebuild_arch(self, arch):
2854 shprint (bash , join (self .ctx .ndk_dir , 'build/tools/make-standalone-toolchain.sh' ),
2955 '--arch=' + env ['ARCH' ],
3056 '--platform=android-' + str (self .ctx .android_api ),
31- '--toolchain=' + env ['CROSSHOST' ] + '-' + env ['TOOLCHAIN_VERSION' ],
57+ '--toolchain=' + env ['CROSSHOST' ] + '-' + self .ctx .toolchain_version + ':-llvm' ,
58+ '--use-llvm' ,
59+ '--stl=libc++' ,
3260 '--install-dir=' + env ['CROSSHOME' ]
33- )
61+ )
3462 # Set custom configuration
3563 shutil .copyfile (join (self .get_recipe_dir (), 'user-config.jam' ),
3664 join (env ['BOOST_BUILD_PATH' ], 'user-config.jam' ))
3765
3866 def build_arch (self , arch ):
3967 super (BoostRecipe , self ).build_arch (arch )
4068 env = self .get_recipe_env (arch )
69+ env ['PYTHON_HOST' ] = self .ctx .hostpython
4170 with current_directory (self .get_build_dir (arch .arch )):
4271 # Compile Boost.Build engine with this custom toolchain
4372 bash = sh .Command ('bash' )
44- shprint (bash , 'bootstrap.sh' ,
45- '--with-python=' + join (env ['PYTHON_ROOT' ], 'bin/python.host' ),
46- '--with-python-version=2.7' ,
47- '--with-python-root=' + env ['PYTHON_ROOT' ]
48- ) # Do not pass env
73+ shprint (bash , 'bootstrap.sh' ) # Do not pass env
4974 # Install app stl
50- shutil .copyfile (join (env ['CROSSHOME' ], env ['CROSSHOST' ], 'lib/libgnustl_shared.so' ),
51- join (self .ctx .get_libs_dir (arch .arch ), 'libgnustl_shared.so' ))
75+ shutil .copyfile (
76+ join (self .ctx .ndk_dir , 'sources/cxx-stl/llvm-libc++/libs/'
77+ 'armeabi-v7a/libc++_shared.so' ),
78+ join (self .ctx .get_libs_dir (arch .arch ), 'libc++_shared.so' ))
5279
5380 def select_build_arch (self , arch ):
5481 return arch .arch .replace ('eabi-v7a' , '' ).replace ('eabi' , '' )
5582
5683 def get_recipe_env (self , arch ):
57- env = super (BoostRecipe , self ).get_recipe_env (arch )
84+ # We don't use the normal env because we
85+ # are building with a standalone toolchain
86+ env = environ .copy ()
87+
5888 env ['BOOST_BUILD_PATH' ] = self .get_build_dir (arch .arch ) # find user-config.jam
5989 env ['BOOST_ROOT' ] = env ['BOOST_BUILD_PATH' ] # find boost source
60- env ['PYTHON_ROOT' ] = self .ctx .get_python_install_dir ()
90+
91+ env ['PYTHON_ROOT' ] = self .ctx .python_recipe .link_root (arch .arch )
92+ env ['PYTHON_INCLUDE' ] = self .ctx .python_recipe .include_root (arch .arch )
93+ env ['PYTHON_MAJOR_MINOR' ] = self .ctx .python_recipe .version [:3 ]
94+ env ['PYTHON_LINK_VERSION' ] = self .ctx .python_recipe .major_minor_version_string
95+ if 'python3' in self .ctx .python_recipe .name :
96+ env ['PYTHON_LINK_VERSION' ] += 'm'
97+
6198 env ['ARCH' ] = self .select_build_arch (arch )
62- env ['ANDROIDAPI' ] = str (self .ctx .android_api )
6399 env ['CROSSHOST' ] = env ['ARCH' ] + '-linux-androideabi'
64100 env ['CROSSHOME' ] = join (env ['BOOST_ROOT' ], 'standalone-' + env ['ARCH' ] + '-toolchain' )
65- env ['TOOLCHAIN_PREFIX' ] = join (env ['CROSSHOME' ], 'bin' , env ['CROSSHOST' ])
66101 return env
67102
68103
0 commit comments