From e41f4fdd0efd9b19d5363def8ecb057fc6326d57 Mon Sep 17 00:00:00 2001 From: Vlad Ureche Date: Thu, 23 Jan 2014 21:24:57 +0100 Subject: [PATCH 1/5] Build infrastructure --- .gitignore | 24 ++++++++++++++++++++++++ build.sbt | 13 +++++++------ gitignore.SAMPLE | 5 ----- project/Build.scala | 39 +++++++++++++++++++++++++++++++++++++++ project/build.properties | 2 +- project/plugins.sbt | 3 +++ readme.md | 18 +++++++++++++++++- 7 files changed, 91 insertions(+), 13 deletions(-) create mode 100644 .gitignore delete mode 100644 gitignore.SAMPLE create mode 100644 project/Build.scala diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..4ac590576188 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +*.class +*.log + +# sbt specific +dist/* +target/ +lib_managed/ +src_managed/ +project/boot/ +project/plugins/project/ +project/local-plugins.sbt +.history + +# Scala-IDE specific +.scala_dependencies +.cache +.classpath +.project +.settings +bin/ + +# idea +.idea +.idea_modules diff --git a/build.sbt b/build.sbt index 8e84bd19c73e..1891b21058f7 100644 --- a/build.sbt +++ b/build.sbt @@ -1,13 +1,14 @@ + name := "dotty" -organization := "lamp" +scalaVersion in Global := "2.11.0-M7" -scalaVersion := "2.10.0" +version in Global := "0.1-SNAPSHOT" -scalaSource in Compile <<= baseDirectory / "src" +organization in Global := "org.scala-lang" -scalacOptions in Global ++= Seq("-feature", "-deprecation", "-language:_") +organizationName in Global := "LAMP/EPFL" -libraryDependencies <+= scalaVersion ( sv => "org.scala-lang" % "scala-reflect" % sv ) +organizationHomepage in Global := Some(url("http://lamp.epfl.ch")) -scalaSource in Test <<= baseDirectory / "test" \ No newline at end of file +homepage in Global := Some(url("http://scala-lang.org")) diff --git a/gitignore.SAMPLE b/gitignore.SAMPLE deleted file mode 100644 index 189e089d438e..000000000000 --- a/gitignore.SAMPLE +++ /dev/null @@ -1,5 +0,0 @@ -.idea -.idea_modules -.gitignore -target -project/local-plugins.sbt diff --git a/project/Build.scala b/project/Build.scala new file mode 100644 index 000000000000..2453d0057790 --- /dev/null +++ b/project/Build.scala @@ -0,0 +1,39 @@ +import sbt._ +import Keys._ +import Process._ + +object MiniboxingBuild extends Build { + + val defaults = Defaults.defaultSettings ++ Seq( + // set sources to src/, tests to test/ and resources to resources/ + scalaSource in Compile <<= baseDirectory(_ / "src"), + javaSource in Compile <<= baseDirectory(_ / "src"), + scalaSource in Test <<= baseDirectory(_ / "test"), + javaSource in Test <<= baseDirectory(_ / "test"), + resourceDirectory in Compile <<= baseDirectory(_ / "resources"), + unmanagedSourceDirectories in Compile <<= (scalaSource in Compile)(Seq(_)), + unmanagedSourceDirectories in Test <<= (scalaSource in Test)(Seq(_)), + + // include sources in eclipse (downloads source code for all dependencies) + //http://stackoverflow.com/questions/10472840/how-to-attach-sources-to-sbt-managed-dependencies-in-scala-ide#answer-11683728 + com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseKeys.withSource := true, + + // to get Scala 2.11 + resolvers += Resolver.sonatypeRepo("releases"), + + // get reflect and xml onboard + libraryDependencies ++= Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value, + "org.scala-lang.modules" %% "scala-xml" % "1.0.0-RC7"), + + // get junit onboard + libraryDependencies += "com.novocode" % "junit-interface" % "0.9" % "test", + + // scalac options + scalacOptions in Global ++= Seq("-feature", "-deprecation", "-language:_"), + + // main class + mainClass in (Compile, run) := Some("dotty.tools.dotc.Main") + ) + + lazy val dotty = Project(id = "miniboxing", base = file("."), settings = defaults) +} diff --git a/project/build.properties b/project/build.properties index 66ad72ce2eba..0974fce44da5 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.12.2 +sbt.version=0.13.0 diff --git a/project/plugins.sbt b/project/plugins.sbt index b6864b47bbbc..654570000877 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,6 @@ // Add personal SBT plugins for IDEs, etc to `local-plugins.sbt` // // e.g. addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.1.0") + +// Scala IDE project file generator +addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.2.0") diff --git a/readme.md b/readme.md index c6ad8d0bc04b..3049604f71b2 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,20 @@ dotty ===== -The experimental compiler for a Scala dialect based on DOT \ No newline at end of file +The experimental compiler for a Scala dialect based on DOT. + +### To get started: +``` + sbt compile + sbt run +``` +The tests (`sbt test`) don''t work yet. + + +### To use the Scala IDE: +``` + sbt eclipse +``` +Notes: + * You will need the Scala IDE for 2.11.0-M7 + * There are 2 spurious version incompatibility warnings From 80209dd9aea9cb922200aefc9b6afc650ba35db8 Mon Sep 17 00:00:00 2001 From: Vlad Ureche Date: Thu, 23 Jan 2014 22:52:59 +0100 Subject: [PATCH 2/5] Fix (run, Test) classpath issues --- project/Build.scala | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index 2453d0057790..ecf0008322fa 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -2,7 +2,7 @@ import sbt._ import Keys._ import Process._ -object MiniboxingBuild extends Build { +object DottyBuild extends Build { val defaults = Defaults.defaultSettings ++ Seq( // set sources to src/, tests to test/ and resources to resources/ @@ -31,9 +31,23 @@ object MiniboxingBuild extends Build { // scalac options scalacOptions in Global ++= Seq("-feature", "-deprecation", "-language:_"), - // main class - mainClass in (Compile, run) := Some("dotty.tools.dotc.Main") + // Adjust classpath for running dotty + mainClass in (Compile, run) := Some("dotty.tools.dotc.Main"), + fork in run := true, + fork in Test := true, + // http://grokbase.com/t/gg/simple-build-tool/135ke5y90p/sbt-setting-jvm-boot-paramaters-for-scala + javaOptions <++= (managedClasspath in Runtime, packageBin in Compile) map { (attList, bin) => + // put the Scala {library, reflect, compiler} in the classpath + val path = for { + file <- attList.map(_.data) + path = file.getAbsolutePath + } yield "-Xbootclasspath/p:" + path + // dotty itself needs to be in the bootclasspath + val self = "-Xbootclasspath/a:" + bin + System.err.println("PATH: " + path) + self :: path.toList + } ) - lazy val dotty = Project(id = "miniboxing", base = file("."), settings = defaults) + lazy val dotty = Project(id = "dotty", base = file("."), settings = defaults) } From 6fe84c0fb18556a1b9538d5dc572323583bf9a2c Mon Sep 17 00:00:00 2001 From: Vlad Ureche Date: Thu, 23 Jan 2014 23:00:10 +0100 Subject: [PATCH 3/5] Update readme with instructions for Eclipse --- readme.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/readme.md b/readme.md index 3049604f71b2..cdc52265cab8 100644 --- a/readme.md +++ b/readme.md @@ -18,3 +18,9 @@ The tests (`sbt test`) don''t work yet. Notes: * You will need the Scala IDE for 2.11.0-M7 * There are 2 spurious version incompatibility warnings + * To run dotty in Eclipse: + * Navigate to `dotty.tools.dotc.Main` + * Run As ... > Scala Application + * then go to Run Configurations > Main$ > Classpath > Bootstrap entries: + * add the Scala library (Advanced... > Add library ... > Scala library) + * add the dotty classfiles (Add projects... > [x] dotty) From 4b68d181cc216bc60c81562b168ba85999a59350 Mon Sep 17 00:00:00 2001 From: Vlad Ureche Date: Thu, 23 Jan 2014 23:10:31 +0100 Subject: [PATCH 4/5] Nitpicking --- project/Build.scala | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index ecf0008322fa..a82fc3484b7b 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -6,13 +6,13 @@ object DottyBuild extends Build { val defaults = Defaults.defaultSettings ++ Seq( // set sources to src/, tests to test/ and resources to resources/ - scalaSource in Compile <<= baseDirectory(_ / "src"), - javaSource in Compile <<= baseDirectory(_ / "src"), - scalaSource in Test <<= baseDirectory(_ / "test"), - javaSource in Test <<= baseDirectory(_ / "test"), - resourceDirectory in Compile <<= baseDirectory(_ / "resources"), - unmanagedSourceDirectories in Compile <<= (scalaSource in Compile)(Seq(_)), - unmanagedSourceDirectories in Test <<= (scalaSource in Test)(Seq(_)), + scalaSource in Compile := baseDirectory.value / "src", + javaSource in Compile := baseDirectory.value / "src", + scalaSource in Test := baseDirectory.value / "test", + javaSource in Test := baseDirectory.value / "test", + resourceDirectory in Compile := baseDirectory.value / "resources", + unmanagedSourceDirectories in Compile := Seq((scalaSource in Compile).value), + unmanagedSourceDirectories in Test := Seq((scalaSource in Test).value), // include sources in eclipse (downloads source code for all dependencies) //http://stackoverflow.com/questions/10472840/how-to-attach-sources-to-sbt-managed-dependencies-in-scala-ide#answer-11683728 @@ -43,9 +43,9 @@ object DottyBuild extends Build { path = file.getAbsolutePath } yield "-Xbootclasspath/p:" + path // dotty itself needs to be in the bootclasspath - val self = "-Xbootclasspath/a:" + bin - System.err.println("PATH: " + path) - self :: path.toList + val fullpath = ("-Xbootclasspath/a:" + bin) :: path.toList + // System.err.println("BOOTPATH: " + fullpath) + fullpath } ) From 426128d3faa646d5c21325cdadf8f3bed04d2cec Mon Sep 17 00:00:00 2001 From: Vlad Ureche Date: Thu, 23 Jan 2014 23:18:20 +0100 Subject: [PATCH 5/5] More nitpicking --- examples/hello.scala | 5 +++++ readme.md | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 examples/hello.scala diff --git a/examples/hello.scala b/examples/hello.scala new file mode 100644 index 000000000000..87e0b1e5e5ca --- /dev/null +++ b/examples/hello.scala @@ -0,0 +1,5 @@ +package hello + +object world extends App { + println("hello dotty!") +} diff --git a/readme.md b/readme.md index cdc52265cab8..b44bc2333425 100644 --- a/readme.md +++ b/readme.md @@ -7,8 +7,9 @@ The experimental compiler for a Scala dialect based on DOT. ``` sbt compile sbt run + sbt test ``` -The tests (`sbt test`) don''t work yet. +At least half of the tests fail, we need to diagnose them. ### To use the Scala IDE: @@ -20,7 +21,8 @@ Notes: * There are 2 spurious version incompatibility warnings * To run dotty in Eclipse: * Navigate to `dotty.tools.dotc.Main` - * Run As ... > Scala Application - * then go to Run Configurations > Main$ > Classpath > Bootstrap entries: - * add the Scala library (Advanced... > Add library ... > Scala library) - * add the dotty classfiles (Add projects... > [x] dotty) + * `Run As...` > `Scala Application` + * then go to `Run Configurations` > `Main$` > `Classpath` > `Bootstrap entries`: + * add the Scala library (`Advanced...` > `Add library...` > `Scala library`) + * add the dotty classfiles (`Add projects...` > `[x] dotty`) + * then go to `Run Configurations` > `Main$` > `Arguments` and add `${project_loc}/examples/hello.scala`