[reflection] Check whether a pointer is valid before dereferencing (#19842)
[mono-project.git] / sdks / builds / wrap-configure.sh
blob735fd778dc2eed70e8ab700ea82617bf1f3c1b5a
1 #!/bin/bash -e
3 START=$(date -u +"%s")
5 # First argument is the directory where we'll execute configure
6 # We assume the directory name is descriptive and use it in messages
7 # and temporary file names.
8 DIR="$1"
9 D=$(basename "$DIR")
10 shift
12 # Check if a cache is being used
13 if test -f "$D.config.cache"; then
14 HAS_CACHE=1
17 mkdir -p "$D"
18 echo "Configuring $D"
19 cd "$DIR"
21 # The rest of the arguments is the command to execute.
23 # We capture the output to a log (to make the output more quiet), and only
24 # print it if something goes wrong (in which case we print config.log as well,
25 # which can be quite useful when looking at configure problems on bots where
26 # there's much information in that file).
28 # If a cache was used and configure failed, we remove the cache and then try
29 # again.
31 if ! "$@" > ".stamp-configure-$D.log" 2>&1; then
32 FAILED=1
33 if [[ x"$HAS_CACHE" == "x1" ]]; then
34 echo "Configuring $D failed, but a cache was used. Will try to configure without the cache."
35 rm "../$D.config.cache"
36 if ! "$@" > ".stamp-configure-$D.log" 2>&1; then
37 echo "Configuring $D failed without cache as well."
38 else
39 FAILED=
43 if [[ x"$FAILED" == "x1" ]]; then
44 echo "Configuring $D failed:"
45 sed "s/^/ /" < ".stamp-configure-$D.log"
47 # Only show config.log if building on CI (jenkins/wrench)
48 SHOW_CONFIG_LOG=0
49 if test -n "$JENKINS_HOME"; then
50 SHOW_CONFIG_LOG=1
51 elif test -n "$BUILD_REVISION"; then
52 SHOW_CONFIG_LOG=1
54 if [[ x$SHOW_CONFIG_LOG == x1 ]]; then
55 echo
56 echo " *** config.log *** "
57 echo
58 sed "s/^/ /" < config.log
60 exit 1
64 END=$(date -u +"%s")
65 DIFF=$((END-START))
67 echo "Configured $D in $((DIFF/60))m $((DIFF%60))s"