Skip to content

Commit 46696d5

Browse files
committed
wip: use right launcher in bin/scala
1 parent b0d0bd9 commit 46696d5

File tree

8 files changed

+44
-25
lines changed

8 files changed

+44
-25
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,17 +233,14 @@ jobs:
233233
run: sbt "dist-win-x64/pack" & bash -version
234234
shell: cmd
235235

236-
# skip while Windows runner is on Java 8, and we use jar launcher for Scala CLI
237236
- name: cygwin tests
238237
run: '"C:\Program Files\cygwin64\bin\bash" ./project/scripts/winCmdTests'
239238
shell: cmd
240239

241-
# skip while Windows runner is on Java 8, and we use jar launcher for Scala CLI
242240
- name: msys tests
243241
run: '"C:\Program Files\Git\bin\bash" ./project/scripts/winCmdTests'
244242
shell: cmd
245243

246-
# skip while Windows runner is on Java 8, and we use jar launcher for Scala CLI
247244
- name: win tests
248245
run: './project/scripts/winCmdTests.bat'
249246
shell: cmd

bin/common

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,43 @@ target="$1"
99

1010
shift # Mutates $@ by deleting the first element ($1)
1111

12+
unset cygwin mingw msys darwin
13+
14+
# COLUMNS is used together with command line option '-pageWidth'.
15+
if command -v tput >/dev/null 2>&1; then
16+
export COLUMNS="$(tput -Tdumb cols)"
17+
fi
18+
19+
case "`uname`" in
20+
CYGWIN*) cygwin=true
21+
;;
22+
MINGW*) mingw=true
23+
;;
24+
MSYS*) msys=true
25+
;;
26+
Darwin*) darwin=true
27+
;;
28+
esac
29+
30+
unset DIST_PROJECT DIST_DIR
31+
32+
if [[ ${cygwin-} || ${mingw-} || ${msys-} ]]; then
33+
DIST_PROJECT="dist-win-x64"
34+
DIST_DIR="dist/win-x64"
35+
else
36+
DIST_PROJECT="dist"
37+
DIST_DIR="dist"
38+
fi
39+
1240
# Marker file used to obtain the date of latest call to sbt-back
13-
version="$ROOT/dist/target/pack/VERSION"
41+
version="$ROOT/$DIST_DIR/target/pack/VERSION"
1442

1543
# Create the target if absent or if file changed in ROOT/compiler
1644
new_files="$(find "$ROOT/compiler" \( -iname "*.scala" -o -iname "*.java" \) -newer "$version" 2> /dev/null)"
1745

1846
if [ ! -f "$version" ] || [ ! -z "$new_files" ]; then
1947
echo "Building Dotty..."
20-
(cd $ROOT && sbt "dist/pack")
48+
(cd $ROOT && sbt "$DIST_PROJECT/pack")
2149
fi
2250

23-
"$target" "$@"
51+
"$ROOT/$DIST_DIR/target/pack/bin/$target" "$@"

bin/scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ scala_args() {
3535
echo "--power ${CLI_ARGS[@]} ${SCRIPT_ARGS[@]}"
3636
}
3737

38-
"$ROOT/bin/common" "$ROOT/dist/target/pack/bin/scala" $(scala_args "$@")
38+
"$ROOT/bin/common" "scala" $(scala_args "$@")

bin/scalac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >& /dev/null && pwd)/.."
44

5-
"$ROOT/bin/common" "$ROOT/dist/target/pack/bin/scalac" "$@"
5+
"$ROOT/bin/common" "scalac" "$@"

bin/scaladoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >& /dev/null && pwd)/.."
44

5-
"$ROOT/bin/common" "$ROOT/dist/target/pack/bin/scaladoc" "$@"
5+
"$ROOT/bin/common" "scaladoc" "$@"

dist/bin/cli-common

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,16 @@ if [[ ${cygwin-} || ${mingw-} || ${msys-} ]]; then
7171
esac
7272
fi
7373

