Skip to content

Commit 3c31ec9

Browse files
committed
download native launchers and overwrite scripts
1 parent 72fd2bb commit 3c31ec9

12 files changed

+226
-123
lines changed

build.sbt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ val `scaladoc-js-main` = Build.`scaladoc-js-main`
2828
val `scaladoc-js-contributors` = Build.`scaladoc-js-contributors`
2929
val `scala3-bench-run` = Build.`scala3-bench-run`
3030
val dist = Build.dist
31+
val `dist-mac-x64` = Build.`dist-mac-x64`
32+
val `dist-mac-aarch64` = Build.`dist-mac-aarch64`
33+
val `dist-win-x64` = Build.`dist-win-x64`
34+
val `dist-linux-x64` = Build.`dist-linux-x64`
35+
val `dist-linux-aarch64` = Build.`dist-linux-aarch64`
3136
val `community-build` = Build.`community-build`
3237
val `sbt-community-build` = Build.`sbt-community-build`
3338
val `scala3-presentation-compiler` = Build.`scala3-presentation-compiler`
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
SCALA_CLI_CMD_BASH=("\"$PROG_HOME/bin/scala-cli\"")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
set SCALA_CLI_CMD_WIN="%_PROG_HOME%\bin\scala-cli.exe"

dist/bin/cli-common

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -71,44 +71,7 @@ if [[ ${cygwin-} || ${mingw-} || ${msys-} ]]; then
7171
esac
7272
fi
7373

