Skip to content

Commit 910892e

Browse files
author
zhixin.lm
committed
修改 build.sh 文件内容
1 parent 57c031a commit 910892e

File tree

1 file changed

+158
-44
lines changed

1 file changed

+158
-44
lines changed

build.sh

Lines changed: 158 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,126 @@
1-
#!/bin/bash
1+
#!/bin/sh
2+
3+
export AUTOM4TE="autom4te"
4+
export AUTOCONF="autoconf"
5+
6+
OS_RELEASE=0
7+
OS_ARCH="x86_64"
8+
version=`cat /proc/version`
9+
ELX_OPTION="--with-beyondtrust=yes"
10+
11+
MINIDUMP_OPTION=
12+
if [[ "$version" =~ "aarch64" ]]
13+
then
14+
MINIDUMP_OPTION="--with-obproxy-minidump=no"
15+
else
16+
MINIDUMP_OPTION="--with-obproxy-minidump=yes"
17+
fi
18+
219
TOPDIR="$(dirname $(readlink -f "$0"))"
320
DEP_DIR=${TOPDIR}/deps/3rd/usr/local/oceanbase/deps/devel
421
TOOLS_DIR=${TOPDIR}/deps/3rd/usr/local/oceanbase/devtools
522
RUNTIME_DIR=${TOPDIR}/deps/3rd/usr
623
CPU_CORES=`grep -c ^processor /proc/cpuinfo`
724
MAKE_ARGS="-j $CPU_CORES"
25+
BOLT_PATH=${TOPDIR}/deps/3rd/opt/alibaba-cloud-compiler/bin
826

9-
PACKAGE=${2:-obproxy-ce}
10-
VERSION=${3:-`cat rpm/${PACKAGE}-VER.txt`}
27+
export DEP_DIR;
28+
export TOOLS_DIR;
29+
export RUNTIME_DIR;
30+
31+
PACKAGE=${2:-obproxy}
32+
OBPROXY_VERSION=${3:-`cat rpm/${PACKAGE}-ce-VER.txt`}
1133
RELEASE=${4:-1}
1234
PREFIX=/home/admin/obproxy
1335
SPEC_FILE=obproxy.spec
1436

