aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--project/Build.scala4
-rw-r--r--src/dotty/tools/dotc/repl/InterpreterLoop.scala3
-rw-r--r--src/dotty/tools/dotc/repl/ManifestInfo.scala20
3 files changed, 26 insertions, 1 deletions
diff --git a/project/Build.scala b/project/Build.scala
index 7c57bd862..5b8465b4e 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -6,6 +6,7 @@ import scala.reflect.io.Path
import org.scalajs.sbtplugin.ScalaJSPlugin
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
+import sbt.Package.ManifestAttributes
object DottyBuild extends Build {
@@ -172,6 +173,9 @@ object DottyBuild extends Build {
fork in Test := true,
parallelExecution in Test := false,
+ // Add git-hash used to package the distribution to the manifest to know it in runtime and report it in REPL
+ packageOptions += ManifestAttributes(("Git-Hash", VersionUtil.gitHash)),
+
// http://grokbase.com/t/gg/simple-build-tool/135ke5y90p/sbt-setting-jvm-boot-paramaters-for-scala
javaOptions <++= (dependencyClasspath in Runtime, packageBin in Compile) map { (attList, bin) =>
// put the Scala {library, reflect} in the classpath
diff --git a/src/dotty/tools/dotc/repl/InterpreterLoop.scala b/src/dotty/tools/dotc/repl/InterpreterLoop.scala
index 8b1000f2e..b3ac41c55 100644
--- a/src/dotty/tools/dotc/repl/InterpreterLoop.scala
+++ b/src/dotty/tools/dotc/repl/InterpreterLoop.scala
@@ -66,7 +66,8 @@ class InterpreterLoop(compiler: Compiler, config: REPL.Config)(implicit ctx: Con
output.flush()
}
- val version = ".next (pre-alpha)"
+ val gitHash = ManifestInfo.attributes.getOrElse("Git-Hash", "unknown")
+ val version = s".next (pre-alpha, git-hash: $gitHash)"
/** The main read-eval-print loop for the interpreter. It calls
* `command()` for each line of input.
diff --git a/src/dotty/tools/dotc/repl/ManifestInfo.scala b/src/dotty/tools/dotc/repl/ManifestInfo.scala
new file mode 100644
index 000000000..206dccd67
--- /dev/null
+++ b/src/dotty/tools/dotc/repl/ManifestInfo.scala
@@ -0,0 +1,20 @@
+package dotty.tools.dotc.repl
+
+import java.net.JarURLConnection
+import scala.collection.JavaConversions._
+
+object ManifestInfo {
+
+ val attributes: Map[String, String] = {
+ for {
+ resourceUrl <- Option(getClass.getResource(getClass.getSimpleName + ".class"))
+ urlConnection = resourceUrl.openConnection() if urlConnection.isInstanceOf[JarURLConnection]
+ manifest <- Option(urlConnection.asInstanceOf[JarURLConnection].getManifest)
+ } yield {
+ manifest.getMainAttributes.foldLeft(Map[String, String]())(
+ (map, attribute) => map + (attribute._1.toString -> attribute._2.toString)
+ )
+ }
+ }.getOrElse(Map())
+
+}