Skip to content

Commit

Permalink
Merge pull request #125 from alexarchambault/merge-upstream
Browse files Browse the repository at this point in the history
Merge upstream changes
  • Loading branch information
alexarchambault authored Dec 14, 2022
2 parents 7169d10 + 67a0287 commit 20d804f
Show file tree
Hide file tree
Showing 54 changed files with 396 additions and 4,057 deletions.
5 changes: 5 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Scala Steward: Reformat with scalafmt 3.0.8
9f3d87ca53be47fb391f90b7370c4dbc6914b503

# Scala Steward: Reformat with scalafmt 3.6.1
77bc6a5845189a9659476d29fd7c02be5327ab8a
19 changes: 0 additions & 19 deletions .github/workflows/steward.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .scala-steward.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
updates.ignore = [
{ groupId = "com.github.plokhotnyuk.jsoniter-scala" },
{ groupId = "ch.epfl.scala", artifactId = "nailgun-server" },
{ groupId = "ch.epfl.scala", artifactId = "sbt-release-early" }
]
commits.message = "build(deps): Update ${artifactName} from ${currentVersion} to ${nextVersion}"
updates.limit = 5
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.5.8"
version = "3.6.1"
runner.dialect = scala213
maxColumn = 100
docstrings.style = Asterisk
Expand Down
22 changes: 4 additions & 18 deletions backend/src/main/scala/bloop/CompilerCache.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import javax.tools.JavaFileObject.Kind
import javax.tools.{JavaCompiler => JavaxCompiler}

import scala.collection.mutable.HashSet
import scala.concurrent.ExecutionContext

