Skip to content

Commit

Permalink
replace pack command, do not produce lib directory, write classpath t…
Browse files Browse the repository at this point in the history
…o file
  • Loading branch information
bishabosha committed Jun 21, 2024
1 parent c1b25d6 commit 9d41c7b
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 228 deletions.
63 changes: 11 additions & 52 deletions dist/bin/common
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,62 +6,21 @@ source "$PROG_HOME/bin/common-shared"
# * The code below is for Dotty
# *-------------------------------------------------*/

find_lib () {
for lib in "$PROG_HOME"/lib/$1 ; do
if [[ -f "$lib" ]]; then
if [ -n "$CYGPATHCMD" ]; then
"$CYGPATHCMD" -am "$lib"
elif [[ $mingw || $msys ]]; then
echo "$lib" | sed 's|/|\\\\|g'
else
echo "$lib"
fi
return
load_classpath () {
command="$1"
psep_pattern="$2"
__CLASS_PATH=""
while IFS= read -r line; do
if ! [[ ( -n ${conemu-} || -n ${msys-}) && "$line" == "*jna-5*" ]]; then
# jna-5 only appropriate for some combinations
__CLASS_PATH+="$PROG_HOME/maven2/$line$psep_pattern"
fi
done
done < "$PROG_HOME/etc/$command.classpath"
echo "$__CLASS_PATH"
}

DOTTY_COMP=$(find_lib "*scala3-compiler*")
DOTTY_INTF=$(find_lib "*scala3-interfaces*")
DOTTY_LIB=$(find_lib "*scala3-library*")
DOTTY_STAGING=$(find_lib "*scala3-staging*")
DOTTY_TASTY_INSPECTOR=$(find_lib "*scala3-tasty-inspector*")
TASTY_CORE=$(find_lib "*tasty-core*")
SCALA_ASM=$(find_lib "*scala-asm*")
SCALA_LIB=$(find_lib "*scala-library*")
SBT_INTF=$(find_lib "*compiler-interface*")
JLINE_READER=$(find_lib "*jline-reader-3*")
JLINE_TERMINAL=$(find_lib "*jline-terminal-3*")
JLINE_TERMINAL_JNA=$(find_lib "*jline-terminal-jna-3*")

# jna-5 only appropriate for some combinations
[[ ${conemu-} && ${msys-} ]] || JNA=$(find_lib "*jna-5*")

compilerJavaClasspathArgs () {
# echo "dotty-compiler: $DOTTY_COMP"
# echo "dotty-interface: $DOTTY_INTF"
# echo "dotty-library: $DOTTY_LIB"
# echo "tasty-core: $TASTY_CORE"
# echo "scala-asm: $SCALA_ASM"
# echo "scala-lib: $SCALA_LIB"
# echo "sbt-intface: $SBT_INTF"

toolchain=""
toolchain+="$SCALA_LIB$PSEP"
toolchain+="$DOTTY_LIB$PSEP"
toolchain+="$SCALA_ASM$PSEP"
toolchain+="$SBT_INTF$PSEP"
toolchain+="$DOTTY_INTF$PSEP"
toolchain+="$DOTTY_COMP$PSEP"
toolchain+="$TASTY_CORE$PSEP"
toolchain+="$DOTTY_STAGING$PSEP"
toolchain+="$DOTTY_TASTY_INSPECTOR$PSEP"

# jine
toolchain+="$JLINE_READER$PSEP"
toolchain+="$JLINE_TERMINAL$PSEP"
toolchain+="$JLINE_TERMINAL_JNA$PSEP"
[ -n "${JNA-}" ] && toolchain+="$JNA$PSEP"
toolchain="$(load_classpath "scala" "$PSEP")"

if [ -n "${jvm_cp_args-}" ]; then
jvm_cp_args="$toolchain$jvm_cp_args"
Expand Down
16 changes: 1 addition & 15 deletions dist/bin/common.bat
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,6 @@ if not defined _PROG_HOME (
set _EXITCODE=1
goto :eof
)
set "_LIB_DIR=%_PROG_HOME%\lib"
set "_ETC_DIR=%_PROG_HOME%\etc"

set _PSEP=;

for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*scala3-compiler*"') do set "_SCALA3_COMP=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*scala3-interfaces*"') do set "_SCALA3_INTF=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*scala3-library*"') do set "_SCALA3_LIB=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*scala3-staging*"') do set "_SCALA3_STAGING=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*scala3-tasty-inspector*"') do set "_SCALA3_TASTY_INSPECTOR=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*tasty-core*"') do set "_TASTY_CORE=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*scala-asm*"') do set "_SCALA_ASM=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*scala-library*"') do set "_SCALA_LIB=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*compiler-interface*"') do set "_SBT_INTF=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*jline-reader-3*"') do set "_JLINE_READER=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*jline-terminal-3*"') do set "_JLINE_TERMINAL=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*jline-terminal-jna-3*"') do set "_JLINE_TERMINAL_JNA=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*jna-5*"') do set "_JNA=%_LIB_DIR%\%%f"
Empty file modified dist/bin/scalac
100644 → 100755
Empty file.
43 changes: 20 additions & 23 deletions dist/bin/scalac.bat
Original file line number Diff line number Diff line change
Expand Up @@ -88,29 +88,10 @@ goto :eof

@rem output parameter: _JVM_CP_ARGS
:compilerJavaClasspathArgs
@rem echo scala3-compiler: %_SCALA3_COMP%
@rem echo scala3-interface: %_SCALA3_INTF%
@rem echo scala3-library: %_SCALA3_LIB%
@rem echo tasty-core: %_TASTY_CORE%
@rem echo scala-asm: %_SCALA_ASM%
@rem echo scala-lib: %_SCALA_LIB%
@rem echo sbt-intface: %_SBT_INTF%

set "__TOOLCHAIN=%_SCALA_LIB%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_LIB%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA_ASM%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SBT_INTF%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_INTF%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_COMP%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_TASTY_CORE%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_STAGING%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_TASTY_INSPECTOR%%_PSEP%"

@rem # jline
set "__TOOLCHAIN=%__TOOLCHAIN%%_JLINE_READER%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_JLINE_TERMINAL%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_JLINE_TERMINAL_JNA%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_JNA%%_PSEP%"

call :loadClasspathFromFile

set "__TOOLCHAIN=%_CLASS_PATH%"

if defined _SCALA_CPATH (
set "_JVM_CP_ARGS=%__TOOLCHAIN%%_SCALA_CPATH%"
Expand All @@ -119,6 +100,22 @@ if defined _SCALA_CPATH (
)
goto :eof

@REM concatentate every line in "%_ETC_DIR%\scala.classpath" with _PSEP
:loadClasspathFromFile
set _CLASS_PATH=
if exist "%_ETC_DIR%\scala.classpath" (
for /f "usebackq delims=" %%i in ("%_ETC_DIR%\scala.classpath") do (
set "_LIB=%_PROG_HOME%\maven2\%%i"
set "_LIB=!_LIB:/=\!"
if not defined _CLASS_PATH (
set "_CLASS_PATH=!_LIB!"
) else (
set "_CLASS_PATH=!_CLASS_PATH!%_PSEP%!_LIB!"
)
)
)
goto :eof

@rem #########################################################################
@rem ## Cleanups

Expand Down
57 changes: 1 addition & 56 deletions dist/bin/scaladoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,62 +53,7 @@ addScrip() {
}

classpathArgs () {
CLASS_PATH=""
CLASS_PATH+="$(find_lib "*scaladoc*")$PSEP"
CLASS_PATH+="$(find_lib "*scala3-compiler*")$PSEP"
CLASS_PATH+="$(find_lib "*scala3-interfaces*")$PSEP"
CLASS_PATH+="$(find_lib "*scala3-library*")$PSEP"
CLASS_PATH+="$(find_lib "*tasty-core*")$PSEP"
CLASS_PATH+="$(find_lib "*scala3-tasty-inspector*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-0*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-ext-anchorlink*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-ext-autolink*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-ext-emoji*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-ext-gfm-strikethrough*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-ext-gfm-tasklist*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-ext-wikilink*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-ext-yaml-front-matter*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-ext-tables*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-ext-ins*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-ext-superscript*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-util*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-util-ast*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-util-data*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-util-dependency*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-util-misc*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-util-format*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-util-sequence*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-util-builder*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-util-collection*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-util-visitor*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-util-options*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-util-html*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-formatter*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-ast*")$PSEP"
CLASS_PATH+="$(find_lib "*liqp*")$PSEP"
CLASS_PATH+="$(find_lib "*jsoup*")$PSEP"
CLASS_PATH+="$(find_lib "*jackson-dataformat-yaml*")$PSEP"
CLASS_PATH+="$(find_lib "*jackson-datatype-jsr310*")$PSEP"
CLASS_PATH+="$(find_lib "*strftime4j*")$PSEP"
CLASS_PATH+="$(find_lib "*scala-asm*")$PSEP"
CLASS_PATH+="$(find_lib "*compiler-interface*")$PSEP"
CLASS_PATH+="$(find_lib "*jline-reader*")$PSEP"
CLASS_PATH+="$(find_lib "*jline-terminal-3*")$PSEP"
CLASS_PATH+="$(find_lib "*jline-terminal-jna*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-formatter*")$PSEP"
CLASS_PATH+="$(find_lib "*autolink-0.6*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-jira-converter*")$PSEP"
CLASS_PATH+="$(find_lib "*antlr4*")$PSEP"
CLASS_PATH+="$(find_lib "*jackson-annotations*")$PSEP"
CLASS_PATH+="$(find_lib "*jackson-core*")$PSEP"
CLASS_PATH+="$(find_lib "*jackson-databind*")$PSEP"
CLASS_PATH+="$(find_lib "*snakeyaml*")$PSEP"
CLASS_PATH+="$(find_lib "*scala-library*")$PSEP"
CLASS_PATH+="$(find_lib "*protobuf-java*")$PSEP"
CLASS_PATH+="$(find_lib "*util-interface*")$PSEP"
CLASS_PATH+="$(find_lib "*jna-5*")$PSEP"
CLASS_PATH+="$(find_lib "*antlr4-runtime*")$PSEP"
CLASS_PATH="$(load_classpath "scaladoc" "$PSEP")"

jvm_cp_args="-classpath \"$CLASS_PATH\""
}
Expand Down
66 changes: 15 additions & 51 deletions dist/bin/scaladoc.bat
Original file line number Diff line number Diff line change
Expand Up @@ -105,60 +105,24 @@ goto :eof

@rem output parameter: _CLASS_PATH
:classpathArgs
set "_LIB_DIR=%_PROG_HOME%\lib"
set _CLASS_PATH=
set "_ETC_DIR=%_PROG_HOME%\etc"
@rem keep list in sync with bash script `bin\scaladoc` !
call :updateClasspath "scaladoc"
call :updateClasspath "scala3-compiler"
call :updateClasspath "scala3-interfaces"
call :updateClasspath "scala3-library"
call :updateClasspath "tasty-core"
call :updateClasspath "scala3-tasty-inspector"
call :updateClasspath "flexmark-0"
call :updateClasspath "flexmark-html-parser"
call :updateClasspath "flexmark-ext-anchorlink"
call :updateClasspath "flexmark-ext-autolink"
call :updateClasspath "flexmark-ext-emoji"
call :updateClasspath "flexmark-ext-gfm-strikethrough"
call :updateClasspath "flexmark-ext-gfm-tables"
call :updateClasspath "flexmark-ext-gfm-tasklist"
call :updateClasspath "flexmark-ext-wikilink"
call :updateClasspath "flexmark-ext-yaml-front-matter"
call :updateClasspath "liqp"
call :updateClasspath "jsoup"
call :updateClasspath "jackson-dataformat-yaml"
call :updateClasspath "jackson-datatype-jsr310"
call :updateClasspath "strftime4j"
call :updateClasspath "scala-asm"
call :updateClasspath "compiler-interface"
call :updateClasspath "jline-reader"
call :updateClasspath "jline-terminal-3"
call :updateClasspath "jline-terminal-jna"
call :updateClasspath "flexmark-util"
call :updateClasspath "flexmark-formatter"
call :updateClasspath "autolink-0.6"
call :updateClasspath "flexmark-jira-converter"
call :updateClasspath "antlr4"
call :updateClasspath "jackson-annotations"
call :updateClasspath "jackson-core"
call :updateClasspath "jackson-databind"
call :updateClasspath "snakeyaml"
call :updateClasspath "scala-library"
call :updateClasspath "protobuf-java"
call :updateClasspath "util-interface"
call :updateClasspath "jna-5"
call :updateClasspath "flexmark-ext-tables"
call :updateClasspath "flexmark-ext-ins"
call :updateClasspath "flexmark-ext-superscript"
call :updateClasspath "antlr4-runtime"
call :loadClasspathFromFile
goto :eof

@rem input parameter: %1=pattern for library file
@rem output parameter: _CLASS_PATH
:updateClasspath
set "__PATTERN=%~1"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*%__PATTERN%*" 2^>NUL') do (
set "_CLASS_PATH=!_CLASS_PATH!%_LIB_DIR%\%%f%_PSEP%"
@REM concatentate every line in "%_ETC_DIR%\scaladoc.classpath" with _PSEP
:loadClasspathFromFile
set _CLASS_PATH=
if exist "%_ETC_DIR%\scaladoc.classpath" (
for /f "usebackq delims=" %%i in ("%_ETC_DIR%\scaladoc.classpath") do (
set "_LIB=%_PROG_HOME%\maven2\%%i"
set "_LIB=!_LIB:/=\!"
if not defined _CLASS_PATH (
set "_CLASS_PATH=!_LIB!"
) else (
set "_CLASS_PATH=!_CLASS_PATH!%_PSEP%!_LIB!"
)
)
)
goto :eof

Expand Down
7 changes: 6 additions & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2127,7 +2127,12 @@ object Build {
republishRepo := target.value / "republish",
packResourceDir += (republishRepo.value / "bin" -> "bin"),
packResourceDir += (republishRepo.value / "maven2" -> "maven2"),
Compile / pack := (Compile / pack).dependsOn(republish).value,
packResourceDir += (republishRepo.value / "etc" -> "etc"),
republishCommandLibs +=
("scala" -> List("scala3-interfaces", "scala3-compiler", "scala3-library", "tasty-core", "scala3-staging", "scala3-tasty-inspector")),
republishCommandLibs +=
("scaladoc" -> List("scala3-interfaces", "scala3-compiler", "scala3-library", "tasty-core", "scala3-tasty-inspector", "scaladoc")),
Compile / pack := republishPack.value,
)

lazy val dist = project.asDist(Bootstrapped)
Expand Down
Loading

0 comments on commit 9d41c7b

Please sign in to comment.