modify build.sh (#77)

* now user can specify --fe, --be and --clean
This commit is contained in:
morningman
2017-09-06 17:18:25 +08:00
committed by 李超勇
parent 58f0bf64a1
commit 07f450e1a8

134
build.sh
View File

@ -29,7 +29,7 @@ ROOT=`dirname "$0"`
ROOT=`cd "$ROOT"; pwd`
export PALO_HOME=$ROOT
PARALLEL=4
PARALLEL=8
# Check java version
if [ -z $JAVA_HOME ]; then
@ -52,54 +52,130 @@ fi
cd ${PALO_HOME}
# Check args
CLEAN_ALL=0
if [ $# -ne 0 ]; then
if [ "$1"x == "-clean"x ]; then
CLEAN_ALL=1
fi
usage() {
echo "
Usage: $0 <options>
Optional options:
--be build Backend
--fe build Frontend
--clean clean and build target
Eg.
$0 build Backend and Frontend without clean
$0 --be build Backend without clean
$0 --fe --clean clean and build Frontend
$0 --fe --be --clean clean, build and run Frontend and Backend
"
exit 1
}
OPTS=$(getopt \
-n $0 \
-o '' \
-l 'be' \
-l 'fe' \
-l 'clean' \
-- "$@")
if [ $? != 0 ] ; then
usage
fi
echo "CLEAN_ALL: "${CLEAN_ALL}
eval set -- "$OPTS"
BUILD_BE=
BUILD_FE=
CLEAN=
RUN_UT=
if [ $# == 1 ] ; then
# defuat
BUILD_BE=1
BUILD_FE=1
CLEAN=0
RUN_UT=0
else
BUILD_BE=0
BUILD_FE=0
CLEAN=0
RUN_UT=0
while true; do
case "$1" in
--be) BUILD_BE=1 ; shift ;;
--fe) BUILD_FE=1 ; shift ;;
--clean) CLEAN=1 ; shift ;;
--ut) RUN_UT=1 ; shift ;;
--) shift ; break ;;
*) ehco "Internal error" ; exit 1 ;;
esac
done
fi
if [ ${CLEAN} -eq 1 -a ${BUILD_BE} -eq 0 -a ${BUILD_FE} -eq 0 ]; then
echo "--clean can not be specified without --fe or --be"
exit 1
fi
echo "Get params:
BUILD_BE -- $BUILD_BE
BUILD_FE -- $BUILD_FE
CLEAN -- $CLEAN
RUN_UT -- $RUN_UT
"
# Clean output
if [ ${CLEAN} -eq 1 ]; then
if [ ${BUILD_BE} -eq 1 -a ${BUILD_FE} -eq 1 ]; then
rm -rf ${PALO_HOME}/output/
elif [ ${BUILD_BE} -eq 1 ]; then
rm -rf ${PALO_HOME}/output/be
else
rm -rf ${PALO_HOME}/output/fe
fi
fi
# Clean and build generated code
echo "Build generated code"
cd ${PALO_HOME}/gensrc
if [ ${CLEAN_ALL} -eq 1 ]; then
if [ ${CLEAN} -eq 1 ]; then
make clean
fi
make
cd ${PALO_HOME}
# Clean and build Backend
echo "Build Backend"
if [ ${CLEAN_ALL} -eq 1 ]; then
rm ${PALO_HOME}/be/build/ -rf
rm ${PALO_HOME}/be/output/ -rf
if [ ${BUILD_BE} -eq 1 ] ; then
echo "Build Backend"
if [ ${CLEAN} -eq 1 ]; then
rm ${PALO_HOME}/be/build/ -rf
rm ${PALO_HOME}/be/output/ -rf
fi
mkdir -p ${PALO_HOME}/be/build/
cd ${PALO_HOME}/be/build/
cmake ../
make -j${PARALLEL}
make install
cd ${PALO_HOME}
fi
mkdir -p ${PALO_HOME}/be/build/
cd ${PALO_HOME}/be/build/
cmake ../
make -j${PARALLEL}
make install
cd ${PALO_HOME}
# Build docs, should be built before Frontend
echo "Build docs"
cd ${PALO_HOME}/docs
if [ ${CLEAN_ALL} -eq 1 ]; then
if [ ${CLEAN} -eq 1 ]; then
make clean
fi
make
cd ${PALO_HOME}
# Clean and build Frontend
echo "Build Frontend"
cd ${PALO_HOME}/fe
if [ ${CLEAN_ALL} -eq 1 ]; then
ant clean
if [ ${BUILD_FE} -eq 1 ] ; then
echo "Build Frontend"
cd ${PALO_HOME}/fe
if [ ${CLEAN} -eq 1 ]; then
ant clean
fi
ant install
cd ${PALO_HOME}
fi
ant install
cd ${PALO_HOME}
# Clean and prepare output dir
PALO_OUTPUT=${PALO_HOME}/output/
@ -107,8 +183,12 @@ rm -rf ${PALO_OUTPUT}
mkdir -p ${PALO_OUTPUT}
#Copy Frontend and Backend
cp -R ${PALO_HOME}/fe/output ${PALO_OUTPUT}/fe
cp -R ${PALO_HOME}/be/output ${PALO_OUTPUT}/be
if [ ${BUILD_FE} -eq 1 ]; then
cp -R ${PALO_HOME}/fe/output ${PALO_OUTPUT}/fe
fi
if [ ${BUILD_BE} -eq 1 ]; then
cp -R ${PALO_HOME}/be/output ${PALO_OUTPUT}/be
fi
echo "***************************************"
echo "Successfully build Palo."