Debian Codegraph @

etc/ci/github-actions-make.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2
3 set -x
4 cd "$(dirname "$0")/../.." || exit 7
5
6 if [ ! -z "${TOUCH}" ]; then
7 make -j2 -t ${TOUCH} || exit $?
8 fi
9
10 OUTPUT_SYNC=""
11 if make -h 2>/dev/null | grep -q output-sync; then
12 OUTPUT_SYNC="--output-sync"
13 else
14 echo "WARNING: make does not support --output-sync"
15 fi
16
17 reportify=" --errors"
18
19 if [ "$1" == "--warnings" ]; then
20 reportify+=" $1"
21 shift
22 fi
23 if [ ! -z "${reportify}" ]; then
24 reportify="COQC=$(pwd)/etc/coq-scripts/github/reportify-coq.sh${reportify} ${COQBIN}coqc"
25 fi
26
27 if [ -z "${SED+x}" ]; then
28 # use gsed on macOS
29 if command -v gsed >/dev/null 2>&1; then
30 SED=gsed
31 else
32 SED=sed
33 fi
34 fi
35
36 if [ -z "${SED_Z}" ]; then
37 SED_Z="${SED} -z"
38 fi
39
40 export SED
41 export SED_Z
42
43 make_one_time_file_real=""
44 unameOut="$(uname -s)"
45 if [[ "${unameOut}" == CYGWIN* ]]; then
46 # time on cygwin doesn't report accurate user times, so we use real times
47 make_one_time_file_real="--real"
48 fi
49
50 echo "::add-matcher::.github/make.json"
51
52 rm -f finished.ok
53 (make "$@" ${OUTPUT_SYNC} TIMED=1 TIMING=1 "${reportify}" 2>&1 && touch finished.ok) | tee -a time-of-build.log
54 python "./etc/coq-scripts/timing/make-one-time-file.py" ${make_one_time_file_real} "time-of-build.log" "time-of-build-pretty.log" || exit $?
55
56 git status
57 git ls-files --others --exclude-standard
58 git diff
59
60 cat time-of-build-pretty.log
61 if [ ! -f finished.ok ]; then
62 # see https://stackoverflow.com/a/15394738/377022 for more alternatives
63 if [[ ! " $* " =~ " validate " ]]; then
64 make "$@" TIMED=1 TIMING=1 VERBOSE=1 || exit $?
65 else
66 exit 1
67 fi
68 fi
69
70 unameOut="$(uname -s)"
71 if [[ "${unameOut}" == CYGWIN* ]]; then
72 # generated build outputs have a different path, so we fix up the paths
73 git grep --name-only 'D:\\a\\fiat-crypto\\fiat-crypto.src.ExtractionOCaml.' | xargs ${SED} s',D:\\a\\fiat-crypto\\fiat-crypto.src.ExtractionOCaml.\(.*\).exe,src/ExtractionOCaml/\1,g' -i
74 fi
75
76 if [ ! -z "$(git diff)" ]; then
77 git submodule foreach --recursive git diff
78 git submodule foreach --recursive git status
79 git diff
80 diff_msg="$(git diff 2>&1; git submodule foreach --recursive git diff 2>&1; git submodule foreach --recursive git status 2>&1)"
81 diff_msg="$(printf "Non-empty-diff:\n%s\n" "${diff_msg}" | ${SED_Z} 's/\n/%0A/g')"
82 if [ "${ALLOW_DIFF}" != "1" ]; then
83 printf "::error::%s" "${diff_msg}"
84 exit 1
85 else
86 printf "::warning::%s" "${diff_msg}"
87 fi
88 fi