Skip to content

Commit b88767d

Browse files
authored
Merge pull request #1252 from Iqoqo/master
compile numpy for x86
2 parents dab32b7 + bd761e3 commit b88767d

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

pythonforandroid/archs.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
class Arch(object):
1111

12+
include_prefix = None
13+
'''The prefix for the include dir in the NDK.'''
14+
1215
toolchain_prefix = None
1316
'''The prefix for the toolchain dir in the NDK.'''
1417

@@ -44,7 +47,7 @@ def get_env(self, with_flags_in_cc=True):
4447
# post-15 NDK per
4548
# https://android.googlesource.com/platform/ndk/+/ndk-r15-release/docs/UnifiedHeaders.md
4649
env['CFLAGS'] += ' -isystem {}/sysroot/usr/include/{}'.format(
47-
self.ctx.ndk_dir, self.ctx.toolchain_prefix)
50+
self.ctx.ndk_dir, self.ctx.include_prefix)
4851
else:
4952
sysroot = self.ctx.ndk_platform
5053
env['CFLAGS'] += ' -I{}'.format(self.ctx.ndk_platform)
@@ -67,10 +70,12 @@ def get_env(self, with_flags_in_cc=True):
6770
if py_platform in ['linux2', 'linux3']:
6871
py_platform = 'linux'
6972

73+
include_prefix = self.ctx.include_prefix
7074
toolchain_prefix = self.ctx.toolchain_prefix
7175
toolchain_version = self.ctx.toolchain_version
7276
command_prefix = self.command_prefix
7377

78+
env['INCLUDE_PREFIX'] = include_prefix
7479
env['TOOLCHAIN_PREFIX'] = toolchain_prefix
7580
env['TOOLCHAIN_VERSION'] = toolchain_version
7681

@@ -138,6 +143,7 @@ def get_env(self, with_flags_in_cc=True):
138143

139144
class ArchARM(Arch):
140145
arch = "armeabi"
146+
include_prefix = 'arm-linux-androideabi'
141147
toolchain_prefix = 'arm-linux-androideabi'
142148
command_prefix = 'arm-linux-androideabi'
143149
platform_dir = 'arch-arm'
@@ -157,6 +163,7 @@ def get_env(self, with_flags_in_cc=True):
157163

158164
class Archx86(Arch):
159165
arch = 'x86'
166+
include_prefix = 'i686-linux-android'
160167
toolchain_prefix = 'x86'
161168
command_prefix = 'i686-linux-android'
162169
platform_dir = 'arch-x86'
@@ -171,7 +178,8 @@ def get_env(self, with_flags_in_cc=True):
171178

172179
class Archx86_64(Arch):
173180
arch = 'x86_64'
174-
toolchain_prefix = 'x86'
181+
include_prefix = 'x86_64-linux-android'
182+
toolchain_prefix = 'x86_64'
175183
command_prefix = 'x86_64-linux-android'
176184
platform_dir = 'arch-x86'
177185

@@ -185,6 +193,7 @@ def get_env(self, with_flags_in_cc=True):
185193

186194
class ArchAarch_64(Arch):
187195
arch = 'arm64-v8a'
196+
include_prefix = 'aarch64-linux-android'
188197
toolchain_prefix = 'aarch64-linux-android'
189198
command_prefix = 'aarch64-linux-android'
190199
platform_dir = 'arch-arm64'

pythonforandroid/build.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
364364
# This would need to be changed if supporting multiarch APKs
365365
arch = self.archs[0]
366366
platform_dir = arch.platform_dir
367+
include_prefix = arch.include_prefix
367368
toolchain_prefix = arch.toolchain_prefix
368369
toolchain_version = None
369370
self.ndk_platform = join(
@@ -380,6 +381,13 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
380381
if py_platform in ['linux2', 'linux3']:
381382
py_platform = 'linux'
382383

384+
self.include_prefix = include_prefix
385+
include_path = join(self.ndk_dir, 'sysroot/usr/include/', self.include_prefix)
386+
if not os.path.isdir(include_path):
387+
warning('include directory doesn\'t exist: {}'.format(
388+
include_path))
389+
ok = False
390+
383391
toolchain_versions = []
384392
toolchain_path = join(self.ndk_dir, 'toolchains')
385393
if os.path.isdir(toolchain_path):
@@ -446,6 +454,7 @@ def __init__(self):
446454
self._ndk_ver = None
447455
self.ndk = None
448456

457+
self.include_prefix = None
449458
self.toolchain_prefix = None
450459
self.toolchain_version = None
451460

pythonforandroid/recipes/numpy/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ def get_recipe_env(self, arch):
4848
def prebuild_arch(self, arch):
4949
super(NumpyRecipe, self).prebuild_arch(arch)
5050

51-
warning('Numpy is built assuming the archiver name is '
52-
'arm-linux-androideabi-ar, which may not always be true!')
5351

5452

5553
recipe = NumpyRecipe()

pythonforandroid/recipes/numpy/patches/ar.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
self.mkpath(os.path.dirname(output_filename))
66
tmp_objects = objects + self.objects
77
+ from os import environ
8-
+ self.archiver[0] = 'arm-linux-androideabi-ar'
8+
+ self.archiver[0] = environ["AR"]
99
while tmp_objects:
1010
objects = tmp_objects[:50]
1111
tmp_objects = tmp_objects[50:]

0 commit comments

Comments
 (0)