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
2
4
from os .path import join , exists
3
5
from os import environ
6
+ import shutil
4
7
import sh
5
8
6
9
"""
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
8
11
including python bindings
9
12
"""
10
13
11
14
12
15
class BoostRecipe (Recipe ):
13
16
# Todo: make recipe compatible with all p4a architectures
14
17
'''
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
16
20
17
21
.. versionchanged:: 0.6.0
18
22
Rewrote recipe to support clang's build. The following changes has
@@ -24,22 +28,33 @@ class BoostRecipe(Recipe):
24
28
- Default compiler for ndk's toolchain set to clang
25
29
- Python version will be detected via user-config.jam
26
30
- 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+
27
36
'''
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
+ )
31
42
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
35
49
36
50
@property
37
51
def versioned_url (self ):
38
52
if self .url is None :
39
53
return None
40
54
return self .url .format (
41
55
version = self .version ,
42
- version_underscore = self .version .replace ('.' , '_' ))
56
+ version_underscore = self .version .replace ('.' , '_' ),
57
+ )
43
58
44
59
def should_build (self , arch ):
45
60
return not exists (join (self .get_build_dir (arch .arch ), 'b2' ))
@@ -48,56 +63,50 @@ def prebuild_arch(self, arch):
48
63
super (BoostRecipe , self ).prebuild_arch (arch )
49
64
env = self .get_recipe_env (arch )
50
65
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
- )
62
66
# 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
+ )
65
71
66
72
def build_arch (self , arch ):
67
73
super (BoostRecipe , self ).build_arch (arch )
68
74
env = self .get_recipe_env (arch )
69
75
env ['PYTHON_HOST' ] = self .ctx .hostpython
70
76
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
82
81
83
82
def get_recipe_env (self , arch ):
84
83
# We don't use the normal env because we
85
84
# are building with a standalone toolchain
86
85
env = environ .copy ()
87
86
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' ]
90
91
91
92
env ['PYTHON_ROOT' ] = self .ctx .python_recipe .link_root (arch .arch )
92
93
env ['PYTHON_INCLUDE' ] = self .ctx .python_recipe .include_root (arch .arch )
93
94
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
95
98
if 'python3' in self .ctx .python_recipe .name :
96
99
env ['PYTHON_LINK_VERSION' ] += 'm'
97
100
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
+ )
101
110
return env
102
111
103
112
0 commit comments