diff options
author | Klaus Aehlig <aehlig@google.com> | 2016-07-11 12:06:07 +0000 |
---|---|---|
committer | Kristina Chodorow <kchodorow@google.com> | 2016-07-11 12:24:59 +0000 |
commit | 276a8cd19d4cde6245ed3323cee695e7834a0b9d (patch) | |
tree | 2dbbb0af748a26b32b9f1270b0ae397df4af50ba | |
parent | 6c0acf527146d1fa5c90eaf180639aae9fea775a (diff) |
Make bootstrapping support a designated work dir
Change the bootstrapping process so that setting the BAZEL_WRKDIR
environment variable will tell the bootstrap process to mostly write
to that directory---apart from adding the symlinks next to the WORKSPACE
file. So setting this variable will avoid the usual writes to random
places in the file system (like /tmp and the user's home directory).
--
Change-Id: I9d1af747e75cc2a7bb1af08308acc9dfd927e920
Reviewed-on: https://bazel-review.googlesource.com/#/c/3963
MOS_MIGRATED_REVID=127075535
-rwxr-xr-x | compile.sh | 4 | ||||
-rwxr-xr-x | scripts/bootstrap/bootstrap.sh | 10 | ||||
-rwxr-xr-x | scripts/bootstrap/buildenv.sh | 15 | ||||
-rwxr-xr-x | scripts/bootstrap/compile.sh | 1 |
4 files changed, 25 insertions, 5 deletions
diff --git a/compile.sh b/compile.sh index 4daeb3ae54..53fc4127b9 100755 --- a/compile.sh +++ b/compile.sh @@ -189,7 +189,9 @@ if [ $DO_TESTS ]; then fi fi fi - $BAZEL --bazelrc=${BAZELRC} --nomaster_bazelrc test \ + $BAZEL --bazelrc=${BAZELRC} --nomaster_bazelrc \ + ${BAZEL_DIR_STARTUP_OPTIONS} \ + test \ --test_tag_filters="${BAZEL_TEST_FILTERS-}" \ --build_tests_only \ --nolegacy_bazel_java_test \ diff --git a/scripts/bootstrap/bootstrap.sh b/scripts/bootstrap/bootstrap.sh index d11b6c5086..e6143f7c0d 100755 --- a/scripts/bootstrap/bootstrap.sh +++ b/scripts/bootstrap/bootstrap.sh @@ -54,7 +54,7 @@ if [ -z "${BAZEL-}" ]; then } else function bazel_build() { - ${BAZEL} --bazelrc=${BAZELRC} build \ + ${BAZEL} --bazelrc=${BAZELRC} ${BAZEL_DIR_STARTUP_OPTIONS} build \ ${BAZEL_ARGS-} \ --verbose_failures \ --javacopt="-source ${JAVA_VERSION} -target ${JAVA_VERSION}" \ @@ -89,9 +89,13 @@ function bootstrap_test() { STRATEGY= fi [ -x "${BAZEL_BIN}" ] || fail "syntax: bootstrap bazel-binary" - run ${BAZEL_BIN} --nomaster_bazelrc --bazelrc=${BAZELRC} clean \ + run ${BAZEL_BIN} --nomaster_bazelrc --bazelrc=${BAZELRC} \ + ${BAZEL_DIR_STARTUP_OPTIONS} \ + clean \ --expunge || return $? - run ${BAZEL_BIN} --nomaster_bazelrc --bazelrc=${BAZELRC} build \ + run ${BAZEL_BIN} --nomaster_bazelrc --bazelrc=${BAZELRC} \ + ${BAZEL_DIR_STARTUP_OPTIONS} \ + build \ ${EXTRA_BAZEL_ARGS-} ${STRATEGY} \ --fetch --nostamp \ --define "JAVA_VERSION=${JAVA_VERSION}" \ diff --git a/scripts/bootstrap/buildenv.sh b/scripts/bootstrap/buildenv.sh index 6efa3556c8..6c851b00c8 100755 --- a/scripts/bootstrap/buildenv.sh +++ b/scripts/bootstrap/buildenv.sh @@ -18,6 +18,19 @@ set -o errexit +# If BAZEL_WRKDIR is set, default all variables to point into +# that directory + +if [ -n "${BAZEL_WRKDIR}" ] ; then + mkdir -p "${BAZEL_WRKDIR}/tmp" + mkdir -p "${BAZEL_WRKDIR}/user_root" + : ${TMPDIR:=${BAZEL_WRKDIR}/tmp} + export TMPDIR + : ${BAZEL_DIR_STARTUP_OPTIONS:="--output_user_root=${BAZEL_WRKDIR}/user_root"} +fi + + +# Set standard variables DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) WORKSPACE_DIR="$(dirname $(dirname ${DIR}))" @@ -245,6 +258,6 @@ function get_java_version() { # Return the target that a bind point to, using Bazel query. function get_bind_target() { - $BAZEL --bazelrc=${BAZELRC} --nomaster_bazelrc \ + $BAZEL --bazelrc=${BAZELRC} --nomaster_bazelrc ${BAZEL_DIR_STARTUP_OPTIONS} \ query "deps($1, 1) - $1" } diff --git a/scripts/bootstrap/compile.sh b/scripts/bootstrap/compile.sh index 2cb8e58710..ff81f2707b 100755 --- a/scripts/bootstrap/compile.sh +++ b/scripts/bootstrap/compile.sh @@ -277,6 +277,7 @@ function bootstrap_build() { --install_md5= \ --workspace_directory=${PWD} \ --nofatal_event_bus_exceptions \ + ${BAZEL_DIR_STARTUP_OPTIONS} \ build \ --ignore_unsupported_sandboxing \ --startup_time=329 --extract_data_time=523 \ |