From 7729a6d53523fdbdfb524b5228a877d616d177f1 Mon Sep 17 00:00:00 2001 From: storypku Date: Sun, 13 Sep 2020 22:57:27 +0800 Subject: [PATCH] Scripts: updated non-interactive mode support for apollo_config.sh Goodbye to tools/apollo.bazelrc.sample --- scripts/apollo_config.sh | 66 ++++++++++++++++++------------------- tools/apollo.bazelrc.sample | 21 ------------ tools/bootstrap.py | 2 -- 3 files changed, 33 insertions(+), 56 deletions(-) delete mode 100644 tools/apollo.bazelrc.sample diff --git a/scripts/apollo_config.sh b/scripts/apollo_config.sh index 735c349e57..dc4e49c633 100755 --- a/scripts/apollo_config.sh +++ b/scripts/apollo_config.sh @@ -15,52 +15,52 @@ # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### +set -e TOP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" source "${TOP_DIR}/cyber/setup.bash" -set -e - BAZEL_CONF="${TOP_DIR}/.apollo.bazelrc" -ARCH="$(uname -m)" - -function config_noninteractive() { - local output_dir="${APOLLO_CACHE_DIR}/bazel" - - > "${BAZEL_CONF}" - echo "startup --output_user_root=\"${output_dir}\"" >> "${BAZEL_CONF}" - echo "common --distdir=\"${APOLLO_BAZEL_DISTDIR}\"" >> "${BAZEL_CONF}" - echo >> "${BAZEL_CONF}" - - echo -e "build --action_env GCC_HOST_COMPILER_PATH=\"/usr/bin/${ARCH}-linux-gnu-gcc-7\"" >> "${BAZEL_CONF}" - cat "${TOP_DIR}/tools/apollo.bazelrc.sample" >> "${BAZEL_CONF}" -} - -function config_interactive() { +function run_bootstrap() { py3_bin="$(which python3 || true)" # Set all env variables "${py3_bin}" "${TOP_DIR}/tools/bootstrap.py" "$@" } -function config() { - if [ $# -eq 0 ]; then - config_noninteractive - else - local mode="$1" - shift - if [ "${mode}" == "--clean" ]; then - rm -f "${BAZEL_CONF}" - elif [[ "${mode}" == "--interactive" || "${mode}" == "-i" ]]; then - config_interactive "$@" - else - config_noninteractive - fi +function main() { + local mycfg="$(basename ${BAZEL_CONF})" + if [[ "$#" -eq 0 ]]; then + run_bootstrap --help + exit 1 fi -} -function main() { - config "$@" + case "$1" in + --clean) + rm -f "${BAZEL_CONF}" + exit 0 + ;; + -h | --help) + run_bootstrap --help + exit 0 + ;; + -i | --interactive) + info "Configure ${mycfg} in interactive mode" + run_bootstrap --interactive + ok "Successfully configured ${mycfg} in interactive mode." + exit 0 + ;; + --noninteractive) + info "Configure ${mycfg} in non-interactive mode" + run_bootstrap --interactive false + ok "Successfully configured ${mycfg} in non-interactive mode." + exit 0 + ;; + *) + run_bootstrap --help + exit 0 + ;; + esac } main "$@" diff --git a/tools/apollo.bazelrc.sample b/tools/apollo.bazelrc.sample deleted file mode 100644 index 291cdc46ab..0000000000 --- a/tools/apollo.bazelrc.sample +++ /dev/null @@ -1,21 +0,0 @@ -build --action_env PYTHON_BIN_PATH="/usr/bin/python3" -build --action_env PYTHON_LIB_PATH="/usr/lib/python3/dist-packages" -build --python_path="/usr/bin/python3" - -build:gpu --config=cuda -build:gpu --config=tensorrt - -build --action_env CUDA_TOOLKIT_PATH="/usr/local/cuda-10.2" -build --action_env TF_CUDA_COMPUTE_CAPABILITIES="3.7,5.2,6.0,6.1,7.0,7.2,7.5" - -# This config refers to building with CUDA available. -build:using_cuda --define=using_cuda=true -build:using_cuda --action_env TF_NEED_CUDA=1 -build:using_cuda --crosstool_top=@local_config_cuda//crosstool:toolchain - -# This config refers to building CUDA with nvcc. -build:cuda --config=using_cuda -build:cuda --define=using_cuda_nvcc=true - -build:tensorrt --action_env TF_NEED_TENSORRT=1 -build:teleop --define=WITH_TELEOP=true diff --git a/tools/bootstrap.py b/tools/bootstrap.py index 6e2da690df..9eb9490c28 100755 --- a/tools/bootstrap.py +++ b/tools/bootstrap.py @@ -962,8 +962,6 @@ def main(): _APOLLO_INSIDE_DOCKER = inside_docker() _INTERACTIVE_MODE = args.interactive - print("== Configure {} {}interactively ==".format(args.output_file, - "" if _INTERACTIVE_MODE else "non-")) # Make a copy of os.environ to be clear when functions and getting and setting # environment variables. -- GitLab