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/34] 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/34] 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/34] 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/34] 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/34] 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/34] 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/34] 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/34] 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/34] 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/34] 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= -) From 6688ea66fe976c534c5ea4d822ea9fcfc428bc0c Mon Sep 17 00:00:00 2001 From: michelou Date: Wed, 14 Nov 2018 17:56:23 +0100 Subject: [PATCH 11/34] added batch scripts for a new PR --- 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 | 426 ++++++++++++++++++++++++++++++++++++++ 9 files changed, 998 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 dist/bin/common.bat create mode 100644 dist/bin/dotc.bat create mode 100644 dist/bin/dotd.bat create mode 100644 dist/bin/dotr.bat create mode 100644 project/scripts/build.bat diff --git a/bin/common.bat b/bin/common.bat new file mode 100644 index 000000000000..264b3fedaa37 --- /dev/null +++ b/bin/common.bat @@ -0,0 +1,119 @@ +@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 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" %* diff --git a/dist/bin/common.bat b/dist/bin/common.bat new file mode 100644 index 000000000000..fd26dbc009f8 --- /dev/null +++ b/dist/bin/common.bat @@ -0,0 +1,63 @@ +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 new file mode 100644 index 000000000000..30675e37f11c --- /dev/null +++ b/dist/bin/dotc.bat @@ -0,0 +1,163 @@ +@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 new file mode 100644 index 000000000000..2712062adbe7 --- /dev/null +++ b/dist/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 /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 new file mode 100644 index 000000000000..8384e7b5ab5d --- /dev/null +++ b/dist/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. 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 new file mode 100644 index 000000000000..760e485a95b9 --- /dev/null +++ b/project/scripts/build.bat @@ -0,0 +1,426 @@ +@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 _CLONE= +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 _CLONE=1& set _BUILD=1& set _BOOTSTRAP=1 + set _ARCHIVES=1 +) else if /i "%__ARG:~0,4%"=="boot" ( + if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _BUILD=1 + set _BOOTSTRAP=1 +) else if /i "%__ARG%"=="cleanall" ( set _CLEAN_ALL=1 +) else if /i "%__ARG%"=="clone" ( set _CLONE=1 +) else if /i "%__ARG:~0,3%"=="doc" ( + if not "%__ARG:~-5%"=="-only" set _CLONE=1& 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 clone update submodules +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% From 205fab545dca6e775b8ae525d9b07c75fc1a1711 Mon Sep 17 00:00:00 2001 From: michelou Date: Wed, 14 Nov 2018 18:36:44 +0100 Subject: [PATCH 12/34] removed debug code from batch scripts --- dist/bin/common.bat | 4 ---- dist/bin/dotc.bat | 13 +------------ dist/bin/dotd.bat | 7 +------ dist/bin/dotr.bat | 6 ------ 4 files changed, 2 insertions(+), 28 deletions(-) diff --git a/dist/bin/common.bat b/dist/bin/common.bat index fd26dbc009f8..1d333d7b7a6f 100644 --- a/dist/bin/common.bat +++ b/dist/bin/common.bat @@ -3,13 +3,10 @@ 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 ( @@ -25,7 +22,6 @@ if defined JAVACMD ( 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 ) ) diff --git a/dist/bin/dotc.bat b/dist/bin/dotc.bat index 30675e37f11c..c7eade2fc917 100644 --- a/dist/bin/dotc.bat +++ b/dist/bin/dotc.bat @@ -1,9 +1,6 @@ @echo off setlocal enabledelayedexpansion -rem only for interactive debugging ! -set _DEBUG=0 - rem ########################################################################## rem ## Environment setup @@ -32,12 +29,11 @@ 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 + rem echo Error: Dotty compiler execution failed 1>&2 set _EXITCODE=1 goto end ) @@ -59,7 +55,6 @@ 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" ( @@ -105,26 +100,21 @@ rem will be available as system properties. 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 @@ -157,7 +147,6 @@ 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 index 2712062adbe7..f1a40fbeca51 100644 --- a/dist/bin/dotd.bat +++ b/dist/bin/dotd.bat @@ -1,9 +1,6 @@ @echo off setlocal enabledelayedexpansion -rem only for interactive debugging ! -set _DEBUG=0 - rem ########################################################################## rem ## Environment setup @@ -21,10 +18,9 @@ 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 + rem echo Error: Dottydoc execution failed 1>&2 set _EXITCODE=1 goto end ) @@ -99,6 +95,5 @@ 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 index 8384e7b5ab5d..61c003af0cae 100644 --- a/dist/bin/dotr.bat +++ b/dist/bin/dotr.bat @@ -1,9 +1,6 @@ @echo off setlocal enabledelayedexpansion -rem only for interactive debugging ! -set _DEBUG=0 - rem ########################################################################## rem ## Environment setup @@ -35,7 +32,6 @@ if %_CASE_1%==1 ( 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 ( @@ -50,7 +46,6 @@ rem elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then 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 @@ -103,6 +98,5 @@ rem ########################################################################## rem ## Cleanups :end -if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% exit /b %_EXITCODE% endlocal From a6df7023fc0c3707f7e0e4b7b87391fddac77add Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Wed, 14 Nov 2018 23:03:35 +0100 Subject: [PATCH 13/34] added compile subcommand to batch script --- project/scripts/build.bat | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/project/scripts/build.bat b/project/scripts/build.bat index 760e485a95b9..92c30b9eba94 100644 --- a/project/scripts/build.bat +++ b/project/scripts/build.bat @@ -65,7 +65,7 @@ if defined _CLONE ( call :clone if not !_EXITCODE!==0 goto end ) -if defined _BUILD ( +if defined _COMPILE ( call :test if not !_EXITCODE!==0 goto end ) @@ -97,7 +97,7 @@ rem output parameters: _VERBOSE, _DOCUMENTATION :args set _ARCHIVES= set _BOOTSTRAP= -set _BUILD= +set _COMPILE= set _CLEAN_ALL= set _CLONE= set _DOCUMENTATION= @@ -110,15 +110,18 @@ 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 _CLONE=1& set _BUILD=1& set _BOOTSTRAP=1 + if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _COMPILE=1& set _BOOTSTRAP=1 set _ARCHIVES=1 ) else if /i "%__ARG:~0,4%"=="boot" ( - if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _BUILD=1 + if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _COMPILE=1 set _BOOTSTRAP=1 ) else if /i "%__ARG%"=="cleanall" ( set _CLEAN_ALL=1 ) else if /i "%__ARG%"=="clone" ( set _CLONE=1 +) else if /i "%__ARG%"=="compile" ( + if not "%__ARG:~-5%"=="-only" set _CLONE=1 + set _COMPILE=1 ) else if /i "%__ARG:~0,3%"=="doc" ( - if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _BUILD=1& set _BOOTSTRAP=1 + if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _COMPILE=1& set _BOOTSTRAP=1 set _DOCUMENTATION=1 ) else ( echo Error: Unknown subcommand %__ARG% @@ -137,10 +140,12 @@ 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] generate compiler bootstrap (after compile) echo boot[strap]-only generate ONLY compiler bootstrap echo cleanall clean project (sbt+git) and quit echo clone update submodules +echo compile generate compiler 1st stage (after clone) +echo compile-only generate ONLY compiler 1st stage echo doc[umentation] generate documentation (after bootstrap) echo doc[umentation]-only] generate ONLY documentation echo help display this help message @@ -265,6 +270,7 @@ if not %_EXITCODE%==0 goto :eof goto :eof :test +echo sbt compile and sbt test if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";compile ;test" call "%_SBT_CMD%" ";compile ;test" if not %ERRORLEVEL%==0 ( From 211ce5de6c5985435b4a1c12559f2841f643743a Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Fri, 16 Nov 2018 14:41:47 +0100 Subject: [PATCH 14/34] add -timer option, fix args subroutine --- project/scripts/build.bat | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/project/scripts/build.bat b/project/scripts/build.bat index 92c30b9eba94..bdbfd7e06f74 100644 --- a/project/scripts/build.bat +++ b/project/scripts/build.bat @@ -93,7 +93,7 @@ rem ########################################################################## rem ## Subroutines rem input parameter: %* -rem output parameters: _VERBOSE, _DOCUMENTATION +rem output parameters: _CLONE, _COMPILE, _DOCUMENTATION, _TIMER, _VERBOSE, :args set _ARCHIVES= set _BOOTSTRAP= @@ -102,12 +102,14 @@ set _CLEAN_ALL= set _CLONE= set _DOCUMENTATION= set _HELP= +set _TIMER=0 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%"=="-timer" ( set _TIMER=1 ) else if /i "%__ARG%"=="-verbose" ( set _VERBOSE=1 ) else if /i "%__ARG:~0,4%"=="arch" ( if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _COMPILE=1& set _BOOTSTRAP=1 @@ -117,7 +119,7 @@ if /i "%__ARG%"=="help" ( set _HELP=1& goto :eof set _BOOTSTRAP=1 ) else if /i "%__ARG%"=="cleanall" ( set _CLEAN_ALL=1 ) else if /i "%__ARG%"=="clone" ( set _CLONE=1 -) else if /i "%__ARG%"=="compile" ( +) else if /i "%__ARG:~0,7%"=="compile" ( if not "%__ARG:~-5%"=="-only" set _CLONE=1 set _COMPILE=1 ) else if /i "%__ARG:~0,3%"=="doc" ( @@ -136,6 +138,7 @@ goto :eof :help echo Usage: %_BASENAME% { options ^| subcommands } echo Options: +echo -timer display total build time echo -verbose display environment settings echo Subcommands: echo arch[ives] generate gz/zip archives (after bootstrap) @@ -178,6 +181,9 @@ if %_VERBOSE%==1 ( echo SBT_OPTS=%SBT_OPTS% echo. ) +if %_TIMER%==1 ( + for /f "delims=" %%i in ('powershell -c "(Get-Date)"') do set _TIMER_START=%%i +) goto :eof :clean_all @@ -424,9 +430,27 @@ if %_DEBUG%==1 ( ) goto :eof +rem output parameter: _DURATION +:duration +set __START=%~1 +set __END=%~2 + +for /f "delims=" %%i in ('powershell -c "$interval = New-TimeSpan -Start '%__START%' -End '%__END%'; Write-Host $interval"') do set _DURATION=%%i +goto :eof + +rem input parameter: 1=start time +:total +set __TIMER_START=%~1 + +for /f "delims=" %%i in ('powershell -c "(Get-Date)"') do set __TIMER_END=%%i +call :duration "%_TIMER_START%" "!__TIMER_END!" +echo Total execution time: %_DURATION% +goto :eof + rem ########################################################################## rem ## Cleanups :end +if %_TIMER%==1 call :total "%_TIMER_START%" if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% exit /b %_EXITCODE% From 221a31e2486fee813b330c7a9056d985d802eb3c Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Thu, 22 Nov 2018 17:59:58 +0100 Subject: [PATCH 15/34] updated help text in build.bat --- project/scripts/build.bat | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/project/scripts/build.bat b/project/scripts/build.bat index bdbfd7e06f74..434404f8fc05 100644 --- a/project/scripts/build.bat +++ b/project/scripts/build.bat @@ -138,20 +138,22 @@ goto :eof :help echo Usage: %_BASENAME% { options ^| subcommands } echo Options: -echo -timer display total build time +echo -timer display total execution time 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 compile) -echo boot[strap]-only generate ONLY compiler bootstrap echo cleanall clean project (sbt+git) and quit echo clone update submodules echo compile generate compiler 1st stage (after clone) -echo compile-only generate ONLY compiler 1st stage echo doc[umentation] generate documentation (after bootstrap) -echo doc[umentation]-only] generate ONLY documentation echo help display this help message +echo Advanced subcommands (no deps): +echo arch[ives]-only generate ONLY gz/zip archives +echo boot[strap]-only generate ONLY compiler bootstrap +echo compile-only generate ONLY compiler 1st stage +echo doc[umentation]-only] generate ONLY documentation + goto :eof rem output parameters: _GIT_CMD, _SBT_CMD From 09b8c1866ed5c97e040fb4380fb2329b3ee68d9d Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Sun, 25 Nov 2018 18:32:43 +0100 Subject: [PATCH 16/34] fixed file separator in build.bat --- project/scripts/build.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/scripts/build.bat b/project/scripts/build.bat index 434404f8fc05..82b8c553f650 100644 --- a/project/scripts/build.bat +++ b/project/scripts/build.bat @@ -271,7 +271,7 @@ 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 "%_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 From eb49bd2e86a5e07cca029996b6db5713b650d3d9 Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Mon, 26 Nov 2018 18:19:33 +0100 Subject: [PATCH 17/34] fixed undefined variable (thanks to @liufengyun) --- dist/bin/dotr.bat | 1 - 1 file changed, 1 deletion(-) diff --git a/dist/bin/dotr.bat b/dist/bin/dotr.bat index 61c003af0cae..3d6f1ea22d0e 100644 --- a/dist/bin/dotr.bat +++ b/dist/bin/dotr.bat @@ -70,7 +70,6 @@ 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" ( From 3a00a89e53488313f8be7158128d877fd51ef1ee Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Mon, 26 Nov 2018 23:03:55 +0100 Subject: [PATCH 18/34] fixed handling of jvm opts --- dist/bin/dotc.bat | 6 +++--- dist/bin/dotr.bat | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/bin/dotc.bat b/dist/bin/dotc.bat index c7eade2fc917..b0faeef0e15b 100644 --- a/dist/bin/dotc.bat +++ b/dist/bin/dotc.bat @@ -88,11 +88,11 @@ rem Optimize for short-running applications, see https://github.com/lampepfl/dot 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" ( +) else if "%__ARG:~0,2%"=="-D" ( call :addJava "%__ARG%" call :addScala "%__ARG%" -) else if "%_ARG:~0,2%"=="-J" ( - call :addJava "%__ARG%" +) else if "%__ARG:~0,2%"=="-J" ( + call :addJava "%__ARG:~2%" call :addScala "%__ARG%" ) else ( call :addResidual "%__ARG%" diff --git a/dist/bin/dotr.bat b/dist/bin/dotr.bat index 3d6f1ea22d0e..b9692e61ecac 100644 --- a/dist/bin/dotr.bat +++ b/dist/bin/dotr.bat @@ -45,7 +45,7 @@ rem elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then 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% + set _JAVA_ARGS=%_JAVA_DEBUG% -classpath "!_CP_ARG!" %_JVM_OPTIONS% %_RESIDUAL_ARGS% %_JAVACMD% !_JAVA_ARGS! ) else ( echo Warning: Command option is not correct. 1>&2 @@ -82,8 +82,8 @@ if /i "%__ARG%"=="-repl" ( 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% +) else if /i "%__ARG:~0,2%"=="-J" ( + set _JVM_OPTIONS=!_JVM_OPTIONS! %__ARG:~2% set _JAVA_OPTIONS=!_JAVA_OPTIONS! %__ARG% ) else ( set _RESIDUAL_ARGS=%_RESIDUAL_ARGS% %__ARG% From 205c6937e00c44a40abb24e9ab547553271418b6 Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Fri, 30 Nov 2018 11:31:21 +0100 Subject: [PATCH 19/34] sync tests in :cmdTests subroutine with shell script --- project/scripts/build.bat | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/project/scripts/build.bat b/project/scripts/build.bat index 82b8c553f650..6f6369aa7b9f 100644 --- a/project/scripts/build.bat +++ b/project/scripts/build.bat @@ -24,6 +24,7 @@ set _TESTS_POS_DIR=%_ROOT_DIR%test\pos set _SOURCE=tests/pos/HelloWorld.scala set _MAIN=HelloWorld +set _TASTY=HelloWorld.tasty set _EXPECTED_OUTPUT=hello world call :args %* @@ -142,16 +143,16 @@ echo -timer display total execution time echo -verbose display environment settings echo Subcommands: echo arch[ives] generate gz/zip archives (after bootstrap) -echo boot[strap] generate compiler bootstrap (after compile) +echo boot[strap] generate+test bootstrapped compiler (after compile) echo cleanall clean project (sbt+git) and quit echo clone update submodules -echo compile generate compiler 1st stage (after clone) +echo compile generate+test 1st stage compiler (after clone) echo doc[umentation] generate documentation (after bootstrap) echo help display this help message echo Advanced subcommands (no deps): echo arch[ives]-only generate ONLY gz/zip archives -echo boot[strap]-only generate ONLY compiler bootstrap -echo compile-only generate ONLY compiler 1st stage +echo boot[strap]-only generate+test ONLY bootstrapped compiler +echo compile-only generate+test ONLY 1st stage compiler echo doc[umentation]-only] generate ONLY documentation goto :eof @@ -176,11 +177,17 @@ 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% + for /f %%i in ('where git.exe') do set __GIT_CMD1=%%i + set __GIT_BRANCH=unknown + for /f "tokens=1-4,*" %%f in ('!__GIT_CMD1! branch -vv ^| findstr /b *') do set __GIT_BRANCH=%%g %%i + echo Tool paths + echo GIT_CMD=!__GIT_CMD1! + echo SBT_CMD=%_SBT_CMD% + echo Tool options + echo JAVA_OPTS=%JAVA_OPTS% + echo SBT_OPTS=%SBT_OPTS% + echo Current Git branch + echo !__GIT_BRANCH! echo. ) if %_TIMER%==1 ( @@ -262,6 +269,11 @@ call "%_SBT_CMD%" ";dotc -decompile -color:never -classpath %_OUT_DIR% %_MAIN%" call :grep "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "%_TMP_FILE%" if not %_EXITCODE%==0 goto :eof +echo testing sbt dotc -decompile from file +call "%_SBT_CMD%" ";dotc -decompile -color:never %_OUT_DIR%\%_TASTY%" > "%_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%" From 169a40bcbb82255f9612d151d6f5eaf7e42fb017 Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Sun, 2 Dec 2018 23:28:05 +0100 Subject: [PATCH 20/34] renamed variable (Oracle's JVM knows _JAVA_OPTIONS !) --- dist/bin/dotc.bat | 2 +- dist/bin/dotr.bat | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dist/bin/dotc.bat b/dist/bin/dotc.bat index b0faeef0e15b..9a4b353c28de 100644 --- a/dist/bin/dotc.bat +++ b/dist/bin/dotc.bat @@ -54,7 +54,7 @@ set _RESIDUAL_ARGS= :args_loop if "%~1"=="" goto args_done -set __ARG=%~1 +set "__ARG=%~1" if "%__ARG%"=="--" ( rem for arg; do addResidual "$arg"; done; set -- ;; ) else if /i "%__ARG%"=="-h" ( diff --git a/dist/bin/dotr.bat b/dist/bin/dotr.bat index b9692e61ecac..23ecf372fdd9 100644 --- a/dist/bin/dotr.bat +++ b/dist/bin/dotr.bat @@ -30,7 +30,7 @@ rem if [ $execute_repl == true ] || ([ $execute_run == false ] && [ $options_ind 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% + set _DOTC_ARGS=!_DOTC_ARGS! %_JAVA_OPTS% -repl %_RESIDUAL_ARGS% echo Starting dotty REPL... %_PROG_HOME%\bin\dotc.bat !_DOTC_ARGS! rem elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then @@ -45,7 +45,7 @@ rem elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then 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!" %_JVM_OPTIONS% %_RESIDUAL_ARGS% + set _JAVA_ARGS=%_JAVA_DEBUG% -classpath "!_CP_ARG!" %_JVM_OPTS% %_RESIDUAL_ARGS% %_JAVACMD% !_JAVA_ARGS! ) else ( echo Warning: Command option is not correct. 1>&2 @@ -64,12 +64,12 @@ set _WITH_COMPILER=0 set _JAVA_DEBUG= set _CLASS_PATH_COUNT=0 set _CLASS_PATH= -set _JVM_OPTIONS= -set _JAVA_OPTIONS= +set _JVM_OPTS= +set _JAVA_OPTS= :args_loop -if "%1"=="" goto args_done -set "__ARG=%1" +if "%~1"=="" goto args_done +set "__ARG=%~1" if /i "%__ARG%"=="-repl" ( set _EXECUTE_REPL=1 ) else if /i "%__ARG%"=="-run" ( @@ -83,8 +83,8 @@ if /i "%__ARG%"=="-repl" ( ) else if /i "%__ARG%"=="-d" ( set _JAVA_DEBUG=%_DEBUG_STR% ) else if /i "%__ARG:~0,2%"=="-J" ( - set _JVM_OPTIONS=!_JVM_OPTIONS! %__ARG:~2% - set _JAVA_OPTIONS=!_JAVA_OPTIONS! %__ARG% + set _JVM_OPTS=!_JVM_OPTS! %__ARG:~2% + set _JAVA_OPTS=!_JAVA_OPTS! %__ARG% ) else ( set _RESIDUAL_ARGS=%_RESIDUAL_ARGS% %__ARG% ) From 7f79714f43eb7c94ec6f993744444465686d385f Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Mon, 3 Dec 2018 01:05:12 +0100 Subject: [PATCH 21/34] fixed call instruction in bin/common.bat --- bin/common.bat | 6 +----- bin/dotc.bat | 1 + bin/dotd.bat | 1 + bin/dotr.bat | 1 + 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/bin/common.bat b/bin/common.bat index 264b3fedaa37..e23f13410943 100644 --- a/bin/common.bat +++ b/bin/common.bat @@ -29,11 +29,7 @@ sbt.bat "dist-bootstrapped/pack" popd :target -set _TARGET=%~1 -rem # Mutates %* by deleting the first element (%1) -shift - -call %_TARGET% %* +call %* goto end diff --git a/bin/dotc.bat b/bin/dotc.bat index 6cb1b20510dd..a77ad8be73a8 100644 --- a/bin/dotc.bat +++ b/bin/dotc.bat @@ -1,4 +1,5 @@ @echo off +setlocal for %%f in ("%~dp0..") do set _ROOT_DIR=%%~sf diff --git a/bin/dotd.bat b/bin/dotd.bat index 5544e2bed952..015e234e99cb 100644 --- a/bin/dotd.bat +++ b/bin/dotd.bat @@ -1,4 +1,5 @@ @echo off +setlocal for %%f in ("%~dp0..") do set _ROOT_DIR=%%~sf diff --git a/bin/dotr.bat b/bin/dotr.bat index 3d62849591df..2a25fd5da5c4 100644 --- a/bin/dotr.bat +++ b/bin/dotr.bat @@ -1,4 +1,5 @@ @echo off +setlocal for %%f in ("%~dp0..") do set _ROOT_DIR=%%~sf From 654eb22910c3a85717225df16a60131aa2241cb3 Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Mon, 3 Dec 2018 01:21:37 +0100 Subject: [PATCH 22/34] splitted build.bat into several parts (same as bash scripts) --- project/scripts/bootstrapCmdTests.bat | 125 ++++++++++++ project/scripts/build.bat | 281 +++++--------------------- project/scripts/cmdTests.bat | 102 ++++++++++ project/scripts/common.bat | 62 ++++++ project/scripts/genDocs.bat | 93 +++++++++ 5 files changed, 437 insertions(+), 226 deletions(-) create mode 100644 project/scripts/bootstrapCmdTests.bat create mode 100644 project/scripts/cmdTests.bat create mode 100644 project/scripts/common.bat create mode 100644 project/scripts/genDocs.bat diff --git a/project/scripts/bootstrapCmdTests.bat b/project/scripts/bootstrapCmdTests.bat new file mode 100644 index 000000000000..23abebe569b6 --- /dev/null +++ b/project/scripts/bootstrapCmdTests.bat @@ -0,0 +1,125 @@ +@echo off + +rem ########################################################################## +rem ## This batch file is based on shell script project/scripts/bootstrapCmdTests + +setlocal enabledelayedexpansion + +rem only for interactive debugging +set _DEBUG=0 + +rem ########################################################################## +rem ## Environment setup + +set _BASENAME=%~n0 + +set _EXITCODE=0 + +for %%f in ("%~dp0..\..") do set _ROOT_DIR=%%~sf +set _SCRIPTS_DIR=%_ROOT_DIR%\project\scripts +set _BIN_DIR=%_ROOT_DIR%\bin + +if not defined __COMMON__ ( + if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\common.bat + call %_SCRIPTS_DIR%\common.bat + if not !_EXITCODE!==0 goto end +) + +rem ########################################################################## +rem ## Main + +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" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) + +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 end + +rem # setup for `dotc`/`dotr` script tests +if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" dist-bootstrapped/pack +call "%_SBT_CMD%" dist-bootstrapped/pack +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) + +rem # check that `dotc` compiles and `dotr` runs it +echo testing ./bin/dotc and ./bin/dotr +call :clear_out "%_OUT_DIR%" +if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotc.bat "%_SOURCE%" -d "%_OUT_DIR%" +call %_BIN_DIR%\dotc.bat "%_SOURCE%" -d "%_OUT_DIR%" +if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotr.bat -classpath "%_OUT_DIR%" "%_MAIN%" ^> "%_TMP_FILE%" +call %_BIN_DIR%\dotr.bat -classpath "%_OUT_DIR%" "%_MAIN%" > "%_TMP_FILE%" +if %_DEBUG%==1 echo [%_BASENAME%] call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" +call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" +if not %_EXITCODE%==0 goto end + +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%" +if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotc.bat -from-tasty -classpath "%_OUT_DIR%" -d "%_OUT1_DIR%" "%_MAIN%" +call %_BIN_DIR%\dotc.bat -from-tasty -classpath "%_OUT_DIR%" -d "%_OUT1_DIR%" "%_MAIN%" +if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotr.bat -classpath "%_OUT1_DIR%" "%_MAIN%" ^> "%_TMP_FILE%" +call %_BIN_DIR%\dotr.bat -classpath "%_OUT1_DIR%" "%_MAIN%" > "%_TMP_FILE%" +if %_DEBUG%==1 echo [%_BASENAME%] call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" +call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" +if not %_EXITCODE%==0 goto end + +rem # echo ":quit" | ./dist-bootstrapped/target/pack/bin/dotr # not supported by CI + +echo testing ./bin/dotd +call :clear_out "%_OUT_DIR%" +if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotd.bat -project Hello -siteroot "%_OUT_DIR%" "%_SOURCE%" +call %_BIN_DIR%\dotd.bat -project Hello -siteroot "%_OUT_DIR%" "%_SOURCE%" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) + +goto end + +rem ########################################################################## +rem ## Subroutines + +: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 + +: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 ########################################################################## +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 index 6f6369aa7b9f..a0cddc7e9848 100644 --- a/project/scripts/build.bat +++ b/project/scripts/build.bat @@ -1,4 +1,8 @@ @echo off + +rem ########################################################################## +rem ## This batch file is based on configuration file .drone.yml + setlocal enabledelayedexpansion rem only for interactive debugging @@ -11,47 +15,21 @@ set _BASENAME=%~n0 set _EXITCODE=0 -set _BOT_TOKEN=dotty-token +for %%f in ("%~dp0..\..") do set _ROOT_DIR=%%~sf +set _SCRIPTS_DIR=%_ROOT_DIR%\project\scripts + +call %_SCRIPTS_DIR%\common.bat +if not %_EXITCODE%==0 goto end 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 _TASTY=HelloWorld.tasty -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 @@ -79,11 +57,14 @@ if defined _BOOTSTRAP ( ) ) ) +if defined _SBT ( + call :test_sbt + if not !_EXITCODE!==0 goto end +) if defined _DOCUMENTATION ( call :documentation if not !_EXITCODE!==0 goto end ) - if defined _ARCHIVES ( call :archives if not !_EXITCODE!==0 goto end @@ -94,7 +75,7 @@ rem ########################################################################## rem ## Subroutines rem input parameter: %* -rem output parameters: _CLONE, _COMPILE, _DOCUMENTATION, _TIMER, _VERBOSE, +rem output parameters: _CLONE, _COMPILE, _DOCUMENTATION, _SBT, _TIMER, _VERBOSE :args set _ARCHIVES= set _BOOTSTRAP= @@ -103,6 +84,7 @@ set _CLEAN_ALL= set _CLONE= set _DOCUMENTATION= set _HELP= +set _SBT= set _TIMER=0 set _VERBOSE=0 @@ -126,8 +108,12 @@ if /i "%__ARG%"=="help" ( set _HELP=1& goto :eof ) else if /i "%__ARG:~0,3%"=="doc" ( if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _COMPILE=1& set _BOOTSTRAP=1 set _DOCUMENTATION=1 +) else if /i "%__ARG%"=="sbt" ( + set _CLONE=1& set _COMPILE=1& set _BOOTSTRAP=1& set _SBT=1 +) else if /i "%__ARG%"=="sbt-only" ( + set _SBT=1 ) else ( - echo Error: Unknown subcommand %__ARG% + echo Error: Unknown subcommand %__ARG% 1>&2 set _EXITCODE=1 goto :eof ) @@ -149,45 +135,29 @@ echo clone update submodules echo compile generate+test 1st stage compiler (after clone) echo doc[umentation] generate documentation (after bootstrap) echo help display this help message +echo sbt test sbt-dotty (after bootstrap) echo Advanced subcommands (no deps): echo arch[ives]-only generate ONLY gz/zip archives echo boot[strap]-only generate+test ONLY bootstrapped compiler echo compile-only generate+test ONLY 1st stage compiler echo doc[umentation]-only] generate ONLY documentation +echo sbt-only test ONLY sbt-dotty 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 set __GIT_BRANCH=unknown for /f "tokens=1-4,*" %%f in ('!__GIT_CMD1! branch -vv ^| findstr /b *') do set __GIT_BRANCH=%%g %%i echo Tool paths - echo GIT_CMD=!__GIT_CMD1! + echo GIT_CMD=!__GIT_CMD1! echo SBT_CMD=%_SBT_CMD% echo Tool options - echo JAVA_OPTS=%JAVA_OPTS% + echo JAVA_OPTS=%JAVA_OPTS% echo SBT_OPTS=%SBT_OPTS% - echo Current Git branch - echo !__GIT_BRANCH! + echo Current Git branch + echo !__GIT_BRANCH! echo. ) if %_TIMER%==1 ( @@ -196,15 +166,15 @@ if %_TIMER%==1 ( goto :eof :clean_all -echo run sbt clean and git clean -xdf +echo run sbt clean and git clean -xdf --exclude=*.bat --exclude=*.ps1 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 %_DEBUG%==1 echo [%_BASENAME%] %_GIT_CMD% clean -xdf --exclude=*.bat --exclude=*.ps1 +%_GIT_CMD% clean -xdf --exclude=*.bat --exclude=*.ps1 if not %ERRORLEVEL%==0 ( set _EXITCODE=1 goto :eof @@ -226,69 +196,6 @@ if not %ERRORLEVEL%==0 ( ) 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 dotc -decompile from file -call "%_SBT_CMD%" ";dotc -decompile -color:never %_OUT_DIR%\%_TASTY%" > "%_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 echo sbt compile and sbt test if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";compile ;test" @@ -299,132 +206,53 @@ if not %ERRORLEVEL%==0 ( 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 +rem see shell script project/scripts/cmdTests +if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\cmdTests.bat +call %_SCRIPTS_DIR%\cmdTests.bat +if not %ERRORLEVEL%==0 ( + echo Error: Failed to run cmdTest.bat 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 + 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 +rem see shell script project/scripts/bootstrapCmdTests +if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\bootstrapCmdTests.bat +call %_SCRIPTS_DIR%\bootstrapCmdTests.bat +if not %ERRORLEVEL%==0 ( + echo Error: Failed to run bootstrapCmdTests.bat 1>&2 set _EXITCODE=1 goto :eof ) -for /f %%i in ('cd') do set _PWD=%%~si - -echo Working directory: %_PWD% - -call "%_SBT_CMD%" genDocs +goto :eof -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 +:test_sbt +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" sbt-dotty/scripted +call "%_SBT_CMD%" sbt-dotty/scripted +if not %ERRORLEVEL%==0 ( + echo Error: Failed to test sbt-dotty 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" - +:documentation +rem see shell script project/scripts/genDocs +if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\genDocs.bat +call %_SCRIPTS_DIR%\genDocs.bat +if not %ERRORLEVEL%==0 ( + set _EXITCODE=1 + goto :eof +) goto :eof :archives @@ -468,3 +296,4 @@ rem ## Cleanups if %_TIMER%==1 call :total "%_TIMER_START%" if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% exit /b %_EXITCODE% +endlocal diff --git a/project/scripts/cmdTests.bat b/project/scripts/cmdTests.bat new file mode 100644 index 000000000000..80d72f018bca --- /dev/null +++ b/project/scripts/cmdTests.bat @@ -0,0 +1,102 @@ +@echo off + +rem ########################################################################## +rem ## This batch file is based on shell script project/scripts/cmdTests + +setlocal enabledelayedexpansion + +rem only for interactive debugging +set _DEBUG=0 + +rem ########################################################################## +rem ## Environment setup + +set _BASENAME=%~n0 + +set _EXITCODE=0 + +for %%f in ("%~dp0..\..") do set _ROOT_DIR=%%~sf +set _SCRIPTS_DIR=%_ROOT_DIR%\project\scripts + +if not defined __COMMON__ ( + if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\common.bat + call %_SCRIPTS_DIR%\common.bat + if not !_EXITCODE!==0 goto end +) + +rem ########################################################################## +rem ## Main + +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 end + +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 end + +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 end + +echo testing sbt dotc -decompile from file +call "%_SBT_CMD%" ";dotc -decompile -color:never %_OUT_DIR%\%_TASTY%" > "%_TMP_FILE%" +call :grep "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "%_TMP_FILE%" +if not %_EXITCODE%==0 goto end + +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 end + +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 end + +goto end + +rem ########################################################################## +rem ## Subroutines + +: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 ########################################################################## +rem ## Cleanups + +:end +if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% +exit /b %_EXITCODE% +endlocal + + diff --git a/project/scripts/common.bat b/project/scripts/common.bat new file mode 100644 index 000000000000..09f61adcad3b --- /dev/null +++ b/project/scripts/common.bat @@ -0,0 +1,62 @@ +rem ########################################################################## +rem ## This code is called in build.bat, cmdTests.bat and bootstrapCmdTest.bat + +rem Flag set to ensure common code is run only once +set __COMMON__= + +set _BOT_TOKEN=dotty-token + +rem set _DRONE_BUILD_EVENT=pull_request +set _DRONE_BUILD_EVENT= +set _DRONE_REMOTE_URL= +set _DRONE_BRANCH= + +set _SOURCE=tests\pos\HelloWorld.scala +set _MAIN=HelloWorld +set _TASTY=HelloWorld.tasty +set _EXPECTED_OUTPUT=hello world + +if exist "C:\Temp\" ( set _TMP_DIR=C:\Temp +) else ( set _TMP_DIR=%TEMP% +) +set _OUT_DIR=%_TMP_DIR%\dotty_out +if not exist "%_OUT_DIR%" mkdir "%_OUT_DIR%" + +set _OUT1_DIR=%_TMP_DIR%\dotty_out1 +if not exist "%_OUT1_DIR%" mkdir "%_OUT1_DIR%" + +set _TMP_FILE=%_TMP_DIR%\dotty_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 :eof +) +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 :eof +) +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=-Xmx2048m ^ +-XX:ReservedCodeCacheSize=2048m ^ +-XX:MaxMetaspaceSize=1024m + +set _USER_HOME=%USERPROFILE% +for /f "delims=\" %%i in ('subst ^| findstr /e "%_USER_HOME%"') do ( + set _USER_HOME=%%i +) +set SBT_OPTS=-Ddotty.drone.mem=4096m ^ +-Dsbt.ivy.home=%_USER_HOME%\.ivy2\ ^ +-Dsbt.log.noformat=true + +rem this batch file was executed successfully +set __COMMON__=1 diff --git a/project/scripts/genDocs.bat b/project/scripts/genDocs.bat new file mode 100644 index 000000000000..5beab2cb9705 --- /dev/null +++ b/project/scripts/genDocs.bat @@ -0,0 +1,93 @@ +@echo off + +rem ########################################################################## +rem ## This batch file is based on shell script project/scripts/genDocs + +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 + +for %%f in ("%~dp0..\..") do set _ROOT_DIR=%%~sf +set _SCRIPTS_DIR=%_ROOT_DIR%\project\scripts + +if not defined __COMMON__ ( + if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\common.bat + call %_SCRIPTS_DIR%\common.bat + if not !_EXITCODE!==0 goto end +) + +rem ########################################################################## +rem ## Main + +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 end +) +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 end +) + +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 end + +rem ########################################################################## +rem ## Subroutines + +rem ########################################################################## +rem ## Cleanups + +:end +if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% +exit /b %_EXITCODE% +endlocal From b1af46c0a604ed38fcc89b6c52372f64b66df6c6 Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Mon, 3 Dec 2018 11:22:00 +0100 Subject: [PATCH 23/34] added missing ERRORLEVEL tests --- project/scripts/bootstrapCmdTests.bat | 12 ++++++++++-- project/scripts/cmdTests.bat | 10 ++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/project/scripts/bootstrapCmdTests.bat b/project/scripts/bootstrapCmdTests.bat index 23abebe569b6..f6d43eadb40e 100644 --- a/project/scripts/bootstrapCmdTests.bat +++ b/project/scripts/bootstrapCmdTests.bat @@ -34,11 +34,17 @@ call "%_SBT_CMD%" "dotty-bench/jmh:run 1 1 tests/pos/alias.scala" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) rem # The above is here as it relies on the bootstrapped library. +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 tests/pos/alias.scala" call "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 tests/pos/alias.scala" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 -with-compiler compiler/src/dotty/tools/dotc/core/Types.scala" call "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 -with-compiler compiler/src/dotty/tools/dotc/core/Types.scala" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) echo testing scala.quoted.Expr.run from sbt dotr +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";dotty-compiler-bootstrapped/dotc tests/run-with-compiler/quote-run.scala; dotty-compiler-bootstrapped/dotr -with-compiler Test" ^> "%_TMP_FILE%" call "%_SBT_CMD%" ";dotty-compiler-bootstrapped/dotc tests/run-with-compiler/quote-run.scala; dotty-compiler-bootstrapped/dotr -with-compiler Test" > "%_TMP_FILE%" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) call :grep "val a: scala.Int = 3" "%_TMP_FILE%" if not %_EXITCODE%==0 goto end @@ -52,8 +58,10 @@ echo testing ./bin/dotc and ./bin/dotr call :clear_out "%_OUT_DIR%" if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotc.bat "%_SOURCE%" -d "%_OUT_DIR%" call %_BIN_DIR%\dotc.bat "%_SOURCE%" -d "%_OUT_DIR%" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotr.bat -classpath "%_OUT_DIR%" "%_MAIN%" ^> "%_TMP_FILE%" call %_BIN_DIR%\dotr.bat -classpath "%_OUT_DIR%" "%_MAIN%" > "%_TMP_FILE%" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) if %_DEBUG%==1 echo [%_BASENAME%] call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" if not %_EXITCODE%==0 goto end @@ -63,14 +71,14 @@ echo testing ./bin/dotc -from-tasty and dotr -classpath call :clear_out "%_OUT1_DIR%" if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotc.bat -from-tasty -classpath "%_OUT_DIR%" -d "%_OUT1_DIR%" "%_MAIN%" call %_BIN_DIR%\dotc.bat -from-tasty -classpath "%_OUT_DIR%" -d "%_OUT1_DIR%" "%_MAIN%" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotr.bat -classpath "%_OUT1_DIR%" "%_MAIN%" ^> "%_TMP_FILE%" call %_BIN_DIR%\dotr.bat -classpath "%_OUT1_DIR%" "%_MAIN%" > "%_TMP_FILE%" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) if %_DEBUG%==1 echo [%_BASENAME%] call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" if not %_EXITCODE%==0 goto end -rem # echo ":quit" | ./dist-bootstrapped/target/pack/bin/dotr # not supported by CI - echo testing ./bin/dotd call :clear_out "%_OUT_DIR%" if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotd.bat -project Hello -siteroot "%_OUT_DIR%" "%_SOURCE%" diff --git a/project/scripts/cmdTests.bat b/project/scripts/cmdTests.bat index 80d72f018bca..1ddf20c99d18 100644 --- a/project/scripts/cmdTests.bat +++ b/project/scripts/cmdTests.bat @@ -30,24 +30,31 @@ rem ## Main 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%" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) call :grep "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" if not %_EXITCODE%==0 goto end 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%" +if %_DEBUG%==1 echo [%_BASENAME%] 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 "%_SBT_CMD%" ";dotc %_SOURCE% -d %_OUT_DIR% ;dotc -from-tasty -classpath %_OUT_DIR% -d %_OUT1_DIR% %_MAIN% ;dotr -classpath %_OUT1_DIR% %_MAIN%" > "%_TMP_FILE%" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) call :grep "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" if not %_EXITCODE%==0 goto end rem # check that `sbt dotc -decompile` runs echo testing sbt dotc -decompile +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";dotc -decompile -color:never -classpath %_OUT_DIR% %_MAIN%" ^> "%_TMP_FILE%" call "%_SBT_CMD%" ";dotc -decompile -color:never -classpath %_OUT_DIR% %_MAIN%" > "%_TMP_FILE%" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) call :grep "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "%_TMP_FILE%" if not %_EXITCODE%==0 goto end echo testing sbt dotc -decompile from file +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";dotc -decompile -color:never %_OUT_DIR%\%_TASTY%" ^> "%_TMP_FILE%" call "%_SBT_CMD%" ";dotc -decompile -color:never %_OUT_DIR%\%_TASTY%" > "%_TMP_FILE%" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) call :grep "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "%_TMP_FILE%" if not %_EXITCODE%==0 goto end @@ -55,12 +62,15 @@ 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%" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) call :grep "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" if not %_EXITCODE%==0 goto end echo testing loading tasty from .tasty file in jar call :clear_out "%_OUT_DIR%" +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";dotc -d %_OUT_DIR%\out.jar %_SOURCE%; dotc -decompile -classpath %_OUT_DIR%\out.jar -color:never %_MAIN%" ^> "%_TMP_FILE%" call "%_SBT_CMD%" ";dotc -d %_OUT_DIR%\out.jar %_SOURCE%; dotc -decompile -classpath %_OUT_DIR%\out.jar -color:never %_MAIN%" > "%_TMP_FILE%" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) call :grep "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "%_TMP_FILE%" if not %_EXITCODE%==0 goto end From 4b5a2bb89b7579356dadb98a48b8afb8d4a04f89 Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Wed, 5 Dec 2018 09:02:57 +0100 Subject: [PATCH 24/34] added missing classpath option --- project/scripts/cmdTests.bat | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/project/scripts/cmdTests.bat b/project/scripts/cmdTests.bat index 1ddf20c99d18..5cf974799262 100644 --- a/project/scripts/cmdTests.bat +++ b/project/scripts/cmdTests.bat @@ -27,6 +27,7 @@ if not defined __COMMON__ ( rem ########################################################################## rem ## Main +rem # check that `sbt dotc` compiles and `sbt dotr` runs it 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%" @@ -52,8 +53,8 @@ call :grep "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "% if not %_EXITCODE%==0 goto end echo testing sbt dotc -decompile from file -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";dotc -decompile -color:never %_OUT_DIR%\%_TASTY%" ^> "%_TMP_FILE%" -call "%_SBT_CMD%" ";dotc -decompile -color:never %_OUT_DIR%\%_TASTY%" > "%_TMP_FILE%" +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";dotc -decompile -color:never -classpath %_OUT_DIR% %_OUT_DIR%\%_TASTY%" ^> "%_TMP_FILE%" +call "%_SBT_CMD%" ";dotc -decompile -color:never -classpath %_OUT_DIR% %_OUT_DIR%\%_TASTY%" > "%_TMP_FILE%" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) call :grep "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "%_TMP_FILE%" if not %_EXITCODE%==0 goto end From 0a59fb3c7a5589b210942cae6e1fa2e236f1f9cf Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Sat, 15 Dec 2018 20:08:32 +0100 Subject: [PATCH 25/34] fixed exit code --- dist/bin/dotr.bat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dist/bin/dotr.bat b/dist/bin/dotr.bat index 23ecf372fdd9..cc67e2d623f8 100644 --- a/dist/bin/dotr.bat +++ b/dist/bin/dotr.bat @@ -47,6 +47,7 @@ rem elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then ) set _JAVA_ARGS=%_JAVA_DEBUG% -classpath "!_CP_ARG!" %_JVM_OPTS% %_RESIDUAL_ARGS% %_JAVACMD% !_JAVA_ARGS! + if not !ERRORLEVEL!==0 ( set _EXITCODE=1& goto end ) ) else ( echo Warning: Command option is not correct. 1>&2 ) @@ -75,7 +76,7 @@ if /i "%__ARG%"=="-repl" ( ) else if /i "%__ARG%"=="-run" ( set _EXECUTE_RUN=1 ) else if /i "%__ARG%"=="-classpath" ( - set _CLASS_PATH=%2 + set _CLASS_PATH=%~2 set /a _CLASS_PATH_COUNT+=1 shift ) else if /i "%__ARG%"=="-with-compiler" ( From 43ebc476fef94628c5dde62aa908bc6e289eb2df Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Sat, 5 Jan 2019 14:46:01 +0100 Subject: [PATCH 26/34] fixed computation of _JAVACMD in common.bat --- dist/bin/common.bat | 10 +++++++--- project/scripts/build.bat | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/dist/bin/common.bat b/dist/bin/common.bat index 1d333d7b7a6f..62325b5b925f 100644 --- a/dist/bin/common.bat +++ b/dist/bin/common.bat @@ -10,9 +10,13 @@ if defined JAVACMD ( ) 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 + set __JAVA_BIN_DIR= + for /f "delims=" %%i in ('where /f java.exe') do ( + set __PATH=%%~dpsi + rem we take first occurence and ignore Oracle path for java executable + if not defined __JAVA_BIN_DIR if "!__PATH!"=="!__PATH:javapath=!" set __JAVA_BIN_DIR=!__PATH! + ) + if defined __JAVA_BIN_DIR set _JAVACMD=!__JAVA_BIN_DIR!\java.exe ) if not defined _JAVACMD ( set _PATH=C:\Progra~1\Java diff --git a/project/scripts/build.bat b/project/scripts/build.bat index a0cddc7e9848..e861a101b354 100644 --- a/project/scripts/build.bat +++ b/project/scripts/build.bat @@ -120,6 +120,9 @@ if /i "%__ARG%"=="help" ( set _HELP=1& goto :eof shift goto args_loop :args_done +if %_TIMER%==1 ( + for /f "delims=" %%i in ('powershell -c "(Get-Date)"') do set _TIMER_START=%%i +) goto :eof :help @@ -160,9 +163,6 @@ if %_VERBOSE%==1 ( echo !__GIT_BRANCH! echo. ) -if %_TIMER%==1 ( - for /f "delims=" %%i in ('powershell -c "(Get-Date)"') do set _TIMER_START=%%i -) goto :eof :clean_all From dc639e251a605af6954f74cd3efe0de2433677ac Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Wed, 9 Jan 2019 14:16:34 +0100 Subject: [PATCH 27/34] removed variable COLORS (use option -color:always|never instead) --- dist/bin/dotc.bat | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dist/bin/dotc.bat b/dist/bin/dotc.bat index 9a4b353c28de..b308d160be55 100644 --- a/dist/bin/dotc.bat +++ b/dist/bin/dotc.bat @@ -47,7 +47,6 @@ set _JAVA_DEBUG= set _HELP= set _VERBOSE= set _QUIET= -set _COLORS= set _SCALA_ARGS= set _JAVA_ARGS= set _RESIDUAL_ARGS= @@ -78,12 +77,10 @@ rem Optimize for short-running applications, see https://github.com/lampepfl/dot ) 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%"=="-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 From 8dce9ac1cb38913f8c9fd3b1c1b1231fd70e4cd9 Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Mon, 14 Jan 2019 15:13:34 +0100 Subject: [PATCH 28/34] fixed name of -Oshort option, removed 2 subroutine calls --- dist/bin/dotc.bat | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/dist/bin/dotc.bat b/dist/bin/dotc.bat index b308d160be55..676fa4bf0856 100644 --- a/dist/bin/dotc.bat +++ b/dist/bin/dotc.bat @@ -33,7 +33,6 @@ if defined JAVA_OPTS ( set _JAVA_OPTS=%JAVA_OPTS% -Dscala.usejavacp=true ^ %_PROG_NAME% %_SCALA_ARGS% %_RESIDUAL_ARGS% if not %ERRORLEVEL%==0 ( - rem echo Error: Dotty compiler execution failed 1>&2 set _EXITCODE=1 goto end ) @@ -72,7 +71,7 @@ if "%__ARG%"=="--" ( ) 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%"=="-Oshort" ( 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% @@ -85,14 +84,9 @@ rem Optimize for short-running applications, see https://github.com/lampepfl/dot 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:~2%" - call :addScala "%__ARG%" -) else ( - call :addResidual "%__ARG%" +) else if "%__ARG:~0,2%"=="-D" ( call :addJava "%__ARG%" +) else if "%__ARG:~0,2%"=="-J" ( call :addJava "%__ARG:~2%" +) else ( call :addResidual "%__ARG%" ) shift goto args_loop From a723c27ee3ac00b8505276d9be85401b2db93267 Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Wed, 23 Jan 2019 10:50:43 +0100 Subject: [PATCH 29/34] improved error messages in build.bat --- project/scripts/build.bat | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/project/scripts/build.bat b/project/scripts/build.bat index e861a101b354..8132f5502b01 100644 --- a/project/scripts/build.bat +++ b/project/scripts/build.bat @@ -113,7 +113,7 @@ if /i "%__ARG%"=="help" ( set _HELP=1& goto :eof ) else if /i "%__ARG%"=="sbt-only" ( set _SBT=1 ) else ( - echo Error: Unknown subcommand %__ARG% 1>&2 + echo Error: Unknown subcommand %__ARG% 1>&2 set _EXITCODE=1 goto :eof ) @@ -201,7 +201,7 @@ echo sbt compile and sbt 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 + echo Error: Failed to run sbt command ";compile ;test" 1>&2 set _EXITCODE=1 goto :eof ) @@ -210,7 +210,7 @@ rem see shell script project/scripts/cmdTests if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\cmdTests.bat call %_SCRIPTS_DIR%\cmdTests.bat if not %ERRORLEVEL%==0 ( - echo Error: Failed to run cmdTest.bat 1>&2 + echo Error: Failed to run cmdTest.bat 1>&2 set _EXITCODE=1 goto :eof ) @@ -220,7 +220,7 @@ goto :eof 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 + echo Error: Failed to run sbt command ";dotty-bootstrapped/compile ;dotty-bootstrapped/test" 1>&2 set _EXITCODE=1 goto :eof ) @@ -229,7 +229,7 @@ rem see shell script project/scripts/bootstrapCmdTests if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\bootstrapCmdTests.bat call %_SCRIPTS_DIR%\bootstrapCmdTests.bat if not %ERRORLEVEL%==0 ( - echo Error: Failed to run bootstrapCmdTests.bat 1>&2 + echo Error: Failed to run bootstrapCmdTests.bat 1>&2 set _EXITCODE=1 goto :eof ) @@ -239,7 +239,7 @@ goto :eof if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" sbt-dotty/scripted call "%_SBT_CMD%" sbt-dotty/scripted if not %ERRORLEVEL%==0 ( - echo Error: Failed to test sbt-dotty 1>&2 + echo Error: Failed to run sbt command sbt-dotty/scripted 1>&2 set _EXITCODE=1 goto :eof ) @@ -250,6 +250,7 @@ rem see shell script project/scripts/genDocs if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\genDocs.bat call %_SCRIPTS_DIR%\genDocs.bat if not %ERRORLEVEL%==0 ( + echo Error: Failed to run genDocs.bat 1>&2 set _EXITCODE=1 goto :eof ) @@ -261,7 +262,7 @@ 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 + echo Error: Directory target not found 1>&2 set _EXITCODE=1 goto :eof ) From c4e56f36be1babf6c07059987beaa285f7ebc9bf Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Sat, 9 Feb 2019 12:57:11 +0100 Subject: [PATCH 30/34] added community-build to batch script --- project/scripts/build.bat | 45 +++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/project/scripts/build.bat b/project/scripts/build.bat index 8132f5502b01..3125890a476c 100644 --- a/project/scripts/build.bat +++ b/project/scripts/build.bat @@ -57,6 +57,10 @@ if defined _BOOTSTRAP ( ) ) ) +if defined _COMMUNITY ( + call :community_build + if not !_EXITCODE!==0 goto end +) if defined _SBT ( call :test_sbt if not !_EXITCODE!==0 goto end @@ -82,6 +86,7 @@ set _BOOTSTRAP= set _COMPILE= set _CLEAN_ALL= set _CLONE= +set _COMMUNITY= set _DOCUMENTATION= set _HELP= set _SBT= @@ -105,6 +110,9 @@ if /i "%__ARG%"=="help" ( set _HELP=1& goto :eof ) else if /i "%__ARG:~0,7%"=="compile" ( if not "%__ARG:~-5%"=="-only" set _CLONE=1 set _COMPILE=1 +) else if /i "%__ARGS:~0,9%"=="community" ( + if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _COMPILE=1& set _BOOTSTRAP=1 + set _COMMUNITY=1 ) else if /i "%__ARG:~0,3%"=="doc" ( if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _COMPILE=1& set _BOOTSTRAP=1 set _DOCUMENTATION=1 @@ -115,7 +123,7 @@ if /i "%__ARG%"=="help" ( set _HELP=1& goto :eof ) else ( echo Error: Unknown subcommand %__ARG% 1>&2 set _EXITCODE=1 - goto :eof + goto :args_done ) shift goto args_loop @@ -136,6 +144,7 @@ echo boot[strap] generate+test bootstrapped compiler (after compi echo cleanall clean project (sbt+git) and quit echo clone update submodules echo compile generate+test 1st stage compiler (after clone) +echo community test community-build (after bootstrap) echo doc[umentation] generate documentation (after bootstrap) echo help display this help message echo sbt test sbt-dotty (after bootstrap) @@ -143,6 +152,7 @@ echo Advanced subcommands (no deps): echo arch[ives]-only generate ONLY gz/zip archives echo boot[strap]-only generate+test ONLY bootstrapped compiler echo compile-only generate+test ONLY 1st stage compiler +echo community-only test ONLY community-build echo doc[umentation]-only] generate ONLY documentation echo sbt-only test ONLY sbt-dotty @@ -150,17 +160,23 @@ goto :eof :init if %_VERBOSE%==1 ( - for /f %%i in ('where git.exe') do set __GIT_CMD1=%%i - set __GIT_BRANCH=unknown - for /f "tokens=1-4,*" %%f in ('!__GIT_CMD1! branch -vv ^| findstr /b *') do set __GIT_BRANCH=%%g %%i + for /f "delims=" %%i in ('where git.exe') do ( + if not defined __GIT_CMD1 set __GIT_CMD1=%%i + ) + for /f "delims=" %%i in ('where java.exe') do ( + if not defined __JAVA_CMD1 set __JAVA_CMD1=%%i + ) + set __BRANCH_NAME=unknown + for /f %%i in ('!__GIT_CMD1! rev-parse --abbrev-ref HEAD') do set __BRANCH_NAME=%%i echo Tool paths echo GIT_CMD=!__GIT_CMD1! + echo JAVA_CMD=!__JAVA_CMD1! echo SBT_CMD=%_SBT_CMD% echo Tool options echo JAVA_OPTS=%JAVA_OPTS% echo SBT_OPTS=%SBT_OPTS% - echo Current Git branch - echo !__GIT_BRANCH! + echo Current Git branch: + echo !__BRANCH_NAME! echo. ) goto :eof @@ -235,6 +251,23 @@ if not %ERRORLEVEL%==0 ( ) goto :eof +:community_build +if %_DEBUG%==1 echo [%_BASENAME%] %_GIT_CMD% submodule update --init --recursive --jobs 7 +%_GIT_CMD% submodule update --init --recursive --jobs 7 +if not %ERRORLEVEL%==0 ( + echo Error: Failed to update Git submodules 1>&2 + set _EXITCODE=1 + goto :eof +) +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" community-build/test +call "%_SBT_CMD%" community-build/test +if not %ERRORLEVEL%==0 ( + echo Error: Failed to run sbt command community-build/test 1>&2 + set _EXITCODE=1 + goto :eof +) +goto :eof + :test_sbt if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" sbt-dotty/scripted call "%_SBT_CMD%" sbt-dotty/scripted From 7f28baae4402a6f2ee959c0455e8c2c3e1d76659 Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Mon, 10 Jun 2019 19:49:51 +0200 Subject: [PATCH 31/34] removed scala-xml dependency --- dist/bin/common | 1 - dist/bin/common.bat | 3 ++- dist/bin/dotc | 1 - dist/bin/dotc.bat | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/dist/bin/common b/dist/bin/common index 3d2ef0a549e2..e039bc369714 100755 --- a/dist/bin/common +++ b/dist/bin/common @@ -109,7 +109,6 @@ DOTTY_INTF=$(find_lib "*dotty-interfaces*") DOTTY_LIB=$(find_lib "*dotty-library*") SCALA_ASM=$(find_lib "*scala-asm*") SCALA_LIB=$(find_lib "*scala-library*") -SCALA_XML=$(find_lib "*scala-xml*") SBT_INTF=$(find_lib "*compiler-interface*") JLINE_READER=$(find_lib "*jline-reader-3*") JLINE_TERMINAL=$(find_lib "*jline-terminal-3*") diff --git a/dist/bin/common.bat b/dist/bin/common.bat index 62325b5b925f..115ce0bac890 100644 --- a/dist/bin/common.bat +++ b/dist/bin/common.bat @@ -52,7 +52,8 @@ for /f %%f in ('dir /a-d /b "%_LIB_DIR%\*dotty-interfaces*"') do set _DOTTY_ 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 +rem removed since version 0.16.x (#5597) +rem 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 diff --git a/dist/bin/dotc b/dist/bin/dotc index 70154e490511..894f16641730 100755 --- a/dist/bin/dotc +++ b/dist/bin/dotc @@ -52,7 +52,6 @@ classpathArgs () { # echo "dotty-library: $DOTTY_LIB" # echo "scala-asm: $SCALA_ASM" # echo "scala-lib: $SCALA_LIB" - # echo "scala-xml: $SCALA_XML" # echo "sbt-intface: $SBT_INTF" toolchain="" diff --git a/dist/bin/dotc.bat b/dist/bin/dotc.bat index 676fa4bf0856..ac939e97265f 100644 --- a/dist/bin/dotc.bat +++ b/dist/bin/dotc.bat @@ -115,7 +115,6 @@ 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% From cc65906c1c4e3a2de0d4dbf861eb9089e2b3c7bd Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Wed, 4 Sep 2019 10:49:54 +0200 Subject: [PATCH 32/34] updated batch scripts for dotty-staging --- community-build/community-projects/ScalaPB | 2 +- community-build/community-projects/algebra | 2 +- .../community-projects/betterfiles | 2 +- community-build/community-projects/fastparse | 2 +- community-build/community-projects/minitest | 2 +- community-build/community-projects/scala-xml | 2 +- community-build/community-projects/scalacheck | 2 +- community-build/community-projects/scalap | 2 +- community-build/community-projects/scalatest | 2 +- community-build/community-projects/scopt | 2 +- community-build/community-projects/shapeless | 2 +- community-build/community-projects/sourcecode | 2 +- community-build/community-projects/squants | 2 +- community-build/community-projects/stdLib213 | 2 +- dist/bin/common.bat | 1 + dist/bin/dotc.bat | 1 + dist/bin/dotd.bat | 2 +- dist/bin/dotr.bat | 2 +- project/scripts/bootstrapCmdTests.bat | 9 ++++ project/scripts/build.bat | 50 +++++++++++++++---- 20 files changed, 66 insertions(+), 27 deletions(-) diff --git a/community-build/community-projects/ScalaPB b/community-build/community-projects/ScalaPB index 94935f6d93ba..79ecc8db710e 160000 --- a/community-build/community-projects/ScalaPB +++ b/community-build/community-projects/ScalaPB @@ -1 +1 @@ -Subproject commit 94935f6d93baeff720e9b2839b985cbcb8d6fded +Subproject commit 79ecc8db710e53f07ea12d1dfef80993bbd62e96 diff --git a/community-build/community-projects/algebra b/community-build/community-projects/algebra index 44a2acf5b758..5dda5f9a18cc 160000 --- a/community-build/community-projects/algebra +++ b/community-build/community-projects/algebra @@ -1 +1 @@ -Subproject commit 44a2acf5b758c0425f48b30b7faa3c677e85a989 +Subproject commit 5dda5f9a18cc2d1ef7863ab5a3d8a9b6d4fd9f71 diff --git a/community-build/community-projects/betterfiles b/community-build/community-projects/betterfiles index b3e30073b857..49b55d6b06e4 160000 --- a/community-build/community-projects/betterfiles +++ b/community-build/community-projects/betterfiles @@ -1 +1 @@ -Subproject commit b3e30073b857dd900fd649a064c490dcee80ef94 +Subproject commit 49b55d6b06e44f0656877105202236a480e89b25 diff --git a/community-build/community-projects/fastparse b/community-build/community-projects/fastparse index 001c69755f99..79431b056713 160000 --- a/community-build/community-projects/fastparse +++ b/community-build/community-projects/fastparse @@ -1 +1 @@ -Subproject commit 001c69755f994ad222c7a903617ba8064ec93f41 +Subproject commit 79431b0567131084e82ed1f5769c3063e2917bf6 diff --git a/community-build/community-projects/minitest b/community-build/community-projects/minitest index 9d5fbb80dcb0..500c0e60d7f9 160000 --- a/community-build/community-projects/minitest +++ b/community-build/community-projects/minitest @@ -1 +1 @@ -Subproject commit 9d5fbb80dcb095baac88deb4960d616870745cf9 +Subproject commit 500c0e60d7f9617c270c799355888873261cb0bd diff --git a/community-build/community-projects/scala-xml b/community-build/community-projects/scala-xml index 04b481ffcc29..19f53ad12d73 160000 --- a/community-build/community-projects/scala-xml +++ b/community-build/community-projects/scala-xml @@ -1 +1 @@ -Subproject commit 04b481ffcc29e7ea52f10f9091e9b918d58f9f7f +Subproject commit 19f53ad12d7311ba85d8a239e40efed47f4786ab diff --git a/community-build/community-projects/scalacheck b/community-build/community-projects/scalacheck index f2f5e672c03b..a7c5010ee2cc 160000 --- a/community-build/community-projects/scalacheck +++ b/community-build/community-projects/scalacheck @@ -1 +1 @@ -Subproject commit f2f5e672c03b46e0ef96a86356561052045b86a7 +Subproject commit a7c5010ee2ccaac17e89b35d8acb080429f2e2a7 diff --git a/community-build/community-projects/scalap b/community-build/community-projects/scalap index dac8a812cfa6..c7ebf924aeb9 160000 --- a/community-build/community-projects/scalap +++ b/community-build/community-projects/scalap @@ -1 +1 @@ -Subproject commit dac8a812cfa68a5e96cbd6b7a34481e075bfd4e4 +Subproject commit c7ebf924aeb963eec33d7ec72efcf3cdfb54a7f3 diff --git a/community-build/community-projects/scalatest b/community-build/community-projects/scalatest index 485e832c980c..40fc91f38ffa 160000 --- a/community-build/community-projects/scalatest +++ b/community-build/community-projects/scalatest @@ -1 +1 @@ -Subproject commit 485e832c980c83143cdd7e9f059cdc21e15aafb9 +Subproject commit 40fc91f38ffa1b936f11e31b0cf794882dae9315 diff --git a/community-build/community-projects/scopt b/community-build/community-projects/scopt index 4699b53dfa73..9155bdcf1342 160000 --- a/community-build/community-projects/scopt +++ b/community-build/community-projects/scopt @@ -1 +1 @@ -Subproject commit 4699b53dfa730f78e025c4626329d8172c330e5f +Subproject commit 9155bdcf13424ed385ba1d2dfc8f6f54ba02b7f0 diff --git a/community-build/community-projects/shapeless b/community-build/community-projects/shapeless index ab34097be4a4..45c822930230 160000 --- a/community-build/community-projects/shapeless +++ b/community-build/community-projects/shapeless @@ -1 +1 @@ -Subproject commit ab34097be4a47138dd10e5c816ce7173a793375d +Subproject commit 45c822930230b8990b9fbe07fd329f8354476cc3 diff --git a/community-build/community-projects/sourcecode b/community-build/community-projects/sourcecode index b23462bbaf37..d1c22e19ed79 160000 --- a/community-build/community-projects/sourcecode +++ b/community-build/community-projects/sourcecode @@ -1 +1 @@ -Subproject commit b23462bbaf3781e27fd54970a76b265cb2ae7e71 +Subproject commit d1c22e19ed79f0a4f57cca8ae7f15193fc579aa6 diff --git a/community-build/community-projects/squants b/community-build/community-projects/squants index c30f46abc841..c178ff07fe72 160000 --- a/community-build/community-projects/squants +++ b/community-build/community-projects/squants @@ -1 +1 @@ -Subproject commit c30f46abc841b9b26f96850a21cfc009545cd22b +Subproject commit c178ff07fe7287b89ec5324dade26500b83ebf67 diff --git a/community-build/community-projects/stdLib213 b/community-build/community-projects/stdLib213 index ec4624b48262..902738911796 160000 --- a/community-build/community-projects/stdLib213 +++ b/community-build/community-projects/stdLib213 @@ -1 +1 @@ -Subproject commit ec4624b482626020e154d2e6161ef5f5f38f166c +Subproject commit 902738911796d1bde386aeea100221112eb241cb diff --git a/dist/bin/common.bat b/dist/bin/common.bat index 115ce0bac890..58cf668287e5 100644 --- a/dist/bin/common.bat +++ b/dist/bin/common.bat @@ -50,6 +50,7 @@ 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%\*dotty-staging*"') do set _DOTTY_STAGING=%_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 rem removed since version 0.16.x (#5597) diff --git a/dist/bin/dotc.bat b/dist/bin/dotc.bat index ac939e97265f..a19449f42b7d 100644 --- a/dist/bin/dotc.bat +++ b/dist/bin/dotc.bat @@ -123,6 +123,7 @@ set __TOOLCHAIN=%__TOOLCHAIN%%_SBT_INTF%%_PSEP% set __TOOLCHAIN=%__TOOLCHAIN%%_DOTTY_INTF%%_PSEP% set __TOOLCHAIN=%__TOOLCHAIN%%_DOTTY_LIB%%_PSEP% set __TOOLCHAIN=%__TOOLCHAIN%%_DOTTY_COMP%%_PSEP% +set __TOOLCHAIN=%__TOOLCHAIN%%_DOTTY_STAGING%%_PSEP% rem # jline set __TOOLCHAIN=%__TOOLCHAIN%%_JLINE_READER%%_PSEP% diff --git a/dist/bin/dotd.bat b/dist/bin/dotd.bat index f1a40fbeca51..91773fd6a472 100644 --- a/dist/bin/dotd.bat +++ b/dist/bin/dotd.bat @@ -79,7 +79,7 @@ for /f %%f in ('dir /a-d /b "%__LIB_DIR%\*ST4*"') do set _ST4_LIB=%__LIB_DIR%\%% 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=%_DOTTY_LIB%%_PSEP%%_DOTTY_COMP%%_PSEP%%_DOTTY_DOC_LIB%%_PSEP%%_DOTTY_INTF%%_PSEP%%_SBT_INTF%%_PSEP%%_DOTTY_STAGING% set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_SCALA_LIB% set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_FLEXMARK_LIBS% set _CLASS_PATH=%_CLASS_PATH%%_PSEP%%_JACKSON_LIBS% diff --git a/dist/bin/dotr.bat b/dist/bin/dotr.bat index cc67e2d623f8..c04965fbf476 100644 --- a/dist/bin/dotr.bat +++ b/dist/bin/dotr.bat @@ -43,7 +43,7 @@ rem elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then 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 _CP_ARG=!_CP_ARG!%_PSEP%%_DOTTY_COMP%%_PSEP%%_DOTTY_INTF%%_PSEP%%_SCALA_ASM%%_PSEP%%_DOTTY_STAGING% ) set _JAVA_ARGS=%_JAVA_DEBUG% -classpath "!_CP_ARG!" %_JVM_OPTS% %_RESIDUAL_ARGS% %_JAVACMD% !_JAVA_ARGS! diff --git a/project/scripts/bootstrapCmdTests.bat b/project/scripts/bootstrapCmdTests.bat index f6d43eadb40e..6d869395904d 100644 --- a/project/scripts/bootstrapCmdTests.bat +++ b/project/scripts/bootstrapCmdTests.bat @@ -66,6 +66,15 @@ if %_DEBUG%==1 echo [%_BASENAME%] call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" if not %_EXITCODE%==0 goto end +rem # check that `dotc` and `dotr` works for staging +call :clear_out "%_OUT_DIR%" +call %_BIN_DIR%\dotc.bat tests/run-staging/i4044f.scala -d "%_OUT_DIR%" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) +call %_BIN_DIR%\dotr.bat -with-compiler -classpath "%_OUT_DIR%" Test > "%_TMP_FILE%" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) +call %_BIN_DIR%\dotd.bat -project Staging -siteroot "%_OUT_DIR%" "tests/run-staging/i4044f.scala" +if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) + 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%" diff --git a/project/scripts/build.bat b/project/scripts/build.bat index 3125890a476c..e7011ca9db83 100644 --- a/project/scripts/build.bat +++ b/project/scripts/build.bat @@ -110,8 +110,8 @@ if /i "%__ARG%"=="help" ( set _HELP=1& goto :eof ) else if /i "%__ARG:~0,7%"=="compile" ( if not "%__ARG:~-5%"=="-only" set _CLONE=1 set _COMPILE=1 -) else if /i "%__ARGS:~0,9%"=="community" ( - if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _COMPILE=1& set _BOOTSTRAP=1 +) else if /i "%__ARG:~0,9%"=="community" ( + rem if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _COMPILE=1& set _BOOTSTRAP=1 set _COMMUNITY=1 ) else if /i "%__ARG:~0,3%"=="doc" ( if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _COMPILE=1& set _BOOTSTRAP=1 @@ -144,7 +144,7 @@ echo boot[strap] generate+test bootstrapped compiler (after compi echo cleanall clean project (sbt+git) and quit echo clone update submodules echo compile generate+test 1st stage compiler (after clone) -echo community test community-build (after bootstrap) +echo community test community-build echo doc[umentation] generate documentation (after bootstrap) echo help display this help message echo sbt test sbt-dotty (after bootstrap) @@ -152,7 +152,6 @@ echo Advanced subcommands (no deps): echo arch[ives]-only generate ONLY gz/zip archives echo boot[strap]-only generate+test ONLY bootstrapped compiler echo compile-only generate+test ONLY 1st stage compiler -echo community-only test ONLY community-build echo doc[umentation]-only] generate ONLY documentation echo sbt-only test ONLY sbt-dotty @@ -206,7 +205,7 @@ if "%_DRONE_BUILD_EVENT%"=="pull_request" if defined _DRONE_REMOTE_URL ( 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 + echo Error: Failed to update Git submodules 1>&2 set _EXITCODE=1 goto :eof ) @@ -233,10 +232,10 @@ if not %ERRORLEVEL%==0 ( 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 %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";dotty-bootstrapped/compile ;dotty-bootstrapped/test ;dotty-semanticdb/compile ;dotty-semanticdb/test ;sjsSandbox/run" +call "%_SBT_CMD%" ";dotty-bootstrapped/compile ;dotty-bootstrapped/test ;dotty-semanticdb/compile ;dotty-semanticdb/test ;sjsSandbox/run" if not %ERRORLEVEL%==0 ( - echo Error: Failed to run sbt command ";dotty-bootstrapped/compile ;dotty-bootstrapped/test" 1>&2 + echo Error: Failed to run sbt command ";dotty-bootstrapped/compile ;dotty-bootstrapped/test ;dotty-semanticdb/compile ;dotty-semanticdb/test ;sjsSandbox/run" 1>&2 set _EXITCODE=1 goto :eof ) @@ -255,12 +254,13 @@ goto :eof if %_DEBUG%==1 echo [%_BASENAME%] %_GIT_CMD% submodule update --init --recursive --jobs 7 %_GIT_CMD% submodule update --init --recursive --jobs 7 if not %ERRORLEVEL%==0 ( - echo Error: Failed to update Git submodules 1>&2 + echo Error: Failed to update Git submodules 1>&2 set _EXITCODE=1 goto :eof ) -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" community-build/test -call "%_SBT_CMD%" community-build/test +echo sbt community-build/test +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" "-Dsbt.cmd=%_SBT_CMD%" community-build/test +call "%_SBT_CMD%" "-Dsbt.cmd=%_SBT_CMD%" community-build/test if not %ERRORLEVEL%==0 ( echo Error: Failed to run sbt command community-build/test 1>&2 set _EXITCODE=1 @@ -278,6 +278,34 @@ if not %ERRORLEVEL%==0 ( ) goto :eof +:test_java11 +set __PATH=C:\opt +for /f "delims=" %%f in ('dir /ad /b "!__PATH!\jdk-11*" 2^>NUL') do set __JDK11_HOME=!__PATH!\%%f +if not defined __JDK11_HOME ( + set __PATH=C:\Progra~1\Java + for /f %%f in ('dir /ad /b "!__PATH!\jdk-11*" 2^>NUL') do set __JDK11_HOME=!__PATH!\%%f +) +if not defined __JDK11_HOME ( + echo Error: Java SDK 11 installation directory not found 1>&2 + set _EXITCODE=1 + goto :eof +) +setlocal +rem export PATH="/usr/lib/jvm/java-11-openjdk-amd64/bin:$PATH" +set "PATH=%__JDK11_HOME%\bin;%PATH%" +rem ./project/scripts/sbt ";compile ;test" +echo sbt compile and sbt test (Java 11) +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";compile ;test" +call "%_SBT_CMD%" ";compile ;test" +if not %ERRORLEVEL%==0 ( + endlocal + echo Error: Failed to run sbt command ";compile ;test" 1>&2 + set _EXITCODE=1 + goto :eof +) +endlocal +goto :eof + :documentation rem see shell script project/scripts/genDocs if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\genDocs.bat From ef04e414aa9759888d8c149f8c52a517143ed020 Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Mon, 28 Oct 2019 17:07:08 +0100 Subject: [PATCH 33/34] redirect debug info to stderr in batch scripts, removed build.bat --- project/scripts/bootstrapCmdTests.bat | 30 +-- project/scripts/build.bat | 361 -------------------------- project/scripts/cmdTests.bat | 20 +- 3 files changed, 25 insertions(+), 386 deletions(-) delete mode 100644 project/scripts/build.bat diff --git a/project/scripts/bootstrapCmdTests.bat b/project/scripts/bootstrapCmdTests.bat index 6d869395904d..7d2174d710b3 100644 --- a/project/scripts/bootstrapCmdTests.bat +++ b/project/scripts/bootstrapCmdTests.bat @@ -29,40 +29,40 @@ rem ########################################################################## rem ## Main rem # check that benchmarks can run -if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" "dotty-bench/jmh:run 1 1 tests/pos/alias.scala" +if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" "dotty-bench/jmh:run 1 1 tests/pos/alias.scala" 1>&2 call "%_SBT_CMD%" "dotty-bench/jmh:run 1 1 tests/pos/alias.scala" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) rem # The above is here as it relies on the bootstrapped library. -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 tests/pos/alias.scala" +if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 tests/pos/alias.scala" 1>&2 call "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 tests/pos/alias.scala" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 -with-compiler compiler/src/dotty/tools/dotc/core/Types.scala" +if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 -with-compiler compiler/src/dotty/tools/dotc/core/Types.scala" 1>&2 call "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 -with-compiler compiler/src/dotty/tools/dotc/core/Types.scala" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) echo testing scala.quoted.Expr.run from sbt dotr -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";dotty-compiler-bootstrapped/dotc tests/run-with-compiler/quote-run.scala; dotty-compiler-bootstrapped/dotr -with-compiler Test" ^> "%_TMP_FILE%" +if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" ";dotty-compiler-bootstrapped/dotc tests/run-with-compiler/quote-run.scala; dotty-compiler-bootstrapped/dotr -with-compiler Test" ^> "%_TMP_FILE%" 1>&2 call "%_SBT_CMD%" ";dotty-compiler-bootstrapped/dotc tests/run-with-compiler/quote-run.scala; dotty-compiler-bootstrapped/dotr -with-compiler Test" > "%_TMP_FILE%" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) call :grep "val a: scala.Int = 3" "%_TMP_FILE%" if not %_EXITCODE%==0 goto end rem # setup for `dotc`/`dotr` script tests -if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" dist-bootstrapped/pack +if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" dist-bootstrapped/pack 1>&2 call "%_SBT_CMD%" dist-bootstrapped/pack if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) rem # check that `dotc` compiles and `dotr` runs it echo testing ./bin/dotc and ./bin/dotr call :clear_out "%_OUT_DIR%" -if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotc.bat "%_SOURCE%" -d "%_OUT_DIR%" +if %_DEBUG%==1 echo [%_BASENAME%] %_BIN_DIR%\dotc.bat "%_SOURCE%" -d "%_OUT_DIR%" 1>&2 call %_BIN_DIR%\dotc.bat "%_SOURCE%" -d "%_OUT_DIR%" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotr.bat -classpath "%_OUT_DIR%" "%_MAIN%" ^> "%_TMP_FILE%" +if %_DEBUG%==1 echo [%_BASENAME%] %_BIN_DIR%\dotr.bat -classpath "%_OUT_DIR%" "%_MAIN%" ^> "%_TMP_FILE%" 1>&2 call %_BIN_DIR%\dotr.bat -classpath "%_OUT_DIR%" "%_MAIN%" > "%_TMP_FILE%" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -if %_DEBUG%==1 echo [%_BASENAME%] call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" +if %_DEBUG%==1 echo [%_BASENAME%] call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" 1>&2 call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" if not %_EXITCODE%==0 goto end @@ -78,19 +78,19 @@ if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) 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%" -if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotc.bat -from-tasty -classpath "%_OUT_DIR%" -d "%_OUT1_DIR%" "%_MAIN%" +if %_DEBUG%==1 echo [%_BASENAME%] %_BIN_DIR%\dotc.bat -from-tasty -classpath "%_OUT_DIR%" -d "%_OUT1_DIR%" "%_MAIN%" 1>&2 call %_BIN_DIR%\dotc.bat -from-tasty -classpath "%_OUT_DIR%" -d "%_OUT1_DIR%" "%_MAIN%" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotr.bat -classpath "%_OUT1_DIR%" "%_MAIN%" ^> "%_TMP_FILE%" +if %_DEBUG%==1 echo [%_BASENAME%] %_BIN_DIR%\dotr.bat -classpath "%_OUT1_DIR%" "%_MAIN%" ^> "%_TMP_FILE%" 1>&2 call %_BIN_DIR%\dotr.bat -classpath "%_OUT1_DIR%" "%_MAIN%" > "%_TMP_FILE%" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -if %_DEBUG%==1 echo [%_BASENAME%] call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" +if %_DEBUG%==1 echo [%_BASENAME%] call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" 1>&2 call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" if not %_EXITCODE%==0 goto end echo testing ./bin/dotd call :clear_out "%_OUT_DIR%" -if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotd.bat -project Hello -siteroot "%_OUT_DIR%" "%_SOURCE%" +if %_DEBUG%==1 echo [%_BASENAME%] %_BIN_DIR%\dotd.bat -project Hello -siteroot "%_OUT_DIR%" "%_SOURCE%" 1>&2 call %_BIN_DIR%\dotd.bat -project Hello -siteroot "%_OUT_DIR%" "%_SOURCE%" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) @@ -103,7 +103,7 @@ rem ## Subroutines set __OUT_DIR=%~1 if exist "%__OUT_DIR%\" ( - if %_DEBUG%==1 echo [%_BASENAME%] del /s /q "%__OUT_DIR%\*" 1^>NUL + if %_DEBUG%==1 echo [%_BASENAME%] del /s /q "%__OUT_DIR%\*" 1^>NUL 1>&2 del /s /q "%__OUT_DIR%\*" 1>NUL ) goto :eof @@ -112,7 +112,7 @@ goto :eof set __PATTERN=%~1 set __FILE=%~2 -if %_DEBUG%==1 echo [%_BASENAME%] findstr "%__PATTERN%" "%__FILE%" +if %_DEBUG%==1 echo [%_BASENAME%] findstr "%__PATTERN%" "%__FILE%" 1>&2 findstr "%__PATTERN%" "%__FILE%" if not %ERRORLEVEL%==0 ( echo Error: Failed to find pattern "%__PATTERN%" in file %__FILE% 1>&2 @@ -137,6 +137,6 @@ rem ########################################################################## rem ## Cleanups :end -if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% +if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% 1>&2 exit /b %_EXITCODE% endlocal diff --git a/project/scripts/build.bat b/project/scripts/build.bat deleted file mode 100644 index e7011ca9db83..000000000000 --- a/project/scripts/build.bat +++ /dev/null @@ -1,361 +0,0 @@ -@echo off - -rem ########################################################################## -rem ## This batch file is based on configuration file .drone.yml - -setlocal enabledelayedexpansion - -rem only for interactive debugging -set _DEBUG=0 - -rem ########################################################################## -rem ## Environment setup - -set _BASENAME=%~n0 - -set _EXITCODE=0 - -for %%f in ("%~dp0..\..") do set _ROOT_DIR=%%~sf -set _SCRIPTS_DIR=%_ROOT_DIR%\project\scripts - -call %_SCRIPTS_DIR%\common.bat -if not %_EXITCODE%==0 goto end - -rem set _DRONE_BUILD_EVENT=pull_request -set _DRONE_BUILD_EVENT= -set _DRONE_REMOTE_URL= -set _DRONE_BRANCH= - -call :args %* -if not %_EXITCODE%==0 goto end -if defined _HELP call :help & exit /b %_EXITCODE% - -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 _COMPILE ( - 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 _COMMUNITY ( - call :community_build - if not !_EXITCODE!==0 goto end -) -if defined _SBT ( - call :test_sbt - if not !_EXITCODE!==0 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: _CLONE, _COMPILE, _DOCUMENTATION, _SBT, _TIMER, _VERBOSE -:args -set _ARCHIVES= -set _BOOTSTRAP= -set _COMPILE= -set _CLEAN_ALL= -set _CLONE= -set _COMMUNITY= -set _DOCUMENTATION= -set _HELP= -set _SBT= -set _TIMER=0 -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%"=="-timer" ( set _TIMER=1 -) else if /i "%__ARG%"=="-verbose" ( set _VERBOSE=1 -) else if /i "%__ARG:~0,4%"=="arch" ( - if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _COMPILE=1& set _BOOTSTRAP=1 - set _ARCHIVES=1 -) else if /i "%__ARG:~0,4%"=="boot" ( - if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _COMPILE=1 - set _BOOTSTRAP=1 -) else if /i "%__ARG%"=="cleanall" ( set _CLEAN_ALL=1 -) else if /i "%__ARG%"=="clone" ( set _CLONE=1 -) else if /i "%__ARG:~0,7%"=="compile" ( - if not "%__ARG:~-5%"=="-only" set _CLONE=1 - set _COMPILE=1 -) else if /i "%__ARG:~0,9%"=="community" ( - rem if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _COMPILE=1& set _BOOTSTRAP=1 - set _COMMUNITY=1 -) else if /i "%__ARG:~0,3%"=="doc" ( - if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _COMPILE=1& set _BOOTSTRAP=1 - set _DOCUMENTATION=1 -) else if /i "%__ARG%"=="sbt" ( - set _CLONE=1& set _COMPILE=1& set _BOOTSTRAP=1& set _SBT=1 -) else if /i "%__ARG%"=="sbt-only" ( - set _SBT=1 -) else ( - echo Error: Unknown subcommand %__ARG% 1>&2 - set _EXITCODE=1 - goto :args_done -) -shift -goto args_loop -:args_done -if %_TIMER%==1 ( - for /f "delims=" %%i in ('powershell -c "(Get-Date)"') do set _TIMER_START=%%i -) -goto :eof - -:help -echo Usage: %_BASENAME% { options ^| subcommands } -echo Options: -echo -timer display total execution time -echo -verbose display environment settings -echo Subcommands: -echo arch[ives] generate gz/zip archives (after bootstrap) -echo boot[strap] generate+test bootstrapped compiler (after compile) -echo cleanall clean project (sbt+git) and quit -echo clone update submodules -echo compile generate+test 1st stage compiler (after clone) -echo community test community-build -echo doc[umentation] generate documentation (after bootstrap) -echo help display this help message -echo sbt test sbt-dotty (after bootstrap) -echo Advanced subcommands (no deps): -echo arch[ives]-only generate ONLY gz/zip archives -echo boot[strap]-only generate+test ONLY bootstrapped compiler -echo compile-only generate+test ONLY 1st stage compiler -echo doc[umentation]-only] generate ONLY documentation -echo sbt-only test ONLY sbt-dotty - -goto :eof - -:init -if %_VERBOSE%==1 ( - for /f "delims=" %%i in ('where git.exe') do ( - if not defined __GIT_CMD1 set __GIT_CMD1=%%i - ) - for /f "delims=" %%i in ('where java.exe') do ( - if not defined __JAVA_CMD1 set __JAVA_CMD1=%%i - ) - set __BRANCH_NAME=unknown - for /f %%i in ('!__GIT_CMD1! rev-parse --abbrev-ref HEAD') do set __BRANCH_NAME=%%i - echo Tool paths - echo GIT_CMD=!__GIT_CMD1! - echo JAVA_CMD=!__JAVA_CMD1! - echo SBT_CMD=%_SBT_CMD% - echo Tool options - echo JAVA_OPTS=%JAVA_OPTS% - echo SBT_OPTS=%SBT_OPTS% - echo Current Git branch: - echo !__BRANCH_NAME! - echo. -) -goto :eof - -:clean_all -echo run sbt clean and git clean -xdf --exclude=*.bat --exclude=*.ps1 -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 --exclude=*.bat --exclude=*.ps1 -%_GIT_CMD% clean -xdf --exclude=*.bat --exclude=*.ps1 -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 - -:test -echo sbt compile and sbt test -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";compile ;test" -call "%_SBT_CMD%" ";compile ;test" -if not %ERRORLEVEL%==0 ( - echo Error: Failed to run sbt command ";compile ;test" 1>&2 - set _EXITCODE=1 - goto :eof -) - -rem see shell script project/scripts/cmdTests -if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\cmdTests.bat -call %_SCRIPTS_DIR%\cmdTests.bat -if not %ERRORLEVEL%==0 ( - echo Error: Failed to run cmdTest.bat 1>&2 - set _EXITCODE=1 - goto :eof -) -goto :eof - -:test_bootstrapped -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";dotty-bootstrapped/compile ;dotty-bootstrapped/test ;dotty-semanticdb/compile ;dotty-semanticdb/test ;sjsSandbox/run" -call "%_SBT_CMD%" ";dotty-bootstrapped/compile ;dotty-bootstrapped/test ;dotty-semanticdb/compile ;dotty-semanticdb/test ;sjsSandbox/run" -if not %ERRORLEVEL%==0 ( - echo Error: Failed to run sbt command ";dotty-bootstrapped/compile ;dotty-bootstrapped/test ;dotty-semanticdb/compile ;dotty-semanticdb/test ;sjsSandbox/run" 1>&2 - set _EXITCODE=1 - goto :eof -) - -rem see shell script project/scripts/bootstrapCmdTests -if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\bootstrapCmdTests.bat -call %_SCRIPTS_DIR%\bootstrapCmdTests.bat -if not %ERRORLEVEL%==0 ( - echo Error: Failed to run bootstrapCmdTests.bat 1>&2 - set _EXITCODE=1 - goto :eof -) -goto :eof - -:community_build -if %_DEBUG%==1 echo [%_BASENAME%] %_GIT_CMD% submodule update --init --recursive --jobs 7 -%_GIT_CMD% submodule update --init --recursive --jobs 7 -if not %ERRORLEVEL%==0 ( - echo Error: Failed to update Git submodules 1>&2 - set _EXITCODE=1 - goto :eof -) -echo sbt community-build/test -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" "-Dsbt.cmd=%_SBT_CMD%" community-build/test -call "%_SBT_CMD%" "-Dsbt.cmd=%_SBT_CMD%" community-build/test -if not %ERRORLEVEL%==0 ( - echo Error: Failed to run sbt command community-build/test 1>&2 - set _EXITCODE=1 - goto :eof -) -goto :eof - -:test_sbt -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" sbt-dotty/scripted -call "%_SBT_CMD%" sbt-dotty/scripted -if not %ERRORLEVEL%==0 ( - echo Error: Failed to run sbt command sbt-dotty/scripted 1>&2 - set _EXITCODE=1 - goto :eof -) -goto :eof - -:test_java11 -set __PATH=C:\opt -for /f "delims=" %%f in ('dir /ad /b "!__PATH!\jdk-11*" 2^>NUL') do set __JDK11_HOME=!__PATH!\%%f -if not defined __JDK11_HOME ( - set __PATH=C:\Progra~1\Java - for /f %%f in ('dir /ad /b "!__PATH!\jdk-11*" 2^>NUL') do set __JDK11_HOME=!__PATH!\%%f -) -if not defined __JDK11_HOME ( - echo Error: Java SDK 11 installation directory not found 1>&2 - set _EXITCODE=1 - goto :eof -) -setlocal -rem export PATH="/usr/lib/jvm/java-11-openjdk-amd64/bin:$PATH" -set "PATH=%__JDK11_HOME%\bin;%PATH%" -rem ./project/scripts/sbt ";compile ;test" -echo sbt compile and sbt test (Java 11) -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";compile ;test" -call "%_SBT_CMD%" ";compile ;test" -if not %ERRORLEVEL%==0 ( - endlocal - echo Error: Failed to run sbt command ";compile ;test" 1>&2 - set _EXITCODE=1 - goto :eof -) -endlocal -goto :eof - -:documentation -rem see shell script project/scripts/genDocs -if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\genDocs.bat -call %_SCRIPTS_DIR%\genDocs.bat -if not %ERRORLEVEL%==0 ( - echo Error: Failed to run genDocs.bat 1>&2 - set _EXITCODE=1 - goto :eof -) -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 output parameter: _DURATION -:duration -set __START=%~1 -set __END=%~2 - -for /f "delims=" %%i in ('powershell -c "$interval = New-TimeSpan -Start '%__START%' -End '%__END%'; Write-Host $interval"') do set _DURATION=%%i -goto :eof - -rem input parameter: 1=start time -:total -set __TIMER_START=%~1 - -for /f "delims=" %%i in ('powershell -c "(Get-Date)"') do set __TIMER_END=%%i -call :duration "%_TIMER_START%" "!__TIMER_END!" -echo Total execution time: %_DURATION% -goto :eof - -rem ########################################################################## -rem ## Cleanups - -:end -if %_TIMER%==1 call :total "%_TIMER_START%" -if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% -exit /b %_EXITCODE% -endlocal diff --git a/project/scripts/cmdTests.bat b/project/scripts/cmdTests.bat index 5cf974799262..93043957c34d 100644 --- a/project/scripts/cmdTests.bat +++ b/project/scripts/cmdTests.bat @@ -19,7 +19,7 @@ for %%f in ("%~dp0..\..") do set _ROOT_DIR=%%~sf set _SCRIPTS_DIR=%_ROOT_DIR%\project\scripts if not defined __COMMON__ ( - if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\common.bat + if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\common.bat 1>&2 call %_SCRIPTS_DIR%\common.bat if not !_EXITCODE!==0 goto end ) @@ -29,7 +29,7 @@ rem ## Main rem # check that `sbt dotc` compiles and `sbt dotr` runs it 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%" +if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" ";dotc %_SOURCE% -d %_OUT_DIR% ;dotr -classpath %_OUT_DIR% %_MAIN%" ^> "%_TMP_FILE%" 1>&2 call "%_SBT_CMD%" ";dotc %_SOURCE% -d %_OUT_DIR% ;dotr -classpath %_OUT_DIR% %_MAIN%" > "%_TMP_FILE%" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) call :grep "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" @@ -38,7 +38,7 @@ if not %_EXITCODE%==0 goto end 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%" -if %_DEBUG%==1 echo [%_BASENAME%] 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%" +if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" ";dotc %_SOURCE% -d %_OUT_DIR% ;dotc -from-tasty -classpath %_OUT_DIR% -d %_OUT1_DIR% %_MAIN% ;dotr -classpath %_OUT1_DIR% %_MAIN%" ^> "%_TMP_FILE%" 1>&2 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%" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) call :grep "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" @@ -46,14 +46,14 @@ if not %_EXITCODE%==0 goto end rem # check that `sbt dotc -decompile` runs echo testing sbt dotc -decompile -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";dotc -decompile -color:never -classpath %_OUT_DIR% %_MAIN%" ^> "%_TMP_FILE%" +if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" ";dotc -decompile -color:never -classpath %_OUT_DIR% %_MAIN%" ^> "%_TMP_FILE%" 1>&2 call "%_SBT_CMD%" ";dotc -decompile -color:never -classpath %_OUT_DIR% %_MAIN%" > "%_TMP_FILE%" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) call :grep "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "%_TMP_FILE%" if not %_EXITCODE%==0 goto end echo testing sbt dotc -decompile from file -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";dotc -decompile -color:never -classpath %_OUT_DIR% %_OUT_DIR%\%_TASTY%" ^> "%_TMP_FILE%" +if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" ";dotc -decompile -color:never -classpath %_OUT_DIR% %_OUT_DIR%\%_TASTY%" ^> "%_TMP_FILE%" 1>&2 call "%_SBT_CMD%" ";dotc -decompile -color:never -classpath %_OUT_DIR% %_OUT_DIR%\%_TASTY%" > "%_TMP_FILE%" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) call :grep "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "%_TMP_FILE%" @@ -61,7 +61,7 @@ if not %_EXITCODE%==0 goto end 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%" +if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" ";dotc %_SOURCE% ; dotr %_MAIN%" ^> "%_TMP_FILE%" 1>&2 call "%_SBT_CMD%" ";dotc %_SOURCE% ; dotr %_MAIN%" > "%_TMP_FILE%" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) call :grep "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" @@ -69,7 +69,7 @@ if not %_EXITCODE%==0 goto end echo testing loading tasty from .tasty file in jar call :clear_out "%_OUT_DIR%" -if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";dotc -d %_OUT_DIR%\out.jar %_SOURCE%; dotc -decompile -classpath %_OUT_DIR%\out.jar -color:never %_MAIN%" ^> "%_TMP_FILE%" +if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" ";dotc -d %_OUT_DIR%\out.jar %_SOURCE%; dotc -decompile -classpath %_OUT_DIR%\out.jar -color:never %_MAIN%" ^> "%_TMP_FILE%" 1>&2 call "%_SBT_CMD%" ";dotc -d %_OUT_DIR%\out.jar %_SOURCE%; dotc -decompile -classpath %_OUT_DIR%\out.jar -color:never %_MAIN%" > "%_TMP_FILE%" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) call :grep "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "%_TMP_FILE%" @@ -84,7 +84,7 @@ rem ## Subroutines set __OUT_DIR=%~1 if exist "%__OUT_DIR%\" ( - if %_DEBUG%==1 echo [%_BASENAME%] del /s /q "%__OUT_DIR%\*" 1^>NUL + if %_DEBUG%==1 echo [%_BASENAME%] del /s /q "%__OUT_DIR%\*" 1>&2 del /s /q "%__OUT_DIR%\*" 1>NUL ) goto :eof @@ -93,7 +93,7 @@ goto :eof set __PATTERN=%~1 set __FILE=%~2 -if %_DEBUG%==1 echo [%_BASENAME%] findstr "%__PATTERN%" "%__FILE%" +if %_DEBUG%==1 echo [%_BASENAME%] findstr "%__PATTERN%" "%__FILE%" 1>&2 findstr "%__PATTERN%" "%__FILE%" if not %ERRORLEVEL%==0 ( echo Error: Failed to find pattern "%__PATTERN%" in file %__FILE% 1>&2 @@ -106,7 +106,7 @@ rem ########################################################################## rem ## Cleanups :end -if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% +if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% 1>&2 exit /b %_EXITCODE% endlocal From 1905d2a7d83c6726cac052ab535a4d90c8ccdf4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20MICHELOUD?= Date: Mon, 11 Nov 2019 16:39:21 +0100 Subject: [PATCH 34/34] added option -cp to dotr.bat, removed project/scripts/*.bat files --- dist/bin/dotr.bat | 4 + project/scripts/bootstrapCmdTests.bat | 142 -------------------------- project/scripts/cmdTests.bat | 113 -------------------- project/scripts/common.bat | 62 ----------- project/scripts/genDocs.bat | 93 ----------------- 5 files changed, 4 insertions(+), 410 deletions(-) delete mode 100644 project/scripts/bootstrapCmdTests.bat delete mode 100644 project/scripts/cmdTests.bat delete mode 100644 project/scripts/common.bat delete mode 100644 project/scripts/genDocs.bat diff --git a/dist/bin/dotr.bat b/dist/bin/dotr.bat index c04965fbf476..2e3253fff921 100644 --- a/dist/bin/dotr.bat +++ b/dist/bin/dotr.bat @@ -79,6 +79,10 @@ if /i "%__ARG%"=="-repl" ( set _CLASS_PATH=%~2 set /a _CLASS_PATH_COUNT+=1 shift +) else if /i "%__ARG%"=="-cp" ( + 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" ( diff --git a/project/scripts/bootstrapCmdTests.bat b/project/scripts/bootstrapCmdTests.bat deleted file mode 100644 index 7d2174d710b3..000000000000 --- a/project/scripts/bootstrapCmdTests.bat +++ /dev/null @@ -1,142 +0,0 @@ -@echo off - -rem ########################################################################## -rem ## This batch file is based on shell script project/scripts/bootstrapCmdTests - -setlocal enabledelayedexpansion - -rem only for interactive debugging -set _DEBUG=0 - -rem ########################################################################## -rem ## Environment setup - -set _BASENAME=%~n0 - -set _EXITCODE=0 - -for %%f in ("%~dp0..\..") do set _ROOT_DIR=%%~sf -set _SCRIPTS_DIR=%_ROOT_DIR%\project\scripts -set _BIN_DIR=%_ROOT_DIR%\bin - -if not defined __COMMON__ ( - if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\common.bat - call %_SCRIPTS_DIR%\common.bat - if not !_EXITCODE!==0 goto end -) - -rem ########################################################################## -rem ## Main - -rem # check that benchmarks can run -if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" "dotty-bench/jmh:run 1 1 tests/pos/alias.scala" 1>&2 -call "%_SBT_CMD%" "dotty-bench/jmh:run 1 1 tests/pos/alias.scala" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) - -rem # The above is here as it relies on the bootstrapped library. -if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 tests/pos/alias.scala" 1>&2 -call "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 tests/pos/alias.scala" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 -with-compiler compiler/src/dotty/tools/dotc/core/Types.scala" 1>&2 -call "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 -with-compiler compiler/src/dotty/tools/dotc/core/Types.scala" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) - -echo testing scala.quoted.Expr.run from sbt dotr -if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" ";dotty-compiler-bootstrapped/dotc tests/run-with-compiler/quote-run.scala; dotty-compiler-bootstrapped/dotr -with-compiler Test" ^> "%_TMP_FILE%" 1>&2 -call "%_SBT_CMD%" ";dotty-compiler-bootstrapped/dotc tests/run-with-compiler/quote-run.scala; dotty-compiler-bootstrapped/dotr -with-compiler Test" > "%_TMP_FILE%" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -call :grep "val a: scala.Int = 3" "%_TMP_FILE%" -if not %_EXITCODE%==0 goto end - -rem # setup for `dotc`/`dotr` script tests -if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" dist-bootstrapped/pack 1>&2 -call "%_SBT_CMD%" dist-bootstrapped/pack -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) - -rem # check that `dotc` compiles and `dotr` runs it -echo testing ./bin/dotc and ./bin/dotr -call :clear_out "%_OUT_DIR%" -if %_DEBUG%==1 echo [%_BASENAME%] %_BIN_DIR%\dotc.bat "%_SOURCE%" -d "%_OUT_DIR%" 1>&2 -call %_BIN_DIR%\dotc.bat "%_SOURCE%" -d "%_OUT_DIR%" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -if %_DEBUG%==1 echo [%_BASENAME%] %_BIN_DIR%\dotr.bat -classpath "%_OUT_DIR%" "%_MAIN%" ^> "%_TMP_FILE%" 1>&2 -call %_BIN_DIR%\dotr.bat -classpath "%_OUT_DIR%" "%_MAIN%" > "%_TMP_FILE%" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -if %_DEBUG%==1 echo [%_BASENAME%] call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" 1>&2 -call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" -if not %_EXITCODE%==0 goto end - -rem # check that `dotc` and `dotr` works for staging -call :clear_out "%_OUT_DIR%" -call %_BIN_DIR%\dotc.bat tests/run-staging/i4044f.scala -d "%_OUT_DIR%" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -call %_BIN_DIR%\dotr.bat -with-compiler -classpath "%_OUT_DIR%" Test > "%_TMP_FILE%" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -call %_BIN_DIR%\dotd.bat -project Staging -siteroot "%_OUT_DIR%" "tests/run-staging/i4044f.scala" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) - -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%" -if %_DEBUG%==1 echo [%_BASENAME%] %_BIN_DIR%\dotc.bat -from-tasty -classpath "%_OUT_DIR%" -d "%_OUT1_DIR%" "%_MAIN%" 1>&2 -call %_BIN_DIR%\dotc.bat -from-tasty -classpath "%_OUT_DIR%" -d "%_OUT1_DIR%" "%_MAIN%" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -if %_DEBUG%==1 echo [%_BASENAME%] %_BIN_DIR%\dotr.bat -classpath "%_OUT1_DIR%" "%_MAIN%" ^> "%_TMP_FILE%" 1>&2 -call %_BIN_DIR%\dotr.bat -classpath "%_OUT1_DIR%" "%_MAIN%" > "%_TMP_FILE%" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -if %_DEBUG%==1 echo [%_BASENAME%] call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" 1>&2 -call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" -if not %_EXITCODE%==0 goto end - -echo testing ./bin/dotd -call :clear_out "%_OUT_DIR%" -if %_DEBUG%==1 echo [%_BASENAME%] %_BIN_DIR%\dotd.bat -project Hello -siteroot "%_OUT_DIR%" "%_SOURCE%" 1>&2 -call %_BIN_DIR%\dotd.bat -project Hello -siteroot "%_OUT_DIR%" "%_SOURCE%" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) - -goto end - -rem ########################################################################## -rem ## Subroutines - -:clear_out -set __OUT_DIR=%~1 - -if exist "%__OUT_DIR%\" ( - if %_DEBUG%==1 echo [%_BASENAME%] del /s /q "%__OUT_DIR%\*" 1^>NUL 1>&2 - del /s /q "%__OUT_DIR%\*" 1>NUL -) -goto :eof - -:grep -set __PATTERN=%~1 -set __FILE=%~2 - -if %_DEBUG%==1 echo [%_BASENAME%] findstr "%__PATTERN%" "%__FILE%" 1>&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 - -: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 ########################################################################## -rem ## Cleanups - -:end -if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% 1>&2 -exit /b %_EXITCODE% -endlocal diff --git a/project/scripts/cmdTests.bat b/project/scripts/cmdTests.bat deleted file mode 100644 index 93043957c34d..000000000000 --- a/project/scripts/cmdTests.bat +++ /dev/null @@ -1,113 +0,0 @@ -@echo off - -rem ########################################################################## -rem ## This batch file is based on shell script project/scripts/cmdTests - -setlocal enabledelayedexpansion - -rem only for interactive debugging -set _DEBUG=0 - -rem ########################################################################## -rem ## Environment setup - -set _BASENAME=%~n0 - -set _EXITCODE=0 - -for %%f in ("%~dp0..\..") do set _ROOT_DIR=%%~sf -set _SCRIPTS_DIR=%_ROOT_DIR%\project\scripts - -if not defined __COMMON__ ( - if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\common.bat 1>&2 - call %_SCRIPTS_DIR%\common.bat - if not !_EXITCODE!==0 goto end -) - -rem ########################################################################## -rem ## Main - -rem # check that `sbt dotc` compiles and `sbt dotr` runs it -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%" 1>&2 -call "%_SBT_CMD%" ";dotc %_SOURCE% -d %_OUT_DIR% ;dotr -classpath %_OUT_DIR% %_MAIN%" > "%_TMP_FILE%" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -call :grep "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" -if not %_EXITCODE%==0 goto end - -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%" -if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" ";dotc %_SOURCE% -d %_OUT_DIR% ;dotc -from-tasty -classpath %_OUT_DIR% -d %_OUT1_DIR% %_MAIN% ;dotr -classpath %_OUT1_DIR% %_MAIN%" ^> "%_TMP_FILE%" 1>&2 -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%" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -call :grep "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" -if not %_EXITCODE%==0 goto end - -rem # check that `sbt dotc -decompile` runs -echo testing sbt dotc -decompile -if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" ";dotc -decompile -color:never -classpath %_OUT_DIR% %_MAIN%" ^> "%_TMP_FILE%" 1>&2 -call "%_SBT_CMD%" ";dotc -decompile -color:never -classpath %_OUT_DIR% %_MAIN%" > "%_TMP_FILE%" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -call :grep "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "%_TMP_FILE%" -if not %_EXITCODE%==0 goto end - -echo testing sbt dotc -decompile from file -if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" ";dotc -decompile -color:never -classpath %_OUT_DIR% %_OUT_DIR%\%_TASTY%" ^> "%_TMP_FILE%" 1>&2 -call "%_SBT_CMD%" ";dotc -decompile -color:never -classpath %_OUT_DIR% %_OUT_DIR%\%_TASTY%" > "%_TMP_FILE%" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -call :grep "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "%_TMP_FILE%" -if not %_EXITCODE%==0 goto end - -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%" 1>&2 -call "%_SBT_CMD%" ";dotc %_SOURCE% ; dotr %_MAIN%" > "%_TMP_FILE%" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -call :grep "%_EXPECTED_OUTPUT%" "%_TMP_FILE%" -if not %_EXITCODE%==0 goto end - -echo testing loading tasty from .tasty file in jar -call :clear_out "%_OUT_DIR%" -if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" ";dotc -d %_OUT_DIR%\out.jar %_SOURCE%; dotc -decompile -classpath %_OUT_DIR%\out.jar -color:never %_MAIN%" ^> "%_TMP_FILE%" 1>&2 -call "%_SBT_CMD%" ";dotc -d %_OUT_DIR%\out.jar %_SOURCE%; dotc -decompile -classpath %_OUT_DIR%\out.jar -color:never %_MAIN%" > "%_TMP_FILE%" -if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) -call :grep "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "%_TMP_FILE%" -if not %_EXITCODE%==0 goto end - -goto end - -rem ########################################################################## -rem ## Subroutines - -:clear_out -set __OUT_DIR=%~1 - -if exist "%__OUT_DIR%\" ( - if %_DEBUG%==1 echo [%_BASENAME%] del /s /q "%__OUT_DIR%\*" 1>&2 - del /s /q "%__OUT_DIR%\*" 1>NUL -) -goto :eof - -:grep -set __PATTERN=%~1 -set __FILE=%~2 - -if %_DEBUG%==1 echo [%_BASENAME%] findstr "%__PATTERN%" "%__FILE%" 1>&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 ########################################################################## -rem ## Cleanups - -:end -if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% 1>&2 -exit /b %_EXITCODE% -endlocal - - diff --git a/project/scripts/common.bat b/project/scripts/common.bat deleted file mode 100644 index 09f61adcad3b..000000000000 --- a/project/scripts/common.bat +++ /dev/null @@ -1,62 +0,0 @@ -rem ########################################################################## -rem ## This code is called in build.bat, cmdTests.bat and bootstrapCmdTest.bat - -rem Flag set to ensure common code is run only once -set __COMMON__= - -set _BOT_TOKEN=dotty-token - -rem set _DRONE_BUILD_EVENT=pull_request -set _DRONE_BUILD_EVENT= -set _DRONE_REMOTE_URL= -set _DRONE_BRANCH= - -set _SOURCE=tests\pos\HelloWorld.scala -set _MAIN=HelloWorld -set _TASTY=HelloWorld.tasty -set _EXPECTED_OUTPUT=hello world - -if exist "C:\Temp\" ( set _TMP_DIR=C:\Temp -) else ( set _TMP_DIR=%TEMP% -) -set _OUT_DIR=%_TMP_DIR%\dotty_out -if not exist "%_OUT_DIR%" mkdir "%_OUT_DIR%" - -set _OUT1_DIR=%_TMP_DIR%\dotty_out1 -if not exist "%_OUT1_DIR%" mkdir "%_OUT1_DIR%" - -set _TMP_FILE=%_TMP_DIR%\dotty_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 :eof -) -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 :eof -) -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=-Xmx2048m ^ --XX:ReservedCodeCacheSize=2048m ^ --XX:MaxMetaspaceSize=1024m - -set _USER_HOME=%USERPROFILE% -for /f "delims=\" %%i in ('subst ^| findstr /e "%_USER_HOME%"') do ( - set _USER_HOME=%%i -) -set SBT_OPTS=-Ddotty.drone.mem=4096m ^ --Dsbt.ivy.home=%_USER_HOME%\.ivy2\ ^ --Dsbt.log.noformat=true - -rem this batch file was executed successfully -set __COMMON__=1 diff --git a/project/scripts/genDocs.bat b/project/scripts/genDocs.bat deleted file mode 100644 index 5beab2cb9705..000000000000 --- a/project/scripts/genDocs.bat +++ /dev/null @@ -1,93 +0,0 @@ -@echo off - -rem ########################################################################## -rem ## This batch file is based on shell script project/scripts/genDocs - -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 - -for %%f in ("%~dp0..\..") do set _ROOT_DIR=%%~sf -set _SCRIPTS_DIR=%_ROOT_DIR%\project\scripts - -if not defined __COMMON__ ( - if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\common.bat - call %_SCRIPTS_DIR%\common.bat - if not !_EXITCODE!==0 goto end -) - -rem ########################################################################## -rem ## Main - -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 end -) -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 end -) - -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 end - -rem ########################################################################## -rem ## Subroutines - -rem ########################################################################## -rem ## Cleanups - -:end -if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% -exit /b %_EXITCODE% -endlocal