Skip to content

Commit 49bffd5

Browse files
committed
Add pyzbar recipe and remove duplicated flags for libzbar
The libzbar recipe contains some flags already set in base class method of get_recipe_env, so removed. Also grants python3 compatibility for libzbar because, despite that the zbar recipe isn't compatible with python3 (the project is stucked in python2 plus it seems unmaintained)...but there are alternatives which can replace it, so we add the pyzbar recipe which works for both versions of python so python3 will have an equivalent to the python2's zbar. Also moved libraries from LDFLAGS to LIBS.
1 parent 1624564 commit 49bffd5

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

pythonforandroid/recipes/libzbar/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class LibZBarRecipe(Recipe):
1111

1212
url = 'https://github.com/ZBar/ZBar/archive/{version}.zip'
1313

14-
depends = ['hostpython2', 'python2', 'libiconv']
14+
depends = ['libiconv']
1515

1616
patches = ["werror.patch"]
1717

@@ -24,9 +24,7 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
2424
libiconv = self.get_recipe('libiconv', self.ctx)
2525
libiconv_dir = libiconv.get_build_dir(arch.arch)
2626
env['CFLAGS'] += ' -I' + os.path.join(libiconv_dir, 'include')
27-
env['LDSHARED'] = env['CC'] + \
28-
' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
29-
env['LDFLAGS'] += " -landroid -liconv"
27+
env['LIBS'] = env.get('LIBS', '') + ' -landroid -liconv'
3028
return env
3129

3230
def build_arch(self, arch):
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from os.path import join
2+
from pythonforandroid.recipe import PythonRecipe
3+
4+
5+
class PyZBarRecipe(PythonRecipe):
6+
7+
version = '0.1.7'
8+
9+
url = 'https://github.com/NaturalHistoryMuseum/pyzbar/archive/v{version}.tar.gz' # noqa
10+
11+
call_hostpython_via_targetpython = False
12+
13+
depends = ['setuptools', 'libzbar']
14+
15+
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
16+
env = super(PyZBarRecipe, self).get_recipe_env(arch, with_flags_in_cc)
17+
libzbar = self.get_recipe('libzbar', self.ctx)
18+
libzbar_dir = libzbar.get_build_dir(arch.arch)
19+
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
20+
env['CFLAGS'] += ' -I' + join(libzbar_dir, 'include')
21+
env['LDFLAGS'] += ' -L' + join(libzbar_dir, 'zbar', '.libs')
22+
env['LIBS'] = env.get('LIBS', '') + ' -landroid -lzbar'
23+
return env
24+
25+
26+
recipe = PyZBarRecipe()

0 commit comments

Comments
 (0)