2
2
from pythonforandroid .toolchain import shprint , current_directory , info
3
3
from pythonforandroid .patching import (is_darwin , is_api_gt ,
4
4
check_all , is_api_lt , is_ndk )
5
+ from pythonforandroid .logger import logger
5
6
from pythonforandroid .util import ensure_dir
6
7
from os .path import exists , join , realpath
7
8
from os import environ
@@ -33,11 +34,10 @@ def build_arch(self, arch):
33
34
with current_directory (build_dir ):
34
35
env = environ .copy ()
35
36
36
-
37
37
# TODO: Get this information from p4a's arch system
38
38
android_host = 'arm-linux-androideabi'
39
39
android_build = sh .Command (join (recipe_build_dir , 'config.guess' ))().stdout .strip ().decode ('utf-8' )
40
- platform_dir = join (self .ctx .ndk_dir , 'platforms' , 'android-19 ' , 'arch-arm' )
40
+ platform_dir = join (self .ctx .ndk_dir , 'platforms' , 'android-21 ' , 'arch-arm' )
41
41
toolchain = '{android_host}-4.9' .format (android_host = android_host )
42
42
toolchain = join (self .ctx .ndk_dir , 'toolchains' , toolchain , 'prebuilt' , 'linux-x86_64' )
43
43
CC = '{clang} -target {target} -gcc-toolchain {toolchain}' .format (
@@ -58,34 +58,57 @@ def build_arch(self, arch):
58
58
env ['READELF' ] = READELF
59
59
env ['STRIP' ] = STRIP
60
60
61
- ndk_flags = '--sysroot={ndk_sysroot} -D__ANDROID_API__=19 -isystem {ndk_android_host}' .format (
61
+ ndk_flags = '--sysroot={ndk_sysroot} -D__ANDROID_API__=21 -isystem {ndk_android_host}' .format (
62
62
ndk_sysroot = join (self .ctx .ndk_dir , 'sysroot' ),
63
63
ndk_android_host = join (self .ctx .ndk_dir , 'sysroot' , 'usr' , 'include' , android_host ))
64
- sysroot = join (self .ctx .ndk_dir , 'platforms' , 'android-19 ' , 'arch-arm' )
64
+ sysroot = join (self .ctx .ndk_dir , 'platforms' , 'android-21 ' , 'arch-arm' )
65
65
env ['CFLAGS' ] = env .get ('CFLAGS' , '' ) + ' ' + ndk_flags
66
66
env ['CPPFLAGS' ] = env .get ('CPPFLAGS' , '' ) + ' ' + ndk_flags
67
- env ['LDFLAGS' ] = env .get ('LDFLAGS' , '' ) + ' --sysroot={} -march=armv7-a -Wl,--fix-cortex-a8' .format (sysroot )
67
+ env ['LDFLAGS' ] = env .get ('LDFLAGS' , '' ) + ' --sysroot={} -L{}' .format (sysroot , join (sysroot , 'usr' , 'lib' ))
68
+
69
+ # Manually add the libs directory, and copy some object
70
+ # files to the current directory otherwise they aren't
71
+ # picked up. This seems necessary because the --sysroot
72
+ # setting in LDFLAGS is overridden by the other flags.
73
+ # TODO: Work out why this doesn't happen in the original
74
+ # bpo-30386 Makefile system.
75
+ logger .warning ('Doing some hacky stuff to link properly' )
76
+ lib_dir = join (sysroot , 'usr' , 'lib' )
77
+ env ['LDFLAGS' ] += ' -L{}' .format (lib_dir )
78
+ shprint (sh .cp , join (lib_dir , 'crtbegin_so.o' ), './' )
79
+ shprint (sh .cp , join (lib_dir , 'crtend_so.o' ), './' )
80
+
81
+ env ['SYSROOT' ] = sysroot
68
82
69
83
print ('CPPflags' , env ['CPPFLAGS' ])
70
84
print ('LDFLAGS' , env ['LDFLAGS' ])
71
85
72
86
print ('LD is' , env ['LD' ])
73
87
74
- shprint (sh .Command (join (recipe_build_dir , 'configure' )),
75
- * (' ' .join (('--host={android_host}' ,
76
- '--build={android_build}' ,
77
- '--enable-shared' ,
78
- '--disable-ipv6' ,
79
- 'ac_cv_file__dev_ptmx=yes' ,
80
- 'ac_cv_file__dev_ptc=no' ,
81
- '--without-ensurepip' ,
82
- 'ac_cv_little_endian_double=yes' ,
83
- '--prefix={prefix}' ,
84
- '--exec-prefix={exec_prefix}' )).format (
85
- android_host = android_host ,
86
- android_build = android_build ,
87
- prefix = sys_prefix ,
88
- exec_prefix = sys_exec_prefix )).split (' ' ), _env = env )
88
+ if not exists ('config.status' ):
89
+ shprint (sh .Command (join (recipe_build_dir , 'configure' )),
90
+ * (' ' .join (('--host={android_host}' ,
91
+ '--build={android_build}' ,
92
+ '--enable-shared' ,
93
+ '--disable-ipv6' ,
94
+ 'ac_cv_file__dev_ptmx=yes' ,
95
+ 'ac_cv_file__dev_ptc=no' ,
96
+ '--without-ensurepip' ,
97
+ 'ac_cv_little_endian_double=yes' ,
98
+ '--prefix={prefix}' ,
99
+ '--exec-prefix={exec_prefix}' )).format (
100
+ android_host = android_host ,
101
+ android_build = android_build ,
102
+ prefix = sys_prefix ,
103
+ exec_prefix = sys_exec_prefix )).split (' ' ), _env = env )
104
+
105
+ import ipdb
106
+ ipdb .set_trace ()
107
+
108
+ shprint (sh .make , 'all' , _env = env )
109
+
110
+ exit (1 )
111
+
89
112
90
113
# if not exists('config.status'):
91
114
0 commit comments