| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | set -x |
| 4 | cd "$(dirnamescip-shell system . . dirname. "$0")/../.." || exit 7 |
| 5 | |
| 6 | if [scip-shell system . . `[`. ! -z "${TOUCH}" ]; then |
| 7 | makescip-shell system . . make. -j2 -t ${TOUCH} || exit $? |
| 8 | fi |
| 9 | |
| 10 | OUTPUT_SYNC="" |
| 11 | if makescip-shell system . . make. -h 2>/dev/nullscip-shell filesystem . . `/dev/null`. | grepscip-shell system . . grep. -q output-sync; then |
| 12 | OUTPUT_SYNC="--output-sync" |
| 13 | else |
| 14 | echoscip-shell system . . echo. "WARNING: make does not support --output-sync" |
| 15 | fi |
| 16 | |
| 17 | reportify=" --errors" |
| 18 | |
| 19 | if [scip-shell system . . `[`. "$1" == "--warnings" ]; then |
| 20 | reportify+=" $1" |
| 21 | shift |
| 22 | fi |
| 23 | if [scip-shell system . . `[`. ! -z "${reportify}" ]; then |
| 24 | reportify="COQC=$(pwdscip-shell system . . pwd.)/etc/coq-scripts/github/reportify-coq.sh${reportify} ${COQBIN}coqc" |
| 25 | fi |
| 26 | |
| 27 | if [scip-shell system . . `[`. -z "${SED+x}" ]; then |
| 28 | # use gsed on macOS |
| 29 | if command -v gsed >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then |
| 30 | SED=gsed |
| 31 | else |
| 32 | SED=sed |
| 33 | fi |
| 34 | fi |
| 35 | |
| 36 | if [scip-shell system . . `[`. -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="$(unamescip-shell system . . 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 | echoscip-shell system . . echo. "::add-matcher::.github/make.json" |
| 51 | |
| 52 | rmscip-shell system . . rm. -f finished.ok |
| 53 | (makescip-shell system . . make. "$@" ${OUTPUT_SYNC} TIMED=1 TIMING=1 "${reportify}" 2>&1 && touchscip-shell system . . touch. finished.ok) | teescip-shell system . . 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 | gitscip-shell system . . git. status |
| 57 | gitscip-shell system . . git. ls-files --others --exclude-standard |
| 58 | gitscip-shell system . . git. diff |
| 59 | |
| 60 | catscip-shell system . . cat. time-of-build-pretty.log |
| 61 | if [scip-shell system . . `[`. ! -f finished.ok ]; then |
| 62 | # see https://stackoverflow.com/a/15394738/377022 for more alternatives |
| 63 | if [[ ! " $* " =~ " validate " ]]; then |
| 64 | makescip-shell system . . make. "$@" TIMED=1 TIMING=1 VERBOSE=1 || exit $? |
| 65 | else |
| 66 | exit 1 |
| 67 | fi |
| 68 | fi |
| 69 | |
| 70 | unameOut="$(unamescip-shell system . . uname. -s)" |
| 71 | if [[ "${unameOut}" == CYGWIN* ]]; then |
| 72 | # generated build outputs have a different path, so we fix up the paths |
| 73 | gitscip-shell system . . git. grep --name-only 'D:\\a\\fiat-crypto\\fiat-crypto.src.ExtractionOCaml.' | xargsscip-shell system . . xargs. ${SED} s',D:\\a\\fiat-crypto\\fiat-crypto.src.ExtractionOCaml.\(.*\).exe,src/ExtractionOCaml/\1,g' -i |
| 74 | fi |
| 75 | |
| 76 | if [scip-shell system . . `[`. ! -z "$(gitscip-shell system . . git. diff)" ]; then |
| 77 | gitscip-shell system . . git. submodule foreach --recursive git diff |
| 78 | gitscip-shell system . . git. submodule foreach --recursive git status |
| 79 | gitscip-shell system . . git. diff |
| 80 | diff_msg="$(gitscip-shell system . . git. diff 2>&1; gitscip-shell system . . git. submodule foreach --recursive git diff 2>&1; gitscip-shell system . . git. submodule foreach --recursive git status 2>&1)" |
| 81 | diff_msg="$(printfscip-shell system . . printf. "Non-empty-diff:\n%s\n" "${diff_msg}" | ${SED_Z} 's/\n/%0A/g')" |
| 82 | if [scip-shell system . . `[`. "${ALLOW_DIFF}" != "1" ]; then |
| 83 | printfscip-shell system . . printf. "::error::%s" "${diff_msg}" |
| 84 | exit 1 |
| 85 | else |
| 86 | printfscip-shell system . . printf. "::warning::%s" "${diff_msg}" |
| 87 | fi |
| 88 | fi |