Adding Zbar Light and Libzbar recipes (#359)
* Adding receipes for zbar camera Adding recipes for libzbar and zbarlight for ios bar code scanning. * removed shprint Removed unnecessary shprint
This commit is contained in:
parent
ee7abed8dc
commit
c4852a4b97
4 changed files with 144 additions and 0 deletions
56
recipes/libzbar/__init__.py
Executable file
56
recipes/libzbar/__init__.py
Executable file
|
@ -0,0 +1,56 @@
|
|||
from toolchain import Recipe,shprint
|
||||
from os.path import join
|
||||
import sh
|
||||
import os
|
||||
|
||||
class LibZBarRecipe(Recipe):
|
||||
|
||||
version = '0.10'
|
||||
|
||||
url = 'https://github.com/ZBar/ZBar/archive/{version}.zip'
|
||||
|
||||
depends = ['hostpython2']
|
||||
|
||||
library = 'zbar/.libs/libzbar.a'
|
||||
|
||||
include_per_arch = True
|
||||
include_dir = [
|
||||
("include", "")
|
||||
]
|
||||
|
||||
def prebuild_arch(self, arch):
|
||||
if self.has_marker("patched"):
|
||||
return
|
||||
self.apply_patch("werror.patch")
|
||||
self.set_marker("patched")
|
||||
|
||||
def build_arch(self, arch):
|
||||
super(LibZBarRecipe, self).build_arch(arch)
|
||||
build_env = arch.get_env()
|
||||
build_env["CFLAGS"] = " ".join([
|
||||
"-I{}".format(join(self.ctx.dist_dir, "build","libiconv",arch.arch)) +
|
||||
" -arch {}".format(arch.arch),build_env['CFLAGS']
|
||||
])
|
||||
shprint(sh.Command('autoreconf') ,'-vif')
|
||||
shprint(sh.Command('./configure'),
|
||||
"CC={}".format(build_env["CC"]),
|
||||
"LD={}".format(build_env["LD"]),
|
||||
"CFLAGS={}".format(build_env["CFLAGS"]),
|
||||
"LDFLAGS={}".format(build_env["LDFLAGS"]),
|
||||
"--host={}".format(arch.triple),
|
||||
'--target={}'.format(arch.triple),
|
||||
# Python bindings are compiled in a separated recipe
|
||||
'--with-python=no',
|
||||
'--with-gtk=no',
|
||||
'--with-qt=no',
|
||||
'--with-x=no',
|
||||
'--with-jpeg=no',
|
||||
'--with-imagemagick=no',
|
||||
'--enable-pthread=no',
|
||||
'--enable-video=no',
|
||||
"--disable-shared",
|
||||
_env=build_env)
|
||||
shprint(sh.make, 'clean')
|
||||
shprint(sh.make, _env=build_env)
|
||||
|
||||
recipe = LibZBarRecipe()
|
13
recipes/libzbar/werror.patch
Executable file
13
recipes/libzbar/werror.patch
Executable file
|
@ -0,0 +1,13 @@
|
|||
diff --git a/configure.ac b/configure.ac
|
||||
index 256aedb..727caba 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -3,7 +3,7 @@ AC_PREREQ([2.61])
|
||||
AC_INIT([zbar], [0.10], [spadix@users.sourceforge.net])
|
||||
AC_CONFIG_AUX_DIR(config)
|
||||
AC_CONFIG_MACRO_DIR(config)
|
||||
-AM_INIT_AUTOMAKE([1.10 -Wall -Werror foreign subdir-objects std-options dist-bzip2])
|
||||
+AM_INIT_AUTOMAKE([1.10 -Wall foreign subdir-objects std-options dist-bzip2])
|
||||
AC_CONFIG_HEADERS([include/config.h])
|
||||
AC_CONFIG_SRCDIR(zbar/scanner.c)
|
||||
LT_PREREQ([2.2])
|
69
recipes/zbarlight/__init__.py
Executable file
69
recipes/zbarlight/__init__.py
Executable file
|
@ -0,0 +1,69 @@
|
|||
import os
|
||||
from toolchain import Recipe
|
||||
from os.path import join
|
||||
import sh
|
||||
import fnmatch
|
||||
from distutils.dir_util import copy_tree
|
||||
|
||||
class ZbarLightRecipe(Recipe):
|
||||
version = '1.2'
|
||||
url = 'https://github.com/Polyconseil/zbarlight/archive/{version}.tar.gz'
|
||||
library = "zbarlight.a"
|
||||
depends = ['hostpython2','python2', 'libzbar']
|
||||
pbx_libraries = ["libz","libbz2",'libc++','libsqlite3','CoreMotion']
|
||||
include_per_arch = True
|
||||
|
||||
def get_zbar_env(self, arch):
|
||||
build_env = arch.get_env()
|
||||
dest_dir = join(self.ctx.dist_dir, "root", "python")
|
||||
build_env["IOSROOT"] = self.ctx.root_dir
|
||||
build_env["IOSSDKROOT"] = arch.sysroot
|
||||
build_env["LDSHARED"] = join(self.ctx.root_dir, "tools", "liblink")
|
||||
build_env["ARM_LD"] = build_env["LD"]
|
||||
build_env["ARCH"] = arch.arch
|
||||
build_env["C_INCLUDE_PATH"] = join(arch.sysroot, "usr", "include")
|
||||
build_env["LIBRARY_PATH"] = join(arch.sysroot, "usr", "lib")
|
||||
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
|
||||
build_env["CFLAGS"] = " ".join([
|
||||
" -I{}".format(join(self.ctx.dist_dir, "include", arch.arch, "libzbar",'zbar')) +
|
||||
" -arch {}".format(arch.arch)
|
||||
])
|
||||
build_env['LDFLAGS'] += " -lios -lpython -lzbar"
|
||||
return build_env
|
||||
|
||||
def build_arch(self, arch):
|
||||
build_env = self.get_zbar_env(arch)
|
||||
hostpython = sh.Command(self.ctx.hostpython)
|
||||
shprint(hostpython, "setup.py", "build",
|
||||
_env=build_env)
|
||||
self.apply_patch("zbarlight_1_2.patch")#Issue getting the version, hard coding for now
|
||||
self.biglink()
|
||||
|
||||
def install(self):
|
||||
arch = list(self.filtered_archs)[0]
|
||||
build_dir = join(self.get_build_dir(arch.arch),'build','lib.macosx-10.13-x86_64-2.7','zbarlight')
|
||||
dist_dir = join(self.ctx.dist_dir,'root','python2','lib','python2.7','site-packages','zbarlight')
|
||||
#Patch before Copying
|
||||
#self.apply_patch("zbarlight_1_2.patch")#Issue getting the version, hard coding for now
|
||||
copy_tree(build_dir, dist_dir)
|
||||
os.remove(join(dist_dir,'_zbarlight.c'))
|
||||
|
||||
|
||||
def _patch__init__(self):
|
||||
init = join(self.ctx.dist_dir,'root','python2','lib','python2.7',
|
||||
'site-packages','zbarlight', "__init__.py")
|
||||
shprint(
|
||||
sh.sed, "-i.bak",
|
||||
"s/__version__ = pkg_resources.get_distribution('zbarlight').version'"
|
||||
"/__version__ = '{version}'/g",
|
||||
init)
|
||||
|
||||
def biglink(self):
|
||||
dirs = []
|
||||
for root, dirnames, filenames in os.walk(self.build_dir):
|
||||
if fnmatch.filter(filenames, "*.so.libs"):
|
||||
dirs.append(root)
|
||||
cmd = sh.Command(join(self.ctx.root_dir, "tools", "biglink"))
|
||||
shprint(cmd, join(self.build_dir, "zbarlight.a"), *dirs)
|
||||
|
||||
recipe = ZbarLightRecipe()
|
6
recipes/zbarlight/zbarlight_1_2.patch
Executable file
6
recipes/zbarlight/zbarlight_1_2.patch
Executable file
|
@ -0,0 +1,6 @@
|
|||
--- zbarlight-1.2/build/lib.macosx-10.13-x86_64-2.7/zbarlight/__init__.py
|
||||
+++ zbarlight-1.2/build/lib.macosx-10.13-x86_64-2.7/zbarlight/__init__.py
|
||||
@@ -10,1 +10,1 @@
|
||||
-__version__ = pkg_resources.get_distribution('zbarlight').version
|
||||
+__version__ = '1.2'
|
||||
|
Loading…
Reference in a new issue