diff options
author | Rolf Bjarne Kvinge <rolf@xamarin.com> | 2018-04-18 15:26:20 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2018-05-01 01:20:20 +0300 |
commit | a085951264bf82fbf77765078d1138d04ad4d6ab (patch) | |
tree | dce9f75b118f64c90c5b350875f475605cba3784 | |
parent | b4a42e6e4b35cb87bc2b8e1f58e8651087336a34 (diff) |
[sdks] Wrap configure to provide better output.
Wrap configure in a script that:
* Captures stdout/stderr and only shows it in case of errors.
* If configure fails, and a cache file was used, deletes the cache file and
tries again.
* If configure really fails, then print config.log in addition to
stdout/stderr, since a lot of valuable diagnostic output is in that file
(and it's annoying to track down configure failures on bots when the file
with the important output has already been deleted).
-rw-r--r-- | sdks/builds/runtime.mk | 2 | ||||
-rwxr-xr-x | sdks/builds/wrap-configure.sh | 57 |
2 files changed, 58 insertions, 1 deletions
diff --git a/sdks/builds/runtime.mk b/sdks/builds/runtime.mk index 876585b7496..9c82a71616d 100644 --- a/sdks/builds/runtime.mk +++ b/sdks/builds/runtime.mk @@ -50,7 +50,7 @@ __$(1)_CONFIGURE_ENVIRONMENT = \ .stamp-$(1)-$$(CONFIGURATION)-configure: $$(TOP)/configure .stamp-$(1)-toolchain mkdir -p $$(TOP)/sdks/builds/$(1)-$$(CONFIGURATION) - cd $$(TOP)/sdks/builds/$(1)-$$(CONFIGURATION) && $(if $$(_$(1)_PATH),PATH="$$$$PATH:$$(_$(1)_PATH)") $$(TOP)/configure $$(_$(1)_AC_VARS) $$(__$(1)_CONFIGURE_ENVIRONMENT) $$(_$(1)_CONFIGURE_FLAGS) + $(if $$(_$(1)_PATH),PATH="$$$$PATH:$$(_$(1)_PATH)") ./wrap-configure.sh $$(TOP)/sdks/builds/$(1)-$$(CONFIGURATION) $(abspath $(TOP)/configure) $$(_$(1)_AC_VARS) $$(__$(1)_CONFIGURE_ENVIRONMENT) $$(_$(1)_CONFIGURE_FLAGS) touch $$@ .PHONY: .stamp-$(1)-configure diff --git a/sdks/builds/wrap-configure.sh b/sdks/builds/wrap-configure.sh new file mode 100755 index 00000000000..9e077a27389 --- /dev/null +++ b/sdks/builds/wrap-configure.sh @@ -0,0 +1,57 @@ +#!/bin/bash -e + +START=$(date -u +"%s") + +# First argument is the directory where we'll execute configure +# We assume the directory name is descriptive and use it in messages +# and temporary file names. +DIR="$1" +D=$(basename "$DIR") +shift + +# Check if a cache is being used +if test -f "$D.config.cache"; then + HAS_CACHE=1 +fi + +mkdir -p "$D" +echo "Configuring $D" +cd "$DIR" + +# The rest of the arguments is the command to execute. +# +# We capture the output to a log (to make the output more quiet), and only +# print it if something goes wrong (in which case we print config.log as well, +# which can be quite useful when looking at configure problems on bots where +# there's much information in that file). +# +# If a cache was used and configure failed, we remove the cache and then try +# again. +# +if ! "$@" > ".stamp-configure-$D.log" 2>&1; then + FAILED=1 + if [[ x"$HAS_CACHE" == "x1" ]]; then + echo "Configuring $D failed, but a cache was used. Will try to configure without the cache." + rm "../$D.config.cache" + if ! "$@" > ".stamp-configure-$D.log" 2>&1; then + echo "Configuring $D failed without cache as well." + else + FAILED= + fi + fi + + if [[ x"$FAILED" == "x1" ]]; then + echo "Configuring $D failed:" + sed "s/^/ /" < ".stamp-configure-$D.log" + echo + echo " *** config.log *** " + echo + sed "s/^/ /" < config.log + exit 1 + fi +fi + +END=$(date -u +"%s") +DIFF=$((END-START)) + +echo "Configured $D in $((DIFF/60))m $((DIFF%60))s" |