0
点赞
收藏
分享

微信扫一扫

量化交易之linux篇 - shell脚本 - 生成并部署libctpmd.so(通过命令行参数决定debug和release两种模式)


#!/bin/bash

COMPILE_TYPE=release # default is release.


# 根据命令行 参数(或无参数), 决定编译模式
if [ $# -eq 1 ] && ([ $1 = debug ] || [ $1 = release ])
then
COMPILE_TYPE=$1 # shell 中的 等号两边 不能有空格.

elif [ $# -eq 1 ] && ([ $1 != debug ] || [ $1 != release ])
then
echo param $1 is error.
exit

elif [ $# -gt 1 ]
then
echo error: param counts more than 1.
exit

fi


CTP_SO_NAME=libctpmd.so

PLUGINS_INDIR=../../bin/${COMPILE_TYPE}/plugins/
PLUGINS_OUTDIR=/home/admin/online/${COMPILE_TYPE}/plugins/


# compile libctpmd.so
if [ -f 'makefile' ] || [ -f 'Makefile' ] # [] 内侧两端的空格 不能省略!!!
then
if ! make ${COMPILE_TYPE} # check compile
then
echo make ${COMPILE_TYPE} error.
exit
fi

else
echo 'makefile or Makefile not exist.'
exit

fi
sleep 1s


# deployment $PLUGINS_OUTDIR
cp ${PLUGINS_INDIR}${CTP_SO_NAME} ${PLUGINS_OUTDIR}
if [ $COMPILE_TYPE = debug ]
then
cp ${PLUGINS_OUTDIR}${CTP_SO_NAME} /home/admin/online/bin/${COMPILE_TYPE}/plugins/
fi
sleep 1s


# hint of deployment complete
echo
echo -------- $CTP_SO_NAME deployment complete. --------

if [ $COMPILE_TYPE = debug ]
then
ls -l ${PLUGINS_OUTDIR}${CTP_SO_NAME}
ls -l /home/admin/online/bin/${COMPILE_TYPE}/plugins/${CTP_SO_NAME}

echo
echo exe path of ${COMPILE_TYPE} is /home/admin/online/bin/${COMPILE_TYPE}/

elif [ $COMPILE_TYPE = release ]
then
ls -l ${PLUGINS_OUTDIR}${CTP_SO_NAME}

echo
echo exe path of ${COMPILE_TYPE} is /home/admin/online/${COMPILE_TYPE}/

fi
sleep 1s

echo

举报

相关推荐

0 条评论