15-
function sw()
16-
{
17-
export DEP_DIR;
18-
export TOOLS_DIR;
19-
export RUNTIME_DIR;
20-
export DEP_VAR=$DEP_DIR/var/;
21-
/sbin/ldconfig -n $DEP_DIR/lib;
22-
export LD_LIBRARY_PATH=$DEP_DIR/lib:$DEP_VAR/usr/local/lib64:$DEP_VAR/usr/local/lib:$DEP_VAR/usr/lib64:$DEP_VAR/usr/lib:$DEP_VAR/lib64:/usr/lib/x86_64-linux-gnu;
23-
export LIBRARY_PATH=$DEP_DIR/lib:$DEP_VAR/usr/local/lib64:$DEP_VAR/usr/local/lib:$DEP_VAR/usr/lib64:$DEP_VAR/usr/lib:/usr/lib/x86_64-linux-gnu;
24-
export CPLUS_INCLUDE_PATH=$DEP_DIR/include:${RUNTIME_DIR}/include:$DEP_VAR/usr/local/include:$DEP_VAR/usr/include:$DEP_VAR/devel/include:/usr/include/x86_64-linux-gnu;
25-
export C_INCLUDE_PATH=$DEP_DIR/include:${RUNTIME_DIR}/include:/usr/include/x86_64-linux-gnu;
26-
export PATH=$DEP_DIR/bin:$TOOLS_DIR/bin:$PATH;
37+
source /etc/os-release || exit 1
38+
39+
PNAME=${PRETTY_NAME:-"${NAME} ${VERSION}"}
40+
41+
function compat_centos8() {
42+
echo "[NOTICE] '$PNAME' is compatible with CentOS 8, use el8 dependencies list"
43+
OS_RELEASE=8
2744
}
2845

29-
export AUTOM4TE="autom4te"
30-
export AUTOCONF="autoconf"
46+
function compat_centos7() {
47+
echo "[NOTICE] '$PNAME' is compatible with CentOS 7, use el7 dependencies list"
48+
OS_RELEASE=7
49+
}
50+
51+
function not_supported() {
52+
echo "[ERROR] '$PNAME' is not supported yet."
53+
}
54+
55+
function version_ge() {
56+
test "$(awk -v v1=$VERSION_ID -v v2=$1 'BEGIN{print(v1>=v2)?"1":"0"}' 2>/dev/null)" == "1"
57+
}
58+
59+
function get_os_release() {
60+
OS_ARCH="$(uname -m)" || exit 1
61+
if [[ "${OS_ARCH}x" == "x86_64x" ]]; then
62+
case "$ID" in
63+
alinux)
64+
version_ge "3" && compat_centos8 && return
65+
version_ge "2.1903" && compat_centos7 && return
66+
;;
67+
alios)
68+
version_ge "8.0" && compat_centos8 && return
69+
version_ge "7.2" && compat_centos7 && return
70+
;;
71+
anolis)
72+
version_ge "8.0" && compat_centos8 && return
73+
version_ge "7.0" && compat_centos7 && return
74+
;;
75+
ubuntu)
76+
version_ge "16.04" && compat_centos7 && return
77+
;;
78+
centos)
79+
version_ge "8.0" && OS_RELEASE=8 && return
80+
version_ge "7.0" && OS_RELEASE=7 && return
81+
;;
82+
almalinux)
83+
version_ge "8.0" && compat_centos8 && return
84+
;;
85+
debian)
86+
version_ge "9" && compat_centos7 && return
87+
;;
88+
fedora)
89+
version_ge "33" && compat_centos7 && return
90+
;;
91+
opensuse-leap)
92+
version_ge "15" && compat_centos7 && return
93+
;;
94+
#suse
95+
sles)
96+
version_ge "15" && compat_centos7 && return
97+
;;
98+
uos)
99+
version_ge "20" && compat_centos7 && return
100+
;;
101+
esac
102+
elif [[ "${OS_ARCH}x" == "aarch64x" ]]; then
103+
case "$ID" in
104+
alios)
105+
version_ge "8.0" && compat_centos8 && return
106+
version_ge "7.0" && compat_centos7 && return
107+
;;
108+
centos)
109+
version_ge "8.0" && OS_RELEASE=8 && return
110+
version_ge "7.0" && OS_RELEASE=7 && return
111+
;;
112+
esac
113+
fi
114+
not_supported && return 1
115+
}
31116

32117
function do_init()
33118
{
34-
set -x
35-
sw
36-
aclocal
37-
libtoolize --force --copy --automake
38-
autoconf --force
39-
automake --foreign --copy --add-missing -Woverride -Werror
119+
set -x
120+
aclocal
121+
libtoolize --force --copy --automake
122+
autoconf --force
123+
automake --foreign --copy --add-missing -Woverride -Werror
40124
}
41125

42126
function do_dep_init()
@@ -48,24 +132,31 @@ function do_dep_init()
48132

49133
function do_clean()
50134
{
51-
echo 'cleaning...'
52-
make distclean >/dev/null 2>&1
53-
rm -rf autom4te.cache
54-
for fn in aclocal.m4 configure config.guess config.sub depcomp install-sh \
55-
ltmain.sh libtool missing mkinstalldirs config.log config.status Makefile; do
56-
rm -f $fn
57-
done
58-
59-
find . -name Makefile.in -exec rm -f {} \;
60-
find . -path ./tools/codestyle/astyle/build -prune -o -path ./doc -prune -o -name Makefile -exec rm -f {} \;
61-
find . -name .deps -prune -exec rm -rf {} \;
62-
echo 'done'
135+
echo 'cleaning...'
136+
make distclean >/dev/null 2>&1
137+
rm -rf autom4te.cache
138+
for fn in aclocal.m4 configure config.guess config.sub depcomp install-sh \
139+
ltmain.sh libtool missing mkinstalldirs config.log config.status Makefile; do
140+
rm -f $fn
141+
done
142+
143+
find . -name Makefile.in -exec rm -f {} \;
144+
find . -path ./tools/codestyle/astyle/build -prune -o -path ./doc -prune -o -name Makefile -exec rm -f {} \;
145+
find . -name .deps -prune -exec rm -rf {} \;
146+
echo 'done'
63147
}
64148