import bloop.CompilerCache.JavacKey
import bloop.io.AbsolutePath
Expand All @@ -33,7 +32,6 @@ import sbt.internal.inc.javac.JavaTools
import sbt.internal.inc.javac.Javadoc
import sbt.internal.inc.javac.WriteReportingJavaFileObject
import sbt.internal.util.LoggerWriter
import sbt.librarymanagement.Resolver
import xsbti.ComponentProvider
import xsbti.VirtualFile
import xsbti.compile.ClassFileManager
Expand All @@ -49,19 +47,12 @@ object CompilerCache {
}
final class CompilerCache(
componentProvider: ComponentProvider,
retrieveDir: AbsolutePath,
logger: Logger,
userResolvers: List[Resolver],
userScalaCache: Option[ConcurrentHashMap[ScalaInstance, ScalaCompiler]],
userJavacCache: Option[ConcurrentHashMap[JavacKey, JavaCompiler]],
scheduler: ExecutionContext
logger: Logger
) {

private val scalaCompilerCache =
userScalaCache.getOrElse(new ConcurrentHashMap[ScalaInstance, ScalaCompiler]())
private val scalaCompilerCache = new ConcurrentHashMap[ScalaInstance, ScalaCompiler]()

private val javaCompilerCache =
userJavacCache.getOrElse(new ConcurrentHashMap[JavacKey, JavaCompiler]())
private val javaCompilerCache = new ConcurrentHashMap[JavacKey, JavaCompiler]()

def get(
scalaInstance: ScalaInstance,
Expand All @@ -88,12 +79,7 @@ final class CompilerCache(
private[bloop] def withLogger(logger: Logger): CompilerCache = {
new CompilerCache(
componentProvider,
retrieveDir,
logger,
userResolvers,
userScalaCache,
userJavacCache,
scheduler
logger
)
}

Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/scala/bloop/task/Task.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import scala.util.Success
import scala.util.Try

import monix.eval.{Task => MonixTask}
import monix.execution.Callback
import monix.execution.Cancelable
import monix.execution.CancelableFuture
import monix.execution.Scheduler
import monix.execution.Callback

/**
* This task was introduced as a compatibilty layer to ublock bloop migration from monix2.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package sbt.internal.inc.bloop.internal

import scala.collection.parallel.immutable.ParVector

import bloop.task.Task

import _root_.bloop.UniqueCompileInputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import xsbti.compile.analysis.Stamp

object BloopStamps {
private val converter = PlainVirtualFileConverter.converter
def initial: ReadStamps = {
Stamps.initial(
Stamper.forLastModifiedInRootPaths(converter),
// The hash is for the sources
BloopStamps.forHash,
Stamper.forHashInRootPaths(converter)
)
}

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

private final val emptyHash = scala.util.Random.nextInt()
private final val directoryHash = scala.util.Random.nextInt()
Expand All @@ -34,8 +34,11 @@ object BloopStamps {
def directoryHash(path: Path): FileHash = FileHash.of(path, directoryHash)
def isDirectoryHash(fh: FileHash): Boolean = fh.hash == directoryHash

def forHash(file: VirtualFileRef): Hash = {
fromBloopHashToZincHash(ByteHasher.hashFileContents(converter.toPath(file).toFile()))
def forHash(fileRef: VirtualFileRef): Hash = {
val file = converter.toPath(fileRef).toFile()
if (file.exists())
fromBloopHashToZincHash(ByteHasher.hashFileContents(file))
else fromBloopHashToZincHash(0)
}

def emptyStamps: Stamp = EmptyStamp
Expand Down
8 changes: 2 additions & 6 deletions backend/src/test/scala/bloop/CompilerCacheSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import javax.tools.DiagnosticListener
import javax.tools.JavaFileObject
import javax.tools.StandardLocation

import scala.concurrent.ExecutionContext

import bloop.io.AbsolutePath
import bloop.io.Paths
import bloop.logging.RecordingLogger
Expand Down Expand Up @@ -77,8 +75,7 @@ class CompilerCacheSpec {
val wr2 = new WriteReportingJavaFileObject(fo2, classFileManager)
val wr3 = new WriteReportingJavaFileObject(fo3, classFileManager)

val ec = ExecutionContext.global
val compilerCache = new CompilerCache(null, tempDir, logger, List.empty, None, None, ec)
val compilerCache = new CompilerCache(null, logger)
val bloopCompiler = new compilerCache.BloopJavaCompiler(compiler)
val invalidatingFileManager =
new bloopCompiler.BloopInvalidatingFileManager(javacFileManager, classFileManager)
Expand Down Expand Up @@ -135,12 +132,11 @@ class CompilerCacheSpec {
private def withCompilerCache(op: CompilerCache => Unit): Unit = {
val tempDir = AbsolutePath(Files.createTempDirectory("compiler-cache-spec"))
try {
val ec = ExecutionContext.global
val logger = new RecordingLogger()
val componentProvider =
BloopComponentCompiler.getComponentProvider(tempDir.resolve("components"))
val compilerCache =
new CompilerCache(componentProvider, tempDir, logger, List.empty, None, None, ec)
new CompilerCache(componentProvider, logger)
op(compilerCache)
} finally {
Paths.delete(tempDir)
Expand Down
56 changes: 27 additions & 29 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ lazy val shared = project
sonatypeSetting,
name := "bloop-shared",
libraryDependencies ++= Seq(
Dependencies.bsp4s,
Dependencies.jsoniterCore,
Dependencies.jsoniterMacros,
Dependencies.bsp4s excludeAll ExclusionRule(
organization = "com.github.plokhotnyuk.jsoniter-scala"
),
Dependencies.coursierInterface,
Dependencies.zinc,
Dependencies.log4j,
Expand All @@ -84,10 +88,12 @@ lazy val backend = project
sonatypeSetting,
name := "bloop-backend",
buildInfoPackage := "bloop.internal.build",
buildInfoKeys := BloopBackendInfoKeys,
buildInfoKeys := Seq[BuildInfoKey](
Keys.scalaVersion,
Keys.scalaOrganization
),
buildInfoObject := "BloopScalaInfo",
libraryDependencies ++= List(
Dependencies.javaDebug,
Dependencies.nailgun,
Dependencies.scalazCore,
Dependencies.scalazConcurrent,
Expand Down Expand Up @@ -117,27 +123,6 @@ val testResourceSettings = {
})
}

// Needs to be called `jsonConfig` because of naming conflict with sbt universe...
lazy val config = project
.disablePlugins(ScalafixPlugin)
.settings(
sonatypeSetting,
name := "bloop-config",
crossScalaVersions := Seq(Dependencies.Scala212Version, Dependencies.Scala213Version),
scalacOptions := {
scalacOptions.value.filterNot(opt => opt == "-deprecation"),
},
testResourceSettings,
testSettings,
libraryDependencies ++= {
List(
Dependencies.jsoniterCore,
Dependencies.jsoniterMacros % Provided,
Dependencies.scalacheck % Test
)
}
)

lazy val tmpDirSettings = Def.settings(
javaOptions in Test += {
val tmpDir = (baseDirectory in ThisBuild).value / "target" / "tests-tmp"
Expand All @@ -150,8 +135,7 @@ import build.BuildImplementation.jvmOptions
lazy val frontend: Project = project
.dependsOn(
backend,
backend % "test->test",
config
backend % "test->test"
)
.enablePlugins(BuildInfoPlugin)
.configs(IntegrationTest)
Expand Down Expand Up @@ -180,7 +164,18 @@ lazy val frontend: Project = project
bloopName := "bloop",
(Compile / run / mainClass) := Some("bloop.Cli"),
buildInfoPackage := "bloop.internal.build",
buildInfoKeys := bloopInfoKeys(nativeBridge04, jsBridge1),
buildInfoKeys := List[BuildInfoKey](
Keys.organization,
build.BuildKeys.bloopName,
Keys.version,
Keys.scalaVersion,
nailgunClientLocation,
"zincVersion" -> Dependencies.zincVersion,
"bspVersion" -> Dependencies.bspVersion,
"nativeBridge04" -> (nativeBridge04Name + "_" + Keys.scalaBinaryVersion.value),
"jsBridge1" -> (jsBridge1Name + "_" + Keys.scalaBinaryVersion.value),
"snailgunVersion" -> Dependencies.snailgunVersion
),
(run / javaOptions) ++= jvmOptions,
(Test / javaOptions) ++= jvmOptions,
tmpDirSettings,
Expand All @@ -193,19 +188,21 @@ lazy val frontend: Project = project
Dependencies.jsoniterMacros % Provided,
Dependencies.caseApp,
Dependencies.scalaDebugAdapter,
Dependencies.bloopConfig,
Dependencies.libdaemonjvm,
Dependencies.logback
)
)

val jsBridge1Name = "bloop-js-bridge-1"
lazy val jsBridge1 = project
.dependsOn(frontend % Provided, frontend % "test->test")
.in(file("bridges") / "scalajs-1")
.disablePlugins(ScalafixPlugin)
.settings(testSettings)
.settings(
sonatypeSetting,
name := "bloop-js-bridge-1",
name := jsBridge1Name,
libraryDependencies ++= List(
Dependencies.scalaJsLinker1,
Dependencies.scalaJsLogging1,
Expand All @@ -216,14 +213,15 @@ lazy val jsBridge1 = project
)
)

val nativeBridge04Name = "bloop-native-bridge-0-4"
lazy val nativeBridge04 = project
.dependsOn(frontend % Provided, frontend % "test->test")
.in(file("bridges") / "scala-native-0.4")
.disablePlugins(ScalafixPlugin)
.settings(testSettings)
.settings(
sonatypeSetting,
name := "bloop-native-bridge-0.4",
name := nativeBridge04Name,
libraryDependencies += Dependencies.scalaNativeTools04,
(Test / javaOptions) ++= jvmOptions,
(Test / fork) := true
Expand Down
Loading

0 comments on commit 20d804f

Please sign in to comment.