From 3b7f3a25196844ed8a3f41e9feefba2ad9bc955b Mon Sep 17 00:00:00 2001 From: wqh17101 <597935261@qq.com> Date: Thu, 18 Feb 2021 22:26:44 +0800 Subject: [PATCH] update preparation.sh to support specify the zbar_home and work dir Signed-off-by: wqh17101 <597935261@qq.com> --- zbar_lite/preparation.sh | 118 +++++++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 47 deletions(-) diff --git a/zbar_lite/preparation.sh b/zbar_lite/preparation.sh index 7aeb711d..16265f1c 100644 --- a/zbar_lite/preparation.sh +++ b/zbar_lite/preparation.sh @@ -1,59 +1,83 @@ #!/bin/bash set -e -mkdir -p src/zbar/ +if [[ $1 = "--help" ]] || [[ $1 = "-h" ]] +then + echo "this is a script to prepare for zbar_lite build" + help="Usage: $0 [ZBAR_SOURCE_HOME] [WORKDIR] + -h, --help print this help, then exit + ZBAR_SOURCE_HOME the zbar source code home dir which should contain dir zbar and include + WORKDIR the work dir,default is the dir which this script in + " + echo "${help}" + exit 0 +fi + +DEFAULT_WORKDIR=$(dirname $(readlink -f "$0")) +WORKDIR=${2:-$DEFAULT_WORKDIR} +ZBAR_SOURCE_HOME=${1:-$WORKDIR} + -mkdir -p src/zbar/video -cp ../zbar/video/null.c src/zbar/video/ +echo " WORKDIR is $WORKDIR" +echo " ZBAR_SOURCE_HOME is $ZBAR_SOURCE_HOME" -cp -r ../zbar/decoder src/zbar/ -cp -r ../zbar/qrcode src/zbar/ -cp -r ../zbar/processor src/zbar/ -cp -r ../zbar/window src/zbar/ +echo "copy zbar source code" +mkdir -p ${WORKDIR}/src/zbar -cp ../python/*.c zbar/ -cp ../python/*.h zbar/ +mkdir -p ${WORKDIR}/src/zbar/video +cp ${ZBAR_SOURCE_HOME}/zbar/video/null.c ${WORKDIR}/src/zbar/video/ -cp ../include/zbar.h src/ +cp -r ${ZBAR_SOURCE_HOME}/zbar/decoder ${WORKDIR}/src/zbar/ +cp -r ${ZBAR_SOURCE_HOME}/zbar/qrcode ${WORKDIR}/src/zbar/ +cp -r ${ZBAR_SOURCE_HOME}/zbar/processor ${WORKDIR}/src/zbar/ +cp -r ${ZBAR_SOURCE_HOME}/zbar/window ${WORKDIR}/src/zbar/ -if [ -f "../include/config.h" ] +cp ${ZBAR_SOURCE_HOME}/include/zbar.h ${WORKDIR}/src/ + + +if [ -f "${ZBAR_SOURCE_HOME}/include/config.h" ] then -cp ../include/config.h src/ +cp ${ZBAR_SOURCE_HOME}/include/config.h ${WORKDIR}/src/ fi -cp ../zbar/config.c src/zbar/ -cp ../zbar/convert.c src/zbar/ -cp ../zbar/debug.h src/zbar/ -cp ../zbar/decoder.c src/zbar/ -cp ../zbar/decoder.h src/zbar/ -cp ../zbar/error.c src/zbar/ -cp ../zbar/error.h src/zbar/ -cp ../zbar/event.h src/zbar/ -cp ../zbar/image.c src/zbar/ -cp ../zbar/image.h src/zbar/ -cp ../zbar/img_scanner.c src/zbar/ -cp ../zbar/img_scanner.h src/zbar/ -cp ../zbar/mutex.h src/zbar/ -cp ../zbar/qrcode.h src/zbar/ -cp ../zbar/refcnt.c src/zbar/ -cp ../zbar/refcnt.h src/zbar/ -cp ../zbar/scanner.c src/zbar/ -cp ../zbar/sqcode.c src/zbar/ -cp ../zbar/sqcode.h src/zbar/ -cp ../zbar/svg.h src/zbar/ -cp ../zbar/symbol.c src/zbar/ -cp ../zbar/symbol.h src/zbar/ -cp ../zbar/thread.h src/zbar/ -cp ../zbar/timer.h src/zbar/ -cp ../zbar/video.c src/zbar/ -cp ../zbar/video.h src/zbar/ -cp ../zbar/window.h src/zbar/ -cp ../zbar/window.c src/zbar/ -cp ../zbar/processor.c src/zbar/ -cp ../zbar/processor.h src/zbar/ - - -sed -i 's/"ISO8859-1"/"UTF-8"/g' ./src/zbar/qrcode/qrdectxt.c -sed -i 's/"BIG-5"/"UTF-8"/g' ./src/zbar/qrcode/qrdectxt.c -sed -i 's/"SJIS"/"UTF-8"/g' ./src/zbar/qrcode/qrdectxt.c +cp ${ZBAR_SOURCE_HOME}/zbar/config.c ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/convert.c ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/debug.h ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/decoder.c ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/decoder.h ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/error.c ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/error.h ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/event.h ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/image.c ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/image.h ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/img_scanner.c ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/img_scanner.h ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/mutex.h ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/qrcode.h ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/refcnt.c ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/refcnt.h ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/scanner.c ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/sqcode.c ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/sqcode.h ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/svg.h ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/symbol.c ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/symbol.h ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/thread.h ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/timer.h ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/video.c ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/video.h ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/window.h ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/window.c ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/processor.c ${WORKDIR}/src/zbar/ +cp ${ZBAR_SOURCE_HOME}/zbar/processor.h ${WORKDIR}/src/zbar/ + +echo "copy zbar python module source code" +mkdir -p ${WORKDIR}/zbar/ +cp ${ZBAR_SOURCE_HOME}/python/*.c ${WORKDIR}/zbar/ +cp ${ZBAR_SOURCE_HOME}/python/*.h ${WORKDIR}/zbar/ + +echo "set output encoding to UTF-8" +sed -i 's/"ISO8859-1"/"UTF-8"/g' ${WORKDIR}/src/zbar/qrcode/qrdectxt.c +sed -i 's/"BIG-5"/"UTF-8"/g' ${WORKDIR}/src/zbar/qrcode/qrdectxt.c +sed -i 's/"SJIS"/"UTF-8"/g' ${WORKDIR}/src/zbar/qrcode/qrdectxt.c \ No newline at end of file