From cbcd575e8e9947bedf44a63c6b25b46cf5050049 Mon Sep 17 00:00:00 2001 From: Jamie Thompson Date: Fri, 17 May 2024 20:38:57 +0200 Subject: [PATCH] wip: use right launcher in bin/scala --- bin/common | 34 +++++++++++++++++++++++++++++++--- bin/scala | 2 +- bin/scalac | 2 +- bin/scaladoc | 2 +- dist/bin/scala | 1 + dist/bin/scala.bat | 16 +++------------- 6 files changed, 38 insertions(+), 19 deletions(-) diff --git a/bin/common b/bin/common index 7d3aa7148265..971459ee6fe2 100755 --- a/bin/common +++ b/bin/common @@ -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" "$@" diff --git a/bin/scala b/bin/scala index 2df274fe95ba..fabdfa5ea2dc 100755 --- a/bin/scala +++ b/bin/scala @@ -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 "$@") diff --git a/bin/scalac b/bin/scalac index faeb48d92d87..d141b9a6c6bb 100755 --- a/bin/scalac +++ b/bin/scalac @@ -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" "$@" diff --git a/bin/scaladoc b/bin/scaladoc index 11a754c6579f..02decabb9ae3 100755 --- a/bin/scaladoc +++ b/bin/scaladoc @@ -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" "$@" diff --git a/dist/bin/scala b/dist/bin/scala index 6b5930e3c215..43d38b70adc6 100755 --- a/dist/bin/scala +++ b/dist/bin/scala @@ -61,6 +61,7 @@ eval "${SCALA_CLI_CMD_BASH[@]}" \ "--cli-default-scala-version \"$SCALA_VERSION\"" \ "-r \"$MVN_REPOSITORY\"" \ "${scala_args[@]}" + scala_exit_status=$? onExit diff --git a/dist/bin/scala.bat b/dist/bin/scala.bat index 8b4c08da553f..d473facbbb1c 100644 --- a/dist/bin/scala.bat +++ b/dist/bin/scala.bat @@ -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%" %* @@ -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 (