build_befor_commit.sh 1.1 KB
Newer Older
梦境迷离's avatar
梦境迷离 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/bin/bash
# set -v

enable_language=("java","rust","scala", "python")
root_path=`pwd`

# auto compile java and scala
`gradle -s build > java_scala_compile.log`

for sub_module in $(ls $root_path)
do
	module_name=(${sub_module//-/ })
	arr_length=${#module_name[*]}
	if [[ -d $sub_module ]] && [[ "$arr_length" -eq 2 ]] ;then
		echo "sub module [ $sub_module ]"
		if [[  $arr_length -eq 2 ]];then
			lang=${module_name[0]}
			project=${module_name[0]}
			is_enable=`echo "${enable_language[@]}" | grep -wq "$lang" &&  echo "Yes" || echo "No"`
			if [[  "$is_enable" = "No" ]];then
				echo "############ [ not enable $lang language in this project ]"
				break
			fi
梦境迷离's avatar
梦境迷离 已提交
24
			# compile rust and fmt code
梦境迷离's avatar
梦境迷离 已提交
25 26 27
			case "$lang" in
			"rust")
			echo "################# [ compile $sub_module ]"
梦境迷离's avatar
梦境迷离 已提交
28
			`cd $sub_module;cargo build >/dev/null 2>&1;cargo fmt --all; cd .. `;;
梦境迷离's avatar
梦境迷离 已提交
29 30 31 32 33 34 35 36 37 38 39 40 41
			# compile python
			"python")
			echo "############ [ TODO ]";;
			*)
			echo "| exclude $sub_module";;
			esac
			for cdir in $(ls $sub_module)
			do
				echo "       | file ############ [ $cdir ]"
			done
		fi
	fi
done