Files
fc/server/tools/gen_data/gen_data.sh
T
2026-05-23 22:10:14 +08:00

97 lines
3.0 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#/bin/bash
# ---------------------------------------------------------
# 配置数据生成工具
# @author whjing2011@gmail.com
# ---------------------------------------------------------
if [ "" == "$ROOT" ]; then
if [ -f ../dev.sh ]; then
../dev.sh $@
exit 0
else
echo -e "\e[91m>>\e[0;0m 此脚本必须通过tools/dev.sh调用才能正常工作"
exit 1
fi
fi
if [ -f $ROOT/tools/temp_gen_data/gen_data.sh ]; then
source $ROOT/tool/temp_gen_data/gen_data.sh
fi
DOC[gen_data]="生成目标数据配置文件"
fun_gen_data(){
cd ${ROOT}/tools/gen_data/
fun_option $@
echo "输入信息===>$1 $option"
$ERL -noshell -pa "${ROOT}/tools/ebin" -pa "./ebin" -eval "make:all(),gen_data:gen($1,$option)" -s c q
}
DOC[gen_xml]="生成数据文件 XML"
fun_gen_xml(){
cd ${ROOT}/tools/gen_data/
mkdir -p template
fun_option $@
$ERL -noshell -pa "${ROOT}/tools/ebin" -pa "${ROOT}/tools/gen_data/ebin" -eval "make:all(), gen_xml:gen($1,$option)" -s c q
}
DOC[gen_data_cfg]="生成新数据文件gen_data/cfg/*.erl"
fun_gen_data_cfg(){
cd ${ROOT}/tools/gen_data/
if [ "$1" = "" ]; then
[[ ! -f ./env_cfg.erl ]] && cp -f tpl/env_cfg.erl . || echo "env_cfg.erl配置数据已生成"
fun_option $@
$ERL -noshell -pa "${ROOT}/tools/gen_data/ebin" -eval "make:all(), gen_data_file:gen_cfg($1,$option)" -s c q
else
fun_option $@
$ERL -noshell -pa "${ROOT}/tools/gen_data/ebin" -eval "make:all(), gen_data_file:gen_cfg($1,$option)" -s c q
fi
}
## 长参数处理
## --lang=cn --encoding=unicode --srv_path=xxx --cli_path=xxx --php_path=xxx --data_dir=xxx --proc_num=1 --mod=all
## -l cn -e unicode -s xxx -c xxx -p xxx -d xxx -n1 -mall
fun_option(){
mkdir -p ebin out
TEMP=`getopt -o l:e:d:s:c:p:n:m: --long lang:,encoding:,data_dir:,srv_path:,cli_path:,php_path:,proc_num:,mod: -- "$@" 2>/dev/null`
eval set -- "$TEMP"
option="[{author,<<\"$AUTHOR\">>}"
while true :
do
[ -z "$1" ] && break;
arg=$1
shift
echo "option===>$arg"
case "$arg" in
-l|--lang)
option=$option",{lang,$1}"
shift;;
-e|--encoding)
option=$option",{encoding,$1}"
shift;;
-m|--mod)
option=$option",{mod,$1}"
shift;;
-n|--proc_num)
option=$option",{proc_num,$1}"
shift;;
-d|--data_dir)
option=$option",{data_dir,\"$1\"}"
shift;;
-s|--srv_path)
option=$option",{srv_path,\"$1\"}"
shift;;
-c|--cli_path)
option=$option",{cli_path,\"$1\"}"
shift;;
-p|--php_path)
option=$option",{php_path,\"$1\"}"
shift;;
*)
;;
esac
done
option=$option"]"
echo "参数信息===>$option"
}