65149
function do_config()
66150
{
67151
set -x
68-
sw
152+
get_os_release
153+
154+
if test ${OS_RELEASE} -eq 8 -a "${OS_ARCH}x" = "aarch64x" ; then
155+
sed -i "/The path to search for executables/{N;N;N;d;}" configure.ac
156+
sed -i "/set gcc executable path/{N;N;N;d;}" configure.ac
157+
sed -i "/set g++ executable path/{N;N;N;d;}" configure.ac
158+
fi
159+
69160
case "x$1" in
70161
xdebug)
71162
# configure for developers
@@ -89,8 +180,8 @@ function do_config()
89180
;;
90181
xerrsim)
91182
# configure for error injection
92-
./configure --with-gcc-version=9.3.0 --with-coverage=no --enable-buildtime=no --enable-strip-ut=no --enable-silent-rules --enable-dlink-observer=no --with-errsim=yes ${MINIDUMP_OPTION} ${ELX_OPTION}
93-
echo -e "\033[31m ===build errsim version=== \033[0m"
183+
./configure --with-gcc-version=9.3.0 --with-coverage=no --enable-buildtime=no --enable-strip-ut=no --enable-silent-rules --enable-dlink-observer=no --with-errsim=yes
184+
echo -e "\033[31m ===build errsim version=== \033[0m"
94185
;;
95186
*)
96187
# configure for release
@@ -103,15 +194,33 @@ function do_config()
103194
function do_make()
104195
{
105196
set -x
106-
sw
107197
make $MAKE_ARGS
108198
}
109199

110-
function do_rpm()
200+
function do_bolt()
111201
{
112202
set -x
113-
sw
203+
echo -e "[BUILD] do bolt opt"
204+
rm -f ${TOPDIR}/src/obproxy/obproxy.origin
205+
cp ${TOPDIR}/src/obproxy/obproxy ${TOPDIR}/src/obproxy/obproxy.origin
206+
${BOLT_PATH}/llvm-bolt ${TOPDIR}/src/obproxy/obproxy.origin \
207+
-o ${TOPDIR}/src/obproxy/obproxy \
208+
-data=${TOPDIR}/bolt/perf.bolt.fdata.point_select \
209+
-data2=${TOPDIR}/bolt/perf.bolt.fdata.read_write \
210+
-reorder-blocks=ext-tsp \
211+
-reorder-functions=hfsort+ \
212+
-split-functions=3 \
213+
-split-all-cold \
214+
-dyno-stats \
215+
--use-gnu-stack \
216+
--update-debug-sections \
217+
--bolt-info=false \
218+
-v=0
219+
}
114220

221+
function do_rpm()
222+
{
223+
set -x
115224
echo "[BUILD] make dist..."
116225
make dist-gzip || exit 1
117226

@@ -122,11 +231,11 @@ function do_rpm()
122231
mkdir -p ${TMP_DIR}/RPMS
123232
mkdir -p ${TMP_DIR}/SOURCES
124233
mkdir -p ${TMP_DIR}/SRPMS
125-
cp ${PACKAGE}-${VERSION}.tar.gz ${TMP_DIR}/SOURCES
234+
cp ${PACKAGE}-${OBPROXY_VERSION}.tar.gz ${TMP_DIR}/SOURCES
126235
cd ${TMP_DIR}/BUILD
127236

128237
echo "[BUILD] make rpms..._prefix=${PREFIX} spec_file=${SPEC_FILE}"
129-
rpmbuild --define "_topdir ${TMP_DIR}" --define "NAME ${PACKAGE}" --define "VERSION ${VERSION}" --define "_prefix ${PREFIX}" --define "RELEASE ${RELEASE}" --define "rpm_path ${TOPDIR}" -ba ${TOPDIR}/deps/3rd/${SPEC_FILE} || exit 2
238+
rpmbuild --define "_topdir ${TMP_DIR}" --define "NAME ${PACKAGE}" --define "VERSION ${OBPROXY_VERSION}" --define "_prefix ${PREFIX}" --define "RELEASE ${RELEASE}" --define "rpm_path ${TOPDIR}" -ba ${TOPDIR}/deps/3rd/${SPEC_FILE} || exit 2
130239
echo "[BUILD] make rpms done."
131240

132241
cd ${TOPDIR}
@@ -155,9 +264,14 @@ xrpm)
155264
do_config
156265
do_rpm
157266
;;
267+
xbolt)
268+
# need `do_config release`
269+
do_bolt
270+
;;
158271
*)
159272
do_dep_init
160273
do_config
161274
do_make
162-
;;
275+
do_bolt
276+
;;
163277
esac

0 commit comments

Comments
 (0)