-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathbuild_release.sh
93 lines (74 loc) · 2.61 KB
/
build_release.sh
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env bash
source ./xbuild/sh/base_func.sh
function build_cross_binaries {
which shasum
if [ $? -ne 0 ]; then
echo "you have to install shasum first"
exit 2
fi
local TOP_DIR=$(pwd)
local BUILD_DIR=$(pwd)/xbuild
local BUILD_VERSION=$(date -u +%Y%m%d)
cd ${BUILD_DIR}
local DIR="build"
[[ -d ${DIR} ]] || echo "doesnot exists"
[[ -d ${DIR} ]] || mkdir ${DIR}
if [ $? -ne 0 ]; then
echo "cannot create directory ${BUILD_DIR}/build"
exit 1
fi
cd ${DIR}
rm rsock*.tar.gz
rm rsock*.zip
local VERSION_FILE=VERSION.txt
local SUM_FILE=sum.txt
echo "build on `date -u`" > ${SUM_FILE}
echo "build on `date -u`" > ${VERSION_FILE}
echo "commit head: $(git rev-parse HEAD)" >> ${VERSION_FILE}
get_num_core
local num_core=$?
for chainfile in ${BUILD_DIR}/cmake/Darwin_x86_64.toolchain.cmake ${BUILD_DIR}/cmake/Linux_x86_64.toolchain.cmake; do
echo "toolchain file: ${chainfile}"
local filename=$(basename "$chainfile")
local sub_arch_dir=$(echo ${filename} |cut -d'.' -f 1)
if [ -d ${sub_arch_dir} ]; then
[[ -f CMakeCache.txt ]] && rm CMakeCache.txt
make clean
else
mkdir ${sub_arch_dir}
if [[ $? -ne 0 ]]; then
echo "cannot create directory ${sub_arch_dir}"
exit 1
fi
fi
local SYSNAME=$(echo ${filename} |cut -d'_' -f 1)
# local archpos=$[${#sub_arch_dir} - ${#sysname} - 1]
local archpos=$[1 + ${#SYSNAME} - ${#sub_arch_dir}] # index backwards
local ARCH=${sub_arch_dir:${archpos}}
cd ${sub_arch_dir}
cmake -DCMAKE_TOOLCHAIN_FILE=${chainfile} ${TOP_DIR}
make -j${num_core}
if [ $? -ne 0 ]; then
echo "failed to make target $sub_arch_dir"
exit 3
else
local TAR_FILE="rsock-${SYSNAME}-${ARCH}-${BUILD_VERSION}.tar.gz"
cp ../${VERSION_FILE} .
if [ ${SYSNAME} = "Darwin" ]; then
TAR_FILE="rsock-${SYSNAME}-${ARCH}-${BUILD_VERSION}.zip"
zip "${TAR_FILE}" "server_rsock_${SYSNAME}" "client_rsock_${SYSNAME}" ${VERSION_FILE}
else
tar -czf "${TAR_FILE}" "server_rsock_${SYSNAME}" "client_rsock_${SYSNAME}" ${VERSION_FILE}
fi
rm ${VERSION_FILE}
echo
local sum=$(shasum ${TAR_FILE})
echo ${sum} | tee -a ../${SUM_FILE}
echo
mv ${TAR_FILE} ..
fi
cd -
done
cd ${TOP_DIR}
}
build_cross_binaries