Skip to content

Commit aaf2339

Browse files
committed
Merge commit '4e9fe5b1d77b4cdcd01ea1750540f3d77d5a4a4d' into electrum_20181213
(see kivy#1478)
2 parents 2e86de7 + 4e9fe5b commit aaf2339

15 files changed

Lines changed: 124 additions & 77 deletions

File tree

pythonforandroid/archs.py

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,24 @@ def include_dirs(self):
3030
d.format(arch=self))
3131
for d in self.ctx.include_dirs]
3232

33-
def get_env(self, with_flags_in_cc=True):
33+
def get_env(self, with_flags_in_cc=True, clang=False):
3434
env = {}
3535

36-
env['CFLAGS'] = ' '.join([
37-
'-DANDROID', '-mandroid', '-fomit-frame-pointer'
38-
' -D__ANDROID_API__={}'.format(self.ctx.ndk_api),
39-
])
36+
cflags = [
37+
'-DANDROID',
38+
'-fomit-frame-pointer',
39+
'-D__ANDROID_API__={}'.format(self.ctx.ndk_api)]
40+
if not clang:
41+
cflags += ['-mandroid']
42+
else:
43+
cflags += ['-target armv7-none-linux-androideabi']
44+
android_host = 'arm-linux-androideabi'
45+
platform_dir = join(self.ctx.ndk_dir, 'platforms', 'android-{}'.format(self.ctx.ndk_api), 'arch-arm')
46+
toolchain = '{android_host}-4.9'.format(android_host=android_host)
47+
toolchain = join(self.ctx.ndk_dir, 'toolchains', toolchain, 'prebuilt', 'linux-x86_64')
48+
cflags += ['-gcc-toolchain {}'.format(toolchain)]
49+
50+
env['CFLAGS'] = ' '.join(cflags)
4051
env['LDFLAGS'] = ' '
4152

4253
sysroot = join(self.ctx._ndk_dir, 'sysroot')
@@ -82,9 +93,21 @@ def get_env(self, with_flags_in_cc=True):
8293
env['NDK_CCACHE'] = self.ctx.ccache
8394
env.update({k: v for k, v in environ.items() if k.startswith('CCACHE_')})
8495

85-
cc = find_executable('{command_prefix}-gcc'.format(
86-
command_prefix=command_prefix), path=environ['PATH'])
96+
if clang:
97+
clang_path = join(
98+
self.ctx.ndk_dir, 'toolchains', 'llvm', 'prebuilt',
99+
'linux-x86_64', 'bin')
100+
environ['PATH'] = '{clang_path}:{path}'.format(
101+
clang_path=clang_path, path=environ['PATH'])
102+
exe = join(clang_path, 'clang')
103+
execxx = join(clang_path, 'clang++')
104+
else:
105+
exe = '{command_prefix}-gcc'.format(command_prefix=command_prefix)
106+
execxx = '{command_prefix}-g++'.format(command_prefix=command_prefix)
107+
108+
cc = find_executable(exe, path=environ['PATH'])
87109
if cc is None:
110+
print(environ['PATH'])
88111
print('Searching path are: {!r}'.format(environ['PATH']))
89112
warning('Couldn\'t find executable for CC. This indicates a '
90113
'problem locating the {} executable in the Android '
@@ -93,20 +116,20 @@ def get_env(self, with_flags_in_cc=True):
93116
exit(1)
94117

95118
if with_flags_in_cc:
96-
env['CC'] = '{ccache}{command_prefix}-gcc {cflags}'.format(
97-
command_prefix=command_prefix,
119+
env['CC'] = '{ccache}{exe} {cflags}'.format(
120+
exe=exe,
98121
ccache=ccache,
99122
cflags=env['CFLAGS'])
100-
env['CXX'] = '{ccache}{command_prefix}-g++ {cxxflags}'.format(
101-
command_prefix=command_prefix,
123+
env['CXX'] = '{ccache}{execxx} {cxxflags}'.format(
124+
execxx=execxx,
102125
ccache=ccache,
103126
cxxflags=env['CXXFLAGS'])
104127
else:
105-
env['CC'] = '{ccache}{command_prefix}-gcc'.format(
106-
command_prefix=command_prefix,
128+
env['CC'] = '{ccache}{exe}'.format(
129+
exe=exe,
107130
ccache=ccache)
108-
env['CXX'] = '{ccache}{command_prefix}-g++'.format(
109-
command_prefix=command_prefix,
131+
env['CXX'] = '{ccache}{execxx}'.format(
132+
execxx=execxx,
110133
ccache=ccache)
111134

112135
env['AR'] = '{}-ar'.format(command_prefix)
@@ -151,8 +174,8 @@ class ArchARM(Arch):
151174
class ArchARMv7_a(ArchARM):
152175
arch = 'armeabi-v7a'
153176

154-
def get_env(self, with_flags_in_cc=True):
155-
env = super(ArchARMv7_a, self).get_env(with_flags_in_cc)
177+
def get_env(self, with_flags_in_cc=True, clang=False):
178+
env = super(ArchARMv7_a, self).get_env(with_flags_in_cc, clang=clang)
156179
env['CFLAGS'] = (env['CFLAGS'] +
157180
(' -march=armv7-a -mfloat-abi=softfp '
158181
'-mfpu=vfp -mthumb'))
@@ -166,8 +189,8 @@ class Archx86(Arch):
166189
command_prefix = 'i686-linux-android'
167190
platform_dir = 'arch-x86'
168191

169-
def get_env(self, with_flags_in_cc=True):
170-
env = super(Archx86, self).get_env(with_flags_in_cc)
192+
def get_env(self, with_flags_in_cc=True, clang=False):
193+
env = super(Archx86, self).get_env(with_flags_in_cc, clang=clang)
171194
env['CFLAGS'] = (env['CFLAGS'] +
172195
' -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32')
173196
env['CXXFLAGS'] = env['CFLAGS']
@@ -180,8 +203,8 @@ class Archx86_64(Arch):
180203
command_prefix = 'x86_64-linux-android'
181204
platform_dir = 'arch-x86_64'
182205

183-
def get_env(self, with_flags_in_cc=True):
184-
env = super(Archx86_64, self).get_env(with_flags_in_cc)
206+
def get_env(self, with_flags_in_cc=True, clang=False):
207+
env = super(Archx86_64, self).get_env(with_flags_in_cc, clang=clang)
185208
env['CFLAGS'] = (env['CFLAGS'] +
186209
' -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel')
187210
env['CXXFLAGS'] = env['CFLAGS']
@@ -194,8 +217,8 @@ class ArchAarch_64(Arch):
194217
command_prefix = 'aarch64-linux-android'
195218
platform_dir = 'arch-arm64'
196219

197-
def get_env(self, with_flags_in_cc=True):
198-
env = super(ArchAarch_64, self).get_env(with_flags_in_cc)
220+
def get_env(self, with_flags_in_cc=True, clang=False):
221+
env = super(ArchAarch_64, self).get_env(with_flags_in_cc, clang=clang)
199222
incpath = ' -I' + join(dirname(__file__), 'includes', 'arm64-v8a')
200223
env['EXTRA_CFLAGS'] = incpath
201224
env['CFLAGS'] += incpath

pythonforandroid/distribution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def get_distribution(cls, ctx, name=None, recipes=[],
129129
# If there was a name match but we didn't already choose it,
130130
# then the existing dist is incompatible with the requested
131131
# configuration and the build cannot continue
132-
if name_match_dist is not None and not allow_replace_dist:
132+
if name_match_dist is not None:
133133
error('Asked for dist with name {name} with recipes ({req_recipes}) and '
134134
'NDK API {req_ndk_api}, but a dist '
135135
'with this name already exists and has either incompatible recipes '

pythonforandroid/recipe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,12 @@ def unpack(self, arch):
406406
else:
407407
info('{} is already unpacked, skipping'.format(self.name))
408408

409-
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
409+
def get_recipe_env(self, arch=None, with_flags_in_cc=True, clang=False):
410410
"""Return the env specialized for the recipe
411411
"""
412412
if arch is None:
413413
arch = self.filtered_archs[0]
414-
return arch.get_env(with_flags_in_cc=with_flags_in_cc)
414+
return arch.get_env(with_flags_in_cc=with_flags_in_cc, clang=clang)
415415

416416
def prebuild_arch(self, arch):
417417
'''Run any pre-build tasks for the Recipe. By default, this checks if

pythonforandroid/recipes/android/src/android/_android.pyx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ IF BOOTSTRAP == 'pygame':
99

1010
def check_pause():
1111
return SDL_ANDROID_CheckPause()
12-
12+
1313
def wait_for_resume():
1414
android_accelerometer_enable(False)
1515
SDL_ANDROID_WaitForResume()
1616
android_accelerometer_enable(accelerometer_enabled)
17-
17+
1818
def map_key(scancode, keysym):
1919
SDL_ANDROID_MapKey(scancode, keysym)
2020

@@ -300,16 +300,16 @@ IF IS_PYGAME:
300300
j_chooser_title = <bytes>chooser_title
301301
android_action_send(j_mimetype, j_filename, j_subject, j_text,
302302
j_chooser_title)
303-
303+
304304
cdef extern int android_checkstop()
305305
cdef extern void android_ackstop()
306-
306+
307307
def check_stop():
308308
return android_checkstop()
309-
309+
310310
def ack_stop():
311311
android_ackstop()
312-
312+
313313
# -------------------------------------------------------------------
314314
# URL Opening.
315315
def open_url(url):
@@ -330,7 +330,7 @@ class AndroidBrowser(object):
330330
return open_url(url)
331331
def open_new_tab(self, url):
332332
return open_url(url)
333-
333+
334334
import webbrowser
335335
webbrowser.register('android', AndroidBrowser)
336336

@@ -381,5 +381,3 @@ class AndroidService(object):
381381
'''Stop the service.
382382
'''
383383
stop_service()
384-
385-

pythonforandroid/recipes/cryptography/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def get_recipe_env(self, arch):
1717
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
1818
env['CFLAGS'] += ' -I' + join(openssl_dir, 'include')
1919
env['LDFLAGS'] += ' -L' + openssl_dir + \
20-
' -lssl' + r.version + \
21-
' -lcrypto' + r.version
20+
' -lssl' + r.lib_version + \
21+
' -lcrypto' + r.lib_version
2222

2323
return env
2424

pythonforandroid/recipes/dateutil/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class DateutilRecipe(PythonRecipe):
66
version = '2.6.0'
77
url = 'https://pypi.python.org/packages/51/fc/39a3fbde6864942e8bb24c93663734b74e281b984d1b8c4f95d64b0c21f6/python-dateutil-2.6.0.tar.gz'
88

9-
depends = ['python2', "setuptools"]
9+
depends = [('python2', 'python3'), "setuptools"]
1010
call_hostpython_via_targetpython = False
1111
install_in_hostpython = True
1212

pythonforandroid/recipes/libcurl/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ def build_arch(self, arch):
2020
r = self.get_recipe('openssl', self.ctx)
2121
openssl_dir = r.get_build_dir(arch.arch)
2222

23+
# with-ssl assume the libcrypto is in lib/ subdirectory
24+
# but it will be within the openssl_dir directory directly.
25+
env["LDFLAGS"] += " -L{}".format(openssl_dir)
26+
2327
with current_directory(self.get_build_dir(arch.arch)):
2428
dst_dir = join(self.get_build_dir(arch.arch), 'dist')
2529
shprint(

pythonforandroid/recipes/libtorrent/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def get_recipe_env(self, arch):
7272
if 'openssl' in recipe.ctx.recipe_build_order:
7373
r = self.get_recipe('openssl', self.ctx)
7474
env['OPENSSL_BUILD_PATH'] = r.get_build_dir(arch.arch)
75-
env['OPENSSL_VERSION'] = r.version
75+
env['OPENSSL_VERSION'] = r.lib_version
7676
return env
7777

7878

pythonforandroid/recipes/openssl/__init__.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55

66

77
class OpenSSLRecipe(Recipe):
8-
version = '1.0.2h'
8+
version = '1.1.1'
9+
lib_version = '1.1'
910
url = 'https://www.openssl.org/source/openssl-{version}.tar.gz'
1011

1112
def should_build(self, arch):
12-
return not self.has_libs(arch, 'libssl' + self.version + '.so',
13-
'libcrypto' + self.version + '.so')
13+
return not self.has_libs(arch, 'libssl' + self.lib_version + '.so',
14+
'libcrypto' + self.lib_version + '.so')
1415

1516
def check_symbol(self, env, sofile, symbol):
1617
nm = env.get('NM', 'nm')
@@ -22,19 +23,18 @@ def check_symbol(self, env, sofile, symbol):
2223
return False
2324

2425
def get_recipe_env(self, arch=None):
25-
env = super(OpenSSLRecipe, self).get_recipe_env(arch)
26-
env['OPENSSL_VERSION'] = self.version
27-
env['CFLAGS'] += ' ' + env['LDFLAGS']
28-
env['CC'] += ' ' + env['LDFLAGS']
26+
env = super(OpenSSLRecipe, self).get_recipe_env(arch, clang=True)
27+
env['OPENSSL_VERSION'] = self.lib_version
2928
env['MAKE'] = 'make' # This removes the '-j5', which isn't safe
29+
env['ANDROID_NDK'] = self.ctx.ndk_dir
3030
return env
3131

3232
def select_build_arch(self, arch):
3333
aname = arch.arch
3434
if 'arm64' in aname:
3535
return 'linux-aarch64'
3636
if 'v7a' in aname:
37-
return 'android-armv7'
37+
return 'android-arm'
3838
if 'arm' in aname:
3939
return 'android'
4040
if 'x86' in aname:
@@ -48,20 +48,27 @@ def build_arch(self, arch):
4848
# so instead we manually run perl passing in Configure
4949
perl = sh.Command('perl')
5050
buildarch = self.select_build_arch(arch)
51-
shprint(perl, 'Configure', 'shared', 'no-dso', 'no-krb5', buildarch, _env=env)
51+
# XXX if we don't have no-asm, using clang and ndk-15c, i got:
52+
# crypto/aes/bsaes-armv7.S:1372:14: error: immediate operand must be in the range [0,4095]
53+
# add r8, r6, #.LREVM0SR-.LM0 @ borrow r8
54+
# ^
55+
# crypto/aes/bsaes-armv7.S:1434:14: error: immediate operand must be in the range [0,4095]
56+
# sub r6, r8, #.LREVM0SR-.LSR @ pass constants
57+
shprint(perl, 'Configure', 'shared', 'no-dso', 'no-asm', buildarch, _env=env)
5258
self.apply_patch('disable-sover.patch', arch.arch)
53-
self.apply_patch('rename-shared-lib.patch', arch.arch)
5459

5560
# check_ssl = partial(self.check_symbol, env, 'libssl' + self.version + '.so')
56-
check_crypto = partial(self.check_symbol, env, 'libcrypto' + self.version + '.so')
61+
check_crypto = partial(self.check_symbol, env, 'libcrypto' + self.lib_version + '.so')
5762
while True:
5863
shprint(sh.make, 'build_libs', _env=env)
59-
if all(map(check_crypto, ('SSLeay', 'MD5_Transform', 'MD4_Init'))):
64+
if all(map(check_crypto, ('MD5_Transform', 'MD4_Init'))):
6065
break
66+
import time
67+
time.sleep(3)
6168
shprint(sh.make, 'clean', _env=env)
6269

63-
self.install_libs(arch, 'libssl' + self.version + '.so',
64-
'libcrypto' + self.version + '.so')
70+
self.install_libs(arch, 'libssl' + self.lib_version + '.so',
71+
'libcrypto' + self.lib_version + '.so')
6572

6673

6774
recipe = OpenSSLRecipe()
Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
--- openssl/Makefile 2016-01-28 17:26:49.159522273 +0100
2-
+++ b/Makefile 2016-01-28 17:26:54.358438402 +0100
3-
@@ -342,7 +342,7 @@
4-
link-shared:
5-
@ set -e; for i in $(SHLIBDIRS); do \
6-
$(MAKE) -f $(HERE)/Makefile.shared -e $(BUILDENV) \
7-
- LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
8-
+ LIBNAME=$$i LIBVERSION= \
9-
LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
10-
symlink.$(SHLIB_TARGET); \
11-
libs="$$libs -l$$i"; \
12-
@@ -356,7 +356,7 @@
13-
libs="$(LIBKRB5) $$libs"; \
14-
fi; \
15-
$(CLEARENV) && $(MAKE) -f Makefile.shared -e $(BUILDENV) \
16-
- LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
17-
+ LIBNAME=$$i LIBVERSION= \
18-
LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
19-
LIBDEPS="$$libs $(EX_LIBS)" \
20-
link_a.$(SHLIB_TARGET); \
1+
--- openssl/Makefile.orig 2018-10-20 22:49:40.418310423 +0200
2+
+++ openssl/Makefile 2018-10-20 22:50:23.347322403 +0200
3+
@@ -19,7 +19,7 @@
4+
SHLIB_MAJOR=1
5+
SHLIB_MINOR=1
6+
SHLIB_TARGET=linux-shared
7+
-SHLIB_EXT=.so.$(SHLIB_VERSION_NUMBER)
8+
+SHLIB_EXT=$(SHLIB_VERSION_NUMBER).so
9+
SHLIB_EXT_SIMPLE=.so
10+
SHLIB_EXT_IMPORT=
11+

0 commit comments

Comments
 (0)