Skip to content

Commit f557c42

Browse files
committed
Decompose the README & link all the side-READMEs
1 parent 0bab614 commit f557c42

File tree

2 files changed

+243
-231
lines changed

2 files changed

+243
-231
lines changed

DEV.md

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
## Developer docs
2+
3+
### Requirements
4+
5+
Building Scala CLI requires JVM 17 to work properly.
6+
7+
In theory, our build is able to download and install for its own needs JVM 17 on some OSes however it may not work in
8+
Intellij / Metals out of the box.
9+
10+
The Scala CLI sources ship with Mill launchers, so that Mill itself doesn't need to be installed on your system.
11+
12+
### Common commands
13+
14+
#### Running the CLI from sources
15+
16+
```bash
17+
./mill -i scala …arguments…
18+
```
19+
20+
#### Run unit tests
21+
22+
```bash
23+
./mill 'build-module.test' './mill 'build-module.test'
24+
```
25+
26+
#### Run integration tests with the JVM launcher
27+
28+
```bash
29+
./mill integration.test.jvm
30+
```
31+
32+
Filter test suites with
33+
34+
```bash
35+
./mill integration.test.jvm 'scala.cli.integration.RunTestsDefault.*'
36+
./mill integration.test.jvm 'scala.cli.integration.RunTestsDefault.Multiple scripts'
37+
```
38+
39+
Pass the `--debug` option to debug integration tests:
40+
41+
```bash
42+
./mill integration.test.jvm 'scala.cli.integration.RunTestsDefault.*' --debug
43+
```
44+
45+
The debug option uses 5005 port by default. It is possible to change it as follows:
46+
47+
```bash
48+
./mill integration.test.jvm 'scala.cli.integration.RunTestsDefault.*' --debug:5006
49+
```
50+
51+
#### Run integration tests with the native launcher
52+
53+
(generating the launcher can take several minutes)
54+
55+
```bash
56+
./mill integration.test.native
57+
```
58+
59+
#### Generate native packages
60+
61+
Build native packagers:
62+
63+
* `deb` for linux
64+
* `msi` for windows
65+
* `dmg` and `pkg` for macOS
66+
67+
(generating native packager for specified format)
68+
69+
```bash
70+
./mill -i scala package ..arguments... --deb --output 'path.deb'
71+
./mill -i scala package ..arguments... --dmg --output 'path.dmg'
72+
./mill -i scala package ..arguments... --pkg --output 'path.pkg'
73+
```
74+
75+
#### IDE Import
76+
77+
The Scala CLI repository should work when imported automatically from Mill to IDEA IntelliJ and Metals.
78+
Please raise an issue if you run into any problems.
79+
80+
#### Generate a native launcher
81+
82+
```bash
83+
./mill -i show cli.nativeImage
84+
```
85+
86+
This prints the path to the generated native image.
87+
The file named `scala` at the root of the project should also
88+
be a link to it. (Note that the link is committed and is always there,
89+
whether the files it points at exists or not.)
90+
91+
#### Generate a JVM launcher
92+
93+
```bash
94+
./mill -i show cli.launcher
95+
```
96+
97+
This prints the path to the generated launcher. This launcher is a JAR,
98+
that directly re-uses the class directories of the modules of the project
99+
(so that cleaning up those classes will break the launcher). If this is a
100+
problem (if you wish to run the launcher on another machine or from a
101+
Docker image for example), use a native launcher (see above) or a standalone
102+
JVM one (see below).
103+
104+
#### Generate a standalone JVM launcher
105+
106+
```bash
107+
./mill -i show cli.standaloneLauncher
108+
```
109+
110+
This prints the path to the generated launcher. This launcher is a JAR,
111+
that embeds JARs of the scala-cli modules, and downloads their dependencies
112+
from Maven Central upon first launch (using the coursier cache, just like
113+
a coursier bootstrap).
114+
115+
### Helper projects
116+
117+
A number of features of Scala CLI are managed from external projects, living under
118+
the [`scala-cli` organization](https://github.com/scala-cli) on GitHub. These
119+
projects can be used by Scala CLI as libraries pulled before it's compiled, but also
120+
as binaries. In the latter case, Scala CLI downloads on-the-fly binaries from these
121+
repositories' GitHub release assets, and runs them as external processes.
122+
123+
For example, here are a few external projects used by Scala CLI:
124+
125+
- [scala-js-cli-native-image](https://github.com/scala-cli/scala-js-cli-native-image): provides a binary running the
126+
Scala.js linker
127+
- [scala-cli-signing](https://github.com/scala-cli/scala-cli-signing): provides both libraries and binaries to handle
128+
PGP concerns in Scala CLI
129+
- [libsodiumjni](https://github.com/scala-cli/libsodiumjni): provides minimal JNI bindings for
130+
[libsodium](https://github.com/jedisct1/libsodium), that is used by Scala CLI to encrypt secrets
131+
uploaded as GitHub repository secrets in the `publish setup` sub-command
132+
133+
For the full list of those projects and their description, see the
134+
[scala-cli repository list](https://github.com/orgs/scala-cli/repositories) and the READMEs
135+
of each of these projects.
136+
137+
The use of external binaries allows to make the Scala CLI binary slimmer and faster
138+
to generate, but also allow to lower memory requirements to generate it (allowing to
139+
generate these binaries on the GitHub-provided GitHub actions hosts).
140+
141+
### Website
142+
143+
The Scala CLI website is built with [Docusaurus](https://v1.docusaurus.io/en/) and
144+
uses [Infima](https://infima.dev/docs/layout/spacing) for styling.
145+
146+
Ensure you are using Node >= 16.14.2.
147+
148+
#### Generate the website once
149+
150+
```bash
151+
cd website
152+
yarn
153+
yarn build
154+
npm run serve
155+
```
156+
157+
#### Generate the website continuously
158+
159+
```bash
160+
cd website
161+
yarn
162+
yarn run start
163+
```
164+
165+
### Verifying the documentation
166+
167+
We have a built-in tool to validate `.md` files called [Sclicheck](/sclicheck/Readme.md).
168+
All `Sclicheck` tests can be run with `Mill` + `munit`: (and this is what we run on the CI, too)
169+
170+
```bash
171+
./mill -i docs-tests.test
172+
```
173+
174+
The former also includes testing gifs and `Sclicheck` itself.
175+
To just check the documents, run:
176+
177+
```bash
178+
./mill -i docs-tests.test 'sclicheck.DocTests.*'
179+
```
180+
181+
You can also check all root docs, commands, reference docs, guides or cookbooks:
182+
183+
```bash
184+
./mill -i docs-tests.test 'sclicheck.DocTests.root*'
185+
./mill -i docs-tests.test 'sclicheck.DocTests.guide*'
186+
./mill -i docs-tests.test 'sclicheck.DocTests.command*'
187+
./mill -i docs-tests.test 'sclicheck.DocTests.cookbook*'
188+
./mill -i docs-tests.test 'sclicheck.DocTests.reference*'
189+
```
190+
191+
Similarly, you can check single files:
192+
193+
```bash
194+
./mill -i docs-tests.test 'sclicheck.DocTests.<category> <doc-name>'
195+
```
196+
197+
For example, to run the check on `compile.md`
198+
199+
```bash
200+
./mill -i docs-tests.test 'sclicheck.DocTests.command compile'
201+
```
202+
203+
## Scala CLI logos
204+
205+
Package with various logos for scala-cli can be found
206+
on [google drive](https://drive.google.com/drive/u/1/folders/1M6JeQXmO4DTBeRBKAFJ5HH2p_hbfQnqS)
207+
208+
## Launcher script
209+
210+
There is a script `scala-cli-src` in the repository root that is intended to work exactly like released scala-cli, but
211+
using a binary compiled the worktree.
212+
Just add it to your PATH to get the already-released-scala-cli experience.
213+
214+
## Releases
215+
216+
Instructions on how to
217+
release - [Release Procedure](https://github.com/VirtusLab/scala-cli/blob/main/.github/release/release-procedure.md)
218+
219+
## Debugging BSP server
220+
221+
The easiest way to debug BSP sever is using `scala-cli-src` script with `--bsp-debug-port 5050` flag (the port should be
222+
unique to the workspace where BSP will be debugged). In such case BSP will be launched using local source and will run
223+
on JVM. It will also expects a debugger running in the listen mode using provided port (so the initialization of the
224+
connection can be debugged). In such case we recommend to have option to auto rerun debugging session off (so there is
225+
always a debugger instance ready to be used).

0 commit comments

Comments
 (0)