0%

ERLANG快速编译脚本

项目中使用mmake:all/1进行编译,但是这会遍历所有文件,效率不是很高

svn up, 然后执行下面的脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
fun_quick_make(){
cd $SERVER_DIR
## 获取变化的头文件
hrl_file_list=$(find . -newer time_file -regex .*.hrl -exec basename {} \;)
hrl_f_list=$hrl_file_list

## 获取关联的头文件
all_hrl_files=$(find include -name "*.hrl")
for i in ${hrl_file_list[@]}; do
## for j in $(ag "$i" include/**/* | awk -F ":" '{print $1}'); do
for j in $(grep "$i" $all_hrl_files | awk -F ":" '{print $1}'); do
hrl_f_list="$(basename $j) $hrl_f_list"
done
done

## 获取变化的erl文件
erl_file_list="\"src/main.erl\""
for i in $(find . -newer time_file -regex .*.erl); do
erl_file_list="$erl_file_list,\"${i/.\//}\""
done

## 获取关联的erl文件
all_files=$(find . -name "*.erl")
for i in ${hrl_f_list[@]}; do
##
## why??? php_ssh call fail
##
## for j in $(ag --ignore "robot" "$i" **/* | awk -F ":" '{print $1}' | grep ".erl"); do
## erl_file_list="$erl_file_list,\"$j\""
## done
for j in $(grep "$i" $all_files | awk -F ":" '{print $1}' | grep -v "/robot/"); do
erl_file_list="$erl_file_list,\"${j/.\//}\""
done
done

## 使用`mmake:files/2`编译
${ERL} -pa ${SERVER_EBIN} -pa ${SERVER_BASEEBIN} -noshell -eval "case mmake:files(500,[$erl_file_list]) of up_to_date -> init:stop(); _ -> init:stop(1) end"
if [[ "$?" == "0" ]]; then
touch time_file
fi
}