提交 2393909d 编写于 作者: S storypku

Bazel: re-org bazelrc for cpu/gpu/dbg/opt builds

上级 911c5a6c
......@@ -106,13 +106,13 @@ function main() {
env ${APOLLO_ENV} bash "${build_sh}" --config=dbg "$@"
;;
build_cpu)
env ${APOLLO_ENV} bash "${build_sh}" --config build_cpu "$@"
env ${APOLLO_ENV} bash "${build_sh}" --config=cpu "$@"
;;
build_gpu)
env ${APOLLO_ENV} bash "${build_sh}" --config build_gpu "$@"
env ${APOLLO_ENV} bash "${build_sh}" --config=gpu "$@"
;;
build_opt_gpu)
env ${APOLLO_ENV} bash "${build_sh}" --config build_opt_gpu "$@"
env ${APOLLO_ENV} bash "${build_sh}" --config=opt_gpu "$@"
;;
buildify)
env ${APOLLO_ENV} bash ${APOLLO_ROOT_DIR}/scripts/apollo_buildify.sh
......
......@@ -31,6 +31,8 @@ function determine_disabled_targets() {
}
# components="$(echo -e "${@// /\\n}" | sort -u)"
# if [ ${PIPESTATUS[0]} -ne 0 ]; then ... ; fi
function determine_targets() {
local targets=
local compo="$1"
......@@ -130,8 +132,29 @@ function bazel_build() {
_run_bazel_build_impl "${COMMAND_LINE_OPTIONS}" "$(bazel query ${BUILD_TARGETS})"
}
function build_simulator() {
local SIMULATOR_TOP_DIR="/apollo-simulator"
if [ -d "${SIMULATOR_TOP_DIR}" ] && [ -e "${SIMULATOR_TOP_DIR}/build.sh" ]; then
pushd "${SIMULATOR_TOP_DIR}"
if bash build.sh build ; then
success "Done building Apollo simulator."
else
fail "Building Apollo simulator failed."
fi
popd >/dev/null
fi
}
function main() {
if [ "${USE_GPU}" -eq 1 ]; then
info "Running build under GPU mode. GPU is required to run the build."
else
info "Running build under CPU mode."
fi
info "Building for ${ARCH} arch ..."
bazel_build $@
build_simulator
success "Done building Apollo. Enjoy!"
}
main "$@"
......@@ -16,6 +16,11 @@ set -e
function config_noninteractive() {
local bzl_cfg_file="${APOLLO_ROOT_DIR}/.apollo.bazelrc"
echo "${STARTUP_TXT}" > "${bzl_cfg_file}"
if [ "${USE_GPU}" -eq 1 ]; then
echo "build --config=gpu" >> "${bzl_cfg_file}"
else
echo "build --config=cpu" >> "${bzl_cfg_file}"
fi
cat "${APOLLO_ROOT_DIR}/tools/apollo.bazelrc.sample" >> "${bzl_cfg_file}"
}
......
......@@ -6,13 +6,11 @@ build --action_env CUDA_TOOLKIT_PATH="/usr/local/cuda-10.2"
build --action_env TF_CUDA_COMPUTE_CAPABILITIES="6.0,6.1,7.0,7.2,7.5"
build --action_env GCC_HOST_COMPILER_PATH="/usr/bin/x86_64-linux-gnu-gcc-7"
build --config=gpu
build:gpu --config=cuda
build:gpu --define=USE_GPU=true
build:gpu --config=tensorrt
#build:gpu --action_env USE_GPU=1
# build --config=tensorrt
#build --config=tensorrt
## The following was adapted from tensorflow/.bazelrc
......
......@@ -31,6 +31,8 @@ build --cxxopt="-fdiagnostics-color=always"
# Do not show warnings from external dependencies.
# build --output_filter="^//"
build --config=dbg
# TODO(storypku): disable the following line temporarily as
# external/upb/upb/decode.c:164 can't compile
#build --copt="-Werror=sign-compare"
......@@ -45,18 +47,22 @@ build --define=PREFIX=/usr
build --define=LIBDIR=$(PREFIX)/lib
build --define=INCLUDEDIR=$(PREFIX)/include
# build --enable_platform_specific_config
# dbg config, as a shorthand for '--config=optimize -c dbg'
build:dbg --config=optimize -c dbg
build:opt --config=optimize -c opt
# dbg config, as a shorthand for '--config=opt -c dbg'
build:dbg --config=opt -c dbg
# Instruction set optimizations
build:optimize --copt=-march=native
build:optimize --host_copt=-march=native
build:optimize --define with_default_optimizations=true
## build -c opt
build:opt --copt=-march=native
build:opt --host_copt=-march=native
build:opt --define with_default_optimizations=true
build:cpu --define USE_GPU=false
build:gpu --define USE_GPU=true
build:opt_gpu --config=opt --config=gpu
# Instruction set optimizations
build:native_arch_linux --copt=-march=native
# build with profiling
build:cpu_prof --config=cpu
build:cpu_prof --linkopt=-lprofiler
# Build Apollo with C++ 17 features.
build:c++17 --cxxopt=-std=c++1z
......@@ -67,9 +73,6 @@ build:c++1z --config=c++17
build --cxxopt="-std=c++14"
build --host_cxxopt="-std=c++14"
# build with profiling
build:cpu_prof --linkopt=-lprofiler
# +------------------------------------------------------------+
# | Test Configurations |
# +------------------------------------------------------------+
......@@ -80,6 +83,8 @@ test --test_env=LD_LIBRARY_PATH
# By default prints output only from failed tests.
test --test_output=errors
test:unit_test -c dbg --test_verbose_timeout_warnings
test:coverage --copt=--coverage
test:coverage --cxxopt=--coverage
test:coverage --cxxopt=-fprofile-arcs
......@@ -88,7 +93,6 @@ test:coverage --linkopt=-coverage
test:coverage --linkopt=-lgcov
test:coverage --linkopt=-lgcc
test:coverage --linkopt=-lc
test:unit_test -c dbg --test_verbose_timeout_warnings
# +------------------------------------------------------------+
# | CPP Lint Tests & Unit Tests |
......
......@@ -9,6 +9,9 @@ def if_use_gpu(if_true, if_false = []):
"//conditions:default": if_false,
})
def copts_if_use_gpu():
return if_use_gpu(["-DUSE_GPU=1"], ["-DCPU_ONLY=1"])
def if_x86_mode(if_true, if_false = []):
return select({
"//tools/platform:x86_mode": if_true,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册