#!/bin/bash

project_name="term32960_v1_svr"
project_home="/root/.jenkins/workspace/term32960_v1_svr/"
ctfoproj_home="/root/.jenkins/workspace/ctfoproj/"


yes | cp ${ctfoproj_home}/lib/*.a ${project_home}/dblibs/ctfolibs/lib/
yes | cp -r ${ctfoproj_home}/include/* ${project_home}/dblibs/ctfolibs/include/


make

mkdir -p dev/bin dev/conf/ws
mkdir -p test/bin test/conf/ws
mkdir -p pro/bin pro/conf/ws
if [ -f term32960_v1_svr ]; then
	cp term32960_v1_svr dev/bin/
	cp term32960_v1_svr test/bin/
	cp term32960_v1_svr pro/bin/
else
	echo "build error"
	exit 1
fi

cp ../conf/dev/term32960_v1_svr.conf dev/conf/ws/
cp ../conf/test/term32960_v1_svr.conf test/conf/ws/
cp ../conf/pro/term32960_v1_svr.conf pro/conf/ws/
tar -zcf term32960_v1_svr_dev.tar.gz dev/
tar -zcf term32960_v1_svr_test.tar.gz dev/
tar -zcf term32960_v1_svr_pro.tar.gz pro/


#build term32960_v1_svr
mkdir -p /home/repo/build/${project_name}/${BUILD_NUMBER}/dev
mkdir -p /home/repo/build/${project_name}/${BUILD_NUMBER}/test
mkdir -p /home/repo/build/${project_name}/${BUILD_NUMBER}/prod
scp ${project_home}projects/term32960_v1_svr/term32960_v1_svr_dev.tar.gz /home/repo/build/${project_name}/${BUILD_NUMBER}/dev
scp ${project_home}projects/term32960_v1_svr/term32960_v1_svr_test.tar.gz /home/repo/build/${project_name}/${BUILD_NUMBER}/test
scp ${project_home}projects/term32960_v1_svr/term32960_v1_svr_pro.tar.gz /home/repo/build/${project_name}/${BUILD_NUMBER}/prod