diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 44740278d36c..8ed18be1a703 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 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/cli-common b/dist/bin/cli-common index eb77c9924d06..dd55c38cd409 100644 --- a/dist/bin/cli-common +++ b/dist/bin/cli-common @@ -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=";" @@ -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 # *-------------------------------------------------*/ diff --git a/dist/bin/scala b/dist/bin/scala index 6b5930e3c215..809828e2c51c 100755 --- a/dist/bin/scala +++ b/dist/bin/scala @@ -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 @@ -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 (