Skip to content

Commit

Permalink
Merge pull request #1583 from opacam/rework-zbar
Browse files Browse the repository at this point in the history
[WIP] Rework zbar (add python3 compatibility + add recipes: pyzbar and zbarlight)
  • Loading branch information
AndreMiras authored Jan 21, 2019
2 parents 4b4d55a + fc9acde commit 45a3d8a
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 13 deletions.
6 changes: 2 additions & 4 deletions pythonforandroid/recipes/libzbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class LibZBarRecipe(Recipe):

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

depends = ['hostpython2', 'python2', 'libiconv']
depends = ['libiconv']

patches = ["werror.patch"]

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

def build_arch(self, arch):
Expand Down
26 changes: 26 additions & 0 deletions pythonforandroid/recipes/pyzbar/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from os.path import join
from pythonforandroid.recipe import PythonRecipe


class PyZBarRecipe(PythonRecipe):

version = '0.1.7'

url = 'https://github.com/NaturalHistoryMuseum/pyzbar/archive/v{version}.tar.gz' # noqa

call_hostpython_via_targetpython = False

depends = ['setuptools', 'libzbar']

def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super(PyZBarRecipe, self).get_recipe_env(arch, with_flags_in_cc)
libzbar = self.get_recipe('libzbar', self.ctx)
libzbar_dir = libzbar.get_build_dir(arch.arch)
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
env['CFLAGS'] += ' -I' + join(libzbar_dir, 'include')
env['LDFLAGS'] += ' -L' + join(libzbar_dir, 'zbar', '.libs')
env['LIBS'] = env.get('LIBS', '') + ' -landroid -lzbar'
return env


recipe = PyZBarRecipe()
16 changes: 7 additions & 9 deletions pythonforandroid/recipes/zbar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os
from os.path import join
from pythonforandroid.recipe import PythonRecipe


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

call_hostpython_via_targetpython = False

depends = ['hostpython2', 'python2', 'setuptools', 'libzbar']
depends = [('hostpython2legacy', 'hostpython2'),
('python2legacy', 'python2'),
'setuptools', 'libzbar']

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

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


Expand Down
26 changes: 26 additions & 0 deletions pythonforandroid/recipes/zbarlight/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from os.path import join
from pythonforandroid.recipe import PythonRecipe


class ZBarLightRecipe(PythonRecipe):

version = '2.1'

url = 'https://github.com/Polyconseil/zbarlight/archive/{version}.tar.gz' # noqa

call_hostpython_via_targetpython = False

depends = ['setuptools', 'libzbar']

def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super(ZBarLightRecipe, self).get_recipe_env(arch, with_flags_in_cc)
libzbar = self.get_recipe('libzbar', self.ctx)
libzbar_dir = libzbar.get_build_dir(arch.arch)
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
env['CFLAGS'] += ' -I' + join(libzbar_dir, 'include')
env['LDFLAGS'] += ' -L' + join(libzbar_dir, 'zbar', '.libs')
env['LIBS'] = env.get('LIBS', '') + ' -landroid -lzbar'
return env


recipe = ZBarLightRecipe()

0 comments on commit 45a3d8a

Please sign in to comment.