Skip to content

Commit c6a2a3f

Browse files
authored
Merge pull request #2422 from biboudis/docs-update
Fix #2180: Docs update
2 parents b046500 + 0acf3ba commit c6a2a3f

18 files changed

+302
-183
lines changed

docs/docs/contributing/backend.md

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
---
22
layout: doc-page
3-
title: Working with the backend
3+
title: Working with the Backend
44
---
55

66
The compiler backend is based on a fork of the Scala 2.11 `GenBCode` backend and
7-
lives at https://github.com/lampepfl/scala/tree/sharing-backend. The dotty
8-
source tree contains a git submodule in the directory
7+
lives at
8+
9+
> https://github.com/lampepfl/scala/tree/sharing-backend.
10+
11+
The dotty source tree contains a git submodule in the directory
912
[scala-backend](https://github.com/lampepfl/dotty/tree/master/scala-backend)
1013
that points to this fork. We do not compile every file in this submodule,
1114
instead we add the subset of files we need to the dotty-compiler project in the
@@ -16,39 +19,44 @@ their content is not automatically updated when you do `git checkout` or `git
1619
pull`, instead everytime you switch branch, you need to do:
1720

1821
``` shell
19-
git submodule update --init
22+
$ git submodule update --init
2023
```
2124

2225
## Environment setup
2326

24-
1. Set the following git configuration options to make working with submodules
25-
easier, see the [Git Book](https://git-scm.com/book/en/v2/Git-Tools-Submodules)
27+
1. Set the following git configuration options to make working with submodules easier,
28+
see the [Git Book](https://git-scm.com/book/en/v2/Git-Tools-Submodules)
2629
for more information:
2730
``` shell
28-
git config --global diff.submodule log
29-
git config --global status.submodulesummary 1
30-
git config --global push.recurseSubmodules check
31+
$ git config --global diff.submodule log
32+
$ git config --global status.submodulesummary 1
33+
$ git config --global push.recurseSubmodules check
3134
```
3235

33-
2. Fork https://github.com/lampepfl/scala (in the following commands,
34-
`dotty-staging/scala` is used as a placeholder for your
35-
own fork).
36-
3. ```shell
37-
cd scala-backend
38-
git remote add scala-staging [email protected]:dotty-staging/scala.git
39-
cd ..
40-
```
36+
2. Fork scala from github
37+
38+
> https://github.com/lampepfl/scala
39+
40+
(in the following commands, `dotty-staging/scala` is used as a placeholder for your own fork).
41+
42+
3. Add the new remote to track the upstream branch
43+
```shell
44+
$ cd scala-backend
45+
$ git remote add scala-staging [email protected]:dotty-staging/scala.git
46+
$ cd ..
47+
```
4148

4249
## Workflow when changing to the backend
4350

4451
```shell
45-
cd scala-backend
46-
git checkout -b my-feature-branch
52+
$ cd scala-backend
53+
$ git checkout -b my-feature-branch
54+
4755
# Make some changes ...
56+
$ git push -u scala-backend
4857

49-
git push -u scala-backend
5058
# Open a PR against https://github.com/lampepfl/scala/tree/sharing-backend
51-
cd ..
59+
$ cd ..
5260
```
5361

5462
Once your PR has been merged into the backend, you'll need to make another PR

docs/docs/contributing/debug-tests.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ Both are usually pre-installed on Mac OS and linux distributions.
1414

1515
First, compile the file `tests/debug/while.scala`:
1616

17-
```
18-
bin/dotc tests/debug/while.scala
17+
```shell
18+
$ dotc tests/debug/while.scala
1919
```
2020

2121
Second, run the compiled class with debugging enabled (suppose the main class is `Test`):
2222

23-
```
24-
bin/dotr -d Test
23+
```shell
24+
dotr -d Test
2525
```
2626

2727
Third, start JDB:
@@ -36,7 +36,7 @@ You can run `help` for commands that supported by JDB.
3636

3737
### 1. Annotate the source code with debug information.
3838

39-
Following file (`tests/debug/while.scala`) is an example of annoated source code:
39+
Following file (`tests/debug/while.scala`) is an example of annotated source code:
4040

4141
```Scala
4242
object Test {

docs/docs/contributing/eclipse.md

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,58 @@ layout: doc-page
33
title: Building Dotty with Eclipse
44
---
55

6-
Build setup
6+
Setup
77
-----------
88

9-
1. Run `sbt ;managedSources;eclipse`
9+
You can setup Eclipse by using _[Scala IDE for Eclipse](http://scala-ide.org/)_ directly to run Dotty. Alternatively you can download
10+
your Eclipse distribution of choice and enable the Scala IDE from the Eclipse Marketplace, separately.
1011

11-
2. It is recommended to change the default output folder (in `Properties > java
12+
1. Clone Dotty's repository from Github (and run `sbt managedSources` as described in
13+
[Getting Started](getting-started.md))
14+
2. Generate the Eclipse configuration files:
15+
```shell
16+
$ sbt eclipse
17+
```
18+
19+
- Note: It is recommended to change the default output folder (in `Properties > java
1220
build path > Source`) to `dotty/classes` instead of `dotty/bin` because
1321
`dotty/bin` is reserved for shell scripts.
1422

15-
If you have `CLASSPATH` defined:
23+
Optional: if you have `CLASSPATH` defined:
1624

17-
3. Update your classpath to contain any new required external libraries to run
25+
1. Update your classpath to contain any new required external libraries to run
1826
`./bin/dotc`, `./bin/dotr` outside of Eclipse.
1927

20-
4. Open the `Run Configurations` tab, and edit the `tests` configuration so
28+
1. Open the `Run Configurations` tab, and edit the `tests` configuration so
2129
that it contains a `CLASSPATH` variable which reflects the current
2230
`CLASSPATH`.
31+
32+
33+
Import to Eclipse
34+
-----------------
35+
36+
First step is to import dotty to Eclipse. This is done by selecting `File > Import` from the menu and selecting
37+
_Existing Projects into Workplace_.
38+
39+
![](../../images/eclipse/eclipse-import.png "Import Dotty to Eclipse")
40+
41+
On the next window, select the bare minimum configuration to run Dotty. You will need the compiler, library and the
42+
interfaces.
43+
44+
![](../../images/eclipse/eclipse-select.png "Import Dotty Projects")
45+
46+
47+
Running/Debugging
48+
---------------------------------------------------
49+
50+
To run/debug Dotty you have to create a new configuration from `Run > Run Configurations`. First select the project on the
51+
package explorer and then select the aforementioned option. On the `Main` tab you must have `dotty-compiler` for the
52+
_Project_ and `dotty.tools.dotc.Main` for the _Main class_. Specify the arguments you want for the compiler on the
53+
`Arguments` tab (e.g, flags and source files) and then proceed to the `Classpath` tab. There you must
54+
specify three `Bootstrap Entries` which are the compiler, interfaces and the library as shown in the screenshot below.
55+
Additionally you need to specify the scala-asm library as an external jar dependency. This can be found on your local
56+
`~/.ivy2/cache/` directory.
57+
58+
![](../../images/eclipse/eclipse-runconfiguration.png "Import Dotty Projects")
2359

24-
Running the compiler Main class from Eclipse
25-
--------------------------------------------
26-
1. Navigate to `dotty.tools.dotc.Main`
27-
2. `Run As... > Scala Application`
28-
3. `Run Configurations > Main$ > Classpath > Bootstrap entries`:
29-
- Add the Scala library (`Advanced...` > `Add library...` > `Scala library`)
30-
- Add the Dotty classfiles (`Add projects...` > `[x] dotty`)
31-
4. `Run Configurations > Main$ > Arguments` and add
32-
`${project_loc}/tests/pos/HelloWorld.scala`
60+
The compiler can be run and debugged using the same configuration. To contribute to dotty please follow the [Dotty Developer Guidelines](https://github.com/lampepfl/dotty/blob/master/CONTRIBUTING.md).

docs/docs/contributing/getting-started.md

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,9 @@ layout: doc-page
33
title: Getting Started
44
---
55

6-
Talks on Dotty
7-
--------------
8-
- [Scala's Road Ahead](https://www.youtube.com/watch?v=GHzWqJKFCk4) by Martin Odersky [\[slides\]](http://www.slideshare.net/Odersky/scala-days-nyc-2016)
9-
- [Compilers are Databases](https://www.youtube.com/watch?v=WxyyJyB_Ssc) by Martin Odersky [\[slides\]](http://www.slideshare.net/Odersky/compilers-are-databases)
10-
- [Dotty: Exploring the future of Scala](https://www.youtube.com/watch?v=aftdOFuVU1o) by Dmitry Petrashko [\[slides\]](https://d-d.me/scalaworld2015/#/). This talk includes details about the design of mini-phases and denotations.
11-
- [Making your Scala applications smaller and faster with the Dotty linker](https://www.youtube.com/watch?v=xCeI1ArdXM4) by Dmitry Petrashko [\[slides\]](https://d-d.me/scaladays2015/#/)
12-
- [Dotty: what is it and how it works](https://www.youtube.com/watch?v=wCFbYu7xEJA) by Guillaume Martres [\[slides\]](http://guillaume.martres.me/talks/dotty-tutorial/#/)
13-
- [Hacking on Dotty: A live demo](https://www.youtube.com/watch?v=0OOYGeZLHs4) by Guillaume Martres [\[slides\]](http://guillaume.martres.me/talks/dotty-live-demo/)
14-
- [AutoSpecialization in Dotty](https://vimeo.com/165928176) by Dmitry Petrashko [\[slides\]](https://d-d.me/talks/flatmap2016/#/)
15-
- [Dotty and types: the story so far](https://www.youtube.com/watch?v=YIQjfCKDR5A) by Guillaume Martres [\[slides\]](http://guillaume.martres.me/talks/typelevel-summit-oslo/)
16-
176
Requirements
187
------------
19-
Make sure that you are using Java 8 or later, the output of `java -version`
8+
Make sure that you are using Java 8 or later. The output of `java -version`
209
should contain `1.8`.
2110

2211
Compiling and Running
@@ -26,11 +15,11 @@ Start by cloning the repository:
2615
```bash
2716
$ git clone --recursive https://github.com/lampepfl/dotty.git
2817
$ cd dotty
29-
$ sbt managedSources ## Needed for IDE import to succeed
18+
$ sbt managedSources # Needed for IDE import to succeed
3019
```
3120

3221
Dotty provides a standard sbt build: compiling, running and starting a repl can
33-
all be done from within sbt using
22+
all be done from within sbt:
3423

3524
```bash
3625
$ sbt
@@ -39,13 +28,21 @@ $ sbt
3928
hello world
4029
```
4130

42-
there is also a bash script that can be used in the same way:
31+
There are also bash scripts that can be used in the same way. Assuming that you have cloned the Dotty repo locally, append
32+
the following line on your `.bash_profile`:
4333

44-
```bash
34+
```shell
35+
$ export PATH=$HOME/dotty/bin:$PATH
36+
```
37+
38+
and you will be able to run the corresponding commands directly from your console:
39+
40+
```shell
4541
# Compile code using Dotty
46-
./bin/dotc tests/pos/HelloWorld.scala
42+
$ dotc tests/pos/HelloWorld.scala
43+
4744
# Run it with the proper classpath
48-
./bin/dotr HelloWorld
45+
$ dotr HelloWorld
4946
```
5047

5148

@@ -63,5 +60,5 @@ scala>
6360
or via bash:
6461

6562
```bash
66-
$ ./bin/dotr
63+
$ dotr
6764
```

docs/docs/contributing/intellij-idea.md

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,59 @@ layout: doc-page
33
title: Building Dotty with Intellij IDEA
44
---
55

6-
Dotty compiler support is available in the [Scala plugin nightly] starting
7-
from 2.2.39. You need to install [IDEA 2016.1] to try it.
6+
Setup
7+
-----
88

9-
## To create a new project with Dotty
9+
You can setup IntelliJ [IDEA >= 2016.1](https://www.jetbrains.com/idea/nextversion) to run Dotty.
1010

11-
1. Open New Project dialog and select `Scala` > `Dotty`
12-
2. Proceed as usual and don't forget to create or select Dotty SDK.
11+
Assuming you have cloned dotty's repository from Github (and run `sbt managedSources` as described in [Getting Started](getting-started.md)),
12+
you can now proceed with importing it to IDEA by selecting the
13+
corresponding option from the startup menu. Navigate on the corresponding directory and select it. Next, you need
14+
to select the model of the import and as the screenshot shows, select SBT.
1315

14-
## To compile an existing Scala project with Dotty
16+
![](../../images/idea/idea-import.png "Import Dotty in IDEA")
1517

16-
1. Create a new Dotty SDK:
17-
`Project Structure` > `Global libraries` > `New Global Library` > `Dotty SDK`
18-
2. Replace Scala SDK with Dotty SDK in:
19-
`Project Structure` > `Modules` > `Dependencies`
18+
Next, you select the version of the JDK that this project relies on and verify that you have selected 1.8 (assuming
19+
its installed on your local machine). Otherwise, specify it by pressing *New*.
2020

21-
Java 1.8 should be used as the Project/Module SDK. You also need to enable the
22-
Scala Compile Server to use Dotty compiler.
21+
![](../../images/idea/idea-sdk.png "Select the JDK")
2322

24-
## Notes
25-
* Dotty support is experimental, many features including code highlighting and
26-
worksheet are not ready yet.
27-
* You can download the latest version of Dotty without creating a new Dotty SDK
28-
with the `Update snapshot` button in the Dotty SDK library settings.
29-
* Please report any problems to the [IntelliJ Scala issue tracker] or write
30-
to the [IntelliJ Scala gitter]
23+
On the final window we must select which modules we can import. Here, we are presented with the full list of SBT projects
24+
that are defined in Dotty. You can either select all (expect performance degradation by IDEA if you select all) or
25+
select only the `dotty` module. In order to do that, unselect all modules and select on `dotty`. IDEA, then, automatically
26+
selects all the necessary dependencies and you press OK.
3127

32-
[Scala plugin nightly]: https://confluence.jetbrains.com/display/SCA/Scala+Plugin+Nightly
33-
[IDEA 2016.1]: https://www.jetbrains.com/idea/nextversion/
34-
[IntelliJ Scala issue tracker]: https://youtrack.jetbrains.com/issues/SCL
35-
[IntelliJ Scala gitter]: https://gitter.im/JetBrains/intellij-scala
28+
![](../../images/idea/idea-sbt.png "Select modules to import")
29+
30+
Running/Debugging
31+
-------
32+
33+
To run the compiler you can do it either as an sbt command or via debugging the compiler.
34+
For the first option you can fire up sbt from the `Terminal` window of IDEA or you can do it externally.
35+
For example, to run a test you can write with or without flags:
36+
37+
```shell
38+
dotc tests/pos/Arrays.scala
39+
```
40+
41+
If you are interested in debugging the compiler you can enable the necessary agent on the JVM.
42+
This is done in two steps. For the first step you need to pass the
43+
necessary flag to the running VM. For convenience, this is already in comments on the `Build.scala` file under the
44+
`project` directory. The string you need to uncomment is the following:
45+
46+
> `"-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"`
47+
48+
Uncomment the line and reload the project file with the `reload` command on sbt.
49+
Now, each time you run `dotc` the compiler listens at the designated address and waits the agent to connect.
50+
For, the second step you need to create a configuration for Debug through IDEA:
51+
52+
> Run > Edit Configurations > Add New Configuration > (select) Remote
53+
54+
![](../../images/idea/idea-debug.png "Create a Debug Configuration")
55+
56+
Now every time you run `dotc` you can set your breakpoints and hit the `Debug dotty-debug` button (since we used that name for
57+
the sample configuration above). The default data on the configuration match the enabled agent on the VM so, probably,
58+
you will not need to change anything else.
59+
60+
To contribute to dotty please follow the [Dotty Developer Guidelines](https://github.com/lampepfl/dotty/blob/master/CONTRIBUTING.md).
61+

0 commit comments

Comments
 (0)