Skip to content

Commit 75318c7

Browse files
author
Blaine Freestone
committed
!fixup add -sourceroot
1 parent 6a766fe commit 75318c7

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

src/main/scala/higherkindness/rules_scala/workers/zinc/compile/FilteredSetup.scala

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ import xsbti.compile.{CompileOptions, MiniSetup}
44
import java.nio.file.{Path, Paths}
55

66
/**
7-
* Zinc's MiniSetup contains scalacOptions which include the -sourceroot flag that references
8-
* absolute sandbox paths. These paths are non-deterministic across builds because the sandbox
9-
* directory changes (e.g., __sandbox/4/_main vs __sandbox/8/_main), making the analysis files
10-
* non-deterministic.
7+
* Zinc's MiniSetup contains scalacOptions which include the -sourceroot flag that references absolute sandbox paths.
8+
* These paths are non-deterministic across builds because the sandbox directory changes (e.g., __sandbox/4/_main vs
9+
* __sandbox/8/_main), making the analysis files non-deterministic.
1110
*
12-
* This class filters out the -sourceroot option from the scalacOptions to ensure deterministic
13-
* analysis files.
11+
* This class filters out the -sourceroot option from the scalacOptions to ensure deterministic analysis files.
1412
*
1513
* TODO: Consider if there's a better way to handle this upstream in Zinc
1614
*/
15+
1716
object FilteredSetup {
1817
private val sourcerootFlag = "-sourceroot"
1918

@@ -24,7 +23,6 @@ object FilteredSetup {
2423
val filteredScalacOptions = {
2524
val originalOptions = options.scalacOptions()
2625
val filtered = scala.collection.mutable.ArrayBuffer[String]()
27-
2826
var i = 0
2927
while (i < originalOptions.length) {
3028
val option = originalOptions(i)
@@ -36,7 +34,6 @@ object FilteredSetup {
3634
i += 1
3735
}
3836
}
39-
4037
filtered.toArray
4138
}
4239

src/main/scala/higherkindness/rules_scala/workers/zinc/compile/ZincRunner.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,21 +216,21 @@ object ZincRunner extends WorkerMain[ZincRunnerWorkerConfig] {
216216
scalaInstance.actualVersion.startsWith("3")
217217

218218
val scalacOptions =
219-
workRequest.plugins.view.map(p => s"-Xplugin:$p").toArray ++
220-
workRequest.compilerOptions ++
221-
workRequest.compilerOptionsReferencingPaths.toArray ++
222-
(if (shouldIncludeSourceRoot)
223-
Array("-sourceroot", task.workDir.toAbsolutePath().toString)
224-
else
225-
Array.empty[String])
219+
workRequest.plugins.view.map(p => s"-Xplugin:$p").toArray ++
220+
workRequest.compilerOptions ++
221+
workRequest.compilerOptionsReferencingPaths.toArray ++
222+
(if (shouldIncludeSourceRoot)
223+
Array("-sourceroot", task.workDir.toAbsolutePath().toString)
224+
else
225+
Array.empty[String])
226226

227227
val compileOptions =
228228
CompileOptions.create
229-
.withSources(sources.view.map(source => PlainVirtualFile(source.toAbsolutePath().normalize())).toArray)
230-
.withClasspath((classesOutputDir +: deps.view.map(_.classpath)).map(path => PlainVirtualFile(path)).toArray)
231-
.withClassesDirectory(classesOutputDir)
232-
.withJavacOptions(workRequest.javaCompilerOptions)
233-
.withScalacOptions(scalacOptions)
229+
.withSources(sources.view.map(source => PlainVirtualFile(source.toAbsolutePath().normalize())).toArray)
230+
.withClasspath((classesOutputDir +: deps.view.map(_.classpath)).map(path => PlainVirtualFile(path)).toArray)
231+
.withClassesDirectory(classesOutputDir)
232+
.withJavacOptions(workRequest.javaCompilerOptions)
233+
.withScalacOptions(scalacOptions)
234234

235235
val compilers = {
236236
val scalaCompiler = ZincUtil

0 commit comments

Comments
 (0)