|
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,27 @@ 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['LDFLAGS'] += '--sysroot {} '.format(self.ctx.ndk_platform) |
39 | 53 |
|
40 | 54 | env["CXXFLAGS"] = env["CFLAGS"]
|
41 | 55 |
|
42 |
| - env["LDFLAGS"] = " ".join(['-lm', '-L' + self.ctx.get_libs_dir(self.arch)]) |
| 56 | + env["LDFLAGS"] += " ".join(['-lm', '-L' + self.ctx.get_libs_dir(self.arch)]) |
43 | 57 |
|
44 | 58 | if self.ctx.ndk == 'crystax':
|
45 | 59 | env['LDFLAGS'] += ' -L{}/sources/crystax/libs/{} -lcrystax'.format(self.ctx.ndk_dir, self.arch)
|
|
0 commit comments