From 523a1b893fbea9121a89749d84a47ce6ab4de711 Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Thu, 4 Jul 2024 20:27:13 +0200 Subject: [PATCH 1/4] Reduce the length of the arguments in scaladoc.bat --- dist/bin/scaladoc.bat | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/dist/bin/scaladoc.bat b/dist/bin/scaladoc.bat index 16433a83f501..582175f46171 100644 --- a/dist/bin/scaladoc.bat +++ b/dist/bin/scaladoc.bat @@ -31,7 +31,7 @@ if defined JAVA_OPTS ( set _JAVA_OPTS=%JAVA_OPTS% set "_JAVACMD=!_JAVACMD:%%=%%%%!" call "%_JAVACMD%" %_JAVA_OPTS% %_JAVA_DEBUG% %_JAVA_ARGS% ^ --classpath "%_CLASS_PATH%" ^ +-classpath "@%_CLASS_PATH_FILE%" ^ -Dscala.usejavacp=true ^ dotty.tools.scaladoc.Main %_SCALA_ARGS% %_RESIDUAL_ARGS% if not %ERRORLEVEL%==0 ( @@ -79,9 +79,8 @@ if "%__ARG%"=="--" ( ) else if "%__ARG:~0,2%"=="-D" ( call :addJava "%__ARG%" ) else if "%__ARG:~0,2%"=="-J" ( call :addJava "%__ARG:~2%" ) else ( - if defined _IN_SCRIPTING_ARGS ( call :addScripting "%__ARG%" - ) else ( call :addResidual "%__ARG%" - ) + if defined _IN_SCRIPTING_ARGS ( call :addScripting "%__ARG%") + else ( call :addResidual "%__ARG%" ) ) shift goto args_loop @@ -103,25 +102,33 @@ goto :eof set _RESIDUAL_ARGS=%_RESIDUAL_ARGS% %~1 goto :eof -@rem output parameter: _CLASS_PATH +@rem output parameter: _CLASS_PATH_FILE. +@rem It contains the path th the absolute classpaths :classpathArgs -set "_ETC_DIR=%_PROG_HOME%\etc" -@rem keep list in sync with bash script `bin\scaladoc` ! -call :loadClasspathFromFile + +set _ETC_DIR="%_PROG_HOME%\etc" +set _TMP_DIR="%_PROG_HOME%\tmp" +set _INPUT_CLASSPATH_FILE="%_ETC_DIR%\scaladoc.classpath" +set _OUTPUT_CLASSPATH_FILE="%_TMP_DIR%\scaladoc.classpath" + +@rem Check if the _TMP_DIR exists. If not, create it (first time we run the command) +if not exist "%TMP_DIR%" ( mkdir "%TMP_DIR%" ) + +@rem If the file doesn't exist, create it (first time we run the command) +if not exist "%_OUTPUT_CLASSPATH_FILE%" ( call :loadClasspathFromFile ) +set _CLASS_PATH_FILE="%_OUTPUT_CLASSPATH_FILE%" goto :eof -@REM concatentate every line in "%_ETC_DIR%\scaladoc.classpath" with _PSEP +@REM concatentate every line in _INPUT_CLASSPATH_FILE and dump it in the 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" +if exist "%_INPUT_CLASSPATH_FILE%" ( + for /f "usebackq delims=" %%i in "%_INPUT_CLASSPATH_FILE%" do ( + set _LIB="%_PROG_HOME%\maven2\%%i" + @rem Adapt the paths from Unix style to MS-DOS style set "_LIB=!_LIB:/=\!" - if not defined _CLASS_PATH ( - set "_CLASS_PATH=!_LIB!" - ) else ( - set "_CLASS_PATH=!_CLASS_PATH!%_PSEP%!_LIB!" - ) + @rem Append the processed line to the output file, ensuring a new line + echo !_LIB! >> "%_OUTPUT_CLASSPATH_FILE%" ) ) goto :eof From e4e1a59cf17ffd8ff35fb6fefd471990ef752a71 Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Thu, 4 Jul 2024 21:02:46 +0200 Subject: [PATCH 2/4] Add test for scaladoc classpath caching --- project/scripts/winCmdTests.bat | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/project/scripts/winCmdTests.bat b/project/scripts/winCmdTests.bat index 903f74d7ab98..6e32e8e93c93 100644 --- a/project/scripts/winCmdTests.bat +++ b/project/scripts/winCmdTests.bat @@ -22,4 +22,8 @@ if not %ERRORLEVEL%==0 endlocal& exit /b 1 if not exist "%_SITE_DIR%" mkdir "%_SITE_DIR%" call "%_PREFIX%\bin\scaladoc.bat" -d "%_SITE_DIR%" -project Hello "%_SOURCE%" +@rem call the test twice to test the caching logic +rd /s /q "%_SITE_DIR%" +mkdir "%_SITE_DIR%" +call "%_PREFIX%\bin\scaladoc.bat" -d "%_SITE_DIR%" -project Hello "%_SOURCE%" endlocal From 87cceffb6b5a1fd88785465dac7f82b4cbcc261b Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Thu, 4 Jul 2024 21:40:44 +0200 Subject: [PATCH 3/4] Revert unnecessary changes --- dist/bin/scaladoc.bat | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dist/bin/scaladoc.bat b/dist/bin/scaladoc.bat index 582175f46171..d8fbf9abae0a 100644 --- a/dist/bin/scaladoc.bat +++ b/dist/bin/scaladoc.bat @@ -79,8 +79,9 @@ if "%__ARG%"=="--" ( ) else if "%__ARG:~0,2%"=="-D" ( call :addJava "%__ARG%" ) else if "%__ARG:~0,2%"=="-J" ( call :addJava "%__ARG:~2%" ) else ( - if defined _IN_SCRIPTING_ARGS ( call :addScripting "%__ARG%") - else ( call :addResidual "%__ARG%" ) + if defined _IN_SCRIPTING_ARGS ( call :addScripting "%__ARG%" + ) else ( call :addResidual "%__ARG%" + ) ) shift goto args_loop From 9cfe1f66ec77f47b8153f20abed89447c2be23be Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Thu, 4 Jul 2024 22:34:46 +0200 Subject: [PATCH 4/4] fix scaladoc.bat --- dist/bin/scaladoc.bat | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/dist/bin/scaladoc.bat b/dist/bin/scaladoc.bat index d8fbf9abae0a..d4a9df777ad8 100644 --- a/dist/bin/scaladoc.bat +++ b/dist/bin/scaladoc.bat @@ -107,36 +107,50 @@ goto :eof @rem It contains the path th the absolute classpaths :classpathArgs -set _ETC_DIR="%_PROG_HOME%\etc" -set _TMP_DIR="%_PROG_HOME%\tmp" -set _INPUT_CLASSPATH_FILE="%_ETC_DIR%\scaladoc.classpath" -set _OUTPUT_CLASSPATH_FILE="%_TMP_DIR%\scaladoc.classpath" +@rem fetch the version of scala +call :fetchScalaVersion + +set "_ETC_DIR=%_PROG_HOME%\etc" +set "_TMP_DIR=%_PROG_HOME%\tmp-%_SCALA_VERSION%" +set "_INPUT_CLASSPATH_FILE=%_ETC_DIR%\scaladoc.classpath" +set "_OUTPUT_CLASSPATH_FILE=%_TMP_DIR%\scaladoc.classpath" @rem Check if the _TMP_DIR exists. If not, create it (first time we run the command) -if not exist "%TMP_DIR%" ( mkdir "%TMP_DIR%" ) +if not exist "%_TMP_DIR%" ( mkdir "%_TMP_DIR%" ) @rem If the file doesn't exist, create it (first time we run the command) if not exist "%_OUTPUT_CLASSPATH_FILE%" ( call :loadClasspathFromFile ) -set _CLASS_PATH_FILE="%_OUTPUT_CLASSPATH_FILE%" +set "_CLASS_PATH_FILE=%_OUTPUT_CLASSPATH_FILE%" goto :eof -@REM concatentate every line in _INPUT_CLASSPATH_FILE and dump it in the with _PSEP +@REM concatentate every line in %1 and dump it in %2 :loadClasspathFromFile -set _CLASS_PATH= if exist "%_INPUT_CLASSPATH_FILE%" ( - for /f "usebackq delims=" %%i in "%_INPUT_CLASSPATH_FILE%" do ( - set _LIB="%_PROG_HOME%\maven2\%%i" + for /f "usebackq delims=" %%i in ( "%_INPUT_CLASSPATH_FILE%" ) do ( + set "_LIB=%_PROG_HOME%\maven2\%%i" @rem Adapt the paths from Unix style to MS-DOS style set "_LIB=!_LIB:/=\!" - @rem Append the processed line to the output file, ensuring a new line - echo !_LIB! >> "%_OUTPUT_CLASSPATH_FILE%" + set "_LIB=!_LIB:\=\\!" + @rem Append the processed line to the output file, in the same line + (echo | set /p=""!_LIB!"") >> "%_OUTPUT_CLASSPATH_FILE%" + (echo | set /p=!_PSEP!) >> "%_OUTPUT_CLASSPATH_FILE%" ) ) goto :eof +@rem read for version:=_SCALA_VERSION in VERSION_FILE +@rem output parameter: _SCALA_VERSION. +@rem It contains the path th the absolute classpaths +:fetchScalaVersion +for /f "usebackq delims=" %%G IN ("%_PROG_HOME%\VERSION") do ( + set "line=%%G" + if "!line:~0,9!"=="version:=" ( set "_SCALA_VERSION=!line:~9!" ) +) +goto :eof + @rem ######################################################################### @rem ## Cleanups :end exit /b %_EXITCODE% -endlocal +endlocal \ No newline at end of file