aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xcompile.sh5
-rwxr-xr-xscripts/bootstrap/bootstrap.sh4
-rwxr-xr-xscripts/bootstrap/buildenv.sh29
-rwxr-xr-xscripts/bootstrap/compile.sh8
4 files changed, 34 insertions, 12 deletions
diff --git a/compile.sh b/compile.sh
index 485d54c5fa..24a179f05a 100755
--- a/compile.sh
+++ b/compile.sh
@@ -24,6 +24,11 @@ set -o errexit
cd "$(dirname "$0")"
+# Set the default verbose mode in buildenv.sh so that we do not display command
+# output unless there is a failure. We do this conditionally to offer the user
+# a chance of overriding this in case they want to do so.
+: ${VERBOSE:=no}
+
source scripts/bootstrap/buildenv.sh
function usage() {
diff --git a/scripts/bootstrap/bootstrap.sh b/scripts/bootstrap/bootstrap.sh
index 13e71c0e6f..2fea800680 100755
--- a/scripts/bootstrap/bootstrap.sh
+++ b/scripts/bootstrap/bootstrap.sh
@@ -79,9 +79,9 @@ function bootstrap_test() {
local BAZEL_SUM=$2
local BAZEL_TARGET=${3:-src:bazel}
[ -x "${BAZEL_BIN}" ] || fail "syntax: bootstrap bazel-binary"
- run_silent ${BAZEL_BIN} --nomaster_bazelrc --bazelrc=${BAZELRC} clean \
+ run ${BAZEL_BIN} --nomaster_bazelrc --bazelrc=${BAZELRC} clean \
--expunge || return $?
- run_silent ${BAZEL_BIN} --nomaster_bazelrc --bazelrc=${BAZELRC} build \
+ run ${BAZEL_BIN} --nomaster_bazelrc --bazelrc=${BAZELRC} build \
${EXTRA_BAZEL_ARGS-} \
--strategy=Javac=worker --worker_quit_after_build \
--fetch --nostamp \
diff --git a/scripts/bootstrap/buildenv.sh b/scripts/bootstrap/buildenv.sh
index fa692046ee..98eacf7a26 100755
--- a/scripts/bootstrap/buildenv.sh
+++ b/scripts/bootstrap/buildenv.sh
@@ -43,6 +43,11 @@ msys*|mingw*)
EXE_EXT=".exe"
esac
+# Whether we display build messages or not. We set this conditionally because
+# the file including us or the user may already have defined VERBOSE to their
+# liking.
+: ${VERBOSE:=yes}
+
# List of functions to invoke on exit.
ATEXIT_HANDLERS=
@@ -109,12 +114,24 @@ eval "cleanup_phasefile() {
}"
atexit cleanup_phasefile
-function run_silent() {
- echo "${@}" >${errfile}
- # TODO(kchodorow): figure out why this doesn't exit on a non-zero exit code,
- # even though errexit is set.
- "${@}" >>${errfile} 2>&1 || exit $?
- rm ${errfile}
+# Excutes a command respecting the current verbosity settings.
+#
+# If VERBOSE is yes, the command itself and its output are printed.
+# If VERBOSE is no, the command's output is only displayed in case of failure.
+#
+# Exits the script if the command fails.
+function run() {
+ if [ "${VERBOSE}" = yes ]; then
+ echo "${@}"
+ "${@}" || exit $?
+ else
+ echo "${@}" >"${errfile}"
+ # The exit here is needed because "set -e" on the shell does not cause
+ # errors in functions to exit in all cases. We should probably disable
+ # "set -e" altogether and add explicit error handling where necessary.
+ "${@}" >>"${errfile}" 2>&1 || exit $?
+ rm "${errfile}"
+ fi
}
function fail() {
diff --git a/scripts/bootstrap/compile.sh b/scripts/bootstrap/compile.sh
index 9195e7a48c..e5857195ba 100755
--- a/scripts/bootstrap/compile.sh
+++ b/scripts/bootstrap/compile.sh
@@ -125,13 +125,13 @@ function java_compilation() {
cat "$paramfile" >&2
fi
- run_silent "${JAVAC}" -classpath "${classpath}" -sourcepath "${sourcepath}" \
+ run "${JAVAC}" -classpath "${classpath}" -sourcepath "${sourcepath}" \
-d "${output}/classes" -source "$JAVA_VERSION" -target "$JAVA_VERSION" \
-encoding UTF-8 "@${paramfile}"
log "Extracting helper classes for $name..."
for f in ${library_jars} ; do
- run_silent unzip -qn ${f} -d "${output}/classes"
+ run unzip -qn ${f} -d "${output}/classes"
done
}
@@ -151,13 +151,13 @@ function create_deploy_jar() {
log "Creating $name.jar..."
echo "Main-Class: $mainClass" > $output/MANIFEST.MF
- run_silent "$JAR" cmf $output/MANIFEST.MF $output/$name.jar $packages "$@"
+ run "$JAR" cmf $output/MANIFEST.MF $output/$name.jar $packages "$@"
}
if [ -z "${BAZEL_SKIP_JAVA_COMPILATION}" ]; then
log "Compiling Java stubs for protocol buffers..."
for f in $PROTO_FILES ; do
- run_silent "${PROTOC}" -Isrc/main/protobuf/ --java_out=${OUTPUT_DIR}/src "$f"
+ run "${PROTOC}" -Isrc/main/protobuf/ --java_out=${OUTPUT_DIR}/src "$f"
done
java_compilation "Bazel Java" "$DIRS" "$LIBRARY_JARS" "${OUTPUT_DIR}"