Skip to content

Commit

Permalink
wip: use right launcher in bin/scala
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed May 21, 2024
1 parent b0d0bd9 commit 46696d5
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 25 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,14 @@ jobs:
run: sbt "dist-win-x64/pack" & bash -version
shell: cmd

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

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

# skip while Windows runner is on Java 8, and we use jar launcher for Scala CLI
- name: win tests
run: './project/scripts/winCmdTests.bat'
shell: cmd
Expand Down
34 changes: 31 additions & 3 deletions bin/common
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,43 @@ target="$1"

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

unset cygwin mingw msys darwin

# COLUMNS is used together with command line option '-pageWidth'.
if command -v tput >/dev/null 2>&1; then
export COLUMNS="$(tput -Tdumb cols)"
fi

case "`uname`" in
CYGWIN*) cygwin=true
;;
MINGW*) mingw=true
;;
MSYS*) msys=true
;;
Darwin*) darwin=true
;;
esac

unset DIST_PROJECT DIST_DIR

if [[ ${cygwin-} || ${mingw-} || ${msys-} ]]; then
DIST_PROJECT="dist-win-x64"
DIST_DIR="dist/win-x64"
else
DIST_PROJECT="dist"
DIST_DIR="dist"
fi

# Marker file used to obtain the date of latest call to sbt-back
version="$ROOT/dist/target/pack/VERSION"
version="$ROOT/$DIST_DIR/target/pack/VERSION"

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

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

"$target" "$@"
"$ROOT/$DIST_DIR/target/pack/bin/$target" "$@"
2 changes: 1 addition & 1 deletion bin/scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ scala_args() {
echo "--power ${CLI_ARGS[@]} ${SCRIPT_ARGS[@]}"
}

"$ROOT/bin/common" "$ROOT/dist/target/pack/bin/scala" $(scala_args "$@")
"$ROOT/bin/common" "scala" $(scala_args "$@")
2 changes: 1 addition & 1 deletion bin/scalac
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

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

"$ROOT/bin/common" "$ROOT/dist/target/pack/bin/scalac" "$@"
"$ROOT/bin/common" "scalac" "$@"
2 changes: 1 addition & 1 deletion bin/scaladoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

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

"$ROOT/bin/common" "$ROOT/dist/target/pack/bin/scaladoc" "$@"
"$ROOT/bin/common" "scaladoc" "$@"
7 changes: 5 additions & 2 deletions dist/bin/cli-common
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ if [[ ${cygwin-} || ${mingw-} || ${msys-} ]]; then
esac
fi

source "$PROG_HOME/bin/cli-common-platform"

CLASSPATH_SUFFIX=""
# Path separator used in EXTRA_CLASSPATH
PSEP=":"
PROG_HOME_URI="file://$PROG_HOME"

# translate paths to Windows-mixed format before running java
if [ -n "${CYGPATHCMD-}" ]; then
[ -n "${PROG_HOME-}" ] &&
PROG_HOME=`"$CYGPATHCMD" -am "$PROG_HOME"`
PROG_HOME_URI="file:///$PROG_HOME" # Add extra root dir prefix
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`"$CYGPATHCMD" -am "$JAVA_HOME"`
CLASSPATH_SUFFIX=";"
Expand All @@ -89,12 +89,15 @@ elif [[ ${mingw-} || ${msys-} ]]; then
# For Mingw / Msys, convert paths from UNIX format before anything is touched
[ -n "$PROG_HOME" ] &&
PROG_HOME="`(cd "$PROG_HOME"; pwd -W | sed 's|/|\\\\|g')`"
PROG_HOME_URI="file:///$PROG_HOME" # Add extra root dir prefix
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd -W | sed 's|/|\\\\|g')`"
CLASSPATH_SUFFIX=";"
PSEP=";"
fi

source "$PROG_HOME/bin/cli-common-platform"

#/*--------------------------------------------------
# * The code below is for Dotty
# *-------------------------------------------------*/
Expand Down
3 changes: 2 additions & 1 deletion dist/bin/scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ if [ -z "$SCALA_VERSION" ]; then
exit 1
fi

MVN_REPOSITORY="file://$PROG_HOME/maven2"
MVN_REPOSITORY="$PROG_HOME_URI/maven2"

# escape all script arguments
while [[ $# -gt 0 ]]; do
Expand All @@ -61,6 +61,7 @@ eval "${SCALA_CLI_CMD_BASH[@]}" \
"--cli-default-scala-version \"$SCALA_VERSION\"" \
"-r \"$MVN_REPOSITORY\"" \
"${scala_args[@]}"

scala_exit_status=$?

onExit
16 changes: 3 additions & 13 deletions dist/bin/scala.bat
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ if not %_EXITCODE%==0 goto end

call :setScalaOpts

call "%_PROG_HOME%\bin\cli-common-platform.bat"

@rem SCALA_CLI_CMD_WIN is an array, set in cli-common-platform.bat
call %SCALA_CLI_CMD_WIN% "--prog-name" "scala" "--cli-default-scala-version" "%_SCALA_VERSION%" "-r" "%MVN_REPOSITORY%" %*

Expand All @@ -41,20 +43,8 @@ if not "%char%"==":" (
goto :findColon
)

@REM set _PROG_HOME to the substring from the first colon to the end
set "_PROG_HOME_SUB=!_PROG_HOME:~%index%!"
@REM strip initial character
set "_PROG_HOME_SUB=!_PROG_HOME_SUB:~1!"

@REM set drive to substring from 0 to the first colon
set "_PROG_HOME_DRIVE=!_PROG_HOME:~0,%index%!"



set "_SCALA_VERSION="
set "MVN_REPOSITORY=file://%_PROG_HOME_DRIVE%\%_PROG_HOME_SUB:\=/%/maven2"

call "%_PROG_HOME%\bin\cli-common-platform.bat"
set "MVN_REPOSITORY=file:///%_PROG_HOME:\=/%/maven2"

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

0 comments on commit 46696d5

Please sign in to comment.