From ca7b71049412e0334a5ae5bb620d6baf70efb458 Mon Sep 17 00:00:00 2001 From: Xiangquan Xiao Date: Wed, 8 Jul 2020 10:56:56 -0700 Subject: [PATCH] Scripts: Auto-config if user didn't do it. --- apollo.sh | 4 ++++ docs/howto/how_to_launch_Apollo.md | 2 -- scripts/apollo_clean.sh | 4 ++++ scripts/apollo_config.sh | 21 +++++++++++---------- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/apollo.sh b/apollo.sh index 99bf8c7b35..591e69ebb2 100755 --- a/apollo.sh +++ b/apollo.sh @@ -78,6 +78,10 @@ function apollo_env_setup() { info "${TAB}APOLLO_IN_DOCKER: ${APOLLO_IN_DOCKER}" info "${TAB}APOLLO_VERSION: ${APOLLO_VERSION}" info "${TAB}APOLLO_ENV: ${APOLLO_ENV} USE_GPU=${USE_GPU}" + + if [ ! -f "${APOLLO_ROOT_DIR}/.apollo.bazelrc" ]; then + env ${APOLLO_ENV} bash "${APOLLO_ROOT_DIR}/scripts/apollo_config.sh" "$@" + fi } #TODO(all): Update node modules diff --git a/docs/howto/how_to_launch_Apollo.md b/docs/howto/how_to_launch_Apollo.md index e6f9a7111f..780ace6761 100644 --- a/docs/howto/how_to_launch_Apollo.md +++ b/docs/howto/how_to_launch_Apollo.md @@ -7,8 +7,6 @@ You could still proceed with the next few steps even if you are missing the Linu ./apollo.sh # To make sure you start clean ./apollo.sh clean -# To configure bazel settings -./apollo.sh config # This will build the full system and requires that you have an nVidia GPU with nVidia drivers loaded bash apollo.sh build ``` diff --git a/scripts/apollo_clean.sh b/scripts/apollo_clean.sh index cdfd420760..100d353d08 100755 --- a/scripts/apollo_clean.sh +++ b/scripts/apollo_clean.sh @@ -32,6 +32,10 @@ function clean() { bazel clean --async popd >/dev/null fi + + # Remove local bazel config. + bash "${TOP_DIR}/scripts/apollo_config.sh" --clean + success "Done $0 ${stage}." } diff --git a/scripts/apollo_config.sh b/scripts/apollo_config.sh index 4833baf089..dc4056af46 100755 --- a/scripts/apollo_config.sh +++ b/scripts/apollo_config.sh @@ -13,33 +13,32 @@ EOF set -e +BAZEL_CONF="${TOP_DIR}/.apollo.bazelrc" + function config_noninteractive() { - local bzl_cfg_file="${APOLLO_ROOT_DIR}/.apollo.bazelrc" - echo "${STARTUP_TXT}" > "${bzl_cfg_file}" + echo "${STARTUP_TXT}" > "${BAZEL_CONF}" # determine_gpu_use # FIXME(all): Disable gpu mode for aarch64 until we are ready. if [ "$(uname -m)" = "aarch64" ]; then - echo "build --config=cpu" >> "${bzl_cfg_file}" + echo "build --config=cpu" >> "${BAZEL_CONF}" else if [ "${USE_GPU}" -eq 1 ]; then - echo "build --config=gpu" >> "${bzl_cfg_file}" + echo "build --config=gpu" >> "${BAZEL_CONF}" else - echo "build --config=cpu" >> "${bzl_cfg_file}" + echo "build --config=cpu" >> "${BAZEL_CONF}" fi fi - - cat "${APOLLO_ROOT_DIR}/tools/apollo.bazelrc.sample" >> "${bzl_cfg_file}" + cat "${TOP_DIR}/tools/apollo.bazelrc.sample" >> "${BAZEL_CONF}" } function config_interactive() { if [ -z "$PYTHON_BIN_PATH" ]; then PYTHON_BIN_PATH=$(which python3 || true) fi - local bzl_cfg_file="${APOLLO_ROOT_DIR}/.apollo.bazelrc" # Set all env variables "$PYTHON_BIN_PATH" "${TOP_DIR}/tools/bootstrap.py" "$@" - echo "${STARTUP_TXT}" >> "${bzl_cfg_file}" + echo "${STARTUP_TXT}" >> "${BAZEL_CONF}" } function config() { @@ -48,7 +47,9 @@ function config() { config_noninteractive else local mode="$1" ; shift - if [[ "${mode}" == "--interactive" || "${mode}" == "-i" ]]; then + if [ "${mode}" == "--clean" ]; then + rm -f "${BAZEL_CONF}" + elif [[ "${mode}" == "--interactive" || "${mode}" == "-i" ]]; then config_interactive "$@" else config_noninteractive -- GitLab