|
1 | | -from os.path import (join, dirname) |
| 1 | +from os.path import (exists, join, dirname) |
2 | 2 | from os import environ, uname |
3 | 3 | import sys |
4 | 4 | from distutils.spawn import find_executable |
@@ -33,13 +33,32 @@ def include_dirs(self): |
33 | 33 | def get_env(self, with_flags_in_cc=True): |
34 | 34 | env = {} |
35 | 35 |
|
36 | | - env["CFLAGS"] = " ".join([ |
37 | | - "-DANDROID", "-mandroid", "-fomit-frame-pointer", |
38 | | - "--sysroot", self.ctx.ndk_platform]) |
| 36 | + env['CFLAGS'] = ' '.join([ |
| 37 | + '-DANDROID', '-mandroid', '-fomit-frame-pointer' |
| 38 | + ' -D__ANDROID_API__={}'.format(self.ctx._android_api), |
| 39 | + ]) |
| 40 | + env['LDFLAGS'] = ' ' |
| 41 | + |
| 42 | + sysroot = join(self.ctx._ndk_dir, 'sysroot') |
| 43 | + if exists(sysroot): |
| 44 | + # post-15 NDK per |
| 45 | + # https://android.googlesource.com/platform/ndk/+/ndk-r15-release/docs/UnifiedHeaders.md |
| 46 | + env['CFLAGS'] += ' -isystem {}/sysroot/usr/include/{}'.format( |
| 47 | + self.ctx.ndk_dir, self.ctx.toolchain_prefix) |
| 48 | + else: |
| 49 | + sysroot = self.ctx.ndk_platform |
| 50 | + env['CFLAGS'] += ' -I{}'.format(self.ctx.ndk_platform) |
| 51 | + env['CFLAGS'] += ' -isysroot {} '.format(sysroot) |
| 52 | + env['CFLAGS'] += '-I' + join(self.ctx.get_python_install_dir(), |
| 53 | + 'include/python{}'.format( |
| 54 | + self.ctx.python_recipe.version[0:3]) |
| 55 | + ) |
| 56 | + |
| 57 | + env['LDFLAGS'] += '--sysroot {} '.format(self.ctx.ndk_platform) |
39 | 58 |
|
40 | 59 | env["CXXFLAGS"] = env["CFLAGS"] |
41 | 60 |
|
42 | | - env["LDFLAGS"] = " ".join(['-lm', '-L' + self.ctx.get_libs_dir(self.arch)]) |
| 61 | + env["LDFLAGS"] += " ".join(['-lm', '-L' + self.ctx.get_libs_dir(self.arch)]) |
43 | 62 |
|
44 | 63 | if self.ctx.ndk == 'crystax': |
45 | 64 | env['LDFLAGS'] += ' -L{}/sources/crystax/libs/{} -lcrystax'.format(self.ctx.ndk_dir, self.arch) |
@@ -102,7 +121,7 @@ def get_env(self, with_flags_in_cc=True): |
102 | 121 |
|
103 | 122 | hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx) |
104 | 123 |
|
105 | | - # AND: This hardcodes python version 2.7, needs fixing |
| 124 | + # This hardcodes python version 2.7, needs fixing |
106 | 125 | env['BUILDLIB_PATH'] = join( |
107 | 126 | hostpython_recipe.get_build_dir(self.arch), |
108 | 127 | 'build', 'lib.linux-{}-2.7'.format(uname()[-1])) |
|
0 commit comments