From 588f5c3184715973f944ad949f9d3902b9659113 Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Thu, 2 Jun 2022 10:24:49 -0400 Subject: [PATCH] Always embed git commit into --version output Previously, we attempted to scrub out `git` commits from release binaries using a `sed` invocation in the `cry` script, but as was observed in #1353, this ended up scrubbing out `git` commits on all builds, not just release ones. We have decided that we should just include `git` commits on all builds, so we can fix the issue by removing the buggy use of `sed`. Unfortunately, `cabal`'s recompilation logic is not smart enough to always rebuild `GitRev.hs` on every new commit, even though it should. For this reason, we make the `./cry build` command temporarily dirty the `GitRev.hs` file so that it is forcibly rebuilt, then revert the change to `GitRev.hs` and rebuild. It's rather heavy-handed, but it works. Fixes #1353. --- cry | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/cry b/cry index d2436b3f..63964cbc 100755 --- a/cry +++ b/cry @@ -44,25 +44,17 @@ case $COMMAND in # XXX: This is a workaround the fact that currently Cabal # will not rebuild this file, even though it has TH code, that # depends on the environment. For now, we temporarily modify the - # file, then build, then revert it back after build. + # file, then build, then revert it back, then build once more. dirty_string="-- Last build $(date)" echo "$dirty_string" >> src/GitRev.hs - if [[ -n "$RELEASE" ]]; then - sed -i.bak -e 's/^commitShortHash = .*$/commitShortHash = "UNKNOWN"/' \ - -e 's/^commitHash = .*$/commitHash = "UNKNOWN"/' \ - -e 's/^commitBranch = .*$/commitBranch = "UNKNOWN"/' \ - -e 's/^commitDirty = .*$/commitDirty = False/' \ - -e '/import qualified GitRev/d' \ - src/Cryptol/Version.hs - rm -f src/Cryptol/Version.hs.bak - fi - cabal v2-build "$@" exe:cryptol sed -i.bak "/^-- Last build/d" src/GitRev.hs rm -f src/GitRev.hs.bak + + cabal v2-build "$@" exe:cryptol ;; haddock) echo Building Haddock documentation && cabal v2-haddock ;;