Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce the length of the arguments passed to java in scaladoc.bat #21033

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 36 additions & 14 deletions dist/bin/scaladoc.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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%" ^
hamzaremmal marked this conversation as resolved.
Show resolved Hide resolved
-Dscala.usejavacp=true ^
dotty.tools.scaladoc.Main %_SCALA_ARGS% %_RESIDUAL_ARGS%
if not %ERRORLEVEL%==0 (
Expand Down Expand Up @@ -103,32 +103,54 @@ 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

@rem fetch the version of scala
call :fetchScalaVersion

set "_ETC_DIR=%_PROG_HOME%\etc"
@rem keep list in sync with bash script `bin\scaladoc` !
call :loadClasspathFromFile
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%" )

@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 %1 and dump it in %2
:loadClasspathFromFile
set _CLASS_PATH=
if exist "%_ETC_DIR%\scaladoc.classpath" (
for /f "usebackq delims=" %%i in ("%_ETC_DIR%\scaladoc.classpath") do (
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!"
)
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
4 changes: 4 additions & 0 deletions project/scripts/winCmdTests.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading