1- from pythonforandroid .toolchain import Recipe , shprint , shutil , current_directory
1+ from pythonforandroid .util import current_directory , build_platform
2+ from pythonforandroid .recipe import Recipe
3+ from pythonforandroid .logger import shprint
24from os .path import join , exists
35from os import environ
6+ import shutil
47import sh
58
69"""
7- This recipe creates a custom toolchain and bootstraps Boost from source to build Boost.Build
10+ This recipe bootstraps Boost from source to build Boost.Build
811including python bindings
912"""
1013
1114
1215class BoostRecipe (Recipe ):
1316 # Todo: make recipe compatible with all p4a architectures
1417 '''
15- .. note:: This recipe can be built only against API 21+ and arch armeabi-v7a
18+ .. note:: This recipe can be built only against API 21+ and an android
19+ ndk >= r19
1620
1721 .. versionchanged:: 0.6.0
1822 Rewrote recipe to support clang's build. The following changes has
@@ -24,22 +28,33 @@ class BoostRecipe(Recipe):
2428 - Default compiler for ndk's toolchain set to clang
2529 - Python version will be detected via user-config.jam
2630 - Changed stl's lib from ``gnustl_shared`` to ``c++_shared``
31+
32+ .. versionchanged:: 2019.08.09.1.dev0
33+
34+ - Bumped version number to 1.68.0
35+ - Adapted to work with ndk-r19+
2736 '''
28- version = '1.68.0'
29- url = 'http://downloads.sourceforge.net/project/boost/' \
30- 'boost/{version}/boost_{version_underscore}.tar.bz2'
37+ version = '1.69.0'
38+ url = (
39+ 'http://downloads.sourceforge.net/project/boost/'
40+ 'boost/{version}/boost_{version_underscore}.tar.bz2'
41+ )
3142 depends = [('python2' , 'python3' )]
32- patches = ['disable-so-version.patch' ,
33- 'use-android-libs.patch' ,
34- 'fix-android-issues.patch' ]
43+ patches = [
44+ 'disable-so-version.patch' ,
45+ 'use-android-libs.patch' ,
46+ 'fix-android-issues.patch' ,
47+ ]
48+ need_stl_shared = True
3549
3650 @property
3751 def versioned_url (self ):
3852 if self .url is None :
3953 return None
4054 return self .url .format (
4155 version = self .version ,
42- version_underscore = self .version .replace ('.' , '_' ))
56+ version_underscore = self .version .replace ('.' , '_' ),
57+ )
4358
4459 def should_build (self , arch ):
4560 return not exists (join (self .get_build_dir (arch .arch ), 'b2' ))
@@ -48,56 +63,50 @@ def prebuild_arch(self, arch):
4863 super (BoostRecipe , self ).prebuild_arch (arch )
4964 env = self .get_recipe_env (arch )
5065 with current_directory (self .get_build_dir (arch .arch )):
51- if not exists (env ['CROSSHOME' ]):
52- # Make custom toolchain
53- bash = sh .Command ('bash' )
54- shprint (bash , join (self .ctx .ndk_dir , 'build/tools/make-standalone-toolchain.sh' ),
55- '--arch=' + env ['ARCH' ],
56- '--platform=android-' + str (self .ctx .android_api ),
57- '--toolchain=' + env ['CROSSHOST' ] + '-' + self .ctx .toolchain_version + ':-llvm' ,
58- '--use-llvm' ,
59- '--stl=libc++' ,
60- '--install-dir=' + env ['CROSSHOME' ]
61- )
6266 # Set custom configuration
63- shutil .copyfile (join (self .get_recipe_dir (), 'user-config.jam' ),
64- join (env ['BOOST_BUILD_PATH' ], 'user-config.jam' ))
67+ shutil .copyfile (
68+ join (self .get_recipe_dir (), 'user-config.jam' ),
69+ join (env ['BOOST_BUILD_PATH' ], 'user-config.jam' ),
70+ )
6571
6672 def build_arch (self , arch ):
6773 super (BoostRecipe , self ).build_arch (arch )
6874 env = self .get_recipe_env (arch )
6975 env ['PYTHON_HOST' ] = self .ctx .hostpython
7076 with current_directory (self .get_build_dir (arch .arch )):
71- # Compile Boost.Build engine with this custom toolchain
72- bash = sh .Command ('bash' )
73- shprint (bash , 'bootstrap.sh' ) # Do not pass env
74- # Install app stl
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' ))
79-
80- def select_build_arch (self , arch ):
81- return arch .arch .replace ('eabi-v7a' , '' ).replace ('eabi' , '' )
77+ if not exists ('b2' ):
78+ # Compile Boost.Build engine with this custom toolchain
79+ bash = sh .Command ('bash' )
80+ shprint (bash , 'bootstrap.sh' ) # Do not pass env
8281
8382 def get_recipe_env (self , arch ):
8483 # We don't use the normal env because we
8584 # are building with a standalone toolchain
8685 env = environ .copy ()
8786
88- env ['BOOST_BUILD_PATH' ] = self .get_build_dir (arch .arch ) # find user-config.jam
89- env ['BOOST_ROOT' ] = env ['BOOST_BUILD_PATH' ] # find boost source
87+ # find user-config.jam
88+ env ['BOOST_BUILD_PATH' ] = self .get_build_dir (arch .arch )
89+ # find boost source
90+ env ['BOOST_ROOT' ] = env ['BOOST_BUILD_PATH' ]
9091
9192 env ['PYTHON_ROOT' ] = self .ctx .python_recipe .link_root (arch .arch )
9293 env ['PYTHON_INCLUDE' ] = self .ctx .python_recipe .include_root (arch .arch )
9394 env ['PYTHON_MAJOR_MINOR' ] = self .ctx .python_recipe .version [:3 ]
94- env ['PYTHON_LINK_VERSION' ] = self .ctx .python_recipe .major_minor_version_string
95+ env [
96+ 'PYTHON_LINK_VERSION'
97+ ] = self .ctx .python_recipe .major_minor_version_string
9598 if 'python3' in self .ctx .python_recipe .name :
9699 env ['PYTHON_LINK_VERSION' ] += 'm'
97100
98- env ['ARCH' ] = self .select_build_arch (arch )
99- env ['CROSSHOST' ] = env ['ARCH' ] + '-linux-androideabi'
100- env ['CROSSHOME' ] = join (env ['BOOST_ROOT' ], 'standalone-' + env ['ARCH' ] + '-toolchain' )
101+ env ['ARCH' ] = arch .arch .replace ('-' , '' )
102+ env ['TARGET_TRIPLET' ] = arch .target
103+ env ['CROSSHOST' ] = arch .command_prefix
104+ env ['CROSSHOME' ] = join (
105+ self .ctx .ndk_dir ,
106+ 'toolchains/llvm/prebuilt/{build_platform}' .format (
107+ build_platform = build_platform
108+ ),
109+ )
101110 return env
102111
103112
0 commit comments