Skip to content

Commit ce36200

Browse files
committed
Cross compile cli on Scala 3 LTS & Next
1 parent 98c8e2a commit ce36200

9 files changed

+86
-74
lines changed

.github/scripts/build-linux-aarch64-from-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ eval "$(cs java --env --jvm temurin:17 --jvm-index https://github.com/coursier/j
1111

1212
git config --global --add safe.directory "$(pwd)"
1313

14-
./mill -i show cli.nativeImage
14+
./mill -i show 'cli[]'.nativeImage
1515
./mill -i copyDefaultLauncher ./artifacts
1616
if "true" == $(./mill -i ci.shouldPublish); then
1717
.github/scripts/generate-os-packages.sh

.github/scripts/generate-docker-image.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
55
WORKDIR="$ROOT/out/docker-workdir"
66

77
mkdir -p "$WORKDIR"
8-
./mill -i copyTo cli.nativeImageStatic "$WORKDIR/scala-cli" 1>&2
8+
./mill -i copyTo 'cli[]'.nativeImageStatic "$WORKDIR/scala-cli" 1>&2
99

1010
cd "$WORKDIR"
1111
docker build -t scala-cli -f "$ROOT/.github/scripts/docker/ScalaCliDockerFile" .

.github/scripts/generate-native-image.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
COMMAND="cli.base-image.writeNativeImageScript"
4+
COMMAND="cli[].base-image.writeNativeImageScript"
55

66
# temporary, until we pass JPMS options to native-image,
77
# see https://www.graalvm.org/release-notes/22_2/#native-image
@@ -20,19 +20,19 @@ if [[ "$OSTYPE" == "msys" ]]; then
2020
else
2121
if [ $# == "0" ]; then
2222
if [[ "$OSTYPE" == "linux-gnu" ]]; then
23-
COMMAND="cli.linux-docker-image.writeNativeImageScript"
23+
COMMAND="cli[].linux-docker-image.writeNativeImageScript"
2424
CLEANUP=("sudo" "rm" "-rf" "out/cli/linux-docker-image/nativeImageDockerWorkingDir")
2525
else
2626
CLEANUP=("true")
2727
fi
2828
else
2929
case "$1" in
3030
"static")
31-
COMMAND="cli.static-image.writeNativeImageScript"
31+
COMMAND="cli[].static-image.writeNativeImageScript"
3232
CLEANUP=("sudo" "rm" "-rf" "out/cli/static-image/nativeImageDockerWorkingDir")
3333
;;
3434
"mostly-static")
35-
COMMAND="cli.mostly-static-image.writeNativeImageScript"
35+
COMMAND="cli[].mostly-static-image.writeNativeImageScript"
3636
CLEANUP=("sudo" "rm" "-rf" "out/cli/mostly-static-image/nativeImageDockerWorkingDir")
3737
;;
3838
*)

.github/scripts/generate-os-packages.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ packager() {
2525
}
2626

2727
launcher() {
28-
local launcherMillCommand="cli.nativeImage"
28+
local launcherMillCommand="cli[].nativeImage"
2929
local launcherName
3030

3131
if [[ "${OS-}" == "Windows_NT" ]]; then

.github/scripts/generate-slim-docker-image.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
55
WORKDIR="$ROOT/out/docker-slim-workdir"
66

77
mkdir -p "$WORKDIR"
8-
./mill -i copyTo cli.nativeImageMostlyStatic "$WORKDIR/scala-cli" 1>&2
8+
./mill -i copyTo 'cli[]'.nativeImageMostlyStatic "$WORKDIR/scala-cli" 1>&2
99

1010
cd "$WORKDIR"
1111
docker build -t scala-cli-slim -f "$ROOT/.github/scripts/docker/ScalaCliSlimDockerFile" .

DEV.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,29 @@ The Scala CLI sources ship with Mill launchers, so that Mill itself doesn't need
1313

1414
#### Running the CLI from sources
1515

16+
Run the `scala` target with Mill:
1617
```bash
1718
./mill -i scala …arguments…
1819
```
1920

21+
This is the equivalent of running the `cli` task with the default Scala version:
22+
```bash
23+
./mill -i 'cli[]'.run …arguments…
24+
```
25+
2026
#### Debugging the CLI from sources
2127

2228
```bash
2329
./mill -i debug debug-port …arguments…
2430
```
31+
32+
which is short for:
33+
```bash
34+
./mill -i 'cli[]'.debug debug-port …arguments…
35+
```
2536
E.g:
2637
```bash
27-
./mill -i cli.debug 5050 ~/Main.scala -S 3.3.0
38+
./mill -i 'cli[]'.debug 5050 ~/Main.scala -S 3.3.0
2839
```
2940

3041
#### Run unit tests
@@ -129,7 +140,7 @@ Otherwise, some IDE features may not work correctly, i.e. the debugger might cra
129140
#### Generate a native launcher
130141

131142
```bash
132-
./mill -i show cli.nativeImage
143+
./mill -i show 'cli[]'.nativeImage
133144
```
134145

135146
This prints the path to the generated native image.
@@ -140,7 +151,7 @@ whether the files it points at exists or not.)
140151
#### Generate a JVM launcher
141152

142153
```bash
143-
./mill -i show cli.launcher
154+
./mill -i show 'cli[]'.launcher
144155
```
145156

146157
This prints the path to the generated launcher. This launcher is a JAR,
@@ -153,7 +164,7 @@ JVM one (see below).
153164
#### Generate a standalone JVM launcher
154165

155166
```bash
156-
./mill -i show cli.standaloneLauncher
167+
./mill -i show 'cli[]'.standaloneLauncher
157168
```
158169

159170
This prints the path to the generated launcher. This launcher is a JAR,
@@ -296,15 +307,15 @@ image.
296307
To generate the relevant configuration automatically, you can run:
297308

298309
```bash
299-
./mill -i cli.runWithAssistedConfig <scala-cli-sub-command> <args> <options>
310+
./mill -i 'cli[]'.runWithAssistedConfig <scala-cli-sub-command> <args> <options>
300311
```
301312

302313
Just make sure to run it exactly the same as the native image would have been run, as the configuration is generated for
303314
a particular invocation path. The run has to succeed as well, as the configuration will only be fully generated after an
304315
exit code 0.
305316

306317
```text
307-
Config generated in out/cli/runWithAssistedConfig.dest/config
318+
Config generated in out/cli/<scalaVersion>/runWithAssistedConfig.dest/config
308319
```
309320

310321
As a result, you should get the path to the generated configuration file. It might contain some unnecessary entries, so

0 commit comments

Comments
 (0)