74-
# Resolve JAVA_HOME from javac command path
75-
if [ -z "$JAVA_HOME" ]; then
76-
javaExecutable="`which javac`"
77-
if [ -n "$javaExecutable" -a -f "$javaExecutable" -a ! "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
78-
# readlink(1) is not available as standard on Solaris 10.
79-
readLink=`which readlink`
80-
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
81-
javaExecutable="`readlink -f \"$javaExecutable\"`"
82-
javaHome="`dirname \"$javaExecutable\"`"
83-
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
84-
JAVA_HOME="$javaHome"
85-
export JAVA_HOME
86-
fi
87-
fi
88-
fi
89-
90-
if [ -z "${JAVACMD-}" ] ; then
91-
if [ -n "${JAVA_HOME-}" ] ; then
92-
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
93-
# IBM's JDK on AIX uses strange locations for the executables
94-
JAVACMD="$JAVA_HOME/jre/sh/java"
95-
else
96-
JAVACMD="$JAVA_HOME/bin/java"
97-
fi
98-
else
99-
JAVACMD="`which java`"
100-
fi
101-
fi
102-
103-
if [ ! -x "$JAVACMD" ] ; then
104-
echo "Error: JAVA_HOME is not defined correctly."
105-
echo " We cannot execute $JAVACMD"
106-
exit 1
107-
fi
108-
109-
if [ -z "$JAVA_HOME" ] ; then
110-
echo "Warning: JAVA_HOME environment variable is not set."
111-
fi
74+
source "$PROG_HOME/bin/cli-common-platform"
11275

11376
CLASSPATH_SUFFIX=""
11477
# Path separator used in EXTRA_CLASSPATH
@@ -136,23 +99,6 @@ fi
13699
# * The code below is for Dotty
137100
# *-------------------------------------------------*/
138101

139-
find_lib () {
140-
for lib in "$PROG_HOME"/lib/$1 ; do
141-
if [[ -f "$lib" ]]; then
142-
if [ -n "$CYGPATHCMD" ]; then
143-
"$CYGPATHCMD" -am "$lib"
144-
elif [[ $mingw || $msys ]]; then
145-
echo "$lib" | sed 's|/|\\\\|g'
146-
else
147-
echo "$lib"
148-
fi
149-
return
150-
fi
151-
done
152-
}
153-
154-
SCALA_CLI_JAR="$PROG_HOME/etc/scala-cli.jar"
155-
156102
declare -a scala_args
157103

158104
addScala () {

dist/bin/cli-common-platform

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
source "$PROG_HOME/bin/common-java"
4+
5+
SCALA_CLI_CMD_BASH=("\"$JAVACMD\"" "-jar \"$PROG_HOME/bin/scala-cli.jar\"")

dist/bin/cli-common-platform.bat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@echo off
2+
3+
@rem we need to escape % in the java command path, for some reason this doesnt work in common.bat
4+
set "_JAVACMD=!_JAVACMD:%%=%%%%!"
5+
set SCALA_CLI_CMD_WIN="%_JAVACMD%" "-jar" "%_PROG_HOME%\bin\scala-cli.jar"

dist/bin/common

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -67,44 +67,7 @@ if [[ ${cygwin-} || ${mingw-} || ${msys-} ]]; then
6767
esac
6868
fi
6969

70-
# Resolve JAVA_HOME from javac command path
71-
if [ -z "$JAVA_HOME" ]; then
72-
javaExecutable="`which javac`"
73-
if [ -n "$javaExecutable" -a -f "$javaExecutable" -a ! "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
74-
# readlink(1) is not available as standard on Solaris 10.
75-
readLink=`which readlink`
76-
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
77-
javaExecutable="`readlink -f \"$javaExecutable\"`"
78-
javaHome="`dirname \"$javaExecutable\"`"
79-
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
80-
JAVA_HOME="$javaHome"
81-
export JAVA_HOME
82-
fi
83-
fi
84-
fi
85-
86-
if [ -z "${JAVACMD-}" ] ; then
87-
if [ -n "${JAVA_HOME-}" ] ; then
88-
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89-
# IBM's JDK on AIX uses strange locations for the executables
90-
JAVACMD="$JAVA_HOME/jre/sh/java"
91-
else
92-
JAVACMD="$JAVA_HOME/bin/java"
93-
fi
94-
else
95-
JAVACMD="`which java`"
96-
fi
97-
fi
98-
99-
if [ ! -x "$JAVACMD" ] ; then
100-
echo "Error: JAVA_HOME is not defined correctly."
101-
echo " We cannot execute $JAVACMD"
102-
exit 1
103-
fi
104-
105-
if [ -z "$JAVA_HOME" ] ; then
106-
echo "Warning: JAVA_HOME environment variable is not set."
107-
fi
70+
source "$PROG_HOME/bin/common-java"
10871

10972
CLASSPATH_SUFFIX=""
11073
# Path separator used in EXTRA_CLASSPATH

dist/bin/common-java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
3+
# Resolve JAVA_HOME from javac command path
4+
if [ -z "$JAVA_HOME" ]; then
5+
javaExecutable="`which javac`"
6+
if [ -n "$javaExecutable" -a -f "$javaExecutable" -a ! "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
7+
# readlink(1) is not available as standard on Solaris 10.
8+
readLink=`which readlink`
9+
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
10+
javaExecutable="`readlink -f \"$javaExecutable\"`"
11+
javaHome="`dirname \"$javaExecutable\"`"
12+
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
13+
JAVA_HOME="$javaHome"
14+
export JAVA_HOME
15+
fi
16+
fi
17+
fi
18+
19+
if [ -z "${JAVACMD-}" ] ; then
20+
if [ -n "${JAVA_HOME-}" ] ; then
21+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
22+
# IBM's JDK on AIX uses strange locations for the executables
23+
JAVACMD="$JAVA_HOME/jre/sh/java"
24+
else
25+
JAVACMD="$JAVA_HOME/bin/java"
26+
fi
27+
else
28+
JAVACMD="`which java`"
29+
fi
30+
fi
31+
32+
if [ ! -x "$JAVACMD" ] ; then
33+
echo "Error: JAVA_HOME is not defined correctly."
34+
echo " We cannot execute $JAVACMD"
35+
exit 1
36+
fi
37+
38+
if [ -z "$JAVA_HOME" ] ; then
39+
echo "Warning: JAVA_HOME environment variable is not set."
40+
fi

dist/bin/scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ done
5454

5555
# exec here would prevent onExit from being called, leaving terminal in unusable state
5656
[ -z "${ConEmuPID-}" -o -n "${cygwin-}" ] && export MSYSTEM= PWD= # workaround for #12405
57-
eval "\"$JAVACMD\"" \
58-
"-jar \"$SCALA_CLI_JAR\"" \
57+
58+
# SCALA_CLI_CMD_BASH is an array, set by cli-common-platform
59+
eval "${SCALA_CLI_CMD_BASH[@]}" \
5960
"--prog-name scala" \
6061
"--cli-default-scala-version \"$SCALA_VERSION\"" \
6162
"-r \"$MVN_REPOSITORY\"" \

dist/bin/scala.bat

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ if not %_EXITCODE%==0 goto end
1919

2020
call :setScalaOpts
2121

22-
@rem we need to escape % in the java command path, for some reason this doesnt work in common.bat
23-
set "_JAVACMD=!_JAVACMD:%%=%%%%!"
22+
@rem SCALA_CLI_CMD_WIN is an array, set in cli-common-platform.bat
23+
call %SCALA_CLI_CMD_WIN% "--prog-name" "scala" "--cli-default-scala-version" "%_SCALA_VERSION%" "-r" "%MVN_REPOSITORY%" %*
2424

25-
call "%_JAVACMD%" "-jar" "%SCALA_CLI_JAR%" "--prog-name" "scala" "--cli-default-scala-version" "%_SCALA_VERSION%" "-r" "%MVN_REPOSITORY%" %*
2625
if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end )
2726

2827
goto end
@@ -54,7 +53,8 @@ set "_PROG_HOME_DRIVE=!_PROG_HOME:~0,%index%!"
5453

5554
set "_SCALA_VERSION="
5655
set "MVN_REPOSITORY=file://%_PROG_HOME_DRIVE%\%_PROG_HOME_SUB:\=/%/maven2"
57-
set "SCALA_CLI_JAR=%_PROG_HOME%\etc\scala-cli.jar"
56+
57+
call "%_PROG_HOME%\bin\cli-common-platform.bat"
5858

5959
@rem read for version:=_SCALA_VERSION in VERSION_FILE
6060
FOR /F "usebackq delims=" %%G IN ("%_PROG_HOME%\VERSION") DO (

project/Build.scala

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,22 +2092,63 @@ object Build {
20922092
packMain := Map(),
20932093
publishArtifact := false,
20942094
packGenerateMakefile := false,
2095-
packArchiveName := "scala3-" + dottyVersion,
20962095
republishRepo := target.value / "republish",
2097-
republishLaunchers := {
2098-
val cliV = scalaCliLauncherVersion
2099-
Seq(
2100-
("scala-cli.jar", cliV, url(s"https://github.com/VirtusLab/scala-cli/releases/download/v$cliV/scala-cli.jar"))
2101-
)
2102-
},
2096+
packResourceDir += (republishRepo.value / "bin" -> "bin"),
2097+
packResourceDir += (republishRepo.value / "maven2" -> "maven2"),
21032098
Compile / pack := (Compile / pack).dependsOn(republish).value,
21042099
)
21052100

21062101
lazy val dist = project.asDist(Bootstrapped)
21072102
.settings(
2108-
packResourceDir += (baseDirectory.value / "bin" -> "bin"),
2109-
packResourceDir += (republishRepo.value / "maven2" -> "maven2"),
2110-
packResourceDir += (republishRepo.value / "etc" -> "etc"),
2103+
packArchiveName := "scala3-" + dottyVersion,
2104+
republishBinDir := baseDirectory.value / "bin",
2105+
republishLaunchers +=
2106+
("scala-cli.jar" -> s"https://github.com/VirtusLab/scala-cli/releases/download/v$scalaCliLauncherVersion/scala-cli.jar")
2107+
)
2108+
2109+
lazy val `dist-mac-x64` = project.in(file("dist/mac-x64")).asDist(Bootstrapped)
2110+
.settings(
2111+
republishBinDir := (dist / republishBinDir).value,
2112+
packArchiveName := (dist / packArchiveName).value + "-x86_64-apple-darwin",
2113+
republishBinOverrides += (dist / baseDirectory).value / "bin-native-overrides",
2114+
republishLaunchers +=
2115+
("scala-cli" -> s"gz+https://github.com/VirtusLab/scala-cli/releases/download/v$scalaCliLauncherVersion/scala-cli-x86_64-apple-darwin.gz")
2116+
)
2117+
2118+
lazy val `dist-mac-aarch64` = project.in(file("dist/mac-aarch64")).asDist(Bootstrapped)
2119+
.settings(
2120+
republishBinDir := (dist / republishBinDir).value,
2121+
packArchiveName := (dist / packArchiveName).value + "-aarch64-apple-darwin",
2122+
republishBinOverrides += (dist / baseDirectory).value / "bin-native-overrides",
2123+
republishLaunchers +=
2124+
("scala-cli" -> s"gz+https://github.com/VirtusLab/scala-cli/releases/download/v$scalaCliLauncherVersion/scala-cli-aarch64-apple-darwin.gz")
2125+
)
2126+
2127+
lazy val `dist-win-x64` = project.in(file("dist/win-x64")).asDist(Bootstrapped)
2128+
.settings(
2129+
republishBinDir := (dist / republishBinDir).value,
2130+
packArchiveName := (dist / packArchiveName).value + "-x86_64-pc-win32",
2131+
republishBinOverrides += (dist / baseDirectory).value / "bin-native-overrides",
2132+
republishLaunchers +=
2133+
("scala-cli.exe" -> s"zip+https://github.com/VirtusLab/scala-cli/releases/download/v$scalaCliLauncherVersion/scala-cli-x86_64-pc-win32.zip!/scala-cli.exe")
2134+
)
2135+
2136+
lazy val `dist-linux-x64` = project.in(file("dist/linux-x64")).asDist(Bootstrapped)
2137+
.settings(
2138+
republishBinDir := (dist / republishBinDir).value,
2139+
packArchiveName := (dist / packArchiveName).value + "-x86_64-pc-linux",
2140+
republishBinOverrides += (dist / baseDirectory).value / "bin-native-overrides",
2141+
republishLaunchers +=
2142+
("scala-cli" -> s"gz+https://github.com/VirtusLab/scala-cli/releases/download/v$scalaCliLauncherVersion/scala-cli-x86_64-pc-linux.gz")
2143+
)
2144+
2145+
lazy val `dist-linux-aarch64` = project.in(file("dist/linux-aarch64")).asDist(Bootstrapped)
2146+
.settings(
2147+
republishBinDir := (dist / republishBinDir).value,
2148+
packArchiveName := (dist / packArchiveName).value + "-aarch64-pc-linux",
2149+
republishBinOverrides += (dist / baseDirectory).value / "bin-native-overrides",
2150+
republishLaunchers +=
2151+
("scala-cli" -> s"gz+https://github.com/VirtusLab/scala-cli/releases/download/v$scalaCliLauncherVersion/scala-cli-aarch64-pc-linux.gz")
21112152
)
21122153

21132154
private def customMimaReportBinaryIssues(issueFilterLocation: String) = mimaReportBinaryIssues := {

0 commit comments

Comments
 (0)