Skip to content

Commit fa3a269

Browse files
author
lanmao
committed
Fix pyjnius linking with Qt bootstrap libmain
1 parent 869c74b commit fa3a269

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

pythonforandroid/recipes/pyjnius/__init__.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from pythonforandroid.toolchain import shprint, current_directory, info
33
from pythonforandroid.patching import will_build
44
import sh
5-
from os.path import join
5+
from os.path import exists, join
66

77

88
class PyjniusRecipe(PyProjectRecipe):
@@ -21,12 +21,24 @@ class PyjniusRecipe(PyProjectRecipe):
2121
def get_recipe_env(self, arch, **kwargs):
2222
env = super().get_recipe_env(arch, **kwargs)
2323

24+
generic_main_libs = (
25+
join(self.ctx.bootstrap.build_dir, 'libs', arch.arch,
26+
'libmain_{}.so'.format(arch.arch)),
27+
join(self.ctx.bootstrap.build_dir, 'obj', 'local', arch.arch,
28+
'libmain_{}.so'.format(arch.arch)),
29+
)
30+
if any(exists(lib) for lib in generic_main_libs):
31+
env['PYJNIUS_ANDROID_LIBMAIN'] = 'main_{}'.format(arch.arch)
32+
2433
# Taken from CythonRecipe
25-
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{} '.format(
26-
self.ctx.get_libs_dir(arch.arch) +
27-
' -L{} '.format(self.ctx.libs_dir) +
28-
' -L{}'.format(join(self.ctx.bootstrap.build_dir, 'obj', 'local',
29-
arch.arch)))
34+
env['LDFLAGS'] = env['LDFLAGS'] + ' ' + ' '.join([
35+
'-L{}'.format(self.ctx.get_libs_dir(arch.arch)),
36+
'-L{}'.format(self.ctx.libs_dir),
37+
'-L{}'.format(join(self.ctx.bootstrap.build_dir, 'libs',
38+
arch.arch)),
39+
'-L{}'.format(join(self.ctx.bootstrap.build_dir, 'obj', 'local',
40+
arch.arch)),
41+
])
3042
env['LDSHARED'] = env['CC'] + ' -shared'
3143
env['LIBLINK'] = 'NOTNONE'
3244

pythonforandroid/recipes/pyjnius/genericndkbuild_jnienv_getter.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ diff -Naur pyjnius.orig/jnius/env.py pyjnius/jnius/env.py
66
class AndroidJavaLocation(UnixJavaLocation):
77
def get_libraries(self):
88
- return ['SDL2', 'log']
9-
+ return ['main', 'log']
9+
+ return [getenv('PYJNIUS_ANDROID_LIBMAIN', 'main'), 'log']
1010

1111
def get_include_dirs(self):
1212
# When cross-compiling for Android, we should not use the include dirs

0 commit comments

Comments
 (0)