|
12 | 12 | import sh
|
13 | 13 |
|
14 | 14 | from pythonforandroid.recipe import Recipe, TargetPythonRecipe
|
15 |
| -from pythonforandroid.logger import logger, info, shprint |
| 15 | +from pythonforandroid.logger import info, shprint |
16 | 16 | from pythonforandroid.util import (
|
17 | 17 | current_directory, ensure_dir, walk_valid_filens,
|
18 | 18 | BuildInterruptingException, build_platform)
|
@@ -113,62 +113,23 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
|
113 | 113 | arch=arch, with_flags_in_cc=with_flags_in_cc)
|
114 | 114 |
|
115 | 115 | env = environ.copy()
|
| 116 | + env['HOSTARCH'] = arch.command_prefix |
116 | 117 |
|
117 |
| - android_host = env['HOSTARCH'] = arch.command_prefix |
118 |
| - toolchain = '{toolchain_prefix}-{toolchain_version}'.format( |
119 |
| - toolchain_prefix=self.ctx.toolchain_prefix, |
120 |
| - toolchain_version=self.ctx.toolchain_version) |
121 |
| - toolchain = join(self.ctx.ndk_dir, 'toolchains', |
122 |
| - toolchain, 'prebuilt', build_platform) |
123 |
| - |
124 |
| - env['CC'] = ( |
125 |
| - '{clang} -target {target} -gcc-toolchain {toolchain}').format( |
126 |
| - clang=join(self.ctx.ndk_dir, 'toolchains', 'llvm', 'prebuilt', |
127 |
| - build_platform, 'bin', 'clang'), |
128 |
| - target=arch.target, |
129 |
| - toolchain=toolchain) |
130 |
| - env['AR'] = join(toolchain, 'bin', android_host) + '-ar' |
131 |
| - env['LD'] = join(toolchain, 'bin', android_host) + '-ld' |
132 |
| - env['RANLIB'] = join(toolchain, 'bin', android_host) + '-ranlib' |
133 |
| - env['READELF'] = join(toolchain, 'bin', android_host) + '-readelf' |
134 |
| - env['STRIP'] = join(toolchain, 'bin', android_host) + '-strip' |
135 |
| - env['STRIP'] += ' --strip-debug --strip-unneeded' |
| 118 | + env['CC'] = '{}'.format( |
| 119 | + join(self.ctx.ndk_dir, 'toolchains', 'llvm', 'prebuilt', |
| 120 | + build_platform, 'bin', arch.target + '-clang')) |
136 | 121 |
|
137 | 122 | env['PATH'] = (
|
138 | 123 | '{hostpython_dir}:{old_path}').format(
|
139 | 124 | hostpython_dir=self.get_recipe(
|
140 | 125 | 'host' + self.name, self.ctx).get_path_to_python(),
|
141 | 126 | old_path=env['PATH'])
|
142 | 127 |
|
143 |
| - ndk_flags = ( |
144 |
| - '-fPIC --sysroot={ndk_sysroot} -D__ANDROID_API__={android_api} ' |
145 |
| - '-isystem {ndk_android_host} -I{ndk_include}').format( |
146 |
| - ndk_sysroot=join(self.ctx.ndk_dir, 'sysroot'), |
147 |
| - android_api=self.ctx.ndk_api, |
148 |
| - ndk_android_host=join( |
149 |
| - self.ctx.ndk_dir, 'sysroot', 'usr', 'include', android_host), |
150 |
| - ndk_include=join(self.ctx.ndk_dir, 'sysroot', 'usr', 'include')) |
151 |
| - sysroot = self.ctx.ndk_platform |
152 |
| - env['CFLAGS'] = env.get('CFLAGS', '') + ' ' + ndk_flags |
153 |
| - env['CPPFLAGS'] = env.get('CPPFLAGS', '') + ' ' + ndk_flags |
154 |
| - env['LDFLAGS'] = env.get('LDFLAGS', '') + ' --sysroot={} -L{}'.format( |
155 |
| - sysroot, join(sysroot, 'usr', 'lib')) |
156 |
| - |
157 |
| - # Manually add the libs directory, and copy some object |
158 |
| - # files to the current directory otherwise they aren't |
159 |
| - # picked up. This seems necessary because the --sysroot |
160 |
| - # setting in LDFLAGS is overridden by the other flags. |
161 |
| - # TODO: Work out why this doesn't happen in the original |
162 |
| - # bpo-30386 Makefile system. |
163 |
| - logger.warning('Doing some hacky stuff to link properly') |
164 |
| - lib_dir = join(sysroot, 'usr', 'lib') |
165 |
| - if arch.arch == 'x86_64': |
166 |
| - lib_dir = join(sysroot, 'usr', 'lib64') |
167 |
| - env['LDFLAGS'] += ' -L{}'.format(lib_dir) |
168 |
| - shprint(sh.cp, join(lib_dir, 'crtbegin_so.o'), './') |
169 |
| - shprint(sh.cp, join(lib_dir, 'crtend_so.o'), './') |
170 |
| - |
171 |
| - env['SYSROOT'] = sysroot |
| 128 | + env['CFLAGS'] = ' '.join([ |
| 129 | + '-fPIC', |
| 130 | + '-DANDROID', |
| 131 | + '-D__ANDROID_API__={}'.format(self.ctx.ndk_api), |
| 132 | + ]) |
172 | 133 |
|
173 | 134 | return env
|
174 | 135 |
|
|
0 commit comments