Skip to content

Commit

Permalink
Merge pull request #1072 from utwente-fmt/issue-1050
Browse files Browse the repository at this point in the history
fix #1050: set git buildinfos for caching properly
  • Loading branch information
pieter-bos authored Oct 12, 2023
2 parents b97c54f + 823be71 commit 0650c8f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -681,17 +681,22 @@ object vercors extends Module {
object test extends Tests

object buildInfo extends BuildInfo with ScalaModule {
def gitBranch() = T.command { os.proc("git", "rev-parse", "--abbrev", "HEAD").call().out.text() }
def gitCommit() = T.command { os.proc("git", "rev-parse", "HEAD").call().out.text() }
def gitShortCommit() = T.command { os.proc("git", "rev-parse", "--short=8", "HEAD").call().out.text() }
def gitHasChanges() = T.command { os.proc("git", "diff-index", "--name-only", "HEAD").call().out.text().nonEmpty }

def buildInfoPackageName = "vct.main"
override def buildInfoMembers = T {
Seq(
BuildInfo.Value("name", "VerCors"),
BuildInfo.Value("version", "2.0.0"),
BuildInfo.Value("scalaVersion", scalaVersion()),
BuildInfo.Value("sbtVersion", "-"),
BuildInfo.Value("currentBranch", "unknown branch"),
BuildInfo.Value("currentCommit", "unknown commit"),
BuildInfo.Value("currentShortCommit", "unknown commit"),
BuildInfo.Value("gitHasChanges", ""),
BuildInfo.Value("currentBranch", gitBranch()()),
BuildInfo.Value("currentCommit", gitCommit()()),
BuildInfo.Value("currentShortCommit", gitShortCommit()()),
BuildInfo.Value("gitHasChanges", gitHasChanges()().toString),
BuildInfo.Value("silverCommit", viper.silver.repo.commitish()),
BuildInfo.Value("siliconCommit", viper.silicon.repo.commitish()),
BuildInfo.Value("carbonCommit", viper.carbon.repo.commitish()),
Expand Down
2 changes: 1 addition & 1 deletion src/main/vct/cache/VerificationCache.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ case object VerificationCache extends LazyLogging {
def getSiliconDirectory: Path = getViperDirectory(BuildInfo.siliconCommit).resolve("silicon").resolve("verified")

private def getViperDirectory(backendCommit: String): Path = {
val variate = BuildInfo.gitHasChanges == "false"
val variate = BuildInfo.gitHasChanges != "false"

if(variate) {
logger.warn("Caching is enabled, but results will be discarded, since there were uncommitted changes at compilation time.")
Expand Down

0 comments on commit 0650c8f

Please sign in to comment.