Skip to content

Commit

Permalink
Merge pull request sbt#1433 from Friendseeker/merge-1-x
Browse files Browse the repository at this point in the history
[2.x] Merge 1.x branch into 2.x
  • Loading branch information
eed3si9n authored Oct 20, 2024
2 parents f9ca5e7 + 920d07f commit 7cebe83
Show file tree
Hide file tree
Showing 122 changed files with 486 additions and 207 deletions.
26 changes: 17 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:
- os: ubuntu-latest
java: 21
jobtype: 5
- os: ubuntu-latest
java: 21
jobtype: 6
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand Down Expand Up @@ -67,23 +70,28 @@ jobs:
shell: bash
run: |
sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Shapeless.*" "runBenchmarks"
- name: Checkout Target Branch (4, 5)
if: ${{ github.event_name == 'pull_request' && (matrix.jobtype == 4 || matrix.jobtype == 5) }}
- name: Benchmark (AnalysisFormatBenchmark) (6)
if: ${{ matrix.jobtype == 6 }}
shell: bash
run: |
sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*AnalysisFormatBenchmark.*" "runBenchmarks"
- name: Checkout Target Branch (4-6)
if: ${{ github.event_name == 'pull_request' && (matrix.jobtype >= 4 && matrix.jobtype <= 6) }}
uses: actions/checkout@v4
with:
clean: false
ref: ${{ github.event.pull_request.base.ref }}
- name: Setup SBT
uses: sbt/setup-sbt@v1
if: ${{ github.event_name == 'pull_request' && (matrix.jobtype >= 4 && matrix.jobtype <= 6) }}
- name: Benchmark (Scalac) against Target Branch (4)
if: ${{ github.event_name == 'pull_request' && matrix.jobtype == 4 }}
shell: bash
run: |
sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Scalac.*" "zincBenchmarks3/Jmh/clean" "runBenchmarks"
sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Scalac.*" "runBenchmarks"
- name: Benchmark (Shapeless) against Target Branch (5)
if: ${{ github.event_name == 'pull_request' && matrix.jobtype == 5 }}
shell: bash
run: |
sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Shapeless.*" "zincBenchmarks3/Jmh/clean" "runBenchmarks"
sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Shapeless.*" "runBenchmarks"
# - name: Benchmark (AnalysisFormatBenchmark) against Target Branch (6)
# if: ${{ github.event_name == 'pull_request' && matrix.jobtype == 6 }}
# shell: bash
# run: |
# sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*AnalysisFormatBenchmark.*" "runBenchmarks"
3 changes: 2 additions & 1 deletion .scala-steward.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ pullRequests.frequency = "14 days"
updates.ignore = [
# as per discussion on sbt/zinc#1236, this is
# "if it ain't broke don't fix it" territory
{ groupId = "com.google.protobuf" }
{ groupId = "com.google.protobuf" },
{ groupId = "org.eclipse.jgit" }
]
7 changes: 6 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def mimaSettings: Seq[Setting[?]] = Seq(
"1.5.0",
"1.6.0",
"1.7.0",
"1.8.0",
"1.9.0",
"1.10.0",
)
val versions =
if (scalaVersion.value.startsWith("2.12.")) pre140 ++ post140
Expand Down Expand Up @@ -555,6 +558,9 @@ lazy val zincClasspath = (projectMatrix in internalPath / "zinc-classpath")
exclude[IncompatibleResultTypeProblem](
"sbt.internal.inc.classpath.NativeCopyConfig.*"
),
exclude[IncompatibleResultTypeProblem](
"sbt.internal.inc.ReflectUtilities.fields"
),
exclude[IncompatibleSignatureProblem](
"sbt.internal.inc.classpath.NativeCopyConfig.*"
),
Expand Down Expand Up @@ -597,7 +603,6 @@ lazy val zincScripted = (projectMatrix in internalPath / "zinc-scripted")
.enablePlugins(BuildInfoPlugin)
.settings(
baseSettings,
ideSkipProject := true, // otherwise IntelliJ complains
publish / skip := true,
name := "zinc Scripted",
Compile / buildInfo := Nil, // Only generate build info for tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import java.util.Optional

import sbt.internal.inc.classpath.ClassLoaderCache
import sbt.io.IO
import sbt.io.syntax._
import xsbti.compile._
import sbt.util.Logger
import xsbti.TestCallback.ExtractedClassDependencies
Expand All @@ -35,7 +34,7 @@ trait CompilingSpecification extends AbstractBridgeProviderTestkit {
.get("zinc.build.compilerbridge.scalaVersion")
.getOrElse(sys.error("zinc.build.compilerbridge.scalaVersion property not found"))
def maxErrors = 100
def scala213 = "2.13.14"
def scala213 = "2.13.15"

def scalaCompiler(instance: xsbti.compile.ScalaInstance, bridgeJar: Path): AnalyzingCompiler = {
val bridgeProvider = ZincUtil.constantBridgeProvider(instance, bridgeJar)
Expand Down Expand Up @@ -281,8 +280,8 @@ trait CompilingSpecification extends AbstractBridgeProviderTestkit {
val cp = (si.allJars).map(_.toPath) ++ Array(targetDir)
val classpath = cp.map(converter.toVirtualFile)
sc.doc(
sources = sources.toArray[VirtualFile],
classpath = classpath,
sources = sources.toIndexedSeq,
classpath = classpath.toIndexedSeq,
converter = converter,
outputDirectory = targetDir,
options = Nil,
Expand All @@ -305,7 +304,7 @@ trait CompilingSpecification extends AbstractBridgeProviderTestkit {
val cp = (si.allJars).map(_.toPath) ++ Array(targetDir)
val classpath = cp.map(converter.toVirtualFile)
sc.console(
classpath = classpath,
classpath = classpath.toIndexedSeq,
converter = converter,
options = Nil,
initialCommands = initial,
Expand All @@ -327,7 +326,7 @@ trait CompilingSpecification extends AbstractBridgeProviderTestkit {
val cp = (si.allJars).map(_.toPath) ++ Array(targetDir)
val classpath = cp.map(converter.toVirtualFile)
sc.interactiveConsole(
classpath = classpath,
classpath = classpath.toIndexedSeq,
converter = converter,
options = args.toSeq,
initialCommands = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
package xsbt

import xsbti.{ PathBasedFile, VirtualFile }
import scala.reflect.io.Streamable

private trait AbstractZincFile extends scala.reflect.io.AbstractFile {
def underlying: VirtualFile
Expand All @@ -25,7 +24,22 @@ private final class ZincPlainFile private[xsbt] (val underlying: PathBasedFile)
private final class ZincVirtualFile private[xsbt] (val underlying: VirtualFile)
extends scala.reflect.io.VirtualFile(underlying.name, underlying.id)
with AbstractZincFile {
Streamable.closing(output)(_.write(Streamable.bytes(underlying.input))) // fill in the content
val buffer = new Array[Byte](4096)

val in = underlying.input()
val output0 = output

try {
var readBytes = in.read(buffer)

while (readBytes != -1) {
output0.write(buffer, 0, readBytes)
readBytes = in.read(buffer)
}
} finally {
in.close()
output0.close()
}
}

private object AbstractZincFile {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

package xsbt

import xsbti.{ AnalysisCallback, Severity }
import xsbti.{ AnalysisCallback, AnalysisCallback3, Severity }
import xsbti.compile._

import scala.tools.nsc._
Expand All @@ -20,6 +20,7 @@ import java.nio.file.{ Files, Path }

import scala.reflect.io.PlainFile
import scala.reflect.ReflectAccess._
import scala.reflect.internal.util.BatchSourceFile

/** Defines the interface of the incremental compiler hiding implementation details. */
sealed abstract class CallbackGlobal(
Expand Down Expand Up @@ -78,6 +79,15 @@ sealed class ZincCompiler(settings: Settings, dreporter: DelegatingReporter, out
extends CallbackGlobal(settings, dreporter, output)
with ZincGlobalCompat {

override def getSourceFile(f: AbstractFile): BatchSourceFile = {
val file = (f, callback) match {
case (plainFile: PlainFile, callback3: AnalysisCallback3) =>
AbstractZincFile(callback3.toVirtualFile(plainFile.file.toPath))
case _ => f
}
super.getSourceFile(file)
}

final class ZincRun(compileProgress: CompileProgress) extends Run {
override def informUnitStarting(phase: Phase, unit: CompilationUnit): Unit = {
compileProgress.startUnit(phase.name, unit.source.path)
Expand Down
29 changes: 24 additions & 5 deletions internal/compiler-bridge/src/main/scala/xsbt/CompilerBridge.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import scala.collection.mutable
import scala.reflect.io.AbstractFile
import scala.tools.nsc.CompilerCommand
import Log.debug
import xsbti.compile.analysis.ReadSourceInfos

import java.io.File

/**
Expand Down Expand Up @@ -49,6 +51,16 @@ class InterfaceCompileFailed(
override val toString: String
) extends xsbti.CompileFailed

class InterfaceCompileFailed2(
val arguments: Array[String],
val sourceInfos: ReadSourceInfos,
override val toString: String
) extends xsbti.CompileFailed2 {
import scala.collection.JavaConverters._
val problems: Array[Problem] =
sourceInfos.getAllSourceInfos.values().asScala.flatMap(_.getReportedProblems).toArray
}

class InterfaceCompileCancelled(val arguments: Array[String], override val toString: String)
extends xsbti.CompileCancelled

Expand Down Expand Up @@ -149,8 +161,8 @@ private final class CachedCompiler0(
underlyingReporter: DelegatingReporter,
compileProgress: CompileProgress
): Unit = {
// cast down to AnalysisCallback2
val callback2 = callback.asInstanceOf[xsbti.AnalysisCallback2]
// cast down to AnalysisCallback3
val callback3 = callback.asInstanceOf[xsbti.AnalysisCallback3]

compiler.set(callback, underlyingReporter)
if (command.shouldStopWithInfo) {
Expand All @@ -165,7 +177,7 @@ private final class CachedCompiler0(
run.compileFiles(sources)
processUnreportedWarnings(run)
underlyingReporter.problems.foreach(p =>
callback2.problem2(
callback3.problem2(
p.category,
p.position,
p.message,
Expand All @@ -180,8 +192,10 @@ private final class CachedCompiler0(
}

underlyingReporter.printSummary()
if (!noErrors(underlyingReporter))
handleErrors(underlyingReporter, log)
if (!noErrors(underlyingReporter)) {
val infos = callback3.getSourceInfos
handleErrors(infos, log)
}

// the case where we cancelled compilation _after_ some compilation errors got reported
// will be handled by line above so errors still will be reported properly just potentially not
Expand All @@ -195,6 +209,11 @@ private final class CachedCompiler0(
throw new InterfaceCompileFailed(args, dreporter.problems, "Compilation failed")
}

def handleErrors(sourceInfos: ReadSourceInfos, log: Logger): Nothing = {
debug(log, "Compilation failed (CompilerInterface)")
throw new InterfaceCompileFailed2(args, sourceInfos, "Compilation failed")
}

def handleCompilationCancellation(dreporter: DelegatingReporter, log: Logger): Nothing = {
assert(dreporter.cancelled, "We should get here only if when compilation got cancelled")
debug(log, "Compilation cancelled (CompilerInterface)")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
* This code is generated using [[https://www.scala-sbt.org/contraband]].
*/

// DO NOT EDIT MANUALLY
Expand Down
Loading

0 comments on commit 7cebe83

Please sign in to comment.