Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jchyb committed Oct 23, 2024
1 parent 449ae20 commit 8ec5c8d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
9 changes: 3 additions & 6 deletions backend/src/main/scala/bloop/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1016,12 +1016,9 @@ object Compiler {
BloopClassFileManager.supportedCompileProducts.filter(_ != ".betasty") :+ ".class"
Files
.walk(clientClassesDir.underlying)
.filter(path =>
Files.isRegularFile(path) && deletedCompileProducts.exists(
path.toString.endsWith(_)
)
)
.forEach(path => if (Files.exists(path)) Files.delete(path))
.filter(path => Files.isRegularFile(path))
.filter(path => deletedCompileProducts.exists(path.toString.endsWith(_)))
.forEach(Files.delete(_))
}.map(_ => ())
}

Expand Down
10 changes: 8 additions & 2 deletions frontend/src/main/scala/bloop/engine/tasks/CompileTask.scala
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ object CompileTask {
waitOnReadClassesDir.flatMap { _ =>
// Only when the task is finished, we kickstart the compilation
def compile(inputs: CompileInputs) = {
val firstResult = Compiler.compile(inputs, isBestEffort, isBestEffortDep, true)
val firstResult =
Compiler.compile(inputs, isBestEffort, isBestEffortDep, firstCompilation = true)
firstResult.flatMap {
case result @ Compiler.Result.Failed(
_,
Expand All @@ -196,7 +197,12 @@ object CompileTask {
previousCompilerResult = result,
previousResult = emptyResult
)
Compiler.compile(newInputs, isBestEffort, isBestEffortDep, false)
Compiler.compile(
newInputs,
isBestEffort,
isBestEffortDep,
firstCompilation = false
)
case result => Task(result)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,15 @@ object CompileGraph {
PartialFailure(bundle.project, FailedOrCancelledPromise, Task.now(results))
}

def loop(dag: Dag[Project], isBestEffortDep: Boolean): CompileTraversal = {
def loop(dag: Dag[Project]): CompileTraversal = {
tasks.get(dag) match {
case Some(task) => task
case None =>
val task: Task[Dag[PartialCompileResult]] = dag match {
case Leaf(project) =>
val bundleInputs = BundleInputs(project, dag, Map.empty)
setupAndDeduplicate(client, bundleInputs, computeBundle) { bundle =>
val isBestEffortDep = false
compile(Inputs(bundle, Map.empty), bestEffortAllowed && project.isBestEffort, isBestEffortDep).map { results =>
results.fromCompiler match {
case Compiler.Result.Ok(_) => Leaf(partialSuccess(bundle, results))
Expand All @@ -406,13 +407,13 @@ object CompileGraph {
}

case Aggregate(dags) =>
val downstream = dags.map(loop(_, isBestEffortDep = false))
val downstream = dags.map(loop(_))
Task.gatherUnordered(downstream).flatMap { dagResults =>
Task.now(Parent(PartialEmpty, dagResults))
}

case Parent(project, dependencies) =>
val downstream = dependencies.map(loop(_, isBestEffortDep = false))
val downstream = dependencies.map(loop(_))
Task.gatherUnordered(downstream).flatMap { dagResults =>
val depsSupportBestEffort =
dependencies.map(Dag.dfs(_, mode = Dag.PreOrder)).flatten.forall(_.isBestEffort)
Expand All @@ -433,7 +434,7 @@ object CompileGraph {
case _ => false
}
val continue = bestEffortAllowed && depsSupportBestEffort && successfulBestEffort || failed.isEmpty
val dependsOnBestEffort = failed.nonEmpty && bestEffortAllowed && depsSupportBestEffort || isBestEffortDep
val dependsOnBestEffort = failed.nonEmpty && bestEffortAllowed && depsSupportBestEffort

if (!continue) {
// Register the name of the projects we're blocked on (intransitively)
Expand Down Expand Up @@ -479,7 +480,7 @@ object CompileGraph {
}
}

loop(dag, isBestEffortDep = false)
loop(dag)
}

private def errorToString(err: Throwable): String = {
Expand Down

0 comments on commit 8ec5c8d

Please sign in to comment.