提交 f0db03a9 编写于 作者: S siyangy 提交者: lianglia-apollo

cleanup apollo.sh and apollo_base.sh

上级 c642a8f7
......@@ -16,15 +16,16 @@
# limitations under the License.
###############################################################################
#=================================================
# Utils
#=================================================
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "${DIR}"
source "${DIR}/scripts/apollo_base.sh"
function source_apollo_base() {
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "${DIR}"
source "${DIR}/scripts/apollo_base.sh"
}
function apollo_check_system_config() {
# check operating system
......@@ -48,33 +49,24 @@ function apollo_check_system_config() {
fi
}
apollo_check_system_config
# the machine type, currently support x86_64, aarch64
MACHINE_ARCH=$(uname -m)
IS_X86_64=false
IS_AARCH64=false
BUILD_TARGETS=""
TEST_TARGETS=""
CAN_CARD="fake_can"
rm -rf ./third_party/ros
if [ "$MACHINE_ARCH" == 'x86_64' ]; then
IS_X86_64=true
sed "s/MACHINE_ARCH/x86_64/g" WORKSPACE.in > WORKSPACE
elif [ "$MACHINE_ARCH" == 'aarch64' ]; then
IS_AARCH64=true
sed "s/MACHINE_ARCH/aarch64/g" WORKSPACE.in > WORKSPACE
fi
function check_machine_arch() {
# the machine type, currently support x86_64, aarch64
MACHINE_ARCH=$(uname -m)
if ! $IS_X86_64 && ! $IS_AARCH64 ; then
fail "Unknown machine architecture $MACHINE_ARCH"
exit 1
fi
# Generate WORKSPACE file based on marchine architecture
if [ "$MACHINE_ARCH" == 'x86_64' ]; then
sed "s/MACHINE_ARCH/x86_64/g" WORKSPACE.in > WORKSPACE
elif [ "$MACHINE_ARCH" == 'aarch64' ]; then
sed "s/MACHINE_ARCH/aarch64/g" WORKSPACE.in > WORKSPACE
else
fail "Unknown machine architecture $MACHINE_ARCH"
exit 1
fi
}
function check_esd_files() {
CAN_CARD="fake_can"
if [ -f ./third_party/can_card_library/esd_can/include/ntcan.h \
-a -f ./third_party/can_card_library/esd_can/lib/libntcan.so \
-a -f ./third_party/can_card_library/esd_can/lib/libntcan.so.4 \
......@@ -87,8 +79,6 @@ function check_esd_files() {
fi
}
check_esd_files
function generate_build_targets() {
BUILD_TARGETS=$(bazel query //... | grep -v "_test$" | grep -v "third_party" \
| grep -v "_cpplint$" | grep -v "release" | grep -v "kernel")
......@@ -129,7 +119,7 @@ function apollo_build() {
}
function check() {
local check_start_time=$START_TIME
local check_start_time=$(get_now)
apollo_build && run_test && run_lint
START_TIME=$check_start_time
......@@ -160,7 +150,7 @@ function release() {
ROOT_DIR=$HOME/.cache/release
rm -rf $ROOT_DIR
#modules
# modules
MODULES_DIR=$ROOT_DIR/modules
mkdir -p $MODULES_DIR
for m in control canbus localization decision perception prediction planning
......@@ -175,28 +165,36 @@ function release() {
cp -r modules/$m/conf $TARGET_DIR
fi
done
#control tools
# control tools
mkdir $MODULES_DIR/control/tools
cp bazel-bin/modules/control/tools/pad_terminal $MODULES_DIR/control/tools
#remove all pyc file in modules/
find modules/ -name "*.pyc" | xargs -I {} rm {}
cp -r modules/tools $MODULES_DIR
#ros
# ros
cp -Lr bazel-apollo/external/ros $ROOT_DIR/
#scripts
# scripts
cp -r scripts $ROOT_DIR
#dreamview
cp -Lr bazel-bin/modules/dreamview/dreamview.runfiles/apollo/modules/dreamview $MODULES_DIR
cp -r modules/dreamview/conf $MODULES_DIR/dreamview
#common data
# common data
mkdir $MODULES_DIR/common
cp -r modules/common/data $MODULES_DIR/common
#hmi
# hmi
mkdir -p $MODULES_DIR/hmi/ros_node $MODULES_DIR/hmi/utils
cp bazel-bin/modules/hmi/ros_node/ros_node_service $MODULES_DIR/hmi/ros_node/
cp -r modules/hmi/conf $MODULES_DIR/hmi
cp -r modules/hmi/web $MODULES_DIR/hmi
cp -r modules/hmi/utils/*.py $MODULES_DIR/hmi/utils
# lib
LIB_DIR=$ROOT_DIR/lib
mkdir $LIB_DIR
......@@ -206,7 +204,7 @@ function release() {
do
cp third_party/can_card_library/$m/lib/* $LIB_DIR
done
#hw check
# hw check
mkdir -p $MODULES_DIR/monitor/hwmonitor/hw_check/
cp bazel-bin/modules/monitor/hwmonitor/hw_check/can_check $MODULES_DIR/monitor/hwmonitor/hw_check/
cp bazel-bin/modules/monitor/hwmonitor/hw_check/gps_check $MODULES_DIR/monitor/hwmonitor/hw_check/
......@@ -214,11 +212,13 @@ function release() {
cp bazel-bin/modules/monitor/hwmonitor/hw/tools/esdcan_test_app $MODULES_DIR/monitor/hwmonitor/hw/tools/
fi
cp -r bazel-genfiles/* $LIB_DIR
# doc
cp -r docs $ROOT_DIR
cp LICENSE $ROOT_DIR
cp third_party/ACKNOWLEDGEMENT.txt $ROOT_DIR
#release info
# release info
META=${ROOT_DIR}/meta.txt
echo "Git commit: $(git show --oneline -s | awk '{print $1}')" > $META
echo "Build time: $TIME" >> $META
......@@ -346,7 +346,7 @@ function version() {
echo "Date: ${date}"
}
function buildgnss() {
function build_gnss() {
CURRENT_PATH=$(pwd)
MACHINE_ARCH="$(uname -m)"
INSTALL_PATH="${CURRENT_PATH}/third_party/ros_${MACHINE_ARCH}"
......@@ -387,44 +387,53 @@ function buildgnss() {
rm -rf modules/devel_isolated/
}
case $1 in
check)
check
;;
build)
apollo_build
;;
buildify)
buildify
;;
buildgnss)
buildgnss
;;
doc)
gen_doc
;;
lint)
run_lint
;;
test)
run_test
;;
release)
release 1
;;
release_noproprietary)
release 0
;;
coverage)
gen_coverage
;;
clean)
clean
;;
version)
version
;;
*)
print_usage
;;
esac
function main() {
source_apollo_base
apollo_check_system_config
check_machine_arch
check_esd_files
case $1 in
check)
check
;;
build)
apollo_build
;;
buildify)
buildify
;;
buildgnss)
build_gnss
;;
doc)
gen_doc
;;
lint)
run_lint
;;
test)
run_test
;;
release)
release 1
;;
release_noproprietary)
release 0
;;
coverage)
gen_coverage
;;
clean)
clean
;;
version)
version
;;
*)
print_usage
;;
esac
}
main $@
......@@ -68,65 +68,73 @@ function fail() {
exit -1
}
# Check whether user has agreed license agreement
function check_agreement() {
agreement_record="$HOME/.apollo_agreement.txt"
if [ ! -e "$agreement_record" ]; then
AGREEMENT_FILE="$APOLLO_ROOT_DIR/scripts/AGREEMENT.txt"
if [ ! -e "$AGREEMENT_FILE" ]; then
error "AGREEMENT $AGREEMENT_FILE does not exist."
exit 0
fi
cat $AGREEMENT_FILE
tip="Type 'y' or 'Y' to agree to the license agreement above, or type any other key to exit"
echo $tip
read -n 1 user_agreed
if [ "$user_agreed" == "y" ] || [ "$user_agreed" == "Y" ]; then
rm -rf $agreement_record
cat $AGREEMENT_FILE >> $agreement_record
echo "$tip" >> $agreement_record
echo "$user_agreed" >> $agreement_record
else
exit 0
fi
fi
}
agreement_record="$HOME/.apollo_agreement.txt"
if [ ! -e "$agreement_record" ]; then
AGREEMENT_FILE="$APOLLO_ROOT_DIR/scripts/AGREEMENT.txt"
if [ ! -e "$AGREEMENT_FILE" ]; then
error "AGREEMENT $AGREEMENT_FILE does not exist."
exit 0
fi
cat $AGREEMENT_FILE
tip="Type 'y' or 'Y' to agree to the license agreement above, or type any other key to exit"
echo $tip
read -n 1 user_agreed
if [ "$user_agreed" == "y" ] || [ "$user_agreed" == "Y" ]; then
rm -rf $agreement_record
cat $AGREEMENT_FILE >> $agreement_record
echo "$tip" >> $agreement_record
echo "$user_agreed" >> $agreement_record
else
exit 0
fi
fi
if [ -f /.dockerenv ]; then
APOLLO_IN_DOCKER=true
else
APOLLO_IN_DOCKER=false
fi
if [ "$RELEASE_DOCKER" == 1 ];then
source /apollo/ros/setup.bash
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/apollo/lib
export PYTHONPATH=/apollo/lib:${PYTHONPATH}
else
if [ -e "${APOLLO_ROOT_DIR}/bazel-apollo/external/ros/setup.bash" ]; then
source "${APOLLO_ROOT_DIR}/bazel-apollo/external/ros/setup.bash"
fi
export PYTHONPATH=${APOLLO_ROOT_DIR}/bazel-genfiles:${PYTHONPATH}
fi
function check_in_docker() {
if [ -f /.dockerenv ]; then
APOLLO_IN_DOCKER=true
else
APOLLO_IN_DOCKER=false
fi
export APOLLO_IN_DOCKER
}
if [ ! -e "${APOLLO_ROOT_DIR}/data/log" ]; then
mkdir -p "${APOLLO_ROOT_DIR}/data/log"
fi
function set_lib_path() {
if [ "$RELEASE_DOCKER" == 1 ];then
source /apollo/ros/setup.bash
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/apollo/lib
export PYTHONPATH=/apollo/lib:${PYTHONPATH}
else
if [ -e "${APOLLO_ROOT_DIR}/bazel-apollo/external/ros/setup.bash" ]; then
source "${APOLLO_ROOT_DIR}/bazel-apollo/external/ros/setup.bash"
fi
export PYTHONPATH=${APOLLO_ROOT_DIR}/bazel-genfiles:${PYTHONPATH}
fi
}
if [ ! -e "${APOLLO_ROOT_DIR}/data/bag" ]; then
mkdir -p "${APOLLO_ROOT_DIR}/data/bag"
fi
function create_data_dir() {
if [ ! -e "${APOLLO_ROOT_DIR}/data/log" ]; then
mkdir -p "${APOLLO_ROOT_DIR}/data/log"
fi
if [ ! -e "${APOLLO_ROOT_DIR}/data/core" ]; then
mkdir -p "${APOLLO_ROOT_DIR}/data/core"
fi
if [ ! -e "${APOLLO_ROOT_DIR}/data/bag" ]; then
mkdir -p "${APOLLO_ROOT_DIR}/data/bag"
fi
if [ ! -e "${APOLLO_ROOT_DIR}/data/core" ]; then
mkdir -p "${APOLLO_ROOT_DIR}/data/core"
fi
}
APOLLO_BIN_PREFIX=$APOLLO_ROOT_DIR
if [ -e "${APOLLO_ROOT_DIR}/bazel-bin" ]; then
APOLLO_BIN_PREFIX="${APOLLO_ROOT_DIR}/bazel-bin"
fi
export APOLLO_BIN_PREFIX
export APOLLO_IN_DOCKER
function determine_bin_prefix() {
APOLLO_BIN_PREFIX=$APOLLO_ROOT_DIR
if [ -e "${APOLLO_ROOT_DIR}/bazel-bin" ]; then
APOLLO_BIN_PREFIX="${APOLLO_ROOT_DIR}/bazel-bin"
fi
export APOLLO_BIN_PREFIX
}
function is_stopped() {
MODULE=${1}
......@@ -208,3 +216,9 @@ function run() {
;;
esac
}
check_agreement
check_in_docker
create_data_dir
set_lib_path
determine_bin_prefix
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册