aboutsummaryrefslogtreecommitdiff
path: root/project
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-11-03 15:31:55 +0100
committerGuillaume Martres <smarter@ubuntu.com>2016-11-22 01:35:07 +0100
commitb2143a1dd44b6a87b8a323c4440a5f2bc6897672 (patch)
tree3207008e03250d489e53a7c2cf30159c9e5486b2 /project
parentba7d7a36a83a93de363f0032c3395c36e11cb764 (diff)
downloaddotty-b2143a1dd44b6a87b8a323c4440a5f2bc6897672.tar.gz
dotty-b2143a1dd44b6a87b8a323c4440a5f2bc6897672.tar.bz2
dotty-b2143a1dd44b6a87b8a323c4440a5f2bc6897672.zip
Make `dotr` run binaries similar to script in bin
Diffstat (limited to 'project')
-rw-r--r--project/Build.scala31
1 files changed, 29 insertions, 2 deletions
diff --git a/project/Build.scala b/project/Build.scala
index 233030a72..4ae9ebf29 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -38,6 +38,10 @@ object DottyBuild extends Build {
lazy val dotc =
inputKey[Unit]("run the compiler using the correct classpath, or the user supplied classpath")
+ // Used to run binaries similar to ./bin/dotr script
+ lazy val dotr =
+ inputKey[Unit]("run compiled binary using the correct classpath, or the user supplied classpath")
+
override def settings: Seq[Setting[_]] = {
super.settings ++ Seq(
scalaVersion in Global := "2.11.5",
@@ -78,6 +82,7 @@ object DottyBuild extends Build {
dependsOn(`dotty-library`).
dependsOn(`dotty-interfaces`).
settings(
+ addCommandAlias("dotr", "dotty-compiler/dotr") ++
addCommandAlias("dotc", "dotty-compiler/dotc") ++
addCommandAlias("repl", "dotty-compiler/repl") ++
addCommandAlias(
@@ -173,6 +178,9 @@ object DottyBuild extends Build {
) map { case (k, v) => (k, v.getAbsolutePath) }
},
+ // Set run baseDir to be root of project, makes dotc saner
+ baseDirectory in run := baseDirectory.value / "..",
+
repl := Def.inputTaskDyn {
val args: Seq[String] = spaceDelimited("<arg>").parsed
val dottyLib = packageAll.value("dotty-library")
@@ -181,8 +189,27 @@ object DottyBuild extends Build {
)
}.evaluated,
- // Set run baseDir to be root of project, makes dotc saner
- baseDirectory in run := baseDirectory.value / "..",
+ // Override run to be able to run compiled classfiles
+ dotr := {
+ val args: Seq[String] = spaceDelimited("<arg>").parsed
+ val java: String = Process("which" :: "java" :: Nil) !!
+ val scalaLib = (dependencyClasspath in Runtime, packageAll)
+ .map { (attList, _) =>
+ attList
+ .map(_.data.getAbsolutePath)
+ .find(_.contains("scala-library"))
+ .toList.mkString(":")
+ }.value
+
+ if (java == "")
+ println("Couldn't find java executable on path, please install java to a default location")
+ else if (scalaLib == "") {
+ println("Couldn't find scala-library on classpath, please run using script in bin dir instead")
+ } else {
+ val dottyLib = packageAll.value("dotty-library")
+ s"""$java -classpath .:$dottyLib:$scalaLib ${args.mkString(" ")}""" !
+ }
+ },
dotc := Def.inputTaskDyn {
val dottyLib = packageAll.value("dotty-library")
val args: Seq[String] = spaceDelimited("<arg>").parsed