2023-07-13 09:00:13 +00:00
|
|
|
# Main and minor version definition
|
|
|
|
# usage: ./build.sh oem pid ---> ./build.sh hg 200
|
|
|
|
|
|
|
|
@echo off
|
|
|
|
# clear
|
|
|
|
|
|
|
|
oem=$1 #厂商
|
|
|
|
pid=$2
|
|
|
|
cpu=$(arch) #cpu架构
|
|
|
|
sys=$(cat /etc/issue)
|
|
|
|
sys=${sys%% *} #操作系统
|
|
|
|
|
|
|
|
|
|
|
|
cp CMakeLists.txt CMakeLists.txtbkp
|
|
|
|
|
|
|
|
# replace oem, pid, os and cpu ...
|
|
|
|
if [ "$oem" == "hw" ]; then
|
2023-07-15 01:39:55 +00:00
|
|
|
sed -i "s/hgtwain/hwtwain/g" CMakeLists.txt
|
2023-07-13 09:00:13 +00:00
|
|
|
sed -i "s/DOEM_NONE/DOEM_HANWANG/g" CMakeLists.txt
|
|
|
|
elif [ "$oem" == "lsc" ]; then
|
2023-07-15 01:39:55 +00:00
|
|
|
sed -i "s/hgtwain/lsctwain/g" CMakeLists.txt
|
2023-07-13 09:00:13 +00:00
|
|
|
sed -i "s/DOEM_NONE/DOEM_LISICHENG/g" CMakeLists.txt
|
|
|
|
elif [ "$oem" == "cts" ]; then
|
2023-07-15 01:39:55 +00:00
|
|
|
sed -i "s/hgtwain/ctstwain/g" CMakeLists.txt
|
2023-07-13 09:00:13 +00:00
|
|
|
sed -i "s/DOEM_NONE/DOEM_CANGTIAN/g" CMakeLists.txt
|
|
|
|
|
|
|
|
elif [ "$oem" == "zj" ]; then
|
2023-07-15 01:39:55 +00:00
|
|
|
sed -i "s/hgtwain/zjtwain/g" CMakeLists.txt
|
2023-07-13 09:00:13 +00:00
|
|
|
sed -i "s/DOEM_NONE/DOEM_ZHONGJING/g" CMakeLists.txt
|
|
|
|
elif [ "$oem" == "zg" ]; then
|
2023-07-15 01:39:55 +00:00
|
|
|
sed -i "s/hgtwain/zgtwain/g" CMakeLists.txt
|
2023-07-13 09:00:13 +00:00
|
|
|
sed -i "s/DOEM_NONE/DOEM_ZIGUANG/g" CMakeLists.txt
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$pid" == "" ]; then
|
|
|
|
pid=200
|
|
|
|
fi
|
|
|
|
|
2023-07-20 09:20:00 +00:00
|
|
|
sed -i "s/DPRODUCT_PID=0x200/DPRODUCT_PID=0x${pid}/g" CMakeLists.txt
|
2023-07-13 09:00:13 +00:00
|
|
|
|
|
|
|
if [ "$sys" == "UnionTech" ];
|
|
|
|
then
|
|
|
|
sys="uos"
|
|
|
|
elif [ "$sys" == "Kylin" ];
|
|
|
|
then
|
|
|
|
sys="kylin"
|
|
|
|
else
|
|
|
|
echo "Other linux: "${sys}", change to 'kylin'."
|
|
|
|
sys="kylin"
|
|
|
|
fi
|
|
|
|
|
|
|
|
sed -i "s/kylin/"${sys}"/g" CMakeLists.txt
|
|
|
|
sed -i "s/x86_64/"${cpu}"/g" CMakeLists.txt
|
|
|
|
|
2023-07-10 07:28:45 +00:00
|
|
|
|
|
|
|
origin_dir=$(pwd)
|
|
|
|
|
|
|
|
echo origin path is $origin_dir
|
|
|
|
|
|
|
|
if [ -f ../../build/twain/Makefile ]; then
|
|
|
|
echo ""
|
|
|
|
else
|
2023-07-14 03:35:50 +00:00
|
|
|
mkdir ../../../build
|
|
|
|
mkdir ../../../build/twainds
|
2023-07-10 07:28:45 +00:00
|
|
|
fi
|
|
|
|
|
2023-07-14 03:35:50 +00:00
|
|
|
cd ../../../build/twainds
|
2023-07-10 07:28:45 +00:00
|
|
|
echo building path is $(pwd)
|
|
|
|
rm -rf ./*
|
|
|
|
cmake $origin_dir
|
|
|
|
make -j4
|
2023-07-13 09:00:13 +00:00
|
|
|
|
|
|
|
if [ $? -ne 0 ];then
|
|
|
|
|
|
|
|
err=1
|
|
|
|
echo "--------------------------------------make fail---------------------------------------"
|
|
|
|
# commented, we should restore the CMakeLists.txts...
|
|
|
|
else
|
|
|
|
err=0
|
|
|
|
echo "--------------------------------------make succeed------------------------------------"
|
|
|
|
mv ../../release/${sys}/${cpu}/lib${oem}twain.so ../../release/${sys}/${cpu}/lib${oem}twain${pid}.ds
|
|
|
|
fi
|
|
|
|
|
2023-07-14 03:35:50 +00:00
|
|
|
if [ -f ../../code_device/twain/ds/CMakeLists.txtbkp ]; then
|
|
|
|
mv ../../code_device/twain/ds/CMakeLists.txtbkp ../../code_device/twain/ds/CMakeLists.txt
|
2023-07-13 09:00:13 +00:00
|
|
|
pwd
|
|
|
|
fi
|
|
|
|
|
2023-07-10 07:28:45 +00:00
|
|
|
cd $origin_dir
|
|
|
|
|
2023-07-13 09:00:13 +00:00
|
|
|
exit $err
|
|
|
|
|
|
|
|
|
2023-07-14 03:35:50 +00:00
|
|
|
if [ "$3" == "" ]; then
|
|
|
|
echo -------copy DS to system directory ...-------
|
|
|
|
sudo cp ../../../release/${sys}/${cpu}/lib${oem}twain${pid}.ds /usr/local/lib/twain/
|
|
|
|
fi
|