From bfcccd87b323f3b55cb7649fd28af4e108eae315 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Wed, 12 Feb 2014 14:33:14 +0100 Subject: [PATCH 1/5] Package now creates an executable jar. Added a script to run compiler --- build.sbt | 8 ++++++++ dottyc | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 dottyc diff --git a/build.sbt b/build.sbt index 1891b21058f7..7c13e35bd618 100644 --- a/build.sbt +++ b/build.sbt @@ -12,3 +12,11 @@ organizationName in Global := "LAMP/EPFL" organizationHomepage in Global := Some(url("http://lamp.epfl.ch")) homepage in Global := Some(url("http://scala-lang.org")) + +mainClass in (Compile, packageBin) := Some("dotty.tools.dotc.Main") + +packageOptions in (Compile, packageBin) <+= (target, externalDependencyClasspath in Runtime) map { + (targetDirectory: File, classpath: Classpath) => + val absolutePaths = classpath map { attrFile: Attributed[File] => attrFile.data.toPath().toString() }; + Package.ManifestAttributes(java.util.jar.Attributes.Name.CLASS_PATH -> absolutePaths.reduceOption(_ + " " + _).getOrElse("")) + } diff --git a/dottyc b/dottyc new file mode 100755 index 000000000000..23ebcee0319c --- /dev/null +++ b/dottyc @@ -0,0 +1,30 @@ +#!/bin/bash + +MY_PATH="`dirname \"$0\"`" # relative +MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolute +SCALA_VERSION=2.11.0-M7 +DOTTY_VERSION=0.1 +MAIN_JAR=$MY_PATH/target/scala-$SCALA_VERSION/dotty_$SCALA_VERSION-$DOTTY_VERSION-SNAPSHOT.jar + +function checkjar { + if [ ! -f "$1" ] + then + echo "The script is going to build the required jar file $1 by running \"sbt $2\" [5s until build]" + sleep 5 + cd $MINIBOXING_PATH + sbt $2 + cd - + if [ ! -f "$1" ] + then + echo "The required jar file has not been built by sbt. Please run \"sbt $2\"" + exit 1 + else + echo "The required jar file was built." + fi + fi +} + +checkjar $MAIN_JAR package + +java -jar $MAIN_JAR $@ +#$SCALA_PATH/scalac -bootclasspath $RUNTIME_JAR:$PLUGIN_JAR -Xplugin:$PLUGIN_JAR $@ From 06fd8d650850feae0db24b6680a8181cc47405f5 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Wed, 12 Feb 2014 16:42:26 +0100 Subject: [PATCH 2/5] dottyc now is able to compile simple classes --- build.sbt | 8 -------- dottyc | 21 ++++++++++++++++++--- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/build.sbt b/build.sbt index 7c13e35bd618..1891b21058f7 100644 --- a/build.sbt +++ b/build.sbt @@ -12,11 +12,3 @@ organizationName in Global := "LAMP/EPFL" organizationHomepage in Global := Some(url("http://lamp.epfl.ch")) homepage in Global := Some(url("http://scala-lang.org")) - -mainClass in (Compile, packageBin) := Some("dotty.tools.dotc.Main") - -packageOptions in (Compile, packageBin) <+= (target, externalDependencyClasspath in Runtime) map { - (targetDirectory: File, classpath: Classpath) => - val absolutePaths = classpath map { attrFile: Attributed[File] => attrFile.data.toPath().toString() }; - Package.ManifestAttributes(java.util.jar.Attributes.Name.CLASS_PATH -> absolutePaths.reduceOption(_ + " " + _).getOrElse("")) - } diff --git a/dottyc b/dottyc index 23ebcee0319c..5d6d4774b4c1 100755 --- a/dottyc +++ b/dottyc @@ -5,13 +5,29 @@ MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolute SCALA_VERSION=2.11.0-M7 DOTTY_VERSION=0.1 MAIN_JAR=$MY_PATH/target/scala-$SCALA_VERSION/dotty_$SCALA_VERSION-$DOTTY_VERSION-SNAPSHOT.jar +if [ "$SCALA_LIBRARY_JAR" == "" ] +then + SCALA_LIBRARY_JAR=$HOME/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-$SCALA_VERSION.jar +fi + +if [ "$SCALA_REFLECT_JAR" == "" ] +then + SCALA_REFLECT_JAR=$HOME/.ivy2/cache/org.scala-lang/scala-reflect/jars/scala-reflect-$SCALA_VERSION.jar +fi + +if [ ! -f "$SCALA_LIBRARY_JAR" -o ! -f "$SCALA_REFLECT_JAR" ] +then + echo To use this script please set + echo SCALA_LIBRARY_JAR to point to scala-library-$SCALA_VERSION.jar "(currently $SCALA_LIBRARY_JAR)" + echo SCALA_REFLECT_JAR to point to scala-reflect-$SCALA_VERSION.jar "(currently $SCALA_REFLECT_JAR)" +fi function checkjar { if [ ! -f "$1" ] then echo "The script is going to build the required jar file $1 by running \"sbt $2\" [5s until build]" sleep 5 - cd $MINIBOXING_PATH + cd $MY_PATH sbt $2 cd - if [ ! -f "$1" ] @@ -26,5 +42,4 @@ function checkjar { checkjar $MAIN_JAR package -java -jar $MAIN_JAR $@ -#$SCALA_PATH/scalac -bootclasspath $RUNTIME_JAR:$PLUGIN_JAR -Xplugin:$PLUGIN_JAR $@ +java -cp $MAIN_JAR:$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR -Dscala.usejavacp=true dotty.tools.dotc.Main $@ From 2e7472c5434d7507e08849af90dd094a51bc5821 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Wed, 12 Feb 2014 16:57:34 +0100 Subject: [PATCH 3/5] support symbolic links to dottyc --- dottyc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dottyc b/dottyc index 5d6d4774b4c1..612b3bc11d76 100755 --- a/dottyc +++ b/dottyc @@ -1,6 +1,7 @@ #!/bin/bash -MY_PATH="`dirname \"$0\"`" # relative +MY_PATH="`realpath \"$0\"`" # relative, symbolic links resolved +MY_PATH="`dirname \"$MY_PATH\"`" MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolute SCALA_VERSION=2.11.0-M7 DOTTY_VERSION=0.1 From 59c7dffb4a1386138bcf5ac861de57056c658a1f Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Wed, 12 Feb 2014 17:05:09 +0100 Subject: [PATCH 4/5] Dottyc should be now mac compatible --- dottyc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dottyc b/dottyc index 612b3bc11d76..1186f5314d02 100755 --- a/dottyc +++ b/dottyc @@ -1,5 +1,12 @@ #!/bin/bash - +if [[ "$OSTYPE" == "linux-gnu" ]]; then + MY_PATH="`realpath \"$0\"`" # relative, symbolic links resolved +elif [[ "$OSTYPE" == "darwin"* ]]; then + MY_PATH="`readlink \"$0\"`" # relative, symbolic links resolved +fi +if [[ "$MY_PATH" == "" ]]; then + MY_PATH="$0" +fi MY_PATH="`realpath \"$0\"`" # relative, symbolic links resolved MY_PATH="`dirname \"$MY_PATH\"`" MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolute From abc9d3f67effdb9b907318e0e36510cb0107d9e7 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Thu, 13 Feb 2014 12:38:58 +0100 Subject: [PATCH 5/5] Moved dottyc to bin folder --- dottyc => bin/dottyc | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) rename dottyc => bin/dottyc (79%) diff --git a/dottyc b/bin/dottyc similarity index 79% rename from dottyc rename to bin/dottyc index 1186f5314d02..fd68914d7a51 100755 --- a/dottyc +++ b/bin/dottyc @@ -1,15 +1,10 @@ #!/bin/bash -if [[ "$OSTYPE" == "linux-gnu" ]]; then - MY_PATH="`realpath \"$0\"`" # relative, symbolic links resolved -elif [[ "$OSTYPE" == "darwin"* ]]; then - MY_PATH="`readlink \"$0\"`" # relative, symbolic links resolved -fi +MY_PATH="`readlink \"$0\"`" # relative, symbolic links resolved if [[ "$MY_PATH" == "" ]]; then MY_PATH="$0" fi -MY_PATH="`realpath \"$0\"`" # relative, symbolic links resolved MY_PATH="`dirname \"$MY_PATH\"`" -MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolute +MY_PATH="`( cd \"$MY_PATH\" && pwd )`/../" # absolute SCALA_VERSION=2.11.0-M7 DOTTY_VERSION=0.1 MAIN_JAR=$MY_PATH/target/scala-$SCALA_VERSION/dotty_$SCALA_VERSION-$DOTTY_VERSION-SNAPSHOT.jar