Skip to content

Commit 45a3d8a

Browse files
authored
Merge pull request #1583 from opacam/rework-zbar
[WIP] Rework zbar (add python3 compatibility + add recipes: pyzbar and zbarlight)
2 parents 4b4d55a + fc9acde commit 45a3d8a

File tree

4 files changed

+61
-13
lines changed

4 files changed

+61
-13
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()

pythonforandroid/recipes/zbar/__init__.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import os
1+
from os.path import join
22
from pythonforandroid.recipe import PythonRecipe
33

44

@@ -15,7 +15,9 @@ class ZBarRecipe(PythonRecipe):
1515

1616
call_hostpython_via_targetpython = False
1717

18-
depends = ['hostpython2', 'python2', 'setuptools', 'libzbar']
18+
depends = [('hostpython2legacy', 'hostpython2'),
19+
('python2legacy', 'python2'),
20+
'setuptools', 'libzbar']
1921

2022
patches = ["zbar-0.10-python-crash.patch"]
2123

@@ -24,13 +26,9 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
2426
libzbar = self.get_recipe('libzbar', self.ctx)
2527
libzbar_dir = libzbar.get_build_dir(arch.arch)
2628
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
27-
env['CFLAGS'] += ' -I' + os.path.join(libzbar_dir, 'include')
28-
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7'
29-
# TODO
30-
env['LDSHARED'] = env['CC'] + \
31-
' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
32-
# TODO: hardcoded Python version
33-
env['LDFLAGS'] += " -landroid -lpython2.7 -lzbar"
29+
env['CFLAGS'] += ' -I' + join(libzbar_dir, 'include')
30+
env['LDFLAGS'] += ' -L' + join(libzbar_dir, 'zbar', '.libs')
31+
env['LIBS'] = env.get('LIBS', '') + ' -landroid -lzbar'
3432
return env
3533

3634

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 ZBarLightRecipe(PythonRecipe):
6+
7+
version = '2.1'
8+
9+
url = 'https://github.com/Polyconseil/zbarlight/archive/{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(ZBarLightRecipe, 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 = ZBarLightRecipe()

0 commit comments

Comments
 (0)