Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement: Don't fail on hashing, but use a random hash #2058

Merged
merged 1 commit into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ object BloopZincCompiler {
skip: Boolean = false,
incrementalCompilerOptions: IncOptions,
extra: List[(String, String)]
): Task[CompileConfiguration] = Task.now {
)(implicit logger: ObservedLogger[_]): Task[CompileConfiguration] = Task.now {
// Remove directories from classpath hashes, we're only interested in jars
val jarClasspathHashes = BloopLookup.filterOutDirsFromHashedClasspath(classpathHashes)
val compileSetup = MiniSetup.of(
Expand Down Expand Up @@ -284,7 +284,7 @@ object BloopZincCompiler {
earlyOutput = None,
// deals with pipelining, not supported yet
earlyAnalysisStore = None,
stamper = BloopStamps.initial
stamper = BloopStamps.initial(logger)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object BloopIncremental {
}
}

val current = BloopStamps.initial
val current = BloopStamps.initial(log)
val externalAPI = getExternalAPI(lookup)
val previous = previous0 match { case a: Analysis => a }
val previousRelations = previous.relations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,36 @@ import xsbti.VirtualFileRef
import xsbti.compile.FileHash
import xsbti.compile.analysis.ReadStamps
import xsbti.compile.analysis.Stamp
import scala.util.control.NonFatal
import sbt.util.Logger
import sbt.internal.inc.FarmHash

object BloopStamps {
private val converter = PlainVirtualFileConverter.converter

private def underlying = Stamps.initial(
private def underlying(logger: Logger) = Stamps.initial(
BloopStamps.forHash,
// The hash is for the sources
BloopStamps.forHash,
Stamper.forHashInRootPaths(converter)
libraryStamp(logger)
)
def initial: ReadStamps = Stamps.timeWrapBinaryStamps(underlying, converter)

def libraryStamp(logger: Logger): VirtualFileRef => Stamp = { (file: VirtualFileRef) =>
{
val baseStamp = Stamper.forHashInRootPaths(converter)
try {
baseStamp(file)
} catch {
case NonFatal(e) =>
logger.error(s"Could not calculate hash for ${file.id} because of ${e.getMessage}")
FarmHash.fromLong(emptyHash.toLong)
}

}
}

def initial(logger: Logger): ReadStamps =
Stamps.timeWrapBinaryStamps(underlying(logger), converter)

private final val emptyHash = scala.util.Random.nextInt()
private final val directoryHash = scala.util.Random.nextInt()
Expand Down