74-
source "$PROG_HOME/bin/cli-common-platform"
75-
7674
CLASSPATH_SUFFIX=""
7775
# Path separator used in EXTRA_CLASSPATH
7876
PSEP=":"
77+
PROG_HOME_URI="file://$PROG_HOME"
7978

8079
# translate paths to Windows-mixed format before running java
8180
if [ -n "${CYGPATHCMD-}" ]; then
8281
[ -n "${PROG_HOME-}" ] &&
8382
PROG_HOME=`"$CYGPATHCMD" -am "$PROG_HOME"`
83+
PROG_HOME_URI="file:///$PROG_HOME" # Add extra root dir prefix
8484
[ -n "$JAVA_HOME" ] &&
8585
JAVA_HOME=`"$CYGPATHCMD" -am "$JAVA_HOME"`
8686
CLASSPATH_SUFFIX=";"
@@ -89,12 +89,15 @@ elif [[ ${mingw-} || ${msys-} ]]; then
8989
# For Mingw / Msys, convert paths from UNIX format before anything is touched
9090
[ -n "$PROG_HOME" ] &&
9191
PROG_HOME="`(cd "$PROG_HOME"; pwd -W | sed 's|/|\\\\|g')`"
92+
PROG_HOME_URI="file:///$PROG_HOME" # Add extra root dir prefix
9293
[ -n "$JAVA_HOME" ] &&
9394
JAVA_HOME="`(cd "$JAVA_HOME"; pwd -W | sed 's|/|\\\\|g')`"
9495
CLASSPATH_SUFFIX=";"
9596
PSEP=";"
9697
fi
9798

99+
source "$PROG_HOME/bin/cli-common-platform"
100+
98101
#/*--------------------------------------------------
99102
# * The code below is for Dotty
100103
# *-------------------------------------------------*/

dist/bin/scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if [ -z "$SCALA_VERSION" ]; then
4444
exit 1
4545
fi
4646

47-
MVN_REPOSITORY="file://$PROG_HOME/maven2"
47+
MVN_REPOSITORY="$PROG_HOME_URI/maven2"
4848

4949
# escape all script arguments
5050
while [[ $# -gt 0 ]]; do
@@ -61,6 +61,7 @@ eval "${SCALA_CLI_CMD_BASH[@]}" \
6161
"--cli-default-scala-version \"$SCALA_VERSION\"" \
6262
"-r \"$MVN_REPOSITORY\"" \
6363
"${scala_args[@]}"
64+
6465
scala_exit_status=$?
6566

6667
onExit

dist/bin/scala.bat

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ if not %_EXITCODE%==0 goto end
1919

2020
call :setScalaOpts
2121

22+
call "%_PROG_HOME%\bin\cli-common-platform.bat"
23+
2224
@rem SCALA_CLI_CMD_WIN is an array, set in cli-common-platform.bat
2325
call %SCALA_CLI_CMD_WIN% "--prog-name" "scala" "--cli-default-scala-version" "%_SCALA_VERSION%" "-r" "%MVN_REPOSITORY%" %*
2426

@@ -41,20 +43,8 @@ if not "%char%"==":" (
4143
goto :findColon
4244
)
4345

44-
@REM set _PROG_HOME to the substring from the first colon to the end
45-
set "_PROG_HOME_SUB=!_PROG_HOME:~%index%!"
46-
@REM strip initial character
47-
set "_PROG_HOME_SUB=!_PROG_HOME_SUB:~1!"
48-
49-
@REM set drive to substring from 0 to the first colon
50-
set "_PROG_HOME_DRIVE=!_PROG_HOME:~0,%index%!"
51-
52-
53-
5446
set "_SCALA_VERSION="
55-
set "MVN_REPOSITORY=file://%_PROG_HOME_DRIVE%\%_PROG_HOME_SUB:\=/%/maven2"
56-
57-
call "%_PROG_HOME%\bin\cli-common-platform.bat"
47+
set "MVN_REPOSITORY=file:///%_PROG_HOME:\=/%/maven2"
5848

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

0 commit comments

Comments
 (0)