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

Support Scala 3's Best Effort compilation #2049

Merged
merged 3 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 34 additions & 15 deletions backend/src/main/scala/bloop/BloopClassFileManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final class BloopClassFileManager(
private[this] val generatedFiles = new mutable.HashSet[File]

// Supported compile products by the class file manager
private[this] val supportedCompileProducts = List(".sjsir", ".nir", ".tasty")
private[this] val supportedCompileProducts = List(".sjsir", ".nir", ".tasty", ".betasty")
// Files backed up during compilation
private[this] val movedFiles = new mutable.HashMap[File, File]

Expand Down Expand Up @@ -215,20 +215,38 @@ final class BloopClassFileManager(
clientTracer: BraveTracer
) => {
clientTracer.traceTaskVerbose("copy new products to external classes dir") { _ =>
val config = ParallelOps.CopyConfiguration(5, CopyMode.ReplaceExisting, Set.empty)
ParallelOps
.copyDirectories(config)(
newClassesDir,
clientExternalClassesDir.underlying,
inputs.ioScheduler,
enableCancellation = false,
inputs.logger
)
.map { walked =>
readOnlyCopyDenylist.++=(walked.target)
val config =
ParallelOps.CopyConfiguration(5, CopyMode.ReplaceExisting, Set.empty, Set.empty)
val clientExternalBestEffortDir =
clientExternalClassesDir.underlying.resolve("META-INF/best-effort")

// Deletes all previous best-effort artifacts to get rid of all of the outdated ones.
tgodzik marked this conversation as resolved.
Show resolved Hide resolved
// Since best effort compilation is not affected by incremental compilation,
// all relevant files are always produced by the compiler. Because of this,
// we can always delete all previous files and copy newly created ones
// without losing anything in the process.
val deleteClientExternalBestEffortDir =
Task {
if (Files.exists(clientExternalBestEffortDir)) {
BloopPaths.delete(AbsolutePath(clientExternalBestEffortDir))
}
()
}
.flatMap(_ => deleteAfterCompilation)
}.memoize

deleteClientExternalBestEffortDir *>
ParallelOps
.copyDirectories(config)(
newClassesDir,
clientExternalClassesDir.underlying,
inputs.ioScheduler,
enableCancellation = false,
inputs.logger
)
.map { walked =>
readOnlyCopyDenylist.++=(walked.target)
()
}
.flatMap(_ => deleteAfterCompilation)
}
}
)
Expand Down Expand Up @@ -274,7 +292,8 @@ final class BloopClassFileManager(
else
clientTracer.traceTask("populate empty classes dir") { _ =>
// Prepopulate external classes dir even though compilation failed
val config = ParallelOps.CopyConfiguration(1, CopyMode.NoReplace, Set.empty)
val config =
ParallelOps.CopyConfiguration(1, CopyMode.NoReplace, Set.empty, Set.empty)
ParallelOps
.copyDirectories(config)(
Paths.get(readOnlyClassesDirPath),
Expand Down
Loading
Loading