Skip to content
This repository has been archived by the owner. It is now read-only.

Commit 2e97c3a

Browse files
committed
Add VirtualFile / VirtualFileRef / FileConverter
This implements Zinc support for passing source code as a VirtualFile datatype. This allows build tools to pass source files as in-memory datatype. Another motivation for doing so is to remove machine dependence from the internal state of incremental compilation (Analysis). By making Analysis free of absolute paths, we should be able to cache the file and resume compilation from another machine.
1 parent 86da515 commit 2e97c3a

File tree

101 files changed

+6084
-1556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+6084
-1556
lines changed

.scalafmt.conf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version = 2.3.2
2+
maxColumn = 100
3+
project.git = true
4+
project.excludeFilters = [ /sbt-test/, /input_sources/, /contraband-scala/ ]
5+
6+
# http://docs.scala-lang.org/style/scaladoc.html recommends the JavaDoc style.
7+
# scala/scala is written that way too https://github.com/scala/scala/blob/v2.12.2/src/library/scala/Predef.scala
8+
docstrings = JavaDoc
9+
10+
# This also seems more idiomatic to include whitespace in import x.{ yyy }
11+
spaces.inImportCurlyBraces = true
12+
13+
# This is more idiomatic Scala.
14+
# http://docs.scala-lang.org/style/indentation.html#methods-with-numerous-arguments
15+
align.openParenCallSite = false
16+
align.openParenDefnSite = false
17+
18+
# For better code clarity
19+
danglingParentheses = true
20+
21+
trailingCommas = preserve

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ env:
1010
- ADOPTOPENJDK=8
1111
- ADOPTOPENJDK=11
1212

13-
script: sbt -Dfile.encoding=UTF8 compilerInterface/mimaReportBinaryIssues headerCheck packageBin doc
13+
script: sbt -Dfile.encoding=UTF8 compilerInterface/headerCheck jvmfmtCheck dummyBridge/test doc

build.sbt

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import Dependencies._
12
import Util._
23

34
lazy val scala212 = "2.12.10"
45

5-
ThisBuild / headerLicense := Some(HeaderLicense.Custom(
6-
"""Scala compiler interface
6+
ThisBuild / headerLicense := Some(
7+
HeaderLicense.Custom(
8+
"""Scala compiler interface
79
|
810
|Copyright Lightbend, Inc. and Mark Harrah
911
|
@@ -13,7 +15,8 @@ ThisBuild / headerLicense := Some(HeaderLicense.Custom(
1315
|See the NOTICE file distributed with this work for
1416
|additional information regarding copyright ownership.
1517
|""".stripMargin
16-
))
18+
)
19+
)
1720

1821
def commonSettings: Seq[Setting[_]] = Seq(
1922
Test / publishArtifact := false,
@@ -26,7 +29,7 @@ def commonSettings: Seq[Setting[_]] = Seq(
2629
)
2730

2831
lazy val compilerInterfaceRoot = (project in file("."))
29-
.aggregate(compilerInterface)
32+
.aggregate(compilerInterface, dummyBridge)
3033
.settings(
3134
publish / skip := true,
3235
crossScalaVersions := Vector(),
@@ -40,11 +43,11 @@ lazy val compilerInterfaceRoot = (project in file("."))
4043
| /_/
4144
|welcome to the build for sbt/compiler-interface.
4245
|""".stripMargin +
43-
(if (sys.props("java.specification.version") != "1.8")
44-
s"""!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
46+
(if (sys.props("java.specification.version") != "1.8")
47+
s"""!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
4548
| Java version is ${sys.props("java.specification.version")}. We recommend 1.8.
4649
|!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!""".stripMargin
47-
else "")
50+
else "")
4851
},
4952
)
5053

@@ -63,13 +66,24 @@ lazy val compilerInterface = (project in file("compiler-interface"))
6366
crossPaths := false,
6467
autoScalaLibrary := false,
6568
mimaPreviousArtifacts := Set(
66-
"1.0.0", "1.0.1", "1.0.2", "1.0.3", "1.0.4", "1.0.5",
67-
"1.1.0", "1.1.1", "1.1.2", "1.1.3",
68-
"1.2.0", "1.2.1", "1.2.2",
69-
) map (version =>
70-
organization.value %% moduleName.value % version
71-
cross (if (crossPaths.value) CrossVersion.binary else CrossVersion.disabled)
72-
),
69+
"1.0.0",
70+
"1.0.1",
71+
"1.0.2",
72+
"1.0.3",
73+
"1.0.4",
74+
"1.0.5",
75+
"1.1.0",
76+
"1.1.1",
77+
"1.1.2",
78+
"1.1.3",
79+
"1.2.0",
80+
"1.2.1",
81+
"1.2.2",
82+
) map (
83+
version =>
84+
organization.value %% moduleName.value % version
85+
cross (if (crossPaths.value) CrossVersion.binary else CrossVersion.disabled)
86+
),
7387
mimaBinaryIssueFilters ++= {
7488
import com.typesafe.tools.mima.core._
7589
import com.typesafe.tools.mima.core.ProblemFilters._
@@ -85,6 +99,33 @@ lazy val compilerInterface = (project in file("compiler-interface"))
8599
},
86100
)
87101

102+
lazy val dummyBridge = (project in file("dummy-bridge"))
103+
.dependsOn(compilerInterface)
104+
.settings(
105+
name := "Dummy Compiler Bridge",
106+
scalaVersion := "2.13.1",
107+
publish / skip := true,
108+
exportJars := true,
109+
libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value,
110+
testFrameworks += new TestFramework("verify.runner.Framework"),
111+
libraryDependencies ++= Seq(verify % Test, sbtIo % Test),
112+
// we need to fork because in unit tests we set usejavacp = true which means
113+
// we are expecting all of our dependencies to be on classpath so Scala compiler
114+
// can use them while constructing its own classpath for compilation
115+
Test / fork := true,
116+
// needed because we fork tests and tests are ran in parallel so we have multiple Scala
117+
// compiler instances that are memory hungry
118+
Test / javaOptions ++= {
119+
val si = (Test / scalaInstance).value
120+
val bridge = (Compile / packageBin).value
121+
List(
122+
"-Xmx1G",
123+
"-Dtest.bridgejar=" + bridge.toString,
124+
"-Dtest.sijars=" + si.allJars.toList.mkString(sys.props("path.separator"))
125+
)
126+
},
127+
)
128+
88129
ThisBuild / organization := "org.scala-sbt"
89130
ThisBuild / organizationName := "sbt"
90131
ThisBuild / organizationHomepage := Some(url("https://www.scala-sbt.org/"))
@@ -100,11 +141,15 @@ ThisBuild / developers := List(
100141
)
101142

102143
ThisBuild / description := "a binary contract between Zinc and Scala compilers"
103-
ThisBuild / licenses := List("Apache-2.0" -> new URL("http://www.apache.org/licenses/LICENSE-2.0.txt"))
144+
ThisBuild / licenses := List(
145+
"Apache-2.0" -> new URL("http://www.apache.org/licenses/LICENSE-2.0.txt")
146+
)
104147
ThisBuild / homepage := Some(url("https://github.com/sbt/compiler-interface"))
105148

106149
// Remove all additional repository other than Maven Central from POM
107-
ThisBuild / pomIncludeRepository := { _ => false }
150+
ThisBuild / pomIncludeRepository := { _ =>
151+
false
152+
}
108153
ThisBuild / publishTo := {
109154
val nexus = "https://oss.sonatype.org/"
110155
if (isSnapshot.value) Some("snapshots" at nexus + "content/repositories/snapshots")

0 commit comments

Comments
 (0)