From 72ef612ad21830cd302e7f8ba8a8fdeb2c9b214e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Micheloud?= Date: Mon, 12 Nov 2018 18:46:49 +0100 Subject: [PATCH 01/10] fix exception 'UnmappableCharacterException' in dottydoc on Windows --- doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala b/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala index 826445ea1636..3987039687dd 100644 --- a/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala +++ b/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala @@ -408,7 +408,7 @@ case class Site( } private def toSourceFile(f: JFile): SourceFile = - SourceFile(AbstractFile.getFile(new File(f.toPath)), Source.fromFile(f).toArray) + SourceFile(AbstractFile.getFile(new File(f.toPath)), Source.fromFile(f, "UTF-8").toArray) private def collectFiles(dir: JFile, includes: String => Boolean): Array[JFile] = dir From 0f94c25cdafb5ed8e7329ef886cf30e7c1929c22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Micheloud?= Date: Mon, 12 Nov 2018 19:10:04 +0100 Subject: [PATCH 02/10] add batch scripts to build Dotty distro on Windows --- bin/common.bat | 60 ++++++ bin/dotc.bat | 164 +++++++++++++++++ bin/dotd.bat | 104 +++++++++++ bin/dotr.bat | 108 +++++++++++ project/scripts/build.bat | 377 ++++++++++++++++++++++++++++++++++++++ setenv.bat | 218 ++++++++++++++++++++++ 6 files changed, 1031 insertions(+) create mode 100644 bin/common.bat create mode 100644 bin/dotc.bat create mode 100644 bin/dotd.bat create mode 100644 bin/dotr.bat create mode 100644 project/scripts/build.bat create mode 100644 setenv.bat diff --git a/bin/common.bat b/bin/common.bat new file mode 100644 index 000000000000..4c9b9c10f7ca --- /dev/null +++ b/bin/common.bat @@ -0,0 +1,60 @@ +if defined JAVACMD ( + set _JAVACMD=%JAVACMD% + if %_DEBUG%==1 echo [%_BASENAME%] Using environment variable JAVACMD +) else if defined JAVA_HOME ( + set _JAVACMD=%JAVA_HOME%\bin\java.exe + if %_DEBUG%==1 echo [%_BASENAME%] Using environment variable JAVA_HOME +) else if defined JDK_HOME ( + set _JAVACMD=%JDK_HOME%\bin\java.exe + if %_DEBUG%==1 echo [%_BASENAME%] Using environment variable JDK_HOME +) else ( + where /q java.exe + if !ERRORLEVEL!==0 ( + for /f "delims=" %%i in ('where /f java.exe') do set _JAVA_BIN_DIR=%%~dpsi + rem we ignore Oracle path for java executable + if "!_JAVA_BIN_DIR!"=="!_JAVA_BIN_DIR:javapath=!" set _JAVACMD=!_JAVA_BIN_DIR!\java.exe + ) + if not defined _JAVACMD ( + set _PATH=C:\Progra~1\Java + for /f %%f in ('dir /ad /b "!_PATH!\jre*" 2^>NUL') do set _JAVA_HOME=!_PATH!\%%f + if not defined _JAVA_HOME ( + set _PATH=C:\opt + for /f %%f in ('dir /ad /b "!_PATH!\jdk*" 2^>NUL') do set _JAVA_HOME=!_PATH!\%%f\jre + ) + if defined _JAVA_HOME ( + if %_DEBUG%==1 echo [%_BASENAME%] Using default Java installation directory !_JAVA_HOME! + set _JAVACMD=!_JAVA_HOME!\bin\java.exe + ) + ) +) +if not exist "%_JAVACMD%" ( + if %_DEBUG%==1 echo [%_BASENAME%] Error: Java executable not found ^(%_JAVACMD%^) + set _EXITCODE=1 + goto :eof +) + +if defined DOTTY_HOME ( + set _LIB_DIR=%DOTTY_HOME%\lib +) else ( + if not defined _PROG_HOME ( + for %%f in ("%~dp0..") do set _PROG_HOME=%%~sf + ) + set _LIB_DIR=!_PROG_HOME!\lib +) + +set _PSEP=; + +for /f %%f in ('dir /b "%_LIB_DIR%\*dotty-compiler*"') do set _DOTTY_COMP=%_LIB_DIR%\%%f +for /f %%f in ('dir /b "%_LIB_DIR%\*dotty-interfaces*"') do set _DOTTY_INTF=%_LIB_DIR%\%%f +for /f %%f in ('dir /b "%_LIB_DIR%\*dotty-library*"') do set _DOTTY_LIB=%_LIB_DIR%\%%f +for /f %%f in ('dir /b "%_LIB_DIR%\*scala-asm*"') do set _SCALA_ASM=%_LIB_DIR%\%%f +for /f %%f in ('dir /b "%_LIB_DIR%\*scala-library*"') do set _SCALA_LIB=%_LIB_DIR%\%%f +for /f %%f in ('dir /b "%_LIB_DIR%\*scala-xml*"') do set _SCALA_XML=%_LIB_DIR%\%%f +for /f %%f in ('dir /b "%_LIB_DIR%\*compiler-interface*"') do set _SBT_INTF=%_LIB_DIR%\%%f +for /f %%f in ('dir /b "%_LIB_DIR%\*jline-reader-3*"') do set _JLINE_READER=%_LIB_DIR%\%%f +for /f %%f in ('dir /b "%_LIB_DIR%\*jline-terminal-3*"') do set _JLINE_TERMINAL=%_LIB_DIR%\%%f +for /f %%f in ('dir /b "%_LIB_DIR%\*jline-terminal-jna-3*"') do set _JLINE_TERMINAL_JNA=%_LIB_DIR%\%%f +for /f %%f in ('dir /b "%_LIB_DIR%\*jna-4*"') do set _JNA=%_LIB_DIR%\%%f + +rem debug +set _DEBUG_STR=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 diff --git a/bin/dotc.bat b/bin/dotc.bat new file mode 100644 index 000000000000..83066abf861d --- /dev/null +++ b/bin/dotc.bat @@ -0,0 +1,164 @@ +@echo off +setlocal enabledelayedexpansion + +rem only for interactive debugging ! +set _DEBUG=0 + +rem ########################################################################## +rem ## Environment setup + +set _EXITCODE=0 + +set _BASENAME=%~n0 + +for %%f in ("%~dp0..") do set _PROG_HOME=%%~sf + +call %_PROG_HOME%\bin\common.bat +if not %_EXITCODE%==0 goto end + +set _COMPILER_MAIN=dotty.tools.dotc.Main +set _DECOMPILER_MAIN=dotty.tools.dotc.decompiler.Main +set _REPL_MAIN=dotty.tools.repl.Main + +set _PROG_NAME=%_COMPILER_MAIN% + +call :args %* + +rem ########################################################################## +rem ## Main + +call :classpathArgs + +if defined JAVA_OPTS ( set _JAVA_OPTS=%JAVA_OPTS% +) else ( set _JAVA_OPTS=-Xmx768m -Xms768m +) +if %_DEBUG%==1 echo [%_BASENAME%] "%_JAVACMD%" %_JAVA_OPTS% %_JAVA_DEBUG% %_JAVA_ARGS% %_JVM_CP_ARGS% -Dscala.usejavacp=true %_PROG_NAME% %_SCALA_ARGS% %_RESIDUAL_ARGS% +"%_JAVACMD%" %_JAVA_OPTS% %_JAVA_DEBUG% %_JAVA_ARGS% %_JVM_CP_ARGS% ^ +-Dscala.usejavacp=true ^ +%_PROG_NAME% %_SCALA_ARGS% %_RESIDUAL_ARGS% +if not %ERRORLEVEL%==0 ( + if %_DEBUG%==1 echo [%_BASENAME%] Dotty compiler execution failed + set _EXITCODE=1 + goto end +) +goto end + +rem ########################################################################## +rem ## Subroutines + +:args +set _JAVA_DEBUG= +set _HELP= +set _VERBOSE= +set _QUIET= +set _COLORS= +set _SCALA_ARGS= +set _JAVA_ARGS= +set _RESIDUAL_ARGS= +:args_loop +if "%~1"=="" goto args_done +set _ARG=%~1 +if %_DEBUG%==1 echo [%_BASENAME%] _ARG=%_ARG% +if "%_ARG%"=="--" ( + rem for arg; do addResidual "$arg"; done; set -- ;; +) else if /i "%_ARG%"=="-h" ( + set _HELP=true + call :addScala "-help" +) else if /i "%_ARG%"=="-help" ( + set _HELP=true + call :addScala "-help" +) else if /i "%_ARG%"=="-v" ( + set _VERBOSE=true + call :addScala "-verbose" +) else if /i "%_ARG%"=="-verbose" ( + set _VERBOSE=true + call :addScala "-verbose" +) else if /i "%_ARG%"=="-debug" ( set _JAVA_DEBUG=%_DEBUG_STR% +) else if /i "%_ARG%"=="-q" ( set _QUIET=true +) else if /i "%_ARG%"=="-quiet" ( set _QUIET=true +rem Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222 +) else if "%_ARG%"=="-=short" ( + call :addJava "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" +) else if /i "%_ARG%"=="-repl" ( set _PROG_NAME=%_REPL_MAIN% +) else if /i "%_ARG%"=="-compile" ( set _PROG_NAME=%_COMPILER_MAIN% +) else if /i "%_ARG%"=="-decompile" ( set _PROG_NAME=%_DECOMPILER_MAIN% +) else if /i "%_ARG%"=="print-tasty" ( + set _PROG_NAME=%_DECOMPILER_MAIN% + call :addScala "-print-tasty" +) else if /i "%_ARG%"=="-run" ( set _PROG_NAME=%_REPL_MAIN% +) else if /i "%_ARG%"=="-colors" ( set _COLORS=true +) else if /i "%_ARG%"=="-no-colors" ( set _COLORS= +) else if /i "%_ARG%"=="-with-compiler" ( set _JVM_CP_ARGS=%_PSEP%%_DOTTY_COMP% +rem break out -D and -J options and add them to JAVA_OPTS as well +rem so they reach the JVM in time to do some good. The -D options +rem will be available as system properties. +) else if "%_ARG:~0,2%"=="-D" ( + call :addJava "%_ARG%" + call :addScala "%_ARG%" +) else if "%_ARG:~0,2%"=="-J" ( + call :addJava "%_ARG%" + call :addScala "%_ARG%" +) else ( + call :addResidual "%_ARG%" +) +shift +goto args_loop +:args_done +if %_DEBUG%==1 ( + echo [%_BASENAME%] _VERBOSE=%_VERBOSE% + echo [%_BASENAME%] _PROG_NAME=%_PROG_NAME% +) +goto :eof + +rem output parameter: _SCALA_ARGS +:addScala +set _SCALA_ARGS=%_SCALA_ARGS% %~1 +if %_DEBUG%==1 echo [%_BASENAME%] _SCALA_ARGS=%_SCALA_ARGS% +goto :eof + +rem output parameter: _JAVA_ARGS +:addJava +set _JAVA_ARGS=%_JAVA_ARGS% %~1 +if %_DEBUG%==1 echo [%_BASENAME%] _JAVA_ARGS=%_JAVA_ARGS% +goto :eof + +rem output parameter: _RESIDUAL_ARGS +:addResidual +set _RESIDUAL_ARGS=%_RESIDUAL_ARGS% %~1 +if %_DEBUG%==1 echo [%_BASENAME%] _RESIDUAL_ARGS=%_RESIDUAL_ARGS% +goto :eof + +rem output parameter: _JVM_CP_ARGS +:classpathArgs +rem echo dotty-compiler: %_DOTTY_COMP% +rem echo dotty-interface: %_DOTTY_INTF% +rem echo dotty-library: %_DOTTY_LIB% +rem echo scala-asm: %_SCALA_ASM% +rem echo scala-lib: %_SCALA_LIB% +rem echo scala-xml: %_SCALA_XML% +rem echo sbt-intface: %_SBT_INTF% + +set __TOOLCHAIN=%_SCALA_LIB%%_PSEP% +set __TOOLCHAIN=%__TOOLCHAIN%%_SCALA_ASM%%_PSEP% +set __TOOLCHAIN=%__TOOLCHAIN%%_SBT_INTF%%_PSEP% +set __TOOLCHAIN=%__TOOLCHAIN%%_DOTTY_INTF%%_PSEP% +set __TOOLCHAIN=%__TOOLCHAIN%%_DOTTY_LIB%%_PSEP% +set __TOOLCHAIN=%__TOOLCHAIN%%_DOTTY_COMP%%_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% + +set _JVM_CP_ARGS=-classpath %__TOOLCHAIN% +goto :eof + +rem ########################################################################## +rem ## Cleanups + +:end +if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% +exit /b %_EXITCODE% +endlocal + diff --git a/bin/dotd.bat b/bin/dotd.bat new file mode 100644 index 000000000000..860085fe4f72 --- /dev/null +++ b/bin/dotd.bat @@ -0,0 +1,104 @@ +@echo off +setlocal enabledelayedexpansion + +rem only for interactive debugging ! +set _DEBUG=0 + +rem ########################################################################## +rem ## Environment setup + +set _EXITCODE=0 + +set _BASENAME=%~n0 + +for %%f in ("%~dp0..") do set _PROG_HOME=%%~sf + +call "%_PROG_HOME%\bin\common.bat" +if not %_EXITCODE%==0 goto end + +rem ########################################################################## +rem ## Main + +call :javaClassPath + +if %_DEBUG%==1 echo [%_BASENAME%] "%_JAVACMD%" -Dscala.usejavacp=true -classpath "%_CLASS_PATH%" dotty.tools.dottydoc.Main %* +"%_JAVACMD%" -Dscala.usejavacp=true -classpath "%_CLASS_PATH%" dotty.tools.dottydoc.Main %* +if not %ERRORLEVEL%==0 ( + if %_DEBUG%==1 echo [%_BASENAME%] Dottydoc execution failed + set _EXITCODE=1 + goto end +) +goto end + +rem ########################################################################## +rem ## Subroutines + +rem output parameter: _CLASS_PATH +:javaClassPath +set _LIB_DIR=%_PROG_HOME%\lib + +rem Set dotty-doc dep: +for /f %%f in ('dir /b "%_LIB_DIR%\*dotty-doc*"') do set _DOTTY_DOC_LIB=%_LIB_DIR%\%%f + +rem Set flexmark deps: +for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-0*"') do set _FLEXMARK_LIBS=%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-anchorlink*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-autolink*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-emoji*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-gfm-strikethrough*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-gfm-tables*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-gfm-tasklist*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-ins*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-superscript*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-tables*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-wikilink*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-yaml-front-matter*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-formatter*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-jira-converter*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-util*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% + +rem Set jackson deps: +for /f %%f in ('dir /b "%_LIB_DIR%\*jackson-annotations*"') do set _JACKSON_LIBS=%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*jackson-core*"') do set _JACKSON_LIBS=%_JACKSON_LIBS%%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*jackson-databind*"') do set _JACKSON_LIBS=%_JACKSON_LIBS%%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*jackson-dataformat-yaml*"') do set _JACKSON_LIBS=%_JACKSON_LIBS%%_LIB_DIR%\%%f%_PSEP% + +rem Set liqp dep: +for /f %%f in ('dir /b "%_LIB_DIR%\*liqp*"') do set _LIQP_LIB=%_LIB_DIR%\%%f%_PSEP% + +rem Set ANTLR dep: +for /f %%f in ('dir /b "%_LIB_DIR%\*antlr-3*"') do set _ANTLR_LIB=%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /b "%_LIB_DIR%\*antlr-runtime-3*"') do set _ANTLR_RUNTIME_LIB=%_LIB_DIR%\%%f%_PSEP% + +rem Set autolink dep: +rem conflict with flexmark-ext-autolink-0.11 +for /f %%f in ('dir /b "%_LIB_DIR%\*autolink-0.6*"') do set _AUTOLINK_LIB=%_LIB_DIR%\%%f + +rem Set snakeyaml dep: +for /f %%f in ('dir /b "%_LIB_DIR%\*snakeyaml*"') do set _SNAKEYAML_LIB=%_LIB_DIR%\%%f%_PSEP% + +rem Set ST4 dep: +for /f %%f in ('dir /b "%_LIB_DIR%\*ST4*"') do set _ST4_LIB=%_LIB_DIR%\%%f%_PSEP% + +rem Set jsoup dep: +for /f %%f in ('dir /b "%_LIB_DIR%\*jsoup*"') do set _JSOUP_LIB=%_LIB_DIR%\%%f%_PSEP% + +set _CLASS_PATH=%_DOTTY_LIB%%_PSEP%%_DOTTY_COMP%%_PSEP%%_DOTTY_DOC_LIB%%_PSEP%%_DOTTY_INTF%%_PSEP%%_SBT_INTF% +set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_SCALA_LIB% +set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_FLEXMARK_LIBS% +set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_JACKSON_LIBS% +set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_LIQP_LIB% +set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_ANTLR_LIB%%_PSEP%%_ANTLR_RUNTIME_LIB% +set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_AUTOLINK_LIB% +set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_SNAKEYAML_LIB% +set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_ST4_LIB% +set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_JSOUP_LIB% +goto :eof + +rem ########################################################################## +rem ## Cleanups + +:end +if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% +exit /b %_EXITCODE% +endlocal diff --git a/bin/dotr.bat b/bin/dotr.bat new file mode 100644 index 000000000000..17d3438d87a3 --- /dev/null +++ b/bin/dotr.bat @@ -0,0 +1,108 @@ +@echo off +setlocal enabledelayedexpansion + +rem only for interactive debugging ! +set _DEBUG=0 + +rem ########################################################################## +rem ## Environment setup + +set _EXITCODE=0 + +set _BASENAME=%~n0 + +for %%f in ("%~dp0..") do set _PROG_HOME=%%~sf + +call %_PROG_HOME%\bin\common.bat +if not %_EXITCODE%==0 goto end + +call :args %* + +rem ########################################################################## +rem ## Main + +set _CASE_1=0 +if %_EXECUTE_REPL%==1 set _CASE_1=1 +if %_EXECUTE_RUN%==0 if not defined _RESIDUAL_ARGS set _CASE_1=1 + +set _CASE_2=0 +if %_EXECUTE_RUN%==1 set _CASE_2=1 +if defined _RESIDUAL_ARGS set _CASE_2=1 + +rem if [ $execute_repl == true ] || ([ $execute_run == false ] && [ $options_indicator == 0 ]); then +if %_CASE_1%==1 ( + set _DOTC_ARGS= + if defined _CLASS_PATH set _DOTC_ARGS=-classpath "%_CLASS_PATH%" + set _DOTC_ARGS=!_DOTC_ARGS! %_JAVA_OPTIONS% -repl %_RESIDUAL_ARGS% + echo Starting dotty REPL... + if %_DEBUG%==1 echo [%_BASENAME%] %_PROG_HOME%\bin\dotc.bat !_DOTC_ARGS! + %_PROG_HOME%\bin\dotc.bat !_DOTC_ARGS! +rem elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then +) else if %_CASE_2%==1 ( + set _CP_ARG=%_DOTTY_LIB%%_PSEP%%_SCALA_LIB% + if defined _CLASS_PATH ( set _CP_ARG=!_CP_ARG!%_PSEP%%_CLASS_PATH% + ) else ( set _CP_ARG=!_CP_ARG!%_PSEP%. + ) + if %_CLASS_PATH_COUNT% gtr 1 ( + echo warning: multiple classpaths are found, dotr only use the last one. + ) + if %_WITH_COMPILER%==1 ( + set _CP_ARG=!_CP_ARG!%_PSEP%%_DOTTY_COMP%%_PSEP%%_DOTTY_INTF%%_PSEP%%_SCALA_ASM% + ) + set _JAVA_ARGS=%_JAVA_DEBUG% -classpath "!_CP_ARG!" %_RESIDUAL_ARGS% + if %_DEBUG%==1 echo [%_BASENAME%] %_JAVACMD% !_JAVA_ARGS! + %_JAVACMD% !_JAVA_ARGS! +) else ( + echo warning: command option is not correct. +) + +goto end + +rem ########################################################################## +rem ## Subroutines + +:args +set _RESIDUAL_ARGS= +set _EXECUTE_REPL=0 +set _EXECUTE_RUN=0 +set _WITH_COMPILER=0 +set _JAVA_DEBUG= +set _CLASS_PATH_COUNT=0 +set _CLASS_PATH= +set _JVM_OPTIONS= +set _JAVA_OPTIONS= + +:args_loop +if "%1"=="" goto args_done +set "_ARG=%1" +if %_DEBUG%==1 echo [%_BASENAME%] _ARG=%_ARG% +if /i "%_ARG%"=="-repl" ( + set _EXECUTE_REPL=1 +) else if /i "%_ARG%"=="-run" ( + set _EXECUTE_RUN=1 +) else if /i "%_ARG%"=="-classpath" ( + set _CLASS_PATH=%2 + set /a _CLASS_PATH_COUNT+=1 + shift +) else if /i "%_ARG%"=="-with-compiler" ( + set _WITH_COMPILER=1 +) else if /i "%_ARG%"=="-d" ( + set _JAVA_DEBUG=%_DEBUG_STR% +) else if /i "%_ARG:~0,2%"=="-J" ( + set _JVM_OPTIONS=!_JVM_OPTIONS! %_ARG% + set _JAVA_OPTIONS=!_JAVA_OPTIONS! %_ARG% +) else ( + set _RESIDUAL_ARGS=%_RESIDUAL_ARGS% %_ARG% +) +shift +goto args_loop +:args_done +goto :eof + +rem ########################################################################## +rem ## Cleanups + +:end +if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% +exit /b %_EXITCODE% +endlocal diff --git a/project/scripts/build.bat b/project/scripts/build.bat new file mode 100644 index 000000000000..5d5ba7660f55 --- /dev/null +++ b/project/scripts/build.bat @@ -0,0 +1,377 @@ +@echo off +setlocal enabledelayedexpansion + +rem only for interactive debugging +set _DEBUG=1 + +rem ########################################################################## +rem ## Environment setup + +set _BASENAME=%~n0 + +set _EXITCODE=0 + +set _BOT_TOKEN=dotty-token + +rem set _DRONE_BUILD_EVENT=pull_request +set _DRONE_BUILD_EVENT= +set _DRONE_REMOTE_URL= +set _DRONE_BRANCH= + +for %%f in ("%~dp0..\..") do set _ROOT_DIR=%%~sf +set _BIN_DIR=%_ROOT_DIR%bin +set _TESTS_POS_DIR=%_ROOT_DIR%test\pos + +set _SOURCE=tests/pos/HelloWorld.scala +set _MAIN=HelloWorld +set _EXPECTED_OUTPUT=hello world + +call :args %* +if not %_EXITCODE%==0 ( goto end +) else if defined _HELP ( goto end +) + +set _OUT_DIR=%TEMP%\%_BASENAME%_out +if not exist "%_OUT_DIR%" mkdir "%_OUT_DIR%" + +set _OUT1_DIR=%TEMP%\%_BASENAME%_out1 +if not exist "%_OUT1_DIR%" mkdir "%_OUT1_DIR%" + +set _TMP_FILE=%TEMP%\%_BASENAME%_tmp.txt + +where /q git.exe +if not %ERRORLEVEL%==0 ( + echo Error: Git command not found ^(run setenv.bat^) 1>&2 + set _EXITCODE=1 + goto end +) +set _GIT_CMD=git.exe + +where /q sbt.bat +if not %ERRORLEVEL%==0 ( + echo Error: SBT command not found ^(run setenv.bat^) 1>&2 + set _EXITCODE=1 + goto end +) +rem full path of SBT command is required +for /f %%i in ('where sbt.bat') do set _SBT_CMD=%%i + +rem see file project/scripts/sbt +rem SBT uses the value of the JAVA_OPTS environment variable if defined, rather than the config. +set JAVA_OPTS=-Xmx4096m ^ +-XX:ReservedCodeCacheSize=1024m ^ +-XX:MaxMetaspaceSize=1024m + +set SBT_OPTS=-Ddotty.drone.mem=4096m ^ +-Dsbt.ivy.home=%USERPROFILE%\.ivy2\ ^ +-Dsbt.log.noformat=true + +rem ########################################################################## +rem ## Main + +if defined _CLEAN ( + if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" clean + call "%_SBT_CMD%" clean + goto end +) + +call :clone +if not %_EXITCODE%==0 goto end + +call :test +if not %_EXITCODE%==0 goto end + +if defined _BOOTSTRAP ( + call :test_bootstrapped + rem if not !_EXITCODE!==0 goto end + if not !_EXITCODE!==0 echo ###### Warning: _EXITCODE=!_EXITCODE! ####### 1>&2 +) +if defined _DOCUMENTATION ( + call :documentation + if not !_EXITCODE!==0 goto end +) +if defined _ARCHIVES ( + call :archives + if not !_EXITCODE!==0 goto end +) +goto end + +rem ########################################################################## +rem ## Subroutines + +rem input parameter: %* +rem output parameters: _VERBOSE, _DOCUMENTATION +:args +set _VERBOSE=0 +set _ARCHIVES= +set _BOOTSTRAP= +set _CLEAN= +set _DOCUMENTATION= +set __N=0 +:args_loop +set __ARG=%~1 +if not defined __ARG ( + goto args_done +) else if not "%__ARG:~0,1%"=="-" ( + set /a __N=+1 +) +if /i "%__ARG%"=="help" ( call :help & goto :eof +) else if /i "%__ARG%"=="-verbose" ( set _VERBOSE=1 +) else if /i "%__ARG:~0,4%"=="arch" ( set _ARCHIVES=1 +) else if /i "%__ARG:~0,4%"=="boot" ( set _BOOTSTRAP=1 +) else if /i "%__ARG%"=="clean" ( set _CLEAN=1 +) else if /i "%__ARG:~0,3%"=="doc" ( set _DOCUMENTATION=1 +) else ( + echo %_BASENAME%: Unknown subcommand %__ARG% + set _EXITCODE=1 + goto :eof +) +shift +goto :args_loop +:args_done +goto :eof + +:help +set _HELP=1 +echo Usage: setenv { options ^| subcommands } +echo Options: +echo -verbose display environment settings +echo Subcommands: +echo arch[ives] generate gz/zip archives +echo boot[strap] generate compiler bootstrap +echo clean clean project and leave +echo doc[umentation] generate documentation +echo help display this help message +goto :eof + +:clone +if "%_DRONE_BUILD_EVENT%"=="pull_request" if defined _DRONE_REMOTE_URL ( + %_GIT_CMD% config user.email "dotty.bot@epfl.ch" + %_GIT_CMD% config user.name "Dotty CI" + %_GIT_CMD% pull "%_DRONE_REMOTE_URL%" "%_DRONE_BRANCH%" +) +if %_DEBUG%==1 echo [%_BASENAME%] %_GIT_CMD% submodule update --init --recursive --jobs 3 +%_GIT_CMD% submodule update --init --recursive --jobs 3 +if not %ERRORLEVEL%==0 ( + echo Error: Failed to update Git submodules 1>&2 + set _EXITCODE=1 + goto :eof +) +goto :eof + +:clear_out +set __OUT_DIR=%~1 + +if exist "%__OUT_DIR%" ( + if %_DEBUG%==1 echo [%_BASENAME%] del /s /q "%__OUT_DIR%\*" 1^>NUL + del /s /q "%__OUT_DIR%\*" 1>NUL +) +goto :eof + +:grep +set __PATTERN=%~1 +set __FILE=%~2 + +findstr "%__PATTERN%" "%__FILE%" +if not %ERRORLEVEL%==0 ( + echo Error: Failed to find pattern "%__PATTERN%" in file %__FILE% 1>&2 + set _EXITCODE=1 + goto :eof +) +goto :eof + +rem ## see file project/scripts/cmdTests +:cmdTests +echo testing sbt dotc and dotr +if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" ";dotc %_SOURCE% -d %_OUT_DIR% ;dotr -classpath %_OUT_DIR% %_MAIN%" ^> "%_TMP_FILE%" +call "%_SBT_CMD%" ";dotc %_SOURCE% -d %_OUT_DIR% ;dotr -classpath %_OUT_DIR% %_MAIN%" > "%_TMP_FILE%" +call :grep "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" +if not %_EXITCODE%==0 goto :eof + +rem # check that `sbt dotc` compiles and `sbt dotr` runs it +echo testing sbt dotc -from-tasty and dotr -classpath +call :clear_out "%_OUT_DIR%" +call "%_SBT_CMD%" ";dotc %_SOURCE% -d %_OUT_DIR% ;dotc -from-tasty -classpath %_OUT_DIR% -d %_OUT1_DIR% %_MAIN% ;dotr -classpath %_OUT1_DIR% %_MAIN%" > "%_TMP_FILE%" +call :grep "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" +if not %_EXITCODE%==0 goto :eof + +rem # check that `sbt dotc -decompile` runs +echo testing sbt dotc -decompile +call "%_SBT_CMD%" ";dotc -decompile -color:never -classpath %_OUT_DIR% %_MAIN%" > "%_TMP_FILE%" +call :grep "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "%_TMP_FILE%" +if not %_EXITCODE%==0 goto :eof + +echo testing sbt dotr with no -classpath +call :clear_out "%_OUT_DIR%" +if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" ";dotc %_SOURCE% ; dotr %_MAIN%" ^> "%_TMP_FILE%" +call "%_SBT_CMD%" ";dotc %_SOURCE% ; dotr %_MAIN%" > "%_TMP_FILE%" +call :grep "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" +if not %_EXITCODE%==0 goto :eof + +echo testing loading tasty from .tasty file in jar +call :clear_out "%_OUT_DIR%" +call "%_SBT_CMD%" ";dotc -d %_OUT_DIR%\out.jar %_SOURCE%; dotc -decompile -classpath %_OUT_DIR%/out.jar -color:never %_MAIN%" > "%_TMP_FILE%" +call :grep "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "%_TMP_FILE%" +if not %_EXITCODE%==0 goto :eof + +goto :eof + +:test +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";clean ;compile ;test" +call "%_SBT_CMD%" ";clean ;compile ;test" +if not %ERRORLEVEL%==0 ( + echo Error: Failed to build Dotty 1>&2 + set _EXITCODE=1 + goto :eof +) + +rem ## see shell script project/scripts/cmdTests +call :cmdTests +if not %_EXITCODE%==0 goto :eof + +goto :eof + +:test_pattern +set __PATTERN=%~1 +set __FILE=%~2 + +set /p __PATTERN2=<"%__FILE%" +if not "%__PATTERN2%"=="%__PATTERN%" ( + echo Error: failed to find pattern "%__PATTERN%" in file %__FILE% 1>&2 + set _EXITCODE=1 + goto :eof +) +goto :eof + +rem ## see shell script project/scripts/bootstrapCmdTests +:bootstrapCmdTests +rem # check that benchmarks can run +if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" "dotty-bench/jmh:run 1 1 tests/pos/alias.scala" +call "%_SBT_CMD%" "dotty-bench/jmh:run 1 1 tests/pos/alias.scala" + +rem # The above is here as it relies on the bootstrapped library. +call "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 tests/pos/alias.scala" +call "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 -with-compiler compiler/src/dotty/tools/dotc/core/Types.scala" + +echo testing scala.quoted.Expr.run from sbt dotr +call "%_SBT_CMD%" ";dotty-compiler-bootstrapped/dotc tests/run-with-compiler/quote-run.scala; dotty-compiler-bootstrapped/dotr -with-compiler Test" > "%_TMP_FILE%" +call :grep "val a: scala.Int = 3" "%_TMP_FILE%" +if not %_EXITCODE%==0 goto :eof + +rem # setup for `dotc`/`dotr` script tests +if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" dist-bootstrapped/pack +call "%_SBT_CMD%" dist-bootstrapped/pack + +rem # check that `dotc` compiles and `dotr` runs it +echo testing ./bin/dotc and ./bin/dotr +call :clear_out "%_OUT_DIR%" +call %_BIN_DIR%\dotc "%_SOURCE%" -d "%_OUT_DIR%" +call %_BIN_DIR%\dotr -classpath "%_OUT_DIR%" "%_MAIN%" > "%_TMP_FILE%" +call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" + +rem # check that `dotc -from-tasty` compiles and `dotr` runs it +echo testing ./bin/dotc -from-tasty and dotr -classpath +call :clear_out "%_OUT1_DIR%" +call %_BIN_DIR%\dotc -from-tasty -classpath "%_OUT_DIR%" -d "%_OUT1_DIR%" "%_MAIN%" +call %_BIN_DIR%\dotr -classpath "%_OUT1_DIR%" "%_MAIN%" > "%_TMP_FILE%" +call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" + +rem # echo ":quit" | ./dist-bootstrapped/target/pack/bin/dotr # not supported by CI + +echo testing ./bin/dotd +call :clear_out "%_OUT_DIR%" +call %_BIN_DIR%\dotd -project Hello -siteroot "%_OUT_DIR%" "%_SOURCE%" + +goto :eof + +:test_bootstrapped +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";dotty-bootstrapped/compile ;dotty-bootstrapped/test" +call "%_SBT_CMD%" ";dotty-bootstrapped/compile ;dotty-bootstrapped/test" +if not %ERRORLEVEL%==0 ( + echo Error: failed to bootstrap Dotty 1>&2 + set _EXITCODE=1 + goto :eof +) + +call :bootstrapCmdTests +if not %_EXITCODE%==0 goto :eof + +goto :eof + +:documentation +rem # make sure that _BOT_TOKEN is set +if not defined _BOT_TOKEN ( + echo Error: _BOT_TOKEN env unset, unable to push without password 1>&2 + set _EXITCODE=1 + goto :eof +) +for /f %%i in ('cd') do set _PWD=%%~si + +echo Working directory: %_PWD% + +call "%_SBT_CMD%" genDocs + +rem # make sure that the previous command actually succeeded +if not exist "%_PWD%\docs\_site\" ( + echo Error: output directory did not exist: %_PWD%\docs\_site 1>&2 + set _EXITCODE=1 + goto :eof +) + +goto :eof + +rem # save current head for commit message in gh-pages +rem for /f %%i in ('%_GIT_CMD% rev-parse HEAD 2^>NUL') do set _GIT_HEAD=%%i + +rem # set up remote and github credentials +rem %_GIT_CMD% remote add doc-remote "https://dotty-bot:%_BOT_TOKEN%@github.com/lampepfl/dotty-website.git" +rem %_GIT_CMD% config user.name "dotty-bot" +rem %_GIT_CMD% config user.email "dotty-bot@d-d.me" + +rem # check out correct branch +rem %_GIT_CMD% fetch doc-remote gh-pages +rem %_GIT_CMD% checkout gh-pages + +rem # move newly generated _site dir to $PWD +rem move %_PWD%\docs\_site . + +rem # remove everything BUT _site dir +rem del /f /q /s -rf !(_site) + +rem # copy new contents to $PWD +rem move _site\* . + +rem # remove now empty _site dir +rem del /f /q /s _site + +rem # add all contents of $PWD to commit +rem %_GIT_CMD% add -A +rem %_GIT_CMD% commit -m "Update gh-pages site for %_GIT_HEAD%" || echo "nothing new to commit" + +rem # push to doc-remote +rem %_GIT_CMD% push doc-remote || echo "couldn't push, since nothing was added" + +goto :eof + +:archives +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" dist-bootstrapped/packArchive +call "%_SBT_CMD%" dist-bootstrapped/packArchive +rem output directory for gz/zip archives +set __TARGET_DIR=%_ROOT_DIR%\dist-bootstrapped\target +if not exist "%__TARGET_DIR%\" ( + echo Error: Directory target not found 1>&2 + set _EXITCODE=1 + goto :eof +) +if %_DEBUG%==1 ( + echo Output directory: %__TARGET_DIR%\ + dir /b /a-d "%__TARGET_DIR%" +) +goto :eof + +rem ########################################################################## +rem ## Cleanups + +:end +if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% +exit /b %_EXITCODE% diff --git a/setenv.bat b/setenv.bat new file mode 100644 index 000000000000..5651dc492512 --- /dev/null +++ b/setenv.bat @@ -0,0 +1,218 @@ +@echo off +setlocal enabledelayedexpansion + +rem only for interactive debugging +set _DEBUG=0 + +rem ########################################################################## +rem ## Environment setup + +set _BASENAME=%~n0 + +set _EXITCODE=0 + +call :args %* +if not %_EXITCODE%==0 goto end + +rem ########################################################################## +rem ## Main + +set _JDK_PATH= +set _SBT_PATH= +set _GIT_PATH= + +call :javac +if not %_EXITCODE%==0 goto end + +call :sbt +if not %_EXITCODE%==0 goto end + +call :git +if not %_EXITCODE%==0 goto end + +if "%~1"=="clean" call :clean + +goto end + +rem ########################################################################## +rem ## Subroutines + +rem input parameter: %* +:args +set _VERBOSE=0 +set __N=0 +:args_loop +set __ARG=%~1 +if not defined __ARG ( + goto args_done +) else if not "%__ARG:~0,1%"=="-" ( + set /a __N=!__N!+1 +) +if /i "%__ARG%"=="help" ( call :help & goto :eof +) else if /i "%__ARG%"=="-verbose" ( set _VERBOSE=1 +) else ( + echo %_BASENAME%: Unknown subcommand %__ARG% + set _EXITCODE=1 + goto :eof +) +shift +goto :args_loop +:args_done +goto :eof + +:help +echo Usage: setenv { options ^| subcommands } +echo Options: +echo -verbose display environment settings +echo Subcommands: +echo help display this help message +goto :eof + +:javac +where /q javac.exe +if %ERRORLEVEL%==0 goto :eof + +if defined JDK_HOME ( + set _JDK_HOME=%JDK_HOME% + if %_DEBUG%==1 echo [%_BASENAME%] Using environment variable JDK_HOME +) else ( + set _PATH=C:\Progra~1\Java + for /f "delims=" %%f in ('dir /ad /b "!_PATH!\jdk1.8*" 2^>NUL') do set _JDK_HOME=!_PATH!\%%f + if not defined _JDK_HOME ( + set _PATH=C:\opt + for /f %%f in ('dir /ad /b "!_PATH!\jdk1.8*" 2^>NUL') do set _JDK_HOME=!_PATH!\%%f + ) + if defined _JDK_HOME ( + if %_DEBUG%==1 echo [%_BASENAME%] Using default Java SDK installation directory !_JDK_HOME! + ) +) +if not exist "%_JDK_HOME%\bin\javac.exe" ( + if %_DEBUG%==1 echo [%_BASENAME%] javac executable not found ^(%_JDK_HOME%^) + set _EXITCODE=1 + goto :eof +) +rem variable _JDK_PATH is prepended to PATH, so path separator must appear as last character +set "_JDK_PATH=%_JDK_HOME%\bin;" +goto :eof + +:sbt +where /q sbt.bat +if %ERRORLEVEL%==0 goto :eof + +if defined SBT_HOME ( + set _SBT_HOME=%SBT_HOME% + if %_DEBUG%==1 echo [%_BASENAME%] Using environment variable SBT_HOME +) else ( + set _PATH=C:\opt + for /f %%f in ('dir /ad /b "!_PATH!\sbt-1*" 2^>NUL') do set _SBT_HOME=!_PATH!\%%f + if defined _SBT_HOME ( + if %_DEBUG%==1 echo [%_BASENAME%] Using default sbt installation directory !_SBT_HOME! + ) +) +if not exist "%_SBT_HOME%\bin\sbt.bat" ( + if %_DEBUG%==1 echo [%_BASENAME%] sbt executable not found ^(%_SBT_HOME%^) + set _EXITCODE=1 + goto :eof +) +set "_SBT_PATH=;%_SBT_HOME%\bin" +goto :eof + +:git +where /q git.exe +if %ERRORLEVEL%==0 goto :eof + +if defined GIT_HOME ( + set _GIT_HOME=%GIT_HOME% + if %_DEBUG%==1 echo [%_BASENAME%] Using environment variable GIT_HOME +) else ( + set __PATH=C:\opt + if exist "!__PATH!\Git\" ( set _GIT_HOME=!__PATH!\Git + ) else ( + for /f %%f in ('dir /ad /b "!__PATH!\Git*" 2^>NUL') do set _GIT_HOME=!__PATH!\%%f + if not defined _GIT_HOME ( + set __PATH=C:\Progra~1 + for /f %%f in ('dir /ad /b "!__PATH!\Git*" 2^>NUL') do set _GIT_HOME=!__PATH!\%%f + ) + ) + if defined _GIT_HOME ( + if %_DEBUG%==1 echo [%_BASENAME%] Using default Git installation directory !_GIT_HOME! + ) +) +if not exist "%_GIT_HOME%\bin\git.exe" ( + echo Git executable not found ^(%_GIT_HOME%^) + set _EXITCODE=1 + goto :eof +) +set "_GIT_PATH=;%_GIT_HOME%\bin;%_GIT_HOME%\usr\bin" +goto :eof + +:clean +for %%f in ("%~dp0") do set __ROOT_DIR=%%~sf +for /f %%i in ('dir /ad /b "%__ROOT_DIR%\" 2^>NUL') do ( + for /f %%j in ('dir /ad /b "%%i\target\scala-*" 2^>NUL') do ( + if %_DEBUG%==1 echo [%_BASENAME%] rmdir /s /q %__ROOT_DIR%%%i\target\%%j\classes 1^>NUL 2^>^&1 + rmdir /s /q %__ROOT_DIR%%%i\target\%%j\classes 1>NUL 2>&1 + ) +) +goto :eof + +rem output parameter: _SBT_VERSION +rem Note: SBT requires special handling to know its version (no comment) +:sbt_version +set _SBT_VERSION= +for /f %%i in ('where sbt.bat') do for %%f in ("%%~dpi..") do set __SBT_LAUNCHER=%%~sf\bin\sbt-launch.jar +for /f "tokens=1,*" %%i in ('java.exe -jar "%__SBT_LAUNCHER%" sbtVersion ^| findstr [0-9].[0-9]') do set _SBT_VERSION=%%j +for /f "tokens=1,*" %%i in ('java.exe -jar "%__SBT_LAUNCHER%" scalaVersion ^| findstr [0-9].[0-9]') do set _SBT_VERSION=%_SBT_VERSION%/%%j +goto :eof + +:print_env +set __VERBOSE=%1 +set __VERSIONS_LINE1= +set __VERSIONS_LINE2= +set __WHERE_ARGS= +where /q javac.exe +if %ERRORLEVEL%==0 ( + for /f "tokens=1,2,*" %%i in ('javac.exe -version 2^>^&1') do set "__VERSIONS_LINE1=%__VERSIONS_LINE1% javac %%j," + set __WHERE_ARGS=%__WHERE_ARGS% javac.exe +) +where /q java.exe +if %ERRORLEVEL%==0 ( + for /f "tokens=1,2,3,*" %%i in ('java.exe -version 2^>^&1 ^| findstr version 2^>^&1') do set "__VERSIONS_LINE1=%__VERSIONS_LINE1% java %%~k," + set __WHERE_ARGS=%__WHERE_ARGS% java.exe +) +call :sbt_version +if defined _SBT_VERSION ( + set __VERSIONS_LINE2=%__VERSIONS_LINE2% sbt %_SBT_VERSION%, + set __WHERE_ARGS=%__WHERE_ARGS% sbt.bat +) +where /q git.exe +if %ERRORLEVEL%==0 ( + for /f "tokens=1,2,*" %%i in ('git.exe --version') do set __VERSIONS_LINE2=%__VERSIONS_LINE2% git %%k, + set __WHERE_ARGS=%__WHERE_ARGS% git.exe +) +where /q diff.exe +if %ERRORLEVEL%==0 ( + for /f "tokens=1-3,*" %%i in ('diff.exe --version ^| findstr diff') do set __VERSIONS_LINE2=%__VERSIONS_LINE2% diff %%l + set __WHERE_ARGS=%__WHERE_ARGS% diff.exe +) +echo Tool versions: +echo %__VERSIONS_LINE1% +echo %__VERSIONS_LINE2% +if %__VERBOSE%==1 ( + rem if %_DEBUG%==1 echo [%_BASENAME%] where %__WHERE_ARGS% + echo Tool paths: + for /f "tokens=*" %%p in ('where %__WHERE_ARGS%') do echo %%p +) +goto :eof + +rem ########################################################################## +rem ## Cleanups + +:end +endlocal & ( + if not defined JAVA_HOME set JAVA_HOME=%_JDK_HOME% + set "PATH=%_JDK_PATH%%PATH%%_SBT_PATH%%_GIT_PATH%;%~dp0project\scripts" + call :print_env %_VERBOSE% + if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% + for /f "delims==" %%i in ('set ^| findstr /b "_"') do set %%i= +) From 36f6108757b10521117088d37640f43dac4ee79f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Micheloud?= Date: Tue, 13 Nov 2018 11:03:44 +0100 Subject: [PATCH 03/10] small improvements in batch scripts for Dotty 0.10 --- bin/common.bat | 27 ++++++++++++----------- bin/dotc.bat | 55 +++++++++++++++++++++++------------------------ bin/dotd.bat | 58 +++++++++++++++++++++++++------------------------- bin/dotr.bat | 24 ++++++++++----------- 4 files changed, 83 insertions(+), 81 deletions(-) diff --git a/bin/common.bat b/bin/common.bat index 4c9b9c10f7ca..fd26dbc009f8 100644 --- a/bin/common.bat +++ b/bin/common.bat @@ -1,3 +1,6 @@ +rem ########################################################################## +rem ## Code common to dotc.bat, dotd.bat and dotr.bat + if defined JAVACMD ( set _JAVACMD=%JAVACMD% if %_DEBUG%==1 echo [%_BASENAME%] Using environment variable JAVACMD @@ -28,7 +31,7 @@ if defined JAVACMD ( ) ) if not exist "%_JAVACMD%" ( - if %_DEBUG%==1 echo [%_BASENAME%] Error: Java executable not found ^(%_JAVACMD%^) + echo Error: Java executable not found ^(%_JAVACMD%^) 1>&2 set _EXITCODE=1 goto :eof ) @@ -44,17 +47,17 @@ if defined DOTTY_HOME ( set _PSEP=; -for /f %%f in ('dir /b "%_LIB_DIR%\*dotty-compiler*"') do set _DOTTY_COMP=%_LIB_DIR%\%%f -for /f %%f in ('dir /b "%_LIB_DIR%\*dotty-interfaces*"') do set _DOTTY_INTF=%_LIB_DIR%\%%f -for /f %%f in ('dir /b "%_LIB_DIR%\*dotty-library*"') do set _DOTTY_LIB=%_LIB_DIR%\%%f -for /f %%f in ('dir /b "%_LIB_DIR%\*scala-asm*"') do set _SCALA_ASM=%_LIB_DIR%\%%f -for /f %%f in ('dir /b "%_LIB_DIR%\*scala-library*"') do set _SCALA_LIB=%_LIB_DIR%\%%f -for /f %%f in ('dir /b "%_LIB_DIR%\*scala-xml*"') do set _SCALA_XML=%_LIB_DIR%\%%f -for /f %%f in ('dir /b "%_LIB_DIR%\*compiler-interface*"') do set _SBT_INTF=%_LIB_DIR%\%%f -for /f %%f in ('dir /b "%_LIB_DIR%\*jline-reader-3*"') do set _JLINE_READER=%_LIB_DIR%\%%f -for /f %%f in ('dir /b "%_LIB_DIR%\*jline-terminal-3*"') do set _JLINE_TERMINAL=%_LIB_DIR%\%%f -for /f %%f in ('dir /b "%_LIB_DIR%\*jline-terminal-jna-3*"') do set _JLINE_TERMINAL_JNA=%_LIB_DIR%\%%f -for /f %%f in ('dir /b "%_LIB_DIR%\*jna-4*"') do set _JNA=%_LIB_DIR%\%%f +for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*dotty-compiler*"') do set _DOTTY_COMP=%_LIB_DIR%\%%f +for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*dotty-interfaces*"') do set _DOTTY_INTF=%_LIB_DIR%\%%f +for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*dotty-library*"') do set _DOTTY_LIB=%_LIB_DIR%\%%f +for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*scala-asm*"') do set _SCALA_ASM=%_LIB_DIR%\%%f +for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*scala-library*"') do set _SCALA_LIB=%_LIB_DIR%\%%f +for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*scala-xml*"') do set _SCALA_XML=%_LIB_DIR%\%%f +for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*compiler-interface*"') do set _SBT_INTF=%_LIB_DIR%\%%f +for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*jline-reader-3*"') do set _JLINE_READER=%_LIB_DIR%\%%f +for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*jline-terminal-3*"') do set _JLINE_TERMINAL=%_LIB_DIR%\%%f +for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*jline-terminal-jna-3*"') do set _JLINE_TERMINAL_JNA=%_LIB_DIR%\%%f +for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*jna-4*"') do set _JNA=%_LIB_DIR%\%%f rem debug set _DEBUG_STR=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 diff --git a/bin/dotc.bat b/bin/dotc.bat index 83066abf861d..30675e37f11c 100644 --- a/bin/dotc.bat +++ b/bin/dotc.bat @@ -55,59 +55,58 @@ set _COLORS= set _SCALA_ARGS= set _JAVA_ARGS= set _RESIDUAL_ARGS= + :args_loop if "%~1"=="" goto args_done -set _ARG=%~1 -if %_DEBUG%==1 echo [%_BASENAME%] _ARG=%_ARG% -if "%_ARG%"=="--" ( +set __ARG=%~1 +if %_DEBUG%==1 echo [%_BASENAME%] __ARG=%__ARG% +if "%__ARG%"=="--" ( rem for arg; do addResidual "$arg"; done; set -- ;; -) else if /i "%_ARG%"=="-h" ( +) else if /i "%__ARG%"=="-h" ( set _HELP=true call :addScala "-help" -) else if /i "%_ARG%"=="-help" ( +) else if /i "%__ARG%"=="-help" ( set _HELP=true call :addScala "-help" -) else if /i "%_ARG%"=="-v" ( +) else if /i "%__ARG%"=="-v" ( set _VERBOSE=true call :addScala "-verbose" -) else if /i "%_ARG%"=="-verbose" ( +) else if /i "%__ARG%"=="-verbose" ( set _VERBOSE=true call :addScala "-verbose" -) else if /i "%_ARG%"=="-debug" ( set _JAVA_DEBUG=%_DEBUG_STR% -) else if /i "%_ARG%"=="-q" ( set _QUIET=true -) else if /i "%_ARG%"=="-quiet" ( set _QUIET=true +) else if /i "%__ARG%"=="-debug" ( set _JAVA_DEBUG=%_DEBUG_STR% +) else if /i "%__ARG%"=="-q" ( set _QUIET=true +) else if /i "%__ARG%"=="-quiet" ( set _QUIET=true rem Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222 -) else if "%_ARG%"=="-=short" ( +) else if "%__ARG%"=="-=short" ( call :addJava "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" -) else if /i "%_ARG%"=="-repl" ( set _PROG_NAME=%_REPL_MAIN% -) else if /i "%_ARG%"=="-compile" ( set _PROG_NAME=%_COMPILER_MAIN% -) else if /i "%_ARG%"=="-decompile" ( set _PROG_NAME=%_DECOMPILER_MAIN% -) else if /i "%_ARG%"=="print-tasty" ( +) else if /i "%__ARG%"=="-repl" ( set _PROG_NAME=%_REPL_MAIN% +) else if /i "%__ARG%"=="-compile" ( set _PROG_NAME=%_COMPILER_MAIN% +) else if /i "%__ARG%"=="-decompile" ( set _PROG_NAME=%_DECOMPILER_MAIN% +) else if /i "%__ARG%"=="print-tasty" ( set _PROG_NAME=%_DECOMPILER_MAIN% call :addScala "-print-tasty" -) else if /i "%_ARG%"=="-run" ( set _PROG_NAME=%_REPL_MAIN% -) else if /i "%_ARG%"=="-colors" ( set _COLORS=true -) else if /i "%_ARG%"=="-no-colors" ( set _COLORS= -) else if /i "%_ARG%"=="-with-compiler" ( set _JVM_CP_ARGS=%_PSEP%%_DOTTY_COMP% +) else if /i "%__ARG%"=="-run" ( set _PROG_NAME=%_REPL_MAIN% +) else if /i "%__ARG%"=="-colors" ( set _COLORS=true +) else if /i "%__ARG%"=="-no-colors" ( set _COLORS= +) else if /i "%__ARG%"=="-with-compiler" ( set _JVM_CP_ARGS=%_PSEP%%_DOTTY_COMP% rem break out -D and -J options and add them to JAVA_OPTS as well rem so they reach the JVM in time to do some good. The -D options rem will be available as system properties. ) else if "%_ARG:~0,2%"=="-D" ( - call :addJava "%_ARG%" - call :addScala "%_ARG%" + call :addJava "%__ARG%" + call :addScala "%__ARG%" ) else if "%_ARG:~0,2%"=="-J" ( - call :addJava "%_ARG%" - call :addScala "%_ARG%" + call :addJava "%__ARG%" + call :addScala "%__ARG%" ) else ( - call :addResidual "%_ARG%" + call :addResidual "%__ARG%" ) shift goto args_loop :args_done -if %_DEBUG%==1 ( - echo [%_BASENAME%] _VERBOSE=%_VERBOSE% - echo [%_BASENAME%] _PROG_NAME=%_PROG_NAME% -) +if %_DEBUG%==1 echo [%_BASENAME%] _VERBOSE=%_VERBOSE% +if %_DEBUG%==1 echo [%_BASENAME%] _PROG_NAME=%_PROG_NAME% goto :eof rem output parameter: _SCALA_ARGS diff --git a/bin/dotd.bat b/bin/dotd.bat index 860085fe4f72..2712062adbe7 100644 --- a/bin/dotd.bat +++ b/bin/dotd.bat @@ -13,7 +13,7 @@ set _BASENAME=%~n0 for %%f in ("%~dp0..") do set _PROG_HOME=%%~sf -call "%_PROG_HOME%\bin\common.bat" +call %_PROG_HOME%\bin\common.bat if not %_EXITCODE%==0 goto end rem ########################################################################## @@ -35,53 +35,53 @@ rem ## Subroutines rem output parameter: _CLASS_PATH :javaClassPath -set _LIB_DIR=%_PROG_HOME%\lib +set __LIB_DIR=%_PROG_HOME%\lib rem Set dotty-doc dep: -for /f %%f in ('dir /b "%_LIB_DIR%\*dotty-doc*"') do set _DOTTY_DOC_LIB=%_LIB_DIR%\%%f +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*dotty-doc*"') do set _DOTTY_DOC_LIB=%__LIB_DIR%\%%f rem Set flexmark deps: -for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-0*"') do set _FLEXMARK_LIBS=%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-anchorlink*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-autolink*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-emoji*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-gfm-strikethrough*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-gfm-tables*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-gfm-tasklist*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-ins*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-superscript*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-tables*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-wikilink*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-ext-yaml-front-matter*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-formatter*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-jira-converter*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*flexmark-util*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-0*"') do set _FLEXMARK_LIBS=%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-anchorlink*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-autolink*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-emoji*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-gfm-strikethrough*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-gfm-tables*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-gfm-tasklist*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-ins*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-superscript*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-tables*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-wikilink*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-yaml-front-matter*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-formatter*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-jira-converter*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-util*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% rem Set jackson deps: -for /f %%f in ('dir /b "%_LIB_DIR%\*jackson-annotations*"') do set _JACKSON_LIBS=%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*jackson-core*"') do set _JACKSON_LIBS=%_JACKSON_LIBS%%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*jackson-databind*"') do set _JACKSON_LIBS=%_JACKSON_LIBS%%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*jackson-dataformat-yaml*"') do set _JACKSON_LIBS=%_JACKSON_LIBS%%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*jackson-annotations*"') do set _JACKSON_LIBS=%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*jackson-core*"') do set _JACKSON_LIBS=%_JACKSON_LIBS%%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*jackson-databind*"') do set _JACKSON_LIBS=%_JACKSON_LIBS%%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*jackson-dataformat-yaml*"') do set _JACKSON_LIBS=%_JACKSON_LIBS%%__LIB_DIR%\%%f%_PSEP% rem Set liqp dep: -for /f %%f in ('dir /b "%_LIB_DIR%\*liqp*"') do set _LIQP_LIB=%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*liqp*"') do set _LIQP_LIB=%__LIB_DIR%\%%f%_PSEP% rem Set ANTLR dep: -for /f %%f in ('dir /b "%_LIB_DIR%\*antlr-3*"') do set _ANTLR_LIB=%_LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /b "%_LIB_DIR%\*antlr-runtime-3*"') do set _ANTLR_RUNTIME_LIB=%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*antlr-3*"') do set _ANTLR_LIB=%__LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*antlr-runtime-3*"') do set _ANTLR_RUNTIME_LIB=%__LIB_DIR%\%%f%_PSEP% rem Set autolink dep: rem conflict with flexmark-ext-autolink-0.11 -for /f %%f in ('dir /b "%_LIB_DIR%\*autolink-0.6*"') do set _AUTOLINK_LIB=%_LIB_DIR%\%%f +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*autolink-0.6*"') do set _AUTOLINK_LIB=%__LIB_DIR%\%%f rem Set snakeyaml dep: -for /f %%f in ('dir /b "%_LIB_DIR%\*snakeyaml*"') do set _SNAKEYAML_LIB=%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*snakeyaml*"') do set _SNAKEYAML_LIB=%__LIB_DIR%\%%f%_PSEP% rem Set ST4 dep: -for /f %%f in ('dir /b "%_LIB_DIR%\*ST4*"') do set _ST4_LIB=%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*ST4*"') do set _ST4_LIB=%__LIB_DIR%\%%f%_PSEP% rem Set jsoup dep: -for /f %%f in ('dir /b "%_LIB_DIR%\*jsoup*"') do set _JSOUP_LIB=%_LIB_DIR%\%%f%_PSEP% +for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*jsoup*"') do set _JSOUP_LIB=%__LIB_DIR%\%%f%_PSEP% set _CLASS_PATH=%_DOTTY_LIB%%_PSEP%%_DOTTY_COMP%%_PSEP%%_DOTTY_DOC_LIB%%_PSEP%%_DOTTY_INTF%%_PSEP%%_SBT_INTF% set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_SCALA_LIB% diff --git a/bin/dotr.bat b/bin/dotr.bat index 17d3438d87a3..8384e7b5ab5d 100644 --- a/bin/dotr.bat +++ b/bin/dotr.bat @@ -44,7 +44,7 @@ rem elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then ) else ( set _CP_ARG=!_CP_ARG!%_PSEP%. ) if %_CLASS_PATH_COUNT% gtr 1 ( - echo warning: multiple classpaths are found, dotr only use the last one. + echo Warning: Multiple classpaths are found, dotr only use the last one. 1>&2 ) if %_WITH_COMPILER%==1 ( set _CP_ARG=!_CP_ARG!%_PSEP%%_DOTTY_COMP%%_PSEP%%_DOTTY_INTF%%_PSEP%%_SCALA_ASM% @@ -53,7 +53,7 @@ rem elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then if %_DEBUG%==1 echo [%_BASENAME%] %_JAVACMD% !_JAVA_ARGS! %_JAVACMD% !_JAVA_ARGS! ) else ( - echo warning: command option is not correct. + echo Warning: Command option is not correct. 1>&2 ) goto end @@ -74,25 +74,25 @@ set _JAVA_OPTIONS= :args_loop if "%1"=="" goto args_done -set "_ARG=%1" -if %_DEBUG%==1 echo [%_BASENAME%] _ARG=%_ARG% -if /i "%_ARG%"=="-repl" ( +set "__ARG=%1" +if %_DEBUG%==1 echo [%_BASENAME%] __ARG=%__ARG% +if /i "%__ARG%"=="-repl" ( set _EXECUTE_REPL=1 -) else if /i "%_ARG%"=="-run" ( +) else if /i "%__ARG%"=="-run" ( set _EXECUTE_RUN=1 -) else if /i "%_ARG%"=="-classpath" ( +) else if /i "%__ARG%"=="-classpath" ( set _CLASS_PATH=%2 set /a _CLASS_PATH_COUNT+=1 shift -) else if /i "%_ARG%"=="-with-compiler" ( +) else if /i "%__ARG%"=="-with-compiler" ( set _WITH_COMPILER=1 -) else if /i "%_ARG%"=="-d" ( +) else if /i "%__ARG%"=="-d" ( set _JAVA_DEBUG=%_DEBUG_STR% ) else if /i "%_ARG:~0,2%"=="-J" ( - set _JVM_OPTIONS=!_JVM_OPTIONS! %_ARG% - set _JAVA_OPTIONS=!_JAVA_OPTIONS! %_ARG% + set _JVM_OPTIONS=!_JVM_OPTIONS! %__ARG% + set _JAVA_OPTIONS=!_JAVA_OPTIONS! %__ARG% ) else ( - set _RESIDUAL_ARGS=%_RESIDUAL_ARGS% %_ARG% + set _RESIDUAL_ARGS=%_RESIDUAL_ARGS% %__ARG% ) shift goto args_loop From 07178271fb8ad8685998247889e9048fb0746520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Micheloud?= Date: Tue, 13 Nov 2018 11:04:53 +0100 Subject: [PATCH 04/10] improved subcommands in build.bat --- project/scripts/build.bat | 107 ++++++++++++++++++++++++++------------ 1 file changed, 75 insertions(+), 32 deletions(-) diff --git a/project/scripts/build.bat b/project/scripts/build.bat index 5d5ba7660f55..7cab2507bf29 100644 --- a/project/scripts/build.bat +++ b/project/scripts/build.bat @@ -2,7 +2,7 @@ setlocal enabledelayedexpansion rem only for interactive debugging -set _DEBUG=1 +set _DEBUG=0 rem ########################################################################## rem ## Environment setup @@ -31,17 +31,20 @@ if not %_EXITCODE%==0 ( goto end ) else if defined _HELP ( goto end ) -set _OUT_DIR=%TEMP%\%_BASENAME%_out +if exist "C:\Temp\" ( set _TMP_DIR=C:\Temp +) else ( set _TMP_DIR=%TEMP% +) +set _OUT_DIR=%_TMP_DIR%\%_BASENAME%_out if not exist "%_OUT_DIR%" mkdir "%_OUT_DIR%" -set _OUT1_DIR=%TEMP%\%_BASENAME%_out1 +set _OUT1_DIR=%_TMP_DIR%\%_BASENAME%_out1 if not exist "%_OUT1_DIR%" mkdir "%_OUT1_DIR%" -set _TMP_FILE=%TEMP%\%_BASENAME%_tmp.txt +set _TMP_FILE=%_TMP_DIR%\%_BASENAME%_tmp.txt where /q git.exe if not %ERRORLEVEL%==0 ( - echo Error: Git command not found ^(run setenv.bat^) 1>&2 + echo Error: Git command not found ^(check your PATH variable^) 1>&2 set _EXITCODE=1 goto end ) @@ -49,11 +52,11 @@ set _GIT_CMD=git.exe where /q sbt.bat if not %ERRORLEVEL%==0 ( - echo Error: SBT command not found ^(run setenv.bat^) 1>&2 + echo Error: SBT command not found ^(check your PATH variable^) 1>&2 set _EXITCODE=1 goto end ) -rem full path of SBT command is required +rem full path is required for sbt to run successfully for /f %%i in ('where sbt.bat') do set _SBT_CMD=%%i rem see file project/scripts/sbt @@ -69,27 +72,40 @@ set SBT_OPTS=-Ddotty.drone.mem=4096m ^ rem ########################################################################## rem ## Main -if defined _CLEAN ( - if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" clean - call "%_SBT_CMD%" clean - goto end +if %_VERBOSE%==1 ( + for /f %%i in ('where git.exe') do set _GIT_CMD1=%%i + echo _GIT_CMD=!_GIT_CMD1! + echo _SBT_CMD=%_SBT_CMD% + echo JAVA_OPTS=%JAVA_OPTS% + echo SBT_OPTS=%SBT_OPTS% + echo. +) +if defined _CLEAN_ALL ( + call :clean_all + if not !_EXITCODE!==0 goto end +) +if defined _CLONE ( + call :clone + if not !_EXITCODE!==0 goto end +) +if defined _BUILD ( + call :test + if not !_EXITCODE!==0 goto end ) - -call :clone -if not %_EXITCODE%==0 goto end - -call :test -if not %_EXITCODE%==0 goto end - if defined _BOOTSTRAP ( call :test_bootstrapped rem if not !_EXITCODE!==0 goto end - if not !_EXITCODE!==0 echo ###### Warning: _EXITCODE=!_EXITCODE! ####### 1>&2 + if not !_EXITCODE!==0 ( + if defined _IGNORE ( echo ###### Warning: _EXITCODE=!_EXITCODE! ####### 1>&2 + ) else ( goto end + ) + ) ) if defined _DOCUMENTATION ( call :documentation if not !_EXITCODE!==0 goto end ) + if defined _ARCHIVES ( call :archives if not !_EXITCODE!==0 goto end @@ -105,7 +121,8 @@ rem output parameters: _VERBOSE, _DOCUMENTATION set _VERBOSE=0 set _ARCHIVES= set _BOOTSTRAP= -set _CLEAN= +set _BUILD= +set _CLEAN_ALL= set _DOCUMENTATION= set __N=0 :args_loop @@ -117,10 +134,16 @@ if not defined __ARG ( ) if /i "%__ARG%"=="help" ( call :help & goto :eof ) else if /i "%__ARG%"=="-verbose" ( set _VERBOSE=1 -) else if /i "%__ARG:~0,4%"=="arch" ( set _ARCHIVES=1 -) else if /i "%__ARG:~0,4%"=="boot" ( set _BOOTSTRAP=1 -) else if /i "%__ARG%"=="clean" ( set _CLEAN=1 -) else if /i "%__ARG:~0,3%"=="doc" ( set _DOCUMENTATION=1 +) else if /i "%__ARG:~0,4%"=="arch" ( + if not "%__ARG:~-5%"=="-only" set _BUILD=1 & set _BOOTSTRAP=1 + set _ARCHIVES=1 +) else if /i "%__ARG:~0,4%"=="boot" ( + if not "%__ARG:~-5%"=="-only" set _BUILD=1 + set _BOOTSTRAP=1 +) else if /i "%__ARG%"=="cleanall" ( set _CLEAN_ALL=1 +) else if /i "%__ARG:~0,3%"=="doc" ( + if not "%__ARG:~-5%"=="-only" set _BUILD=1 & set _BOOTSTRAP=1 + set _DOCUMENTATION=1 ) else ( echo %_BASENAME%: Unknown subcommand %__ARG% set _EXITCODE=1 @@ -135,13 +158,31 @@ goto :eof set _HELP=1 echo Usage: setenv { options ^| subcommands } echo Options: -echo -verbose display environment settings +echo -verbose display environment settings echo Subcommands: -echo arch[ives] generate gz/zip archives -echo boot[strap] generate compiler bootstrap -echo clean clean project and leave -echo doc[umentation] generate documentation -echo help display this help message +echo arch[ives] generate gz/zip archives (after bootstrap) +echo arch[ives]-only generate ONLY gz/zip archives +echo boot[strap] generate compiler bootstrap (after build) +echo boot[strap]-only generate ONLY compiler bootstrap +echo cleanall clean project (sbt+git) and quit +echo doc[umentation] generate documentation (after bootstrap) +echo doc[umentation]-only] generate ONLY documentation +echo help display this help message +goto :eof + +:clean_all +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" clean +call "%_SBT_CMD%" clean +if not %ERRORLEVEL%==0 ( + set _EXITCODE=1 + goto :eof +) +if %_DEBUG%==1 echo [%_BASENAME%] %_GIT_CMD% clean -xdf +%_GIT_CMD% clean -xdf +if not %ERRORLEVEL%==0 ( + set _EXITCODE=1 + goto :eof +) goto :eof :clone @@ -172,6 +213,7 @@ goto :eof set __PATTERN=%~1 set __FILE=%~2 +if %_DEBUG%==1 echo [%_BASENAME%] findstr "%__PATTERN%" "%__FILE% findstr "%__PATTERN%" "%__FILE%" if not %ERRORLEVEL%==0 ( echo Error: Failed to find pattern "%__PATTERN%" in file %__FILE% 1>&2 @@ -217,8 +259,8 @@ if not %_EXITCODE%==0 goto :eof goto :eof :test -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";clean ;compile ;test" -call "%_SBT_CMD%" ";clean ;compile ;test" +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";compile ;test" +call "%_SBT_CMD%" ";compile ;test" if not %ERRORLEVEL%==0 ( echo Error: Failed to build Dotty 1>&2 set _EXITCODE=1 @@ -364,6 +406,7 @@ if not exist "%__TARGET_DIR%\" ( goto :eof ) if %_DEBUG%==1 ( + echo. echo Output directory: %__TARGET_DIR%\ dir /b /a-d "%__TARGET_DIR%" ) From 4e5738812601df0948482bc1ac1d80ea1fe09472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Micheloud?= Date: Tue, 13 Nov 2018 23:50:41 +0100 Subject: [PATCH 05/10] move batch scripts for distro to correct directory --- {bin => dist/bin}/common.bat | 0 {bin => dist/bin}/dotc.bat | 0 {bin => dist/bin}/dotd.bat | 0 {bin => dist/bin}/dotr.bat | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {bin => dist/bin}/common.bat (100%) rename {bin => dist/bin}/dotc.bat (100%) rename {bin => dist/bin}/dotd.bat (100%) rename {bin => dist/bin}/dotr.bat (100%) diff --git a/bin/common.bat b/dist/bin/common.bat similarity index 100% rename from bin/common.bat rename to dist/bin/common.bat diff --git a/bin/dotc.bat b/dist/bin/dotc.bat similarity index 100% rename from bin/dotc.bat rename to dist/bin/dotc.bat diff --git a/bin/dotd.bat b/dist/bin/dotd.bat similarity index 100% rename from bin/dotd.bat rename to dist/bin/dotd.bat diff --git a/bin/dotr.bat b/dist/bin/dotr.bat similarity index 100% rename from bin/dotr.bat rename to dist/bin/dotr.bat From 728cdff8f5ccb64e24ad4ba67b3ccf78b6af5a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Micheloud?= Date: Tue, 13 Nov 2018 23:52:38 +0100 Subject: [PATCH 06/10] fix goto label and help handling in batch scripts --- project/scripts/build.bat | 37 ++++++++++++++++--------------------- setenv.bat | 17 ++++++++--------- 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/project/scripts/build.bat b/project/scripts/build.bat index 7cab2507bf29..1e504b747ec6 100644 --- a/project/scripts/build.bat +++ b/project/scripts/build.bat @@ -27,9 +27,8 @@ set _MAIN=HelloWorld set _EXPECTED_OUTPUT=hello world call :args %* -if not %_EXITCODE%==0 ( goto end -) else if defined _HELP ( goto end -) +if not %_EXITCODE%==0 goto end +if defined _HELP call :help & exit /b %_EXITCODE% if exist "C:\Temp\" ( set _TMP_DIR=C:\Temp ) else ( set _TMP_DIR=%TEMP% @@ -118,31 +117,28 @@ rem ## Subroutines rem input parameter: %* rem output parameters: _VERBOSE, _DOCUMENTATION :args -set _VERBOSE=0 set _ARCHIVES= set _BOOTSTRAP= set _BUILD= set _CLEAN_ALL= set _DOCUMENTATION= -set __N=0 +set _HELP= +set _VERBOSE=0 + :args_loop set __ARG=%~1 -if not defined __ARG ( - goto args_done -) else if not "%__ARG:~0,1%"=="-" ( - set /a __N=+1 -) -if /i "%__ARG%"=="help" ( call :help & goto :eof +if not defined __ARG goto args_done +if /i "%__ARG%"=="help" ( set _HELP=1& goto :eof ) else if /i "%__ARG%"=="-verbose" ( set _VERBOSE=1 ) else if /i "%__ARG:~0,4%"=="arch" ( - if not "%__ARG:~-5%"=="-only" set _BUILD=1 & set _BOOTSTRAP=1 + if not "%__ARG:~-5%"=="-only" set _BUILD=1& set _BOOTSTRAP=1 set _ARCHIVES=1 ) else if /i "%__ARG:~0,4%"=="boot" ( if not "%__ARG:~-5%"=="-only" set _BUILD=1 set _BOOTSTRAP=1 ) else if /i "%__ARG%"=="cleanall" ( set _CLEAN_ALL=1 ) else if /i "%__ARG:~0,3%"=="doc" ( - if not "%__ARG:~-5%"=="-only" set _BUILD=1 & set _BOOTSTRAP=1 + if not "%__ARG:~-5%"=="-only" set _BUILD=1& set _BOOTSTRAP=1 set _DOCUMENTATION=1 ) else ( echo %_BASENAME%: Unknown subcommand %__ARG% @@ -150,13 +146,12 @@ if /i "%__ARG%"=="help" ( call :help & goto :eof goto :eof ) shift -goto :args_loop +goto args_loop :args_done goto :eof :help -set _HELP=1 -echo Usage: setenv { options ^| subcommands } +echo Usage: %_BASENAME% { options ^| subcommands } echo Options: echo -verbose display environment settings echo Subcommands: @@ -307,22 +302,22 @@ call "%_SBT_CMD%" dist-bootstrapped/pack rem # check that `dotc` compiles and `dotr` runs it echo testing ./bin/dotc and ./bin/dotr call :clear_out "%_OUT_DIR%" -call %_BIN_DIR%\dotc "%_SOURCE%" -d "%_OUT_DIR%" -call %_BIN_DIR%\dotr -classpath "%_OUT_DIR%" "%_MAIN%" > "%_TMP_FILE%" +call %_BIN_DIR%\dotc.bat "%_SOURCE%" -d "%_OUT_DIR%" +call %_BIN_DIR%\dotr.bat -classpath "%_OUT_DIR%" "%_MAIN%" > "%_TMP_FILE%" call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" rem # check that `dotc -from-tasty` compiles and `dotr` runs it echo testing ./bin/dotc -from-tasty and dotr -classpath call :clear_out "%_OUT1_DIR%" -call %_BIN_DIR%\dotc -from-tasty -classpath "%_OUT_DIR%" -d "%_OUT1_DIR%" "%_MAIN%" -call %_BIN_DIR%\dotr -classpath "%_OUT1_DIR%" "%_MAIN%" > "%_TMP_FILE%" +call %_BIN_DIR%\dotc.bat -from-tasty -classpath "%_OUT_DIR%" -d "%_OUT1_DIR%" "%_MAIN%" +call %_BIN_DIR%\dotr.bat -classpath "%_OUT1_DIR%" "%_MAIN%" > "%_TMP_FILE%" call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" rem # echo ":quit" | ./dist-bootstrapped/target/pack/bin/dotr # not supported by CI echo testing ./bin/dotd call :clear_out "%_OUT_DIR%" -call %_BIN_DIR%\dotd -project Hello -siteroot "%_OUT_DIR%" "%_SOURCE%" +call %_BIN_DIR%\dotd.bat -project Hello -siteroot "%_OUT_DIR%" "%_SOURCE%" goto :eof diff --git a/setenv.bat b/setenv.bat index 5651dc492512..917f1c39b8da 100644 --- a/setenv.bat +++ b/setenv.bat @@ -13,6 +13,7 @@ set _EXITCODE=0 call :args %* if not %_EXITCODE%==0 goto end +if defined _HELP call :help & exit /b %_EXITCODE% rem ########################################################################## rem ## Main @@ -38,17 +39,15 @@ rem ########################################################################## rem ## Subroutines rem input parameter: %* +rem output parameter: _HELP, _VERBOSE :args +set _HELP= set _VERBOSE=0 -set __N=0 + :args_loop set __ARG=%~1 -if not defined __ARG ( - goto args_done -) else if not "%__ARG:~0,1%"=="-" ( - set /a __N=!__N!+1 -) -if /i "%__ARG%"=="help" ( call :help & goto :eof +if not defined __ARG goto args_done +if /i "%__ARG%"=="help" ( set _HELP=1& goto :eof ) else if /i "%__ARG%"=="-verbose" ( set _VERBOSE=1 ) else ( echo %_BASENAME%: Unknown subcommand %__ARG% @@ -56,12 +55,12 @@ if /i "%__ARG%"=="help" ( call :help & goto :eof goto :eof ) shift -goto :args_loop +goto args_loop :args_done goto :eof :help -echo Usage: setenv { options ^| subcommands } +echo Usage: %_BASENAME% { options ^| subcommands } echo Options: echo -verbose display environment settings echo Subcommands: From 52a47663d358264fbea5db05d107b3d05545865e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Micheloud?= Date: Tue, 13 Nov 2018 23:55:33 +0100 Subject: [PATCH 07/10] added batch scripts for sbt pack --- bin/common.bat | 127 +++++++++++++++++++++++++++++++++++++++++++++++++ bin/dotc.bat | 5 ++ bin/dotd.bat | 5 ++ bin/dotr.bat | 5 ++ 4 files changed, 142 insertions(+) create mode 100644 bin/common.bat create mode 100644 bin/dotc.bat create mode 100644 bin/dotd.bat create mode 100644 bin/dotr.bat diff --git a/bin/common.bat b/bin/common.bat new file mode 100644 index 000000000000..0ad054cce557 --- /dev/null +++ b/bin/common.bat @@ -0,0 +1,127 @@ +@echo off +setlocal + +rem # Wrapper for the published dotc/dotr script that check for file changes +rem # and use sbt to re build the compiler as needed. + +rem only for interactive debugging +set _DEBUG=1 + +rem ########################################################################## +rem ## Environment setup + +set _BASENAME=%~n0 + +set _EXITCODE=0 + +for %%f in ("%~dp0..") do set _ROOT_DIR=%%~sf + +rem # Marker file used to obtain the date of latest call to sbt-back +set _VERSION=%_ROOT_DIR%\dist-bootstrapped\target\pack\VERSION + +rem ########################################################################## +rem ## Main + +rem # Create the target if absent or if file changed in ROOT/compiler +rem new_files="$(find "$ROOT/compiler" \( -iname "*.scala" -o -iname "*.java" \) -newer "$version" 2> /dev/null)" +call :new_files "%_VERSION%" + +if exist "%_VERSION%" if %_NEW_FILES%==0 goto target +echo Building Dotty... +pushd %_ROOT% && sbt.bat "dist-bootstrapped/pack" + +:target +set _TARGET=%~1 +rem # Mutates %* by deleting the first element (%1) +shift + +if %_DEBUG%==1 echo [%_BASENAME%] call %_TARGET% %* +call %_TARGET% %* +popd +goto end + +rem ########################################################################## +rem ## Subroutines + +rem input parameter: %1=version file +rem Output parameter: _NEW_FILES +:new_files +set __VERSION_FILE=%~1 + +call :timestamp "%__VERSION_FILE%" +set __VERSION_TIMESTAMP=%_TIMESTAMP% +if %_DEBUG%==1 echo [%_BASENAME%] %__VERSION_TIMESTAMP% %__VERSION_FILE% + +set __JAVA_SOURCE_FILES= +for /f %%i in ('dir /s /b "%_ROOT_DIR%compiler\*.java" 2^>NUL') do ( + set __JAVA_SOURCE_FILES=!__JAVA_SOURCE_FILES! %%i +) +set __SCALA_SOURCE_FILES= +for /f %%i in ('dir /s /b "%_ROOT_DIR%compiler\*.scala" 2^>NUL') do ( + set __SCALA_SOURCE_FILES=!__SCALA_SOURCE_FILES! %%i +) + +call :compile_required "%__VERSION_TIMESTAMP%" "%__JAVA_SOURCE_FILES% %__SCALA_SOURCE_FILES%" +set _NEW_FILES=%_COMPILE_REQUIRED% + +goto :eof + +rem input parameter: 1=timestamp file 2=source files +rem output parameter: _COMPILE_REQUIRED +:compile_required +set __TIMESTAMP_FILE=%~1 +set __SOURCE_FILES=%~2 + +set __SOURCE_TIMESTAMP=00000000000000 +set __N=0 +for %%i in (%__SOURCE_FILES%) do ( + call :timestamp "%%i" + if %_DEBUG%==1 echo [%_BASENAME%] !_TIMESTAMP! %%i + call :newer !_TIMESTAMP! !__SOURCE_TIMESTAMP! + if !_NEWER!==1 set __SOURCE_TIMESTAMP=!_TIMESTAMP! + set /a __N=!__N!+1 +) +if exist "%__TIMESTAMP_FILE%" ( set /p __CLASS_TIMESTAMP=<%__TIMESTAMP_FILE% +) else ( set __CLASS_TIMESTAMP=00000000000000 +) +if %_DEBUG%==1 echo [%_BASENAME%] %__CLASS_TIMESTAMP% %__TIMESTAMP_FILE% + +call :newer %__SOURCE_TIMESTAMP% %__CLASS_TIMESTAMP% +set _COMPILE_REQUIRED=%_NEWER% +goto :eof + +rem output parameter: _NEWER +:newer +set __TIMESTAMP1=%~1 +set __TIMESTAMP2=%~2 + +set __TIMESTAMP1_DATE=%__TIMESTAMP1:~0,8% +set __TIMESTAMP1_TIME=%__TIMESTAMP1:~-6% + +set __TIMESTAMP2_DATE=%__TIMESTAMP2:~0,8% +set __TIMESTAMP2_TIME=%__TIMESTAMP2:~-6% + +if %__TIMESTAMP1_DATE% gtr %__TIMESTAMP2_DATE% ( set _NEWER=1 +) else if %__TIMESTAMP1_DATE% lss %__TIMESTAMP2_DATE% ( set _NEWER=0 +) else if %__TIMESTAMP1_TIME% gtr %__TIMESTAMP2_TIME% ( set _NEWER=1 +) else ( set _NEWER=0 +) +goto :eof + +rem input parameter: 1=file path +rem output parameter: _TIMESTAMP +:timestamp +set __FILE_PATH=%~1 + +set _TIMESTAMP=00000000000000 +for /f %%i in ('powershell -C "(Get-ChildItem '%__FILE_PATH%').LastWriteTime | Get-Date -uformat %%Y%%m%%d%%H%%M%%S"') do ( + set _TIMESTAMP=%%i +) +goto :eof + +rem ########################################################################## +rem ## Cleanups + +:end +exit /b %_EXITCODE% +endlocal \ No newline at end of file diff --git a/bin/dotc.bat b/bin/dotc.bat new file mode 100644 index 000000000000..6cb1b20510dd --- /dev/null +++ b/bin/dotc.bat @@ -0,0 +1,5 @@ +@echo off + +for %%f in ("%~dp0..") do set _ROOT_DIR=%%~sf + +call %_ROOT_DIR%\bin\common.bat "%_ROOT_DIR%\dist-bootstrapped\target\pack\bin\dotc.bat" %* diff --git a/bin/dotd.bat b/bin/dotd.bat new file mode 100644 index 000000000000..5544e2bed952 --- /dev/null +++ b/bin/dotd.bat @@ -0,0 +1,5 @@ +@echo off + +for %%f in ("%~dp0..") do set _ROOT_DIR=%%~sf + +call %_ROOT_DIR%\bin\common.bat "%_ROOT_DIR%\dist-bootstrapped\target\pack\bin\dotd.bat" %* diff --git a/bin/dotr.bat b/bin/dotr.bat new file mode 100644 index 000000000000..3d62849591df --- /dev/null +++ b/bin/dotr.bat @@ -0,0 +1,5 @@ +@echo off + +for %%f in ("%~dp0..") do set _ROOT_DIR=%%~sf + +call %_ROOT_DIR%\bin\common.bat "%_ROOT_DIR%\dist-bootstrapped\target\pack\bin\dotr.bat" %* From 89437fb120ccec725e439b1199f616db061b4813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Micheloud?= Date: Wed, 14 Nov 2018 07:20:20 +0100 Subject: [PATCH 08/10] remove debug code --- bin/common.bat | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/bin/common.bat b/bin/common.bat index 0ad054cce557..264b3fedaa37 100644 --- a/bin/common.bat +++ b/bin/common.bat @@ -1,12 +1,9 @@ @echo off -setlocal +setlocal enabledelayedexpansion rem # Wrapper for the published dotc/dotr script that check for file changes rem # and use sbt to re build the compiler as needed. -rem only for interactive debugging -set _DEBUG=1 - rem ########################################################################## rem ## Environment setup @@ -23,21 +20,21 @@ rem ########################################################################## rem ## Main rem # Create the target if absent or if file changed in ROOT/compiler -rem new_files="$(find "$ROOT/compiler" \( -iname "*.scala" -o -iname "*.java" \) -newer "$version" 2> /dev/null)" call :new_files "%_VERSION%" if exist "%_VERSION%" if %_NEW_FILES%==0 goto target echo Building Dotty... -pushd %_ROOT% && sbt.bat "dist-bootstrapped/pack" +pushd %_ROOT% +sbt.bat "dist-bootstrapped/pack" +popd :target set _TARGET=%~1 rem # Mutates %* by deleting the first element (%1) shift -if %_DEBUG%==1 echo [%_BASENAME%] call %_TARGET% %* call %_TARGET% %* -popd + goto end rem ########################################################################## @@ -50,7 +47,6 @@ set __VERSION_FILE=%~1 call :timestamp "%__VERSION_FILE%" set __VERSION_TIMESTAMP=%_TIMESTAMP% -if %_DEBUG%==1 echo [%_BASENAME%] %__VERSION_TIMESTAMP% %__VERSION_FILE% set __JAVA_SOURCE_FILES= for /f %%i in ('dir /s /b "%_ROOT_DIR%compiler\*.java" 2^>NUL') do ( @@ -73,18 +69,14 @@ set __TIMESTAMP_FILE=%~1 set __SOURCE_FILES=%~2 set __SOURCE_TIMESTAMP=00000000000000 -set __N=0 for %%i in (%__SOURCE_FILES%) do ( call :timestamp "%%i" - if %_DEBUG%==1 echo [%_BASENAME%] !_TIMESTAMP! %%i call :newer !_TIMESTAMP! !__SOURCE_TIMESTAMP! if !_NEWER!==1 set __SOURCE_TIMESTAMP=!_TIMESTAMP! - set /a __N=!__N!+1 ) if exist "%__TIMESTAMP_FILE%" ( set /p __CLASS_TIMESTAMP=<%__TIMESTAMP_FILE% ) else ( set __CLASS_TIMESTAMP=00000000000000 ) -if %_DEBUG%==1 echo [%_BASENAME%] %__CLASS_TIMESTAMP% %__TIMESTAMP_FILE% call :newer %__SOURCE_TIMESTAMP% %__CLASS_TIMESTAMP% set _COMPILE_REQUIRED=%_NEWER% From 34551893ef1966f5050ba7a31fe4fffc5db58fea Mon Sep 17 00:00:00 2001 From: michelou Date: Wed, 14 Nov 2018 14:40:59 +0100 Subject: [PATCH 09/10] improved error messages in batch scripts --- project/scripts/build.bat | 64 ++++++++++++++++++++++----------------- setenv.bat | 20 +++--------- 2 files changed, 40 insertions(+), 44 deletions(-) diff --git a/project/scripts/build.bat b/project/scripts/build.bat index 1e504b747ec6..00572fcb36df 100644 --- a/project/scripts/build.bat +++ b/project/scripts/build.bat @@ -41,27 +41,10 @@ if not exist "%_OUT1_DIR%" mkdir "%_OUT1_DIR%" set _TMP_FILE=%_TMP_DIR%\%_BASENAME%_tmp.txt -where /q git.exe -if not %ERRORLEVEL%==0 ( - echo Error: Git command not found ^(check your PATH variable^) 1>&2 - set _EXITCODE=1 - goto end -) -set _GIT_CMD=git.exe - -where /q sbt.bat -if not %ERRORLEVEL%==0 ( - echo Error: SBT command not found ^(check your PATH variable^) 1>&2 - set _EXITCODE=1 - goto end -) -rem full path is required for sbt to run successfully -for /f %%i in ('where sbt.bat') do set _SBT_CMD=%%i - rem see file project/scripts/sbt rem SBT uses the value of the JAVA_OPTS environment variable if defined, rather than the config. -set JAVA_OPTS=-Xmx4096m ^ --XX:ReservedCodeCacheSize=1024m ^ +set JAVA_OPTS=-Xmx2048m ^ +-XX:ReservedCodeCacheSize=2048m ^ -XX:MaxMetaspaceSize=1024m set SBT_OPTS=-Ddotty.drone.mem=4096m ^ @@ -71,14 +54,9 @@ set SBT_OPTS=-Ddotty.drone.mem=4096m ^ rem ########################################################################## rem ## Main -if %_VERBOSE%==1 ( - for /f %%i in ('where git.exe') do set _GIT_CMD1=%%i - echo _GIT_CMD=!_GIT_CMD1! - echo _SBT_CMD=%_SBT_CMD% - echo JAVA_OPTS=%JAVA_OPTS% - echo SBT_OPTS=%SBT_OPTS% - echo. -) +call :init +if not %_EXITCODE%==0 goto end + if defined _CLEAN_ALL ( call :clean_all if not !_EXITCODE!==0 goto end @@ -141,7 +119,7 @@ if /i "%__ARG%"=="help" ( set _HELP=1& goto :eof if not "%__ARG:~-5%"=="-only" set _BUILD=1& set _BOOTSTRAP=1 set _DOCUMENTATION=1 ) else ( - echo %_BASENAME%: Unknown subcommand %__ARG% + echo Error: Unknown subcommand %__ARG% set _EXITCODE=1 goto :eof ) @@ -165,7 +143,37 @@ echo doc[umentation]-only] generate ONLY documentation echo help display this help message goto :eof +rem output parameters: _GIT_CMD, _SBT_CMD +:init +where /q git.exe +if not %ERRORLEVEL%==0 ( + echo Error: Git command not found ^(check your PATH variable^) 1>&2 + set _EXITCODE=1 + goto end +) +set _GIT_CMD=git.exe + +where /q sbt.bat +if not %ERRORLEVEL%==0 ( + echo Error: SBT command not found ^(check your PATH variable^) 1>&2 + set _EXITCODE=1 + goto end +) +rem full path is required for sbt to run successfully +for /f %%i in ('where sbt.bat') do set _SBT_CMD=%%i + +if %_VERBOSE%==1 ( + for /f %%i in ('where git.exe') do set _GIT_CMD1=%%i + echo _GIT_CMD=!_GIT_CMD1! + echo _SBT_CMD=%_SBT_CMD% + echo JAVA_OPTS=%JAVA_OPTS% + echo SBT_OPTS=%SBT_OPTS% + echo. +) +goto :eof + :clean_all +echo run sbt clean and git clean -xdf if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" clean call "%_SBT_CMD%" clean if not %ERRORLEVEL%==0 ( diff --git a/setenv.bat b/setenv.bat index 917f1c39b8da..3e40b02725ac 100644 --- a/setenv.bat +++ b/setenv.bat @@ -31,8 +31,6 @@ if not %_EXITCODE%==0 goto end call :git if not %_EXITCODE%==0 goto end -if "%~1"=="clean" call :clean - goto end rem ########################################################################## @@ -50,7 +48,7 @@ if not defined __ARG goto args_done if /i "%__ARG%"=="help" ( set _HELP=1& goto :eof ) else if /i "%__ARG%"=="-verbose" ( set _VERBOSE=1 ) else ( - echo %_BASENAME%: Unknown subcommand %__ARG% + echo Error: Unknown subcommand %__ARG% 1>&2 set _EXITCODE=1 goto :eof ) @@ -86,7 +84,7 @@ if defined JDK_HOME ( ) ) if not exist "%_JDK_HOME%\bin\javac.exe" ( - if %_DEBUG%==1 echo [%_BASENAME%] javac executable not found ^(%_JDK_HOME%^) + echo Error: javac executable not found ^(%_JDK_HOME%^) 1>&2 set _EXITCODE=1 goto :eof ) @@ -109,7 +107,7 @@ if defined SBT_HOME ( ) ) if not exist "%_SBT_HOME%\bin\sbt.bat" ( - if %_DEBUG%==1 echo [%_BASENAME%] sbt executable not found ^(%_SBT_HOME%^) + echo Error: sbt executable not found ^(%_SBT_HOME%^) 1>&2 set _EXITCODE=1 goto :eof ) @@ -138,23 +136,13 @@ if defined GIT_HOME ( ) ) if not exist "%_GIT_HOME%\bin\git.exe" ( - echo Git executable not found ^(%_GIT_HOME%^) + echo Error: Git executable not found ^(%_GIT_HOME%^) 1>&2 set _EXITCODE=1 goto :eof ) set "_GIT_PATH=;%_GIT_HOME%\bin;%_GIT_HOME%\usr\bin" goto :eof -:clean -for %%f in ("%~dp0") do set __ROOT_DIR=%%~sf -for /f %%i in ('dir /ad /b "%__ROOT_DIR%\" 2^>NUL') do ( - for /f %%j in ('dir /ad /b "%%i\target\scala-*" 2^>NUL') do ( - if %_DEBUG%==1 echo [%_BASENAME%] rmdir /s /q %__ROOT_DIR%%%i\target\%%j\classes 1^>NUL 2^>^&1 - rmdir /s /q %__ROOT_DIR%%%i\target\%%j\classes 1>NUL 2>&1 - ) -) -goto :eof - rem output parameter: _SBT_VERSION rem Note: SBT requires special handling to know its version (no comment) :sbt_version From 28b4c040b12adc05cba35d888b1686e5fbc0d366 Mon Sep 17 00:00:00 2001 From: michelou Date: Wed, 14 Nov 2018 17:33:19 +0100 Subject: [PATCH 10/10] reverted commits up to 72ef612 (PR #5430) --- bin/common.bat | 119 ----------- bin/dotc.bat | 5 - bin/dotd.bat | 5 - bin/dotr.bat | 5 - dist/bin/common.bat | 63 ------ dist/bin/dotc.bat | 163 --------------- dist/bin/dotd.bat | 104 ---------- dist/bin/dotr.bat | 108 ---------- project/scripts/build.bat | 423 -------------------------------------- setenv.bat | 205 ------------------ 10 files changed, 1200 deletions(-) delete mode 100644 bin/common.bat delete mode 100644 bin/dotc.bat delete mode 100644 bin/dotd.bat delete mode 100644 bin/dotr.bat delete mode 100644 dist/bin/common.bat delete mode 100644 dist/bin/dotc.bat delete mode 100644 dist/bin/dotd.bat delete mode 100644 dist/bin/dotr.bat delete mode 100644 project/scripts/build.bat delete mode 100644 setenv.bat diff --git a/bin/common.bat b/bin/common.bat deleted file mode 100644 index 264b3fedaa37..000000000000 --- a/bin/common.bat +++ /dev/null @@ -1,119 +0,0 @@ -@echo off -setlocal enabledelayedexpansion - -rem # Wrapper for the published dotc/dotr script that check for file changes -rem # and use sbt to re build the compiler as needed. - -rem ########################################################################## -rem ## Environment setup - -set _BASENAME=%~n0 - -set _EXITCODE=0 - -for %%f in ("%~dp0..") do set _ROOT_DIR=%%~sf - -rem # Marker file used to obtain the date of latest call to sbt-back -set _VERSION=%_ROOT_DIR%\dist-bootstrapped\target\pack\VERSION - -rem ########################################################################## -rem ## Main - -rem # Create the target if absent or if file changed in ROOT/compiler -call :new_files "%_VERSION%" - -if exist "%_VERSION%" if %_NEW_FILES%==0 goto target -echo Building Dotty... -pushd %_ROOT% -sbt.bat "dist-bootstrapped/pack" -popd - -:target -set _TARGET=%~1 -rem # Mutates %* by deleting the first element (%1) -shift - -call %_TARGET% %* - -goto end - -rem ########################################################################## -rem ## Subroutines - -rem input parameter: %1=version file -rem Output parameter: _NEW_FILES -:new_files -set __VERSION_FILE=%~1 - -call :timestamp "%__VERSION_FILE%" -set __VERSION_TIMESTAMP=%_TIMESTAMP% - -set __JAVA_SOURCE_FILES= -for /f %%i in ('dir /s /b "%_ROOT_DIR%compiler\*.java" 2^>NUL') do ( - set __JAVA_SOURCE_FILES=!__JAVA_SOURCE_FILES! %%i -) -set __SCALA_SOURCE_FILES= -for /f %%i in ('dir /s /b "%_ROOT_DIR%compiler\*.scala" 2^>NUL') do ( - set __SCALA_SOURCE_FILES=!__SCALA_SOURCE_FILES! %%i -) - -call :compile_required "%__VERSION_TIMESTAMP%" "%__JAVA_SOURCE_FILES% %__SCALA_SOURCE_FILES%" -set _NEW_FILES=%_COMPILE_REQUIRED% - -goto :eof - -rem input parameter: 1=timestamp file 2=source files -rem output parameter: _COMPILE_REQUIRED -:compile_required -set __TIMESTAMP_FILE=%~1 -set __SOURCE_FILES=%~2 - -set __SOURCE_TIMESTAMP=00000000000000 -for %%i in (%__SOURCE_FILES%) do ( - call :timestamp "%%i" - call :newer !_TIMESTAMP! !__SOURCE_TIMESTAMP! - if !_NEWER!==1 set __SOURCE_TIMESTAMP=!_TIMESTAMP! -) -if exist "%__TIMESTAMP_FILE%" ( set /p __CLASS_TIMESTAMP=<%__TIMESTAMP_FILE% -) else ( set __CLASS_TIMESTAMP=00000000000000 -) - -call :newer %__SOURCE_TIMESTAMP% %__CLASS_TIMESTAMP% -set _COMPILE_REQUIRED=%_NEWER% -goto :eof - -rem output parameter: _NEWER -:newer -set __TIMESTAMP1=%~1 -set __TIMESTAMP2=%~2 - -set __TIMESTAMP1_DATE=%__TIMESTAMP1:~0,8% -set __TIMESTAMP1_TIME=%__TIMESTAMP1:~-6% - -set __TIMESTAMP2_DATE=%__TIMESTAMP2:~0,8% -set __TIMESTAMP2_TIME=%__TIMESTAMP2:~-6% - -if %__TIMESTAMP1_DATE% gtr %__TIMESTAMP2_DATE% ( set _NEWER=1 -) else if %__TIMESTAMP1_DATE% lss %__TIMESTAMP2_DATE% ( set _NEWER=0 -) else if %__TIMESTAMP1_TIME% gtr %__TIMESTAMP2_TIME% ( set _NEWER=1 -) else ( set _NEWER=0 -) -goto :eof - -rem input parameter: 1=file path -rem output parameter: _TIMESTAMP -:timestamp -set __FILE_PATH=%~1 - -set _TIMESTAMP=00000000000000 -for /f %%i in ('powershell -C "(Get-ChildItem '%__FILE_PATH%').LastWriteTime | Get-Date -uformat %%Y%%m%%d%%H%%M%%S"') do ( - set _TIMESTAMP=%%i -) -goto :eof - -rem ########################################################################## -rem ## Cleanups - -:end -exit /b %_EXITCODE% -endlocal \ No newline at end of file diff --git a/bin/dotc.bat b/bin/dotc.bat deleted file mode 100644 index 6cb1b20510dd..000000000000 --- a/bin/dotc.bat +++ /dev/null @@ -1,5 +0,0 @@ -@echo off - -for %%f in ("%~dp0..") do set _ROOT_DIR=%%~sf - -call %_ROOT_DIR%\bin\common.bat "%_ROOT_DIR%\dist-bootstrapped\target\pack\bin\dotc.bat" %* diff --git a/bin/dotd.bat b/bin/dotd.bat deleted file mode 100644 index 5544e2bed952..000000000000 --- a/bin/dotd.bat +++ /dev/null @@ -1,5 +0,0 @@ -@echo off - -for %%f in ("%~dp0..") do set _ROOT_DIR=%%~sf - -call %_ROOT_DIR%\bin\common.bat "%_ROOT_DIR%\dist-bootstrapped\target\pack\bin\dotd.bat" %* diff --git a/bin/dotr.bat b/bin/dotr.bat deleted file mode 100644 index 3d62849591df..000000000000 --- a/bin/dotr.bat +++ /dev/null @@ -1,5 +0,0 @@ -@echo off - -for %%f in ("%~dp0..") do set _ROOT_DIR=%%~sf - -call %_ROOT_DIR%\bin\common.bat "%_ROOT_DIR%\dist-bootstrapped\target\pack\bin\dotr.bat" %* diff --git a/dist/bin/common.bat b/dist/bin/common.bat deleted file mode 100644 index fd26dbc009f8..000000000000 --- a/dist/bin/common.bat +++ /dev/null @@ -1,63 +0,0 @@ -rem ########################################################################## -rem ## Code common to dotc.bat, dotd.bat and dotr.bat - -if defined JAVACMD ( - set _JAVACMD=%JAVACMD% - if %_DEBUG%==1 echo [%_BASENAME%] Using environment variable JAVACMD -) else if defined JAVA_HOME ( - set _JAVACMD=%JAVA_HOME%\bin\java.exe - if %_DEBUG%==1 echo [%_BASENAME%] Using environment variable JAVA_HOME -) else if defined JDK_HOME ( - set _JAVACMD=%JDK_HOME%\bin\java.exe - if %_DEBUG%==1 echo [%_BASENAME%] Using environment variable JDK_HOME -) else ( - where /q java.exe - if !ERRORLEVEL!==0 ( - for /f "delims=" %%i in ('where /f java.exe') do set _JAVA_BIN_DIR=%%~dpsi - rem we ignore Oracle path for java executable - if "!_JAVA_BIN_DIR!"=="!_JAVA_BIN_DIR:javapath=!" set _JAVACMD=!_JAVA_BIN_DIR!\java.exe - ) - if not defined _JAVACMD ( - set _PATH=C:\Progra~1\Java - for /f %%f in ('dir /ad /b "!_PATH!\jre*" 2^>NUL') do set _JAVA_HOME=!_PATH!\%%f - if not defined _JAVA_HOME ( - set _PATH=C:\opt - for /f %%f in ('dir /ad /b "!_PATH!\jdk*" 2^>NUL') do set _JAVA_HOME=!_PATH!\%%f\jre - ) - if defined _JAVA_HOME ( - if %_DEBUG%==1 echo [%_BASENAME%] Using default Java installation directory !_JAVA_HOME! - set _JAVACMD=!_JAVA_HOME!\bin\java.exe - ) - ) -) -if not exist "%_JAVACMD%" ( - echo Error: Java executable not found ^(%_JAVACMD%^) 1>&2 - set _EXITCODE=1 - goto :eof -) - -if defined DOTTY_HOME ( - set _LIB_DIR=%DOTTY_HOME%\lib -) else ( - if not defined _PROG_HOME ( - for %%f in ("%~dp0..") do set _PROG_HOME=%%~sf - ) - set _LIB_DIR=!_PROG_HOME!\lib -) - -set _PSEP=; - -for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*dotty-compiler*"') do set _DOTTY_COMP=%_LIB_DIR%\%%f -for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*dotty-interfaces*"') do set _DOTTY_INTF=%_LIB_DIR%\%%f -for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*dotty-library*"') do set _DOTTY_LIB=%_LIB_DIR%\%%f -for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*scala-asm*"') do set _SCALA_ASM=%_LIB_DIR%\%%f -for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*scala-library*"') do set _SCALA_LIB=%_LIB_DIR%\%%f -for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*scala-xml*"') do set _SCALA_XML=%_LIB_DIR%\%%f -for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*compiler-interface*"') do set _SBT_INTF=%_LIB_DIR%\%%f -for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*jline-reader-3*"') do set _JLINE_READER=%_LIB_DIR%\%%f -for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*jline-terminal-3*"') do set _JLINE_TERMINAL=%_LIB_DIR%\%%f -for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*jline-terminal-jna-3*"') do set _JLINE_TERMINAL_JNA=%_LIB_DIR%\%%f -for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*jna-4*"') do set _JNA=%_LIB_DIR%\%%f - -rem debug -set _DEBUG_STR=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 diff --git a/dist/bin/dotc.bat b/dist/bin/dotc.bat deleted file mode 100644 index 30675e37f11c..000000000000 --- a/dist/bin/dotc.bat +++ /dev/null @@ -1,163 +0,0 @@ -@echo off -setlocal enabledelayedexpansion - -rem only for interactive debugging ! -set _DEBUG=0 - -rem ########################################################################## -rem ## Environment setup - -set _EXITCODE=0 - -set _BASENAME=%~n0 - -for %%f in ("%~dp0..") do set _PROG_HOME=%%~sf - -call %_PROG_HOME%\bin\common.bat -if not %_EXITCODE%==0 goto end - -set _COMPILER_MAIN=dotty.tools.dotc.Main -set _DECOMPILER_MAIN=dotty.tools.dotc.decompiler.Main -set _REPL_MAIN=dotty.tools.repl.Main - -set _PROG_NAME=%_COMPILER_MAIN% - -call :args %* - -rem ########################################################################## -rem ## Main - -call :classpathArgs - -if defined JAVA_OPTS ( set _JAVA_OPTS=%JAVA_OPTS% -) else ( set _JAVA_OPTS=-Xmx768m -Xms768m -) -if %_DEBUG%==1 echo [%_BASENAME%] "%_JAVACMD%" %_JAVA_OPTS% %_JAVA_DEBUG% %_JAVA_ARGS% %_JVM_CP_ARGS% -Dscala.usejavacp=true %_PROG_NAME% %_SCALA_ARGS% %_RESIDUAL_ARGS% -"%_JAVACMD%" %_JAVA_OPTS% %_JAVA_DEBUG% %_JAVA_ARGS% %_JVM_CP_ARGS% ^ --Dscala.usejavacp=true ^ -%_PROG_NAME% %_SCALA_ARGS% %_RESIDUAL_ARGS% -if not %ERRORLEVEL%==0 ( - if %_DEBUG%==1 echo [%_BASENAME%] Dotty compiler execution failed - set _EXITCODE=1 - goto end -) -goto end - -rem ########################################################################## -rem ## Subroutines - -:args -set _JAVA_DEBUG= -set _HELP= -set _VERBOSE= -set _QUIET= -set _COLORS= -set _SCALA_ARGS= -set _JAVA_ARGS= -set _RESIDUAL_ARGS= - -:args_loop -if "%~1"=="" goto args_done -set __ARG=%~1 -if %_DEBUG%==1 echo [%_BASENAME%] __ARG=%__ARG% -if "%__ARG%"=="--" ( - rem for arg; do addResidual "$arg"; done; set -- ;; -) else if /i "%__ARG%"=="-h" ( - set _HELP=true - call :addScala "-help" -) else if /i "%__ARG%"=="-help" ( - set _HELP=true - call :addScala "-help" -) else if /i "%__ARG%"=="-v" ( - set _VERBOSE=true - call :addScala "-verbose" -) else if /i "%__ARG%"=="-verbose" ( - set _VERBOSE=true - call :addScala "-verbose" -) else if /i "%__ARG%"=="-debug" ( set _JAVA_DEBUG=%_DEBUG_STR% -) else if /i "%__ARG%"=="-q" ( set _QUIET=true -) else if /i "%__ARG%"=="-quiet" ( set _QUIET=true -rem Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222 -) else if "%__ARG%"=="-=short" ( - call :addJava "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" -) else if /i "%__ARG%"=="-repl" ( set _PROG_NAME=%_REPL_MAIN% -) else if /i "%__ARG%"=="-compile" ( set _PROG_NAME=%_COMPILER_MAIN% -) else if /i "%__ARG%"=="-decompile" ( set _PROG_NAME=%_DECOMPILER_MAIN% -) else if /i "%__ARG%"=="print-tasty" ( - set _PROG_NAME=%_DECOMPILER_MAIN% - call :addScala "-print-tasty" -) else if /i "%__ARG%"=="-run" ( set _PROG_NAME=%_REPL_MAIN% -) else if /i "%__ARG%"=="-colors" ( set _COLORS=true -) else if /i "%__ARG%"=="-no-colors" ( set _COLORS= -) else if /i "%__ARG%"=="-with-compiler" ( set _JVM_CP_ARGS=%_PSEP%%_DOTTY_COMP% -rem break out -D and -J options and add them to JAVA_OPTS as well -rem so they reach the JVM in time to do some good. The -D options -rem will be available as system properties. -) else if "%_ARG:~0,2%"=="-D" ( - call :addJava "%__ARG%" - call :addScala "%__ARG%" -) else if "%_ARG:~0,2%"=="-J" ( - call :addJava "%__ARG%" - call :addScala "%__ARG%" -) else ( - call :addResidual "%__ARG%" -) -shift -goto args_loop -:args_done -if %_DEBUG%==1 echo [%_BASENAME%] _VERBOSE=%_VERBOSE% -if %_DEBUG%==1 echo [%_BASENAME%] _PROG_NAME=%_PROG_NAME% -goto :eof - -rem output parameter: _SCALA_ARGS -:addScala -set _SCALA_ARGS=%_SCALA_ARGS% %~1 -if %_DEBUG%==1 echo [%_BASENAME%] _SCALA_ARGS=%_SCALA_ARGS% -goto :eof - -rem output parameter: _JAVA_ARGS -:addJava -set _JAVA_ARGS=%_JAVA_ARGS% %~1 -if %_DEBUG%==1 echo [%_BASENAME%] _JAVA_ARGS=%_JAVA_ARGS% -goto :eof - -rem output parameter: _RESIDUAL_ARGS -:addResidual -set _RESIDUAL_ARGS=%_RESIDUAL_ARGS% %~1 -if %_DEBUG%==1 echo [%_BASENAME%] _RESIDUAL_ARGS=%_RESIDUAL_ARGS% -goto :eof - -rem output parameter: _JVM_CP_ARGS -:classpathArgs -rem echo dotty-compiler: %_DOTTY_COMP% -rem echo dotty-interface: %_DOTTY_INTF% -rem echo dotty-library: %_DOTTY_LIB% -rem echo scala-asm: %_SCALA_ASM% -rem echo scala-lib: %_SCALA_LIB% -rem echo scala-xml: %_SCALA_XML% -rem echo sbt-intface: %_SBT_INTF% - -set __TOOLCHAIN=%_SCALA_LIB%%_PSEP% -set __TOOLCHAIN=%__TOOLCHAIN%%_SCALA_ASM%%_PSEP% -set __TOOLCHAIN=%__TOOLCHAIN%%_SBT_INTF%%_PSEP% -set __TOOLCHAIN=%__TOOLCHAIN%%_DOTTY_INTF%%_PSEP% -set __TOOLCHAIN=%__TOOLCHAIN%%_DOTTY_LIB%%_PSEP% -set __TOOLCHAIN=%__TOOLCHAIN%%_DOTTY_COMP%%_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% - -set _JVM_CP_ARGS=-classpath %__TOOLCHAIN% -goto :eof - -rem ########################################################################## -rem ## Cleanups - -:end -if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% -exit /b %_EXITCODE% -endlocal - diff --git a/dist/bin/dotd.bat b/dist/bin/dotd.bat deleted file mode 100644 index 2712062adbe7..000000000000 --- a/dist/bin/dotd.bat +++ /dev/null @@ -1,104 +0,0 @@ -@echo off -setlocal enabledelayedexpansion - -rem only for interactive debugging ! -set _DEBUG=0 - -rem ########################################################################## -rem ## Environment setup - -set _EXITCODE=0 - -set _BASENAME=%~n0 - -for %%f in ("%~dp0..") do set _PROG_HOME=%%~sf - -call %_PROG_HOME%\bin\common.bat -if not %_EXITCODE%==0 goto end - -rem ########################################################################## -rem ## Main - -call :javaClassPath - -if %_DEBUG%==1 echo [%_BASENAME%] "%_JAVACMD%" -Dscala.usejavacp=true -classpath "%_CLASS_PATH%" dotty.tools.dottydoc.Main %* -"%_JAVACMD%" -Dscala.usejavacp=true -classpath "%_CLASS_PATH%" dotty.tools.dottydoc.Main %* -if not %ERRORLEVEL%==0 ( - if %_DEBUG%==1 echo [%_BASENAME%] Dottydoc execution failed - set _EXITCODE=1 - goto end -) -goto end - -rem ########################################################################## -rem ## Subroutines - -rem output parameter: _CLASS_PATH -:javaClassPath -set __LIB_DIR=%_PROG_HOME%\lib - -rem Set dotty-doc dep: -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*dotty-doc*"') do set _DOTTY_DOC_LIB=%__LIB_DIR%\%%f - -rem Set flexmark deps: -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-0*"') do set _FLEXMARK_LIBS=%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-anchorlink*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-autolink*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-emoji*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-gfm-strikethrough*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-gfm-tables*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-gfm-tasklist*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-ins*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-superscript*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-tables*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-wikilink*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-ext-yaml-front-matter*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-formatter*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-jira-converter*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*flexmark-util*"') do set _FLEXMARK_LIBS=%_FLEXMARK_LIBS%%__LIB_DIR%\%%f%_PSEP% - -rem Set jackson deps: -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*jackson-annotations*"') do set _JACKSON_LIBS=%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*jackson-core*"') do set _JACKSON_LIBS=%_JACKSON_LIBS%%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*jackson-databind*"') do set _JACKSON_LIBS=%_JACKSON_LIBS%%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*jackson-dataformat-yaml*"') do set _JACKSON_LIBS=%_JACKSON_LIBS%%__LIB_DIR%\%%f%_PSEP% - -rem Set liqp dep: -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*liqp*"') do set _LIQP_LIB=%__LIB_DIR%\%%f%_PSEP% - -rem Set ANTLR dep: -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*antlr-3*"') do set _ANTLR_LIB=%__LIB_DIR%\%%f%_PSEP% -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*antlr-runtime-3*"') do set _ANTLR_RUNTIME_LIB=%__LIB_DIR%\%%f%_PSEP% - -rem Set autolink dep: -rem conflict with flexmark-ext-autolink-0.11 -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*autolink-0.6*"') do set _AUTOLINK_LIB=%__LIB_DIR%\%%f - -rem Set snakeyaml dep: -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*snakeyaml*"') do set _SNAKEYAML_LIB=%__LIB_DIR%\%%f%_PSEP% - -rem Set ST4 dep: -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*ST4*"') do set _ST4_LIB=%__LIB_DIR%\%%f%_PSEP% - -rem Set jsoup dep: -for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*jsoup*"') do set _JSOUP_LIB=%__LIB_DIR%\%%f%_PSEP% - -set _CLASS_PATH=%_DOTTY_LIB%%_PSEP%%_DOTTY_COMP%%_PSEP%%_DOTTY_DOC_LIB%%_PSEP%%_DOTTY_INTF%%_PSEP%%_SBT_INTF% -set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_SCALA_LIB% -set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_FLEXMARK_LIBS% -set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_JACKSON_LIBS% -set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_LIQP_LIB% -set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_ANTLR_LIB%%_PSEP%%_ANTLR_RUNTIME_LIB% -set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_AUTOLINK_LIB% -set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_SNAKEYAML_LIB% -set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_ST4_LIB% -set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_JSOUP_LIB% -goto :eof - -rem ########################################################################## -rem ## Cleanups - -:end -if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% -exit /b %_EXITCODE% -endlocal diff --git a/dist/bin/dotr.bat b/dist/bin/dotr.bat deleted file mode 100644 index 8384e7b5ab5d..000000000000 --- a/dist/bin/dotr.bat +++ /dev/null @@ -1,108 +0,0 @@ -@echo off -setlocal enabledelayedexpansion - -rem only for interactive debugging ! -set _DEBUG=0 - -rem ########################################################################## -rem ## Environment setup - -set _EXITCODE=0 - -set _BASENAME=%~n0 - -for %%f in ("%~dp0..") do set _PROG_HOME=%%~sf - -call %_PROG_HOME%\bin\common.bat -if not %_EXITCODE%==0 goto end - -call :args %* - -rem ########################################################################## -rem ## Main - -set _CASE_1=0 -if %_EXECUTE_REPL%==1 set _CASE_1=1 -if %_EXECUTE_RUN%==0 if not defined _RESIDUAL_ARGS set _CASE_1=1 - -set _CASE_2=0 -if %_EXECUTE_RUN%==1 set _CASE_2=1 -if defined _RESIDUAL_ARGS set _CASE_2=1 - -rem if [ $execute_repl == true ] || ([ $execute_run == false ] && [ $options_indicator == 0 ]); then -if %_CASE_1%==1 ( - set _DOTC_ARGS= - if defined _CLASS_PATH set _DOTC_ARGS=-classpath "%_CLASS_PATH%" - set _DOTC_ARGS=!_DOTC_ARGS! %_JAVA_OPTIONS% -repl %_RESIDUAL_ARGS% - echo Starting dotty REPL... - if %_DEBUG%==1 echo [%_BASENAME%] %_PROG_HOME%\bin\dotc.bat !_DOTC_ARGS! - %_PROG_HOME%\bin\dotc.bat !_DOTC_ARGS! -rem elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then -) else if %_CASE_2%==1 ( - set _CP_ARG=%_DOTTY_LIB%%_PSEP%%_SCALA_LIB% - if defined _CLASS_PATH ( set _CP_ARG=!_CP_ARG!%_PSEP%%_CLASS_PATH% - ) else ( set _CP_ARG=!_CP_ARG!%_PSEP%. - ) - if %_CLASS_PATH_COUNT% gtr 1 ( - echo Warning: Multiple classpaths are found, dotr only use the last one. 1>&2 - ) - if %_WITH_COMPILER%==1 ( - set _CP_ARG=!_CP_ARG!%_PSEP%%_DOTTY_COMP%%_PSEP%%_DOTTY_INTF%%_PSEP%%_SCALA_ASM% - ) - set _JAVA_ARGS=%_JAVA_DEBUG% -classpath "!_CP_ARG!" %_RESIDUAL_ARGS% - if %_DEBUG%==1 echo [%_BASENAME%] %_JAVACMD% !_JAVA_ARGS! - %_JAVACMD% !_JAVA_ARGS! -) else ( - echo Warning: Command option is not correct. 1>&2 -) - -goto end - -rem ########################################################################## -rem ## Subroutines - -:args -set _RESIDUAL_ARGS= -set _EXECUTE_REPL=0 -set _EXECUTE_RUN=0 -set _WITH_COMPILER=0 -set _JAVA_DEBUG= -set _CLASS_PATH_COUNT=0 -set _CLASS_PATH= -set _JVM_OPTIONS= -set _JAVA_OPTIONS= - -:args_loop -if "%1"=="" goto args_done -set "__ARG=%1" -if %_DEBUG%==1 echo [%_BASENAME%] __ARG=%__ARG% -if /i "%__ARG%"=="-repl" ( - set _EXECUTE_REPL=1 -) else if /i "%__ARG%"=="-run" ( - set _EXECUTE_RUN=1 -) else if /i "%__ARG%"=="-classpath" ( - set _CLASS_PATH=%2 - set /a _CLASS_PATH_COUNT+=1 - shift -) else if /i "%__ARG%"=="-with-compiler" ( - set _WITH_COMPILER=1 -) else if /i "%__ARG%"=="-d" ( - set _JAVA_DEBUG=%_DEBUG_STR% -) else if /i "%_ARG:~0,2%"=="-J" ( - set _JVM_OPTIONS=!_JVM_OPTIONS! %__ARG% - set _JAVA_OPTIONS=!_JAVA_OPTIONS! %__ARG% -) else ( - set _RESIDUAL_ARGS=%_RESIDUAL_ARGS% %__ARG% -) -shift -goto args_loop -:args_done -goto :eof - -rem ########################################################################## -rem ## Cleanups - -:end -if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% -exit /b %_EXITCODE% -endlocal diff --git a/project/scripts/build.bat b/project/scripts/build.bat deleted file mode 100644 index 00572fcb36df..000000000000 --- a/project/scripts/build.bat +++ /dev/null @@ -1,423 +0,0 @@ -@echo off -setlocal enabledelayedexpansion - -rem only for interactive debugging -set _DEBUG=0 - -rem ########################################################################## -rem ## Environment setup - -set _BASENAME=%~n0 - -set _EXITCODE=0 - -set _BOT_TOKEN=dotty-token - -rem set _DRONE_BUILD_EVENT=pull_request -set _DRONE_BUILD_EVENT= -set _DRONE_REMOTE_URL= -set _DRONE_BRANCH= - -for %%f in ("%~dp0..\..") do set _ROOT_DIR=%%~sf -set _BIN_DIR=%_ROOT_DIR%bin -set _TESTS_POS_DIR=%_ROOT_DIR%test\pos - -set _SOURCE=tests/pos/HelloWorld.scala -set _MAIN=HelloWorld -set _EXPECTED_OUTPUT=hello world - -call :args %* -if not %_EXITCODE%==0 goto end -if defined _HELP call :help & exit /b %_EXITCODE% - -if exist "C:\Temp\" ( set _TMP_DIR=C:\Temp -) else ( set _TMP_DIR=%TEMP% -) -set _OUT_DIR=%_TMP_DIR%\%_BASENAME%_out -if not exist "%_OUT_DIR%" mkdir "%_OUT_DIR%" - -set _OUT1_DIR=%_TMP_DIR%\%_BASENAME%_out1 -if not exist "%_OUT1_DIR%" mkdir "%_OUT1_DIR%" - -set _TMP_FILE=%_TMP_DIR%\%_BASENAME%_tmp.txt - -rem see file project/scripts/sbt -rem SBT uses the value of the JAVA_OPTS environment variable if defined, rather than the config. -set JAVA_OPTS=-Xmx2048m ^ --XX:ReservedCodeCacheSize=2048m ^ --XX:MaxMetaspaceSize=1024m - -set SBT_OPTS=-Ddotty.drone.mem=4096m ^ --Dsbt.ivy.home=%USERPROFILE%\.ivy2\ ^ --Dsbt.log.noformat=true - -rem ########################################################################## -rem ## Main - -call :init -if not %_EXITCODE%==0 goto end - -if defined _CLEAN_ALL ( - call :clean_all - if not !_EXITCODE!==0 goto end -) -if defined _CLONE ( - call :clone - if not !_EXITCODE!==0 goto end -) -if defined _BUILD ( - call :test - if not !_EXITCODE!==0 goto end -) -if defined _BOOTSTRAP ( - call :test_bootstrapped - rem if not !_EXITCODE!==0 goto end - if not !_EXITCODE!==0 ( - if defined _IGNORE ( echo ###### Warning: _EXITCODE=!_EXITCODE! ####### 1>&2 - ) else ( goto end - ) - ) -) -if defined _DOCUMENTATION ( - call :documentation - if not !_EXITCODE!==0 goto end -) - -if defined _ARCHIVES ( - call :archives - if not !_EXITCODE!==0 goto end -) -goto end - -rem ########################################################################## -rem ## Subroutines - -rem input parameter: %* -rem output parameters: _VERBOSE, _DOCUMENTATION -:args -set _ARCHIVES= -set _BOOTSTRAP= -set _BUILD= -set _CLEAN_ALL= -set _DOCUMENTATION= -set _HELP= -set _VERBOSE=0 - -:args_loop -set __ARG=%~1 -if not defined __ARG goto args_done -if /i "%__ARG%"=="help" ( set _HELP=1& goto :eof -) else if /i "%__ARG%"=="-verbose" ( set _VERBOSE=1 -) else if /i "%__ARG:~0,4%"=="arch" ( - if not "%__ARG:~-5%"=="-only" set _BUILD=1& set _BOOTSTRAP=1 - set _ARCHIVES=1 -) else if /i "%__ARG:~0,4%"=="boot" ( - if not "%__ARG:~-5%"=="-only" set _BUILD=1 - set _BOOTSTRAP=1 -) else if /i "%__ARG%"=="cleanall" ( set _CLEAN_ALL=1 -) else if /i "%__ARG:~0,3%"=="doc" ( - if not "%__ARG:~-5%"=="-only" set _BUILD=1& set _BOOTSTRAP=1 - set _DOCUMENTATION=1 -) else ( - echo Error: Unknown subcommand %__ARG% - set _EXITCODE=1 - goto :eof -) -shift -goto args_loop -:args_done -goto :eof - -:help -echo Usage: %_BASENAME% { options ^| subcommands } -echo Options: -echo -verbose display environment settings -echo Subcommands: -echo arch[ives] generate gz/zip archives (after bootstrap) -echo arch[ives]-only generate ONLY gz/zip archives -echo boot[strap] generate compiler bootstrap (after build) -echo boot[strap]-only generate ONLY compiler bootstrap -echo cleanall clean project (sbt+git) and quit -echo doc[umentation] generate documentation (after bootstrap) -echo doc[umentation]-only] generate ONLY documentation -echo help display this help message -goto :eof - -rem output parameters: _GIT_CMD, _SBT_CMD -:init -where /q git.exe -if not %ERRORLEVEL%==0 ( - echo Error: Git command not found ^(check your PATH variable^) 1>&2 - set _EXITCODE=1 - goto end -) -set _GIT_CMD=git.exe - -where /q sbt.bat -if not %ERRORLEVEL%==0 ( - echo Error: SBT command not found ^(check your PATH variable^) 1>&2 - set _EXITCODE=1 - goto end -) -rem full path is required for sbt to run successfully -for /f %%i in ('where sbt.bat') do set _SBT_CMD=%%i - -if %_VERBOSE%==1 ( - for /f %%i in ('where git.exe') do set _GIT_CMD1=%%i - echo _GIT_CMD=!_GIT_CMD1! - echo _SBT_CMD=%_SBT_CMD% - echo JAVA_OPTS=%JAVA_OPTS% - echo SBT_OPTS=%SBT_OPTS% - echo. -) -goto :eof - -:clean_all -echo run sbt clean and git clean -xdf -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" clean -call "%_SBT_CMD%" clean -if not %ERRORLEVEL%==0 ( - set _EXITCODE=1 - goto :eof -) -if %_DEBUG%==1 echo [%_BASENAME%] %_GIT_CMD% clean -xdf -%_GIT_CMD% clean -xdf -if not %ERRORLEVEL%==0 ( - set _EXITCODE=1 - goto :eof -) -goto :eof - -:clone -if "%_DRONE_BUILD_EVENT%"=="pull_request" if defined _DRONE_REMOTE_URL ( - %_GIT_CMD% config user.email "dotty.bot@epfl.ch" - %_GIT_CMD% config user.name "Dotty CI" - %_GIT_CMD% pull "%_DRONE_REMOTE_URL%" "%_DRONE_BRANCH%" -) -if %_DEBUG%==1 echo [%_BASENAME%] %_GIT_CMD% submodule update --init --recursive --jobs 3 -%_GIT_CMD% submodule update --init --recursive --jobs 3 -if not %ERRORLEVEL%==0 ( - echo Error: Failed to update Git submodules 1>&2 - set _EXITCODE=1 - goto :eof -) -goto :eof - -:clear_out -set __OUT_DIR=%~1 - -if exist "%__OUT_DIR%" ( - if %_DEBUG%==1 echo [%_BASENAME%] del /s /q "%__OUT_DIR%\*" 1^>NUL - del /s /q "%__OUT_DIR%\*" 1>NUL -) -goto :eof - -:grep -set __PATTERN=%~1 -set __FILE=%~2 - -if %_DEBUG%==1 echo [%_BASENAME%] findstr "%__PATTERN%" "%__FILE% -findstr "%__PATTERN%" "%__FILE%" -if not %ERRORLEVEL%==0 ( - echo Error: Failed to find pattern "%__PATTERN%" in file %__FILE% 1>&2 - set _EXITCODE=1 - goto :eof -) -goto :eof - -rem ## see file project/scripts/cmdTests -:cmdTests -echo testing sbt dotc and dotr -if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" ";dotc %_SOURCE% -d %_OUT_DIR% ;dotr -classpath %_OUT_DIR% %_MAIN%" ^> "%_TMP_FILE%" -call "%_SBT_CMD%" ";dotc %_SOURCE% -d %_OUT_DIR% ;dotr -classpath %_OUT_DIR% %_MAIN%" > "%_TMP_FILE%" -call :grep "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" -if not %_EXITCODE%==0 goto :eof - -rem # check that `sbt dotc` compiles and `sbt dotr` runs it -echo testing sbt dotc -from-tasty and dotr -classpath -call :clear_out "%_OUT_DIR%" -call "%_SBT_CMD%" ";dotc %_SOURCE% -d %_OUT_DIR% ;dotc -from-tasty -classpath %_OUT_DIR% -d %_OUT1_DIR% %_MAIN% ;dotr -classpath %_OUT1_DIR% %_MAIN%" > "%_TMP_FILE%" -call :grep "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" -if not %_EXITCODE%==0 goto :eof - -rem # check that `sbt dotc -decompile` runs -echo testing sbt dotc -decompile -call "%_SBT_CMD%" ";dotc -decompile -color:never -classpath %_OUT_DIR% %_MAIN%" > "%_TMP_FILE%" -call :grep "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "%_TMP_FILE%" -if not %_EXITCODE%==0 goto :eof - -echo testing sbt dotr with no -classpath -call :clear_out "%_OUT_DIR%" -if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" ";dotc %_SOURCE% ; dotr %_MAIN%" ^> "%_TMP_FILE%" -call "%_SBT_CMD%" ";dotc %_SOURCE% ; dotr %_MAIN%" > "%_TMP_FILE%" -call :grep "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" -if not %_EXITCODE%==0 goto :eof - -echo testing loading tasty from .tasty file in jar -call :clear_out "%_OUT_DIR%" -call "%_SBT_CMD%" ";dotc -d %_OUT_DIR%\out.jar %_SOURCE%; dotc -decompile -classpath %_OUT_DIR%/out.jar -color:never %_MAIN%" > "%_TMP_FILE%" -call :grep "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "%_TMP_FILE%" -if not %_EXITCODE%==0 goto :eof - -goto :eof - -:test -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";compile ;test" -call "%_SBT_CMD%" ";compile ;test" -if not %ERRORLEVEL%==0 ( - echo Error: Failed to build Dotty 1>&2 - set _EXITCODE=1 - goto :eof -) - -rem ## see shell script project/scripts/cmdTests -call :cmdTests -if not %_EXITCODE%==0 goto :eof - -goto :eof - -:test_pattern -set __PATTERN=%~1 -set __FILE=%~2 - -set /p __PATTERN2=<"%__FILE%" -if not "%__PATTERN2%"=="%__PATTERN%" ( - echo Error: failed to find pattern "%__PATTERN%" in file %__FILE% 1>&2 - set _EXITCODE=1 - goto :eof -) -goto :eof - -rem ## see shell script project/scripts/bootstrapCmdTests -:bootstrapCmdTests -rem # check that benchmarks can run -if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" "dotty-bench/jmh:run 1 1 tests/pos/alias.scala" -call "%_SBT_CMD%" "dotty-bench/jmh:run 1 1 tests/pos/alias.scala" - -rem # The above is here as it relies on the bootstrapped library. -call "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 tests/pos/alias.scala" -call "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 -with-compiler compiler/src/dotty/tools/dotc/core/Types.scala" - -echo testing scala.quoted.Expr.run from sbt dotr -call "%_SBT_CMD%" ";dotty-compiler-bootstrapped/dotc tests/run-with-compiler/quote-run.scala; dotty-compiler-bootstrapped/dotr -with-compiler Test" > "%_TMP_FILE%" -call :grep "val a: scala.Int = 3" "%_TMP_FILE%" -if not %_EXITCODE%==0 goto :eof - -rem # setup for `dotc`/`dotr` script tests -if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" dist-bootstrapped/pack -call "%_SBT_CMD%" dist-bootstrapped/pack - -rem # check that `dotc` compiles and `dotr` runs it -echo testing ./bin/dotc and ./bin/dotr -call :clear_out "%_OUT_DIR%" -call %_BIN_DIR%\dotc.bat "%_SOURCE%" -d "%_OUT_DIR%" -call %_BIN_DIR%\dotr.bat -classpath "%_OUT_DIR%" "%_MAIN%" > "%_TMP_FILE%" -call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" - -rem # check that `dotc -from-tasty` compiles and `dotr` runs it -echo testing ./bin/dotc -from-tasty and dotr -classpath -call :clear_out "%_OUT1_DIR%" -call %_BIN_DIR%\dotc.bat -from-tasty -classpath "%_OUT_DIR%" -d "%_OUT1_DIR%" "%_MAIN%" -call %_BIN_DIR%\dotr.bat -classpath "%_OUT1_DIR%" "%_MAIN%" > "%_TMP_FILE%" -call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" - -rem # echo ":quit" | ./dist-bootstrapped/target/pack/bin/dotr # not supported by CI - -echo testing ./bin/dotd -call :clear_out "%_OUT_DIR%" -call %_BIN_DIR%\dotd.bat -project Hello -siteroot "%_OUT_DIR%" "%_SOURCE%" - -goto :eof - -:test_bootstrapped -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";dotty-bootstrapped/compile ;dotty-bootstrapped/test" -call "%_SBT_CMD%" ";dotty-bootstrapped/compile ;dotty-bootstrapped/test" -if not %ERRORLEVEL%==0 ( - echo Error: failed to bootstrap Dotty 1>&2 - set _EXITCODE=1 - goto :eof -) - -call :bootstrapCmdTests -if not %_EXITCODE%==0 goto :eof - -goto :eof - -:documentation -rem # make sure that _BOT_TOKEN is set -if not defined _BOT_TOKEN ( - echo Error: _BOT_TOKEN env unset, unable to push without password 1>&2 - set _EXITCODE=1 - goto :eof -) -for /f %%i in ('cd') do set _PWD=%%~si - -echo Working directory: %_PWD% - -call "%_SBT_CMD%" genDocs - -rem # make sure that the previous command actually succeeded -if not exist "%_PWD%\docs\_site\" ( - echo Error: output directory did not exist: %_PWD%\docs\_site 1>&2 - set _EXITCODE=1 - goto :eof -) - -goto :eof - -rem # save current head for commit message in gh-pages -rem for /f %%i in ('%_GIT_CMD% rev-parse HEAD 2^>NUL') do set _GIT_HEAD=%%i - -rem # set up remote and github credentials -rem %_GIT_CMD% remote add doc-remote "https://dotty-bot:%_BOT_TOKEN%@github.com/lampepfl/dotty-website.git" -rem %_GIT_CMD% config user.name "dotty-bot" -rem %_GIT_CMD% config user.email "dotty-bot@d-d.me" - -rem # check out correct branch -rem %_GIT_CMD% fetch doc-remote gh-pages -rem %_GIT_CMD% checkout gh-pages - -rem # move newly generated _site dir to $PWD -rem move %_PWD%\docs\_site . - -rem # remove everything BUT _site dir -rem del /f /q /s -rf !(_site) - -rem # copy new contents to $PWD -rem move _site\* . - -rem # remove now empty _site dir -rem del /f /q /s _site - -rem # add all contents of $PWD to commit -rem %_GIT_CMD% add -A -rem %_GIT_CMD% commit -m "Update gh-pages site for %_GIT_HEAD%" || echo "nothing new to commit" - -rem # push to doc-remote -rem %_GIT_CMD% push doc-remote || echo "couldn't push, since nothing was added" - -goto :eof - -:archives -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" dist-bootstrapped/packArchive -call "%_SBT_CMD%" dist-bootstrapped/packArchive -rem output directory for gz/zip archives -set __TARGET_DIR=%_ROOT_DIR%\dist-bootstrapped\target -if not exist "%__TARGET_DIR%\" ( - echo Error: Directory target not found 1>&2 - set _EXITCODE=1 - goto :eof -) -if %_DEBUG%==1 ( - echo. - echo Output directory: %__TARGET_DIR%\ - dir /b /a-d "%__TARGET_DIR%" -) -goto :eof - -rem ########################################################################## -rem ## Cleanups - -:end -if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% -exit /b %_EXITCODE% diff --git a/setenv.bat b/setenv.bat deleted file mode 100644 index 3e40b02725ac..000000000000 --- a/setenv.bat +++ /dev/null @@ -1,205 +0,0 @@ -@echo off -setlocal enabledelayedexpansion - -rem only for interactive debugging -set _DEBUG=0 - -rem ########################################################################## -rem ## Environment setup - -set _BASENAME=%~n0 - -set _EXITCODE=0 - -call :args %* -if not %_EXITCODE%==0 goto end -if defined _HELP call :help & exit /b %_EXITCODE% - -rem ########################################################################## -rem ## Main - -set _JDK_PATH= -set _SBT_PATH= -set _GIT_PATH= - -call :javac -if not %_EXITCODE%==0 goto end - -call :sbt -if not %_EXITCODE%==0 goto end - -call :git -if not %_EXITCODE%==0 goto end - -goto end - -rem ########################################################################## -rem ## Subroutines - -rem input parameter: %* -rem output parameter: _HELP, _VERBOSE -:args -set _HELP= -set _VERBOSE=0 - -:args_loop -set __ARG=%~1 -if not defined __ARG goto args_done -if /i "%__ARG%"=="help" ( set _HELP=1& goto :eof -) else if /i "%__ARG%"=="-verbose" ( set _VERBOSE=1 -) else ( - echo Error: Unknown subcommand %__ARG% 1>&2 - set _EXITCODE=1 - goto :eof -) -shift -goto args_loop -:args_done -goto :eof - -:help -echo Usage: %_BASENAME% { options ^| subcommands } -echo Options: -echo -verbose display environment settings -echo Subcommands: -echo help display this help message -goto :eof - -:javac -where /q javac.exe -if %ERRORLEVEL%==0 goto :eof - -if defined JDK_HOME ( - set _JDK_HOME=%JDK_HOME% - if %_DEBUG%==1 echo [%_BASENAME%] Using environment variable JDK_HOME -) else ( - set _PATH=C:\Progra~1\Java - for /f "delims=" %%f in ('dir /ad /b "!_PATH!\jdk1.8*" 2^>NUL') do set _JDK_HOME=!_PATH!\%%f - if not defined _JDK_HOME ( - set _PATH=C:\opt - for /f %%f in ('dir /ad /b "!_PATH!\jdk1.8*" 2^>NUL') do set _JDK_HOME=!_PATH!\%%f - ) - if defined _JDK_HOME ( - if %_DEBUG%==1 echo [%_BASENAME%] Using default Java SDK installation directory !_JDK_HOME! - ) -) -if not exist "%_JDK_HOME%\bin\javac.exe" ( - echo Error: javac executable not found ^(%_JDK_HOME%^) 1>&2 - set _EXITCODE=1 - goto :eof -) -rem variable _JDK_PATH is prepended to PATH, so path separator must appear as last character -set "_JDK_PATH=%_JDK_HOME%\bin;" -goto :eof - -:sbt -where /q sbt.bat -if %ERRORLEVEL%==0 goto :eof - -if defined SBT_HOME ( - set _SBT_HOME=%SBT_HOME% - if %_DEBUG%==1 echo [%_BASENAME%] Using environment variable SBT_HOME -) else ( - set _PATH=C:\opt - for /f %%f in ('dir /ad /b "!_PATH!\sbt-1*" 2^>NUL') do set _SBT_HOME=!_PATH!\%%f - if defined _SBT_HOME ( - if %_DEBUG%==1 echo [%_BASENAME%] Using default sbt installation directory !_SBT_HOME! - ) -) -if not exist "%_SBT_HOME%\bin\sbt.bat" ( - echo Error: sbt executable not found ^(%_SBT_HOME%^) 1>&2 - set _EXITCODE=1 - goto :eof -) -set "_SBT_PATH=;%_SBT_HOME%\bin" -goto :eof - -:git -where /q git.exe -if %ERRORLEVEL%==0 goto :eof - -if defined GIT_HOME ( - set _GIT_HOME=%GIT_HOME% - if %_DEBUG%==1 echo [%_BASENAME%] Using environment variable GIT_HOME -) else ( - set __PATH=C:\opt - if exist "!__PATH!\Git\" ( set _GIT_HOME=!__PATH!\Git - ) else ( - for /f %%f in ('dir /ad /b "!__PATH!\Git*" 2^>NUL') do set _GIT_HOME=!__PATH!\%%f - if not defined _GIT_HOME ( - set __PATH=C:\Progra~1 - for /f %%f in ('dir /ad /b "!__PATH!\Git*" 2^>NUL') do set _GIT_HOME=!__PATH!\%%f - ) - ) - if defined _GIT_HOME ( - if %_DEBUG%==1 echo [%_BASENAME%] Using default Git installation directory !_GIT_HOME! - ) -) -if not exist "%_GIT_HOME%\bin\git.exe" ( - echo Error: Git executable not found ^(%_GIT_HOME%^) 1>&2 - set _EXITCODE=1 - goto :eof -) -set "_GIT_PATH=;%_GIT_HOME%\bin;%_GIT_HOME%\usr\bin" -goto :eof - -rem output parameter: _SBT_VERSION -rem Note: SBT requires special handling to know its version (no comment) -:sbt_version -set _SBT_VERSION= -for /f %%i in ('where sbt.bat') do for %%f in ("%%~dpi..") do set __SBT_LAUNCHER=%%~sf\bin\sbt-launch.jar -for /f "tokens=1,*" %%i in ('java.exe -jar "%__SBT_LAUNCHER%" sbtVersion ^| findstr [0-9].[0-9]') do set _SBT_VERSION=%%j -for /f "tokens=1,*" %%i in ('java.exe -jar "%__SBT_LAUNCHER%" scalaVersion ^| findstr [0-9].[0-9]') do set _SBT_VERSION=%_SBT_VERSION%/%%j -goto :eof - -:print_env -set __VERBOSE=%1 -set __VERSIONS_LINE1= -set __VERSIONS_LINE2= -set __WHERE_ARGS= -where /q javac.exe -if %ERRORLEVEL%==0 ( - for /f "tokens=1,2,*" %%i in ('javac.exe -version 2^>^&1') do set "__VERSIONS_LINE1=%__VERSIONS_LINE1% javac %%j," - set __WHERE_ARGS=%__WHERE_ARGS% javac.exe -) -where /q java.exe -if %ERRORLEVEL%==0 ( - for /f "tokens=1,2,3,*" %%i in ('java.exe -version 2^>^&1 ^| findstr version 2^>^&1') do set "__VERSIONS_LINE1=%__VERSIONS_LINE1% java %%~k," - set __WHERE_ARGS=%__WHERE_ARGS% java.exe -) -call :sbt_version -if defined _SBT_VERSION ( - set __VERSIONS_LINE2=%__VERSIONS_LINE2% sbt %_SBT_VERSION%, - set __WHERE_ARGS=%__WHERE_ARGS% sbt.bat -) -where /q git.exe -if %ERRORLEVEL%==0 ( - for /f "tokens=1,2,*" %%i in ('git.exe --version') do set __VERSIONS_LINE2=%__VERSIONS_LINE2% git %%k, - set __WHERE_ARGS=%__WHERE_ARGS% git.exe -) -where /q diff.exe -if %ERRORLEVEL%==0 ( - for /f "tokens=1-3,*" %%i in ('diff.exe --version ^| findstr diff') do set __VERSIONS_LINE2=%__VERSIONS_LINE2% diff %%l - set __WHERE_ARGS=%__WHERE_ARGS% diff.exe -) -echo Tool versions: -echo %__VERSIONS_LINE1% -echo %__VERSIONS_LINE2% -if %__VERBOSE%==1 ( - rem if %_DEBUG%==1 echo [%_BASENAME%] where %__WHERE_ARGS% - echo Tool paths: - for /f "tokens=*" %%p in ('where %__WHERE_ARGS%') do echo %%p -) -goto :eof - -rem ########################################################################## -rem ## Cleanups - -:end -endlocal & ( - if not defined JAVA_HOME set JAVA_HOME=%_JDK_HOME% - set "PATH=%_JDK_PATH%%PATH%%_SBT_PATH%%_GIT_PATH%;%~dp0project\scripts" - call :print_env %_VERBOSE% - if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% - for /f "delims==" %%i in ('set ^| findstr /b "_"') do set %%i= -)