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 cbcd575
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 19 deletions.
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" "$@"
1 change: 1 addition & 0 deletions dist/bin/scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 cbcd575

Please sign in to comment.