提交 87405224 编写于 作者: S storypku 提交者: Liu Jiaming

scripts: introduce pathprepend & pathappend & pathremove functions

上级 75f7c433
......@@ -16,18 +16,17 @@ service_path="${cyber_tool_path}/cyber_service"
monitor_path="${cyber_tool_path}/cyber_monitor"
visualizer_path="${bazel_bin_path}/modules/tools/visualizer"
# TODO(all): place all these in one place and add_to_path
# TODO(all): place all these in one place and pathprepend
for entry in "${mainboard_path}" \
"${recorder_path}" "${monitor_path}" \
"${channel_path}" "${node_path}" \
"${service_path}" \
"${launch_path}" \
"${visualizer_path}" ; do
add_to_path "${entry}"
pathprepend "${entry}"
done
# ${CYBER_PATH}/python
export PYTHONPATH=${bazel_bin_path}/cyber/python/internal:${PYTHONPATH}
pathprepend ${bazel_bin_path}/cyber/python/internal PYTHONPATH
export CYBER_DOMAIN_ID=80
export CYBER_IP=127.0.0.1
......
......@@ -31,6 +31,9 @@ export APOLLO_CACHE_DIR="${APOLLO_ROOT_DIR}/.cache"
export APOLLO_SYSROOT_DIR="/opt/apollo/sysroot"
export TAB=" " # 4 spaces
source ${APOLLO_ROOT_DIR}/scripts/common.bashrc
: ${VERBOSE:=yes}
BOLD='\033[1m'
......@@ -209,17 +212,6 @@ function find_prettier_srcs() {
-or -name "*.yml"
}
## Prevent multiple entries of my_bin_path in PATH
function add_to_path() {
if [ -z "$1" ]; then
return
fi
local my_bin_path="$1"
if [ -n "${PATH##*${my_bin_path}}" ] && [ -n "${PATH##*${my_bin_path}:*}" ]; then
export PATH=$PATH:${my_bin_path}
fi
}
## Prevent multiple entries of my_libdir in LD_LIBRARY_PATH
function add_to_ld_library_path() {
if [ -z "$1" ]; then
......@@ -290,7 +282,7 @@ function optarg_check_for_opt() {
function setup_gpu_support() {
if [ -e /usr/local/cuda/ ]; then
add_to_path "/usr/local/cuda/bin"
pathprepend /usr/local/cuda/bin
fi
determine_gpu_use_target
......
......@@ -24,15 +24,9 @@ HOST_ARCH="$(uname -m)"
function set_lib_path() {
local CYBER_SETUP="${APOLLO_ROOT_DIR}/cyber/setup.bash"
[ -e "${CYBER_SETUP}" ] && . "${CYBER_SETUP}"
# TODO(storypku):
# /usr/local/apollo/local_integ/lib
# FIXME(all): remove PYTHONPATH settings
export PYTHONPATH="${APOLLO_ROOT_DIR}/modules/tools:${PYTHONPATH}"
# Set teleop paths
export PYTHONPATH="${APOLLO_ROOT_DIR}/modules/teleop/common:${PYTHONPATH}"
add_to_path "/apollo/modules/teleop/common/scripts"
pathprepend ${APOLLO_ROOT_DIR}/modules/tools PYTHONPATH
pathprepend ${APOLLO_ROOT_DIR}/modules/teleop/common PYTHONPATH
pathprepend /apollo/modules/teleop/common/scripts
}
function create_data_dir() {
......
#!/usr/bin/env bash
#! /usr/bin/env bash
###############################################################################
# Copyright 2020 The Apollo Authors. All Rights Reserved.
#
......@@ -16,40 +15,36 @@
# limitations under the License.
###############################################################################
# Fail on first error.
set -e
cd "$(dirname "${BASH_SOURCE[0]}")"
. ./installer_base.sh
VERSION="1.14.4"
ARCH="$(uname -m)"
if [[ "${ARCH}" == "x86_64" ]]; then
PKG_NAME="go${VERSION}.linux-amd64.tar.gz"
CHECKSUM="b518f21f823759ee30faddb1f623810a432499f050c9338777523d9c8551c62c"
elif [[ "${ARCH}" == "aarch64" ]]; then
PKG_NAME="go${VERSION}.linux-arm64.tar.gz"
CHECKSUM="05dc46ada4e23a1f58e72349f7c366aae2e9c7a7f1e7653095538bc5bba5e077"
else
error "Unsupported arch: ${ARCH}. Exiting..."
exit 1
fi
DOWNLOAD_LINK="https://dl.google.com/go/${PKG_NAME}"
download_if_not_cached "$PKG_NAME" "$CHECKSUM" "$DOWNLOAD_LINK"
tar xzf ${PKG_NAME} -C "${PKGS_DIR}"
GOROOT="${PKGS_DIR}/go"
MY_TEXT="""
export GOROOT=${GOROOT}
if [ -x \"\${GOROOT}/bin/go\" ]; then
add_to_path \"\${GOROOT}/bin\"
fi
"""
echo "${MY_TEXT}" | tee -a "${APOLLO_PROFILE}"
ok "Successfully installed go ${VERSION} to ${GOROOT}"
# clean up.
rm -fr "${PKG_NAME}"
# Ref: http://www.linuxfromscratch.org/blfs/view/svn/postlfs/profile.html
# Written for Beyond Linux From Scratch
# by James Robertson <jameswrobertson@earthlink.net>
# modifications by Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg>
# Functions to help us manage paths. Second argument is the name of the
# path variable to be modified (default: PATH)
pathremove() {
local IFS=':'
local NEWPATH
local DIR
local PATHVARIABLE=${2:-PATH}
for DIR in ${!PATHVARIABLE}; do
if [ "$DIR" != "$1" ]; then
NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
fi
done
export $PATHVARIABLE="$NEWPATH"
}
pathprepend() {
pathremove $1 $2
local PATHVARIABLE=${2:-PATH}
export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
}
pathappend() {
pathremove $1 $2
local PATHVARIABLE=${2:-PATH}
export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
}
export -f pathremove pathprepend pathappend
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册