Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dotr -tasty #3436

Merged
merged 14 commits into from Nov 16, 2017
Merged

Fix dotr -tasty #3436

merged 14 commits into from Nov 16, 2017

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

val scalaLib = attList
.map(_.data.getAbsolutePath)
.find(_.contains("scala-library"))
.toList.mkString(":")

if (java == "")
if (args.isEmpty) {
println("Couldn't run `dotr` without args. Use `repl` to run the repl or add args to run the dotty application")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not call the repl task at this point instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried with repl.evaluated but then dotr only ran repl ignoring the nonempty args. Then I just decided to show this message as we don't really need more in the sbt project.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sbt task evaluation is tricky, you probably need to use a dynamic task to get that to work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is what I thought, hence settled for the message. My main concerns were the factorisation of code and checking the it was executing correctly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should special case for empty args. We need a better solution:
If I run dotr -Xprint:typer, args is not empty, but I still want to run the REPL

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can at least run repl -Xprint:typer.

@@ -640,6 +617,19 @@ object Build {
}
)

def dotDynTask(main: String) = Def.inputTaskDyn {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think runCompilerMain is a better name

println("Couldn't find java executable on path, please install java to a default location")
else if (scalaLib == "") {
} 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(" ")}""".!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're refactoring. Triple quotes is not needed here

.drone.yml Outdated
@@ -25,7 +25,7 @@ pipeline:
image: lampepfl/dotty:2017-10-20
commands:
- cp -R . /tmp/1/ && cd /tmp/1/
- ./project/scripts/sbt ";compile ;testAll ;dotty-bench/jmh:run 1 1 tests/pos/alias.scala"
- ./project/scripts/sbt ";compile ;testAll ;dotty-bench/jmh:run 1 1 tests/pos/alias.scala; ;dotc tests/run/arraycopy.scala ;dotr Test"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests/pos/alias.scala; ;dotc double semicolon?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not sure it is the best place to test an sbt task. @smarter Do you think it should be a scripted test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scripted tests are always good in my opinion :)

val scalaLib = attList
.map(_.data.getAbsolutePath)
.find(_.contains("scala-library"))
.toList.mkString(":")

if (java == "")
if (args.isEmpty) {
println("Couldn't run `dotr` without args. Use `repl` to run the repl or add args to run the dotty application")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should special case for empty args. We need a better solution:
If I run dotr -Xprint:typer, args is not empty, but I still want to run the REPL

@nicolasstucki nicolasstucki force-pushed the abstract-dotc-repl branch 3 times, most recently from 6cf735e to be81325 Compare November 8, 2017 09:58
@nicolasstucki nicolasstucki changed the title Abstract dotc repl Fix dotr -tasty Nov 12, 2017
@nicolasstucki nicolasstucki requested review from smarter and removed request for allanrenucci November 12, 2017 14:23
@nicolasstucki nicolasstucki force-pushed the abstract-dotc-repl branch 2 times, most recently from 069c36d to 7c4d1d7 Compare November 12, 2017 16:12
@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Nov 13, 2017

Next step (in another PR) will be to remove the dotty.tools.dot.FromTasty driver and integrate it to dotty.tools.dot.Main. This will make -tasty an actual ScalaSetings flag.
Done :)

dist/bin/dotc Outdated
@@ -82,7 +81,7 @@ case "$1" in
# Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222
-Oshort) addJava "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" && shift ;;
-repl) PROG_NAME="$ReplMain" && shift ;;
-tasty) addScala "-Yretain-trees" && PROG_NAME="$FromTasty" && shift ;;
-tasty) addScala "-Yretain-trees" && PROG_NAME="$CompilerMain" && shift ;;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just make -Yretain-trees default to true when -tasty is used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, in the compiler itself, instead of doing it in various scripts.

Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM.

@nicolasstucki
Copy link
Contributor Author

Last commit needs review

# check that `dotc` compiles and `dotr` runs it
echo "testing sbt dotc and dotr"
mkdir out/scriptedtest0
./dist-bootstrapped/target/pack/bin/dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to use dist-bootstrapped/**/dotc instead of bin/dotc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to make sure I was testing that version of the script. We could also add some tests for bin/dotc in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bin/dotc just forwards to dist-bootstrapped/target/pack/bin/dotc and calls sbt dist-bootstrapped/pack if needed :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll change it.

@nicolasstucki nicolasstucki merged commit fe24786 into scala:master Nov 16, 2017
nicolasstucki referenced this pull request Nov 17, 2017
Fix #3496: Insert classpath before other arguments
@allanrenucci allanrenucci deleted the abstract-dotc-repl branch December 14, 2017 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants