Skip to content

Commit dc75f8d

Browse files
Merge pull request #25 from scala-cli/graalvm-22.0.0
Update GraalVM to 22.0.0, switch to Java 17
2 parents 5c5547f + 1794818 commit dc75f8d

File tree

7 files changed

+137
-53
lines changed

7 files changed

+137
-53
lines changed

Diff for: .github/workflows/launchers.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ jobs:
2323
with:
2424
jvm: 8
2525
- run: |
26-
./mill -i "native.writeNativeImageScript" generate.sh && \
26+
./mill -i "native.writeNativeImageScript" generate.sh "" && \
2727
./generate.sh && \
2828
./mill -i "native.copyToArtifacts" artifacts/
2929
if: runner.os != 'Windows'
3030
- run: |
31-
@call ./mill.bat -i "native.writeNativeImageScript" generate.bat
31+
@call ./mill.bat -i "native.writeNativeImageScript" generate.bat ""
3232
@call generate.bat
3333
@call ./mill.bat -i "native.copyToArtifacts" artifacts/
3434
shell: cmd
@@ -56,7 +56,7 @@ jobs:
5656
with:
5757
jvm: 8
5858
- run: |
59-
./mill -i "native-static.writeNativeImageScript" generate.sh && \
59+
./mill -i "native-static.writeNativeImageScript" generate.sh "" && \
6060
./generate.sh && \
6161
./mill -i "native-static.copyToArtifacts" artifacts/
6262
- uses: actions/[email protected]
@@ -82,7 +82,7 @@ jobs:
8282
with:
8383
jvm: 8
8484
- run: |
85-
./mill -i "native-mostly-static.writeNativeImageScript" generate.sh && \
85+
./mill -i "native-mostly-static.writeNativeImageScript" generate.sh "" && \
8686
./generate.sh && \
8787
./mill -i "native-mostly-static.copyToArtifacts" artifacts/
8888
- uses: actions/[email protected]

Diff for: .mill-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.12
1+
0.10.2

Diff for: build.sc

+24-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version_mill0.9:0.1.1`
2-
import $ivy.`io.github.alexarchambault.mill::mill-native-image_mill0.9:0.1.12`
3-
import $ivy.`io.github.alexarchambault.mill::mill-native-image-upload:0.1.12`
1+
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.1.4`
2+
import $ivy.`io.github.alexarchambault.mill::mill-native-image::0.1.19`
3+
import $ivy.`io.github.alexarchambault.mill::mill-native-image-upload:0.1.19`
44

55
import de.tobiasroeser.mill.vcs.version._
66
import io.github.alexarchambault.millnativeimage.NativeImage
@@ -11,7 +11,7 @@ import mill.scalalib._
1111
def scalafmtVersion = "3.4.3"
1212

1313
trait ScalafmtNativeImage extends ScalaModule with NativeImage {
14-
def scalaVersion = "2.13.6"
14+
def scalaVersion = "2.13.8"
1515

1616
def nativeImageClassPath = T{
1717
runClasspath()
@@ -22,7 +22,7 @@ trait ScalafmtNativeImage extends ScalaModule with NativeImage {
2222
)
2323
}
2424
def nativeImagePersist = System.getenv("CI") != null
25-
def nativeImageGraalVmJvmId = "graalvm-java11:21.2.0"
25+
def nativeImageGraalVmJvmId = "graalvm-java17:22.0.0"
2626
def nativeImageName = "scalafmt"
2727
def ivyDeps = super.ivyDeps() ++ Seq(
2828
ivy"org.scalameta::scalafmt-cli:$scalafmtVersion"
@@ -43,24 +43,36 @@ trait ScalafmtNativeImage extends ScalaModule with NativeImage {
4343

4444
object native extends ScalafmtNativeImage
4545

46-
def csDockerVersion = "2.0.16"
46+
def csDockerVersion = "2.1.0-M5-18-gfebf9838c"
4747

4848
object `native-static` extends ScalafmtNativeImage {
4949
def nameSuffix = "-static"
50-
def nativeImageDockerParams = Some(
51-
NativeImage.linuxStaticParams(
52-
"messense/rust-musl-cross@sha256:12d0dd535ef7364bf49cb2608ae7eaf60e40d07834eb4d9160c592422a08d3b3",
53-
s"https://github.com/coursier/coursier/releases/download/v$csDockerVersion/cs-x86_64-pc-linux"
50+
def buildHelperImage = T {
51+
os.proc("docker", "build", "-t", "scala-cli-base-musl:latest", ".")
52+
.call(cwd = os.pwd / "musl-image", stdout = os.Inherit)
53+
()
54+
}
55+
def nativeImageDockerParams = T{
56+
buildHelperImage()
57+
Some(
58+
NativeImage.linuxStaticParams(
59+
"scala-cli-base-musl:latest",
60+
s"https://github.com/coursier/coursier/releases/download/v$csDockerVersion/cs-x86_64-pc-linux.gz"
61+
)
5462
)
55-
)
63+
}
64+
def writeNativeImageScript(scriptDest: String, imageDest: String = "") = T.command {
65+
buildHelperImage()
66+
super.writeNativeImageScript(scriptDest, imageDest)()
67+
}
5668
}
5769

5870
object `native-mostly-static` extends ScalafmtNativeImage {
5971
def nameSuffix = "-mostly-static"
6072
def nativeImageDockerParams = Some(
6173
NativeImage.linuxMostlyStaticParams(
6274
"ubuntu:18.04", // TODO Pin that?
63-
s"https://github.com/coursier/coursier/releases/download/v$csDockerVersion/cs-x86_64-pc-linux"
75+
s"https://github.com/coursier/coursier/releases/download/v$csDockerVersion/cs-x86_64-pc-linux.gz"
6476
)
6577
)
6678
}

Diff for: mill

+77-26
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,33 @@
55
# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION
66
#
77
# Project page: https://github.com/lefou/millw
8+
# Script Version: 0.4.2
89
#
910
# If you want to improve this script, please also contribute your changes back!
1011
#
1112
# Licensed under the Apache License, Version 2.0
1213

1314

14-
DEFAULT_MILL_VERSION=0.9.5
15+
DEFAULT_MILL_VERSION=0.10.0
1516

1617
set -e
1718

1819
MILL_REPO_URL="https://github.com/com-lihaoyi/mill"
1920

21+
if [ -z "${CURL_CMD}" ] ; then
22+
CURL_CMD=curl
23+
fi
24+
2025
# Explicit commandline argument takes precedence over all other methods
21-
if [ "x$1" = "x--mill-version" ] ; then
26+
if [ "$1" = "--mill-version" ] ; then
2227
shift
2328
if [ "x$1" != "x" ] ; then
2429
MILL_VERSION="$1"
2530
shift
2631
else
27-
echo "You specified --mill-version without a version."
28-
echo "Please provide a version that matches one provided on"
29-
echo "${MILL_REPO_URL}/releases"
32+
echo "You specified --mill-version without a version." 1>&2
33+
echo "Please provide a version that matches one provided on" 1>&2
34+
echo "${MILL_REPO_URL}/releases" 1>&2
3035
false
3136
fi
3237
fi
@@ -35,59 +40,103 @@ fi
3540
# We reuse it's value and skip searching for a value.
3641

3742
# If not already set, read .mill-version file
38-
if [ "x${MILL_VERSION}" = "x" ] ; then
43+
if [ -z "${MILL_VERSION}" ] ; then
3944
if [ -f ".mill-version" ] ; then
4045
MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)"
4146
fi
4247
fi
4348

44-
if [ "x${XDG_CACHE_HOME}" != "x" ] ; then
49+
if [ -n "${XDG_CACHE_HOME}" ] ; then
4550
MILL_DOWNLOAD_PATH="${XDG_CACHE_HOME}/mill/download"
4651
else
4752
MILL_DOWNLOAD_PATH="${HOME}/.cache/mill/download"
4853
fi
4954

5055
# If not already set, try to fetch newest from Github
51-
if [ "x${MILL_VERSION}" = "x" ] ; then
56+
if [ -z "${MILL_VERSION}" ] ; then
5257
# TODO: try to load latest version from release page
53-
echo "No mill version specified."
54-
echo "You should provide a version via '.mill-version' file or --mill-version option."
58+
echo "No mill version specified." 1>&2
59+
echo "You should provide a version via '.mill-version' file or --mill-version option." 1>&2
5560

5661
mkdir -p "${MILL_DOWNLOAD_PATH}"
57-
LANG=C touch -d '1 hour ago' "${MILL_DOWNLOAD_PATH}/.expire_latest"
58-
if [ "${MILL_DOWNLOAD_PATH}/.latest" -nt "${MILL_DOWNLOAD_PATH}/.expire_latest" ] ; then
62+
LANG=C touch -d '1 hour ago' "${MILL_DOWNLOAD_PATH}/.expire_latest" 2>/dev/null || (
63+
# we might be on OSX or BSD which don't have -d option for touch
64+
# but probably a -A [-][[hh]mm]SS
65+
touch "${MILL_DOWNLOAD_PATH}/.expire_latest"; touch -A -010000 "${MILL_DOWNLOAD_PATH}/.expire_latest"
66+
) || (
67+
# in case we still failed, we retry the first touch command with the intention
68+
# to show the (previously suppressed) error message
69+
LANG=C touch -d '1 hour ago' "${MILL_DOWNLOAD_PATH}/.expire_latest"
70+
)
71+
72+
# POSIX shell variant of bash's -nt operator, see https://unix.stackexchange.com/a/449744/6993
73+
# if [ "${MILL_DOWNLOAD_PATH}/.latest" -nt "${MILL_DOWNLOAD_PATH}/.expire_latest" ] ; then
74+
if [ -n "$(find -L "${MILL_DOWNLOAD_PATH}/.latest" -prune -newer "${MILL_DOWNLOAD_PATH}/.expire_latest")" ]; then
5975
# we know a current latest version
60-
MILL_VERSION="$(head -n 1 ${MILL_DOWNLOAD_PATH}/.latest 2> /dev/null)"
76+
MILL_VERSION=$(head -n 1 "${MILL_DOWNLOAD_PATH}"/.latest 2> /dev/null)
6177
fi
6278

63-
if [ "x${MILL_VERSION}" = "x" ] ; then
79+
if [ -z "${MILL_VERSION}" ] ; then
6480
# we don't know a current latest version
65-
echo "Retrieving latest mill version ..."
66-
LANG=C curl -s -i -f -I ${MILL_REPO_URL}/releases/latest 2> /dev/null | grep --ignore-case Location: | sed s'/^.*tag\///' | tr -d '\r\n' > "${MILL_DOWNLOAD_PATH}/.latest"
67-
MILL_VERSION="$(head -n 1 ${MILL_DOWNLOAD_PATH}/.latest 2> /dev/null)"
81+
echo "Retrieving latest mill version ..." 1>&2
82+
LANG=C ${CURL_CMD} -s -i -f -I ${MILL_REPO_URL}/releases/latest 2> /dev/null | grep --ignore-case Location: | sed s'/^.*tag\///' | tr -d '\r\n' > "${MILL_DOWNLOAD_PATH}/.latest"
83+
MILL_VERSION=$(head -n 1 "${MILL_DOWNLOAD_PATH}"/.latest 2> /dev/null)
6884
fi
6985

70-
if [ "x${MILL_VERSION}" = "x" ] ; then
86+
if [ -z "${MILL_VERSION}" ] ; then
7187
# Last resort
7288
MILL_VERSION="${DEFAULT_MILL_VERSION}"
73-
echo "Falling back to hardcoded mill version ${MILL_VERSION}"
89+
echo "Falling back to hardcoded mill version ${MILL_VERSION}" 1>&2
7490
else
75-
echo "Using mill version ${MILL_VERSION}"
91+
echo "Using mill version ${MILL_VERSION}" 1>&2
7692
fi
7793
fi
7894

7995
MILL="${MILL_DOWNLOAD_PATH}/${MILL_VERSION}"
8096

97+
try_to_use_system_mill() {
98+
MILL_IN_PATH="$(command -v mill || true)"
99+
100+
if [ -z "${MILL_IN_PATH}" ]; then
101+
return
102+
fi
103+
104+
UNIVERSAL_SCRIPT_MAGIC="@ 2>/dev/null # 2>nul & echo off & goto BOF"
105+
106+
if ! head -c 128 "${MILL_IN_PATH}" | grep -qF "${UNIVERSAL_SCRIPT_MAGIC}"; then
107+
if [ -n "${MILLW_VERBOSE}" ]; then
108+
echo "Could not determine mill version of ${MILL_IN_PATH}, as it does not start with the universal script magic2" 1>&2
109+
fi
110+
return
111+
fi
112+
113+
# Roughly the size of the universal script.
114+
MILL_VERSION_SEARCH_RANGE="2403"
115+
MILL_IN_PATH_VERSION=$(head -c "${MILL_VERSION_SEARCH_RANGE}" "${MILL_IN_PATH}" |\
116+
sed -n 's/^.*-DMILL_VERSION=\([^\s]*\) .*$/\1/p' |\
117+
head -n 1)
118+
119+
if [ -z "${MILL_IN_PATH_VERSION}" ]; then
120+
echo "Could not determine mill version, even though ${MILL_IN_PATH} has the universal script magic" 1>&2
121+
return
122+
fi
123+
124+
if [ "${MILL_IN_PATH_VERSION}" = "${MILL_VERSION}" ]; then
125+
MILL="${MILL_IN_PATH}"
126+
fi
127+
}
128+
try_to_use_system_mill
129+
81130
# If not already downloaded, download it
82131
if [ ! -s "${MILL}" ] ; then
83-
132+
84133
# support old non-XDG download dir
85134
MILL_OLD_DOWNLOAD_PATH="${HOME}/.mill/download"
86135
OLD_MILL="${MILL_OLD_DOWNLOAD_PATH}/${MILL_VERSION}"
87136
if [ -x "${OLD_MILL}" ] ; then
88137
MILL="${OLD_MILL}"
89138
else
90-
VERSION_PREFIX="$(echo -n $MILL_VERSION | cut -b -4)"
139+
VERSION_PREFIX="$(echo $MILL_VERSION | cut -b -4)"
91140
case $VERSION_PREFIX in
92141
0.0. | 0.1. | 0.2. | 0.3. | 0.4. )
93142
DOWNLOAD_SUFFIX=""
@@ -98,10 +147,11 @@ if [ ! -s "${MILL}" ] ; then
98147
esac
99148
unset VERSION_PREFIX
100149

101-
DOWNLOAD_FILE=$(mktemp mill.XXXX)
150+
DOWNLOAD_FILE=$(mktemp mill.XXXXXX)
102151
# TODO: handle command not found
103-
echo "Downloading mill ${MILL_VERSION} from ${MILL_REPO_URL}/releases ..."
104-
curl -L -o "${DOWNLOAD_FILE}" "${MILL_REPO_URL}/releases/download/${MILL_VERSION%%-*}/${MILL_VERSION}${DOWNLOAD_SUFFIX}"
152+
echo "Downloading mill ${MILL_VERSION} from ${MILL_REPO_URL}/releases ..." 1>&2
153+
MILL_VERSION_TAG=$(echo $MILL_VERSION | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/')
154+
${CURL_CMD} -f -L -o "${DOWNLOAD_FILE}" "${MILL_REPO_URL}/releases/download/${MILL_VERSION_TAG}/${MILL_VERSION}${DOWNLOAD_SUFFIX}"
105155
chmod +x "${DOWNLOAD_FILE}"
106156
mkdir -p "${MILL_DOWNLOAD_PATH}"
107157
mv "${DOWNLOAD_FILE}" "${MILL}"
@@ -115,6 +165,7 @@ unset MILL_DOWNLOAD_PATH
115165
unset MILL_OLD_DOWNLOAD_PATH
116166
unset OLD_MILL
117167
unset MILL_VERSION
168+
unset MILL_VERSION_TAG
118169
unset MILL_REPO_URL
119170

120-
exec $MILL "$@"
171+
exec "${MILL}" "$@"

Diff for: mill.bat

+16-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ rem You can give the required mill version with --mill-version parameter
55
rem If no version is given, it falls back to the value of DEFAULT_MILL_VERSION
66
rem
77
rem Project page: https://github.com/lefou/millw
8+
rem Script Version: 0.4.2
89
rem
910
rem If you want to improve this script, please also contribute your changes back!
1011
rem
@@ -14,7 +15,7 @@ rem setlocal seems to be unavailable on Windows 95/98/ME
1415
rem but I don't think we need to support them in 2019
1516
setlocal enabledelayedexpansion
1617

17-
set "DEFAULT_MILL_VERSION=0.9.5"
18+
set "DEFAULT_MILL_VERSION=0.10.0"
1819

1920
set "MILL_REPO_URL=https://github.com/com-lihaoyi/mill"
2021

@@ -25,9 +26,9 @@ if [%~1%]==[--mill-version] (
2526
set MILL_VERSION=%~2%
2627
set "STRIP_VERSION_PARAMS=true"
2728
) else (
28-
echo You specified --mill-version without a version.
29-
echo Please provide a version that matches one provided on
30-
echo %MILL_REPO_URL%/releases
29+
echo You specified --mill-version without a version. 1>&2
30+
echo Please provide a version that matches one provided on 1>&2
31+
echo %MILL_REPO_URL%/releases 1>&2
3132
exit /b 1
3233
)
3334
)
@@ -57,31 +58,36 @@ if not exist "%MILL%" (
5758
if [!VERSION_PREFIX!]==[0.4.] set DOWNLOAD_SUFFIX=
5859
set VERSION_PREFIX=
5960

60-
for /F "delims=-" %%A in ("!MILL_VERSION!") do (
61-
set MILL_BASE_VERSION=%%A
61+
for /F "delims=- tokens=1" %%A in ("!MILL_VERSION!") do set MILL_VERSION_BASE=%%A
62+
for /F "delims=- tokens=2" %%A in ("!MILL_VERSION!") do set MILL_VERSION_MILESTONE=%%A
63+
set VERSION_MILESTONE_START=!MILL_VERSION_MILESTONE:~0,1!
64+
if [!VERSION_MILESTONE_START!]==[M] (
65+
set MILL_VERSION_TAG="!MILL_VERSION_BASE!-!MILL_VERSION_MILESTONE!"
66+
) else (
67+
set MILL_VERSION_TAG=!MILL_VERSION_BASE!
6268
)
6369

6470
rem there seems to be no way to generate a unique temporary file path (on native Windows)
6571
set DOWNLOAD_FILE=%MILL%.tmp
6672

67-
set DOWNLOAD_URL=%MILL_REPO_URL%/releases/download/!MILL_BASE_VERSION!/!MILL_VERSION!!DOWNLOAD_SUFFIX!
73+
set DOWNLOAD_URL=%MILL_REPO_URL%/releases/download/!MILL_VERSION_TAG!/!MILL_VERSION!!DOWNLOAD_SUFFIX!
6874

69-
echo Downloading mill %MILL_VERSION% from %MILL_REPO_URL%/releases ...
75+
echo Downloading mill %MILL_VERSION% from %MILL_REPO_URL%/releases ... 1>&2
7076

7177
if not exist "%MILL_DOWNLOAD_PATH%" mkdir "%MILL_DOWNLOAD_PATH%"
7278
rem curl is bundled with recent Windows 10
7379
rem but I don't think we can expect all the users to have it in 2019
7480
where /Q curl
7581
if %ERRORLEVEL% EQU 0 (
76-
curl -L "!DOWNLOAD_URL!" -o "!DOWNLOAD_FILE!"
82+
curl -f -L "!DOWNLOAD_URL!" -o "!DOWNLOAD_FILE!"
7783
) else (
7884
rem bitsadmin seems to be available on Windows 7
7985
rem without /dynamic, github returns 403
8086
rem bitsadmin is sometimes needlessly slow but it looks better with /priority foreground
8187
bitsadmin /transfer millDownloadJob /dynamic /priority foreground "!DOWNLOAD_URL!" "!DOWNLOAD_FILE!"
8288
)
8389
if not exist "!DOWNLOAD_FILE!" (
84-
echo Could not download mill %MILL_VERSION%
90+
echo Could not download mill %MILL_VERSION% 1>&2
8591
exit /b 1
8692
)
8793

Diff for: musl-image/Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# copied from https://github.com/VirtusLab/scala-cli/blob/b73b3e612eeba09c3231da9a51720cb8ddff1874/project/musl-image/Dockerfile
2+
FROM messense/rust-musl-cross@sha256:47a3721b3e186abfd705feb1e03bf1d5212357ea26762cceef11530e0a2f2c7c
3+
ADD setup.sh /setup.sh
4+
RUN /setup.sh

Diff for: musl-image/setup.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# copied from https://github.com/VirtusLab/scala-cli/blob/b73b3e612eeba09c3231da9a51720cb8ddff1874/project/musl-image/setup.sh
5+
6+
cd /usr/local/musl/bin
7+
8+
for i in x86_64-unknown-linux-musl-*; do
9+
dest="$(echo "$i" | sed 's/-unknown//')"
10+
ln -s "$i" "$dest"
11+
done

0 commit comments

Comments
 (0)