Skip to content

Commit

Permalink
Scripts: updated non-interactive mode support for apollo_config.sh
Browse files Browse the repository at this point in the history
Goodbye to tools/apollo.bazelrc.sample
  • Loading branch information
storypku authored and xiaoxq committed Sep 13, 2020
1 parent 1940d11 commit 7729a6d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 56 deletions.
66 changes: 33 additions & 33 deletions scripts/apollo_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
21 changes: 0 additions & 21 deletions tools/apollo.bazelrc.sample

This file was deleted.

2 changes: 0 additions & 2 deletions tools/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7729a6d

Please sign in to comment.