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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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 1c721d80de581f8f52ffc5c791d1def6d686dfc0 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Mon, 3 Dec 2018 10:47:47 +0100 Subject: [PATCH 24/33] Fix window path --- bench/src/main/scala/Benchmarks.scala | 8 ++++++-- .../tools/dotc/consumetasty/ConsumeTasty.scala | 3 ++- .../dotty/tools/dottydoc/staticsite/Site.scala | 15 ++++++++------- project/Build.scala | 10 +++++----- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/bench/src/main/scala/Benchmarks.scala b/bench/src/main/scala/Benchmarks.scala index ec152b5336fa..60206de54f9a 100644 --- a/bench/src/main/scala/Benchmarks.scala +++ b/bench/src/main/scala/Benchmarks.scala @@ -30,8 +30,11 @@ object Bench { val iterations = if (intArgs.length > 1) intArgs(1).toInt else 20 val forks = if (intArgs.length > 2) intArgs(2).toInt else 1 + + import File.{ separator => sep } + val args2 = args1.map { arg => - if ((arg.endsWith(".scala") || arg.endsWith(".java")) && arg.head != '/') "../" + arg + if ((arg.endsWith(".scala") || arg.endsWith(".java")) && !(new File(arg)).isAbsolute) ".." + sep + arg else arg } storeCompileOptions(args2) @@ -61,9 +64,10 @@ object Bench { val libs = if (args.contains("-with-compiler")) compiler_libs else standard_libs var argsNorm = args.filter(_ != "-with-compiler") + import File.{ pathSeparator => sep } var cpIndex = argsNorm.indexOf("-classpath") if (cpIndex == -1) cpIndex = argsNorm.indexOf("-cp") - if (cpIndex != -1) argsNorm(cpIndex + 1) = argsNorm(cpIndex + 1) + java.io.File.pathSeparator + libs + if (cpIndex != -1) argsNorm(cpIndex + 1) = argsNorm(cpIndex + 1) + sep + libs else argsNorm = argsNorm :+ "-classpath" :+ libs val file = new File(COMPILE_OPTS_FILE) diff --git a/compiler/src/dotty/tools/dotc/consumetasty/ConsumeTasty.scala b/compiler/src/dotty/tools/dotc/consumetasty/ConsumeTasty.scala index 6fd80cbe50e2..abf366a94945 100644 --- a/compiler/src/dotty/tools/dotc/consumetasty/ConsumeTasty.scala +++ b/compiler/src/dotty/tools/dotc/consumetasty/ConsumeTasty.scala @@ -17,7 +17,8 @@ object ConsumeTasty { } val currentClasspath = QuoteDriver.currentClasspath - val args = "-from-tasty" +: "-classpath" +: s"$classpath:$currentClasspath" +: classes + import java.io.File.{ pathSeparator => sep } + val args = "-from-tasty" +: "-classpath" +: s"$classpath$sep$currentClasspath" +: classes (new Consume).process(args.toArray) } } diff --git a/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala b/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala index 523f9ebe94ce..2360fcfd7759 100644 --- a/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala +++ b/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala @@ -8,6 +8,7 @@ import java.io.{ File => JFile, OutputStreamWriter, BufferedWriter, ByteArrayInp import java.util.{ List => JList, Arrays } import java.nio.file.Path import java.nio.charset.StandardCharsets +import java.io.File.{ separator => sep } import com.vladsch.flexmark.parser.ParserEmulationProfile import com.vladsch.flexmark.parser.Parser @@ -166,8 +167,8 @@ case class Site( private def defaultParams(pageLocation: JFile, additionalDepth: Int = 0): DefaultParams = { val pathFromRoot = stripRoot(pageLocation) val baseUrl: String = { - val rootLen = root.getAbsolutePath.split('/').length - val assetLen = pageLocation.getAbsolutePath.split('/').length + val rootLen = root.getAbsolutePath.split(sep).length + val assetLen = pageLocation.getAbsolutePath.split(sep).length "../" * (assetLen - rootLen - 1 + additionalDepth) + "." } @@ -197,16 +198,16 @@ case class Site( // Suffix is index.html for packages and therefore the additional depth // is increased by 1 val (suffix, offset) = - if (e.kind == "package") ("/index.html", -1) + if (e.kind == "package") (sep + "index.html", -1) else (".html", 0) val path = if (scala.util.Properties.isWin) e.path.map(_.replace("<", "_").replace(">", "_")) else e.path - val target = mkdirs(fs.getPath(outDir.getAbsolutePath + "/api/" + path.mkString("/") + suffix)) + val target = mkdirs(fs.getPath(outDir.getAbsolutePath + sep + "api" + sep + path.mkString(sep) + suffix)) val params = defaultParams(target.toFile, -1).withPosts(blogInfo).withEntity(Some(e)).toMap - val page = new HtmlPage("_layouts/api-page.html", layouts("api-page").content, params, includes) + val page = new HtmlPage("_layouts" + sep + "api-page.html", layouts("api-page").content, params, includes) render(page).foreach { rendered => val source = new ByteArrayInputStream(rendered.getBytes(StandardCharsets.UTF_8)) @@ -223,9 +224,9 @@ case class Site( } // generate search page: - val target = mkdirs(fs.getPath(outDir.getAbsolutePath + "/api/search.html")) + val target = mkdirs(fs.getPath(outDir.getAbsolutePath + sep + "api" + sep + "search.html")) val searchPageParams = defaultParams(target.toFile, -1).withPosts(blogInfo).toMap - val searchPage = new HtmlPage("_layouts/search.html", layouts("search").content, searchPageParams, includes) + val searchPage = new HtmlPage("_layouts" + sep + "search.html", layouts("search").content, searchPageParams, includes) render(searchPage).foreach { rendered => Files.copy( new ByteArrayInputStream(rendered.getBytes(StandardCharsets.UTF_8)), diff --git a/project/Build.scala b/project/Build.scala index d616430f56fc..91fbf90c704c 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -623,13 +623,13 @@ object Build { val args: List[String] = spaceDelimited("").parsed.toList val attList = (dependencyClasspath in Runtime).value val jars = packageAll.value + import File.{ pathSeparator => sep } val scalaLib = findLib(attList, "scala-library") val dottyLib = jars("dotty-library") def run(args: List[String]): Unit = { - val sep = File.pathSeparator - val fullArgs = insertClasspathInArgs(args, s".$sep$dottyLib$sep$scalaLib") + val fullArgs = insertClasspathInArgs(args, List(".", dottyLib, scalaLib).mkString(sep)) runProcess("java" :: fullArgs, wait = true) } @@ -645,7 +645,7 @@ object Build { val asm = findLib(attList, "scala-asm") val dottyCompiler = jars("dotty-compiler") val dottyInterfaces = jars("dotty-interfaces") - run(insertClasspathInArgs(args1, s"$dottyCompiler:$dottyInterfaces:$asm")) + run(insertClasspathInArgs(args1, List(dottyCompiler, dottyInterfaces, asm).mkString(sep))) } else run(args) }, @@ -1092,8 +1092,8 @@ object Build { Developer( id = "liufengyun", name = "Liu Fengyun", - email = "liufengyun@chaos-lab.com", - url = url("http://chaos-lab.com") + email = "liu@fengy.me", + url = url("https://fengy.me") ), Developer( id = "nicolasstucki", From a5e60dd0d43baeec8a189d303891b4bb7a2bac02 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Mon, 3 Dec 2018 11:29:06 +0100 Subject: [PATCH 25/33] Fix window path in ClassPath --- .../src/dotty/tools/dotc/classpath/DirectoryClassPath.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala b/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala index a761d746efdd..fd0494c661ec 100644 --- a/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala +++ b/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala @@ -206,8 +206,9 @@ case class DirectoryClassPath(dir: JFile) extends JFileDirectoryLookup[ClassFile override def findClass(className: String): Option[ClassRepresentation] = findClassFile(className) map ClassFileEntryImpl def findClassFile(className: String): Option[AbstractFile] = { + import JFile.{ separator => sep } val relativePath = FileUtils.dirPath(className) - val classFile = new JFile(s"$dir/$relativePath.class") + val classFile = new JFile(s"$dir$sep$relativePath.class") if (classFile.exists) { val wrappedClassFile = new dotty.tools.io.File(classFile.toPath) val abstractClassFile = new PlainFile(wrappedClassFile) @@ -230,9 +231,10 @@ case class DirectorySourcePath(dir: JFile) extends JFileDirectoryLookup[SourceFi override def findClass(className: String): Option[ClassRepresentation] = findSourceFile(className) map SourceFileEntryImpl private def findSourceFile(className: String): Option[AbstractFile] = { + import JFile.{ separator => sep } val relativePath = FileUtils.dirPath(className) val sourceFile = Stream("scala", "java") - .map(ext => new JFile(s"$dir/$relativePath.$ext")) + .map(ext => new JFile(s"$dir$sep$relativePath.$ext")) .collectFirst { case file if file.exists() => file } sourceFile.map { file => From 769233a21e3f7fc3a44b09c3d042b741f610aa43 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Mon, 3 Dec 2018 11:50:21 +0100 Subject: [PATCH 26/33] More fix for window path --- .../src/dotty/tools/dotc/classpath/DirectoryClassPath.scala | 4 ++-- compiler/src/dotty/tools/dotc/classpath/FileUtils.scala | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala b/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala index fd0494c661ec..dfd8aa312f88 100644 --- a/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala +++ b/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala @@ -174,7 +174,7 @@ final class JrtClassPath(fs: java.nio.file.FileSystem) extends ClassPath with No if (inPackage == "") Nil else { packageToModuleBases.getOrElse(inPackage, Nil).flatMap(x => - Files.list(x.resolve(inPackage.replace('.', '/'))).iterator().asScala.filter(_.getFileName.toString.endsWith(".class"))).map(x => + Files.list(x.resolve(FileUtils.dirPath(inPackage))).iterator().asScala.filter(_.getFileName.toString.endsWith(".class"))).map(x => ClassFileEntryImpl(new PlainFile(new dotty.tools.io.File(x)))).toVector } } @@ -193,7 +193,7 @@ final class JrtClassPath(fs: java.nio.file.FileSystem) extends ClassPath with No else { val inPackage = packageOf(className) packageToModuleBases.getOrElse(inPackage, Nil).iterator.flatMap{x => - val file = x.resolve(className.replace('.', '/') + ".class") + val file = x.resolve(FileUtils.dirPath(className) + ".class") if (Files.exists(file)) new PlainFile(new dotty.tools.io.File(file)) :: Nil else Nil }.take(1).toList.headOption } diff --git a/compiler/src/dotty/tools/dotc/classpath/FileUtils.scala b/compiler/src/dotty/tools/dotc/classpath/FileUtils.scala index 684fc7a58239..a8628be6db3c 100644 --- a/compiler/src/dotty/tools/dotc/classpath/FileUtils.scala +++ b/compiler/src/dotty/tools/dotc/classpath/FileUtils.scala @@ -43,7 +43,7 @@ object FileUtils { else throw new FatalError("Unexpected source file ending: " + fileName) } - def dirPath(forPackage: String): String = forPackage.replace('.', '/') + def dirPath(forPackage: String): String = forPackage.replace('.', JFile.separatorChar) def endsClass(fileName: String): Boolean = fileName.length > 6 && fileName.substring(fileName.length - 6) == ".class" From 7727d513fac49cf30ee7802b11f099a5476a2ec2 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Tue, 4 Dec 2018 09:34:41 +0100 Subject: [PATCH 27/33] Refactor without using JFile.separator (thanks @michelou) --- .../src/dotty/tools/dotc/classpath/DirectoryClassPath.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala b/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala index dfd8aa312f88..73702947a991 100644 --- a/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala +++ b/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala @@ -206,9 +206,8 @@ case class DirectoryClassPath(dir: JFile) extends JFileDirectoryLookup[ClassFile override def findClass(className: String): Option[ClassRepresentation] = findClassFile(className) map ClassFileEntryImpl def findClassFile(className: String): Option[AbstractFile] = { - import JFile.{ separator => sep } val relativePath = FileUtils.dirPath(className) - val classFile = new JFile(s"$dir$sep$relativePath.class") + val classFile = new JFile(dir, relativePath + ".class") if (classFile.exists) { val wrappedClassFile = new dotty.tools.io.File(classFile.toPath) val abstractClassFile = new PlainFile(wrappedClassFile) @@ -231,10 +230,9 @@ case class DirectorySourcePath(dir: JFile) extends JFileDirectoryLookup[SourceFi override def findClass(className: String): Option[ClassRepresentation] = findSourceFile(className) map SourceFileEntryImpl private def findSourceFile(className: String): Option[AbstractFile] = { - import JFile.{ separator => sep } val relativePath = FileUtils.dirPath(className) val sourceFile = Stream("scala", "java") - .map(ext => new JFile(s"$dir$sep$relativePath.$ext")) + .map(ext => new JFile(dir, relativePath + "." + ext)) .collectFirst { case file if file.exists() => file } sourceFile.map { file => From 4b5a2bb89b7579356dadb98a48b8afb8d4a04f89 Mon Sep 17 00:00:00 2001 From: Dotty CI Date: Wed, 5 Dec 2018 09:02:57 +0100 Subject: [PATCH 28/33] 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 0ff65a5b5dcf35d3d4b7001967e08aa558351146 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Wed, 5 Dec 2018 09:15:52 +0100 Subject: [PATCH 29/33] Address review --- .../src/dotty/tools/dotc/consumetasty/ConsumeTasty.scala | 2 +- project/Build.scala | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/consumetasty/ConsumeTasty.scala b/compiler/src/dotty/tools/dotc/consumetasty/ConsumeTasty.scala index abf366a94945..2e54866459be 100644 --- a/compiler/src/dotty/tools/dotc/consumetasty/ConsumeTasty.scala +++ b/compiler/src/dotty/tools/dotc/consumetasty/ConsumeTasty.scala @@ -17,7 +17,7 @@ object ConsumeTasty { } val currentClasspath = QuoteDriver.currentClasspath - import java.io.File.{ pathSeparator => sep } + import java.io.File.{ pathSeparator => sep } val args = "-from-tasty" +: "-classpath" +: s"$classpath$sep$currentClasspath" +: classes (new Consume).process(args.toArray) } diff --git a/project/Build.scala b/project/Build.scala index 91fbf90c704c..e77c731cd370 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -623,13 +623,12 @@ object Build { val args: List[String] = spaceDelimited("").parsed.toList val attList = (dependencyClasspath in Runtime).value val jars = packageAll.value - import File.{ pathSeparator => sep } val scalaLib = findLib(attList, "scala-library") val dottyLib = jars("dotty-library") def run(args: List[String]): Unit = { - val fullArgs = insertClasspathInArgs(args, List(".", dottyLib, scalaLib).mkString(sep)) + val fullArgs = insertClasspathInArgs(args, List(".", dottyLib, scalaLib).mkString(File.pathSeparator)) runProcess("java" :: fullArgs, wait = true) } @@ -645,7 +644,7 @@ object Build { val asm = findLib(attList, "scala-asm") val dottyCompiler = jars("dotty-compiler") val dottyInterfaces = jars("dotty-interfaces") - run(insertClasspathInArgs(args1, List(dottyCompiler, dottyInterfaces, asm).mkString(sep))) + run(insertClasspathInArgs(args1, List(dottyCompiler, dottyInterfaces, asm).mkString(File.pathSeparator))) } else run(args) }, From 0a7ffbc149b4a4c1a6c2bceb4d548bb701ac1706 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Thu, 6 Dec 2018 12:09:51 +0100 Subject: [PATCH 30/33] More path fixes --- .../tools/dotc/classpath/VirtualDirectoryClassPath.scala | 4 ++-- .../src/dotty/tools/dotc/classpath/ZipArchiveFileLookup.scala | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/classpath/VirtualDirectoryClassPath.scala b/compiler/src/dotty/tools/dotc/classpath/VirtualDirectoryClassPath.scala index 1579e70afc55..ae285f80790b 100644 --- a/compiler/src/dotty/tools/dotc/classpath/VirtualDirectoryClassPath.scala +++ b/compiler/src/dotty/tools/dotc/classpath/VirtualDirectoryClassPath.scala @@ -24,7 +24,7 @@ case class VirtualDirectoryClassPath(dir: VirtualDirectory) extends ClassPath wi protected def emptyFiles: Array[AbstractFile] = Array.empty protected def getSubDir(packageDirName: String): Option[AbstractFile] = - Option(lookupPath(dir)(packageDirName.split('/'), directory = true)) + Option(lookupPath(dir)(packageDirName.split(java.io.File.separator), directory = true)) protected def listChildren(dir: AbstractFile, filter: Option[AbstractFile => Boolean] = None): Array[F] = filter match { case Some(f) => dir.iterator.filter(f).toArray case _ => dir.toArray @@ -41,7 +41,7 @@ case class VirtualDirectoryClassPath(dir: VirtualDirectory) extends ClassPath wi def findClassFile(className: String): Option[AbstractFile] = { val relativePath = FileUtils.dirPath(className) + ".class" - Option(lookupPath(dir)(relativePath split '/', directory = false)) + Option(lookupPath(dir)(relativePath.split(java.io.File.separator), directory = false)) } private[dotty] def classes(inPackage: String): Seq[ClassFileEntry] = files(inPackage) diff --git a/compiler/src/dotty/tools/dotc/classpath/ZipArchiveFileLookup.scala b/compiler/src/dotty/tools/dotc/classpath/ZipArchiveFileLookup.scala index 256956fdb54b..42226e9a3b8f 100644 --- a/compiler/src/dotty/tools/dotc/classpath/ZipArchiveFileLookup.scala +++ b/compiler/src/dotty/tools/dotc/classpath/ZipArchiveFileLookup.scala @@ -66,7 +66,7 @@ trait ZipArchiveFileLookup[FileEntryType <: ClassRepresentation] extends ClassPa } private def findDirEntry(pkg: String): Option[archive.DirEntry] = { - val dirName = s"${FileUtils.dirPath(pkg)}/" + val dirName = pkg.replace('.', '/') + "/" archive.allDirs.get(dirName) } From 0c3e55bdc6a89cdb8b56eb5ffb5963dd49e7fcc2 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Sun, 9 Dec 2018 18:40:41 +0100 Subject: [PATCH 31/33] Path fix for doc-tool and QuoteDriver In QuoteDriver, previous we have path like the following on windows: /C:/Users/dotty/My%20Programs/Java/Test/bin/myJar.jar Credit: https://stackoverflow.com/questions/6164448/convert-url-to-normal-windows-filename-java --- compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala | 3 ++- doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala b/compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala index faf48ae9e966..d0d4332c45ec 100644 --- a/compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala +++ b/compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala @@ -96,7 +96,8 @@ object QuoteDriver { case cl: URLClassLoader => // Loads the classes loaded by this class loader // When executing `run` or `test` in sbt the classpath is not in the property java.class.path - val newClasspath = cl.getURLs.map(_.getFile()) + import java.nio.file.Paths + val newClasspath = cl.getURLs.map(url => Paths.get(url.toURI).toFile) newClasspath.mkString("", java.io.File.pathSeparator, if (classpath0 == "") "" else java.io.File.pathSeparator + classpath0) case _ => classpath0 } diff --git a/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala b/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala index 2360fcfd7759..89a869e9492d 100644 --- a/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala +++ b/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala @@ -167,9 +167,9 @@ case class Site( private def defaultParams(pageLocation: JFile, additionalDepth: Int = 0): DefaultParams = { val pathFromRoot = stripRoot(pageLocation) val baseUrl: String = { - val rootLen = root.getAbsolutePath.split(sep).length - val assetLen = pageLocation.getAbsolutePath.split(sep).length - "../" * (assetLen - rootLen - 1 + additionalDepth) + "." + val rootLen = root.toPath.normalize.getNameCount + val assetLen = pageLocation.toPath.normalize.getNameCount + "../" * (assetLen - rootLen + additionalDepth) + "." } DefaultParams( @@ -203,7 +203,7 @@ case class Site( val path = if (scala.util.Properties.isWin) e.path.map(_.replace("<", "_").replace(">", "_")) - else + else e.path val target = mkdirs(fs.getPath(outDir.getAbsolutePath + sep + "api" + sep + path.mkString(sep) + suffix)) val params = defaultParams(target.toFile, -1).withPosts(blogInfo).withEntity(Some(e)).toMap From 0b847291dc5e8a3c7dbbd725b96253e3f8fa46bb Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Wed, 5 Dec 2018 09:57:19 +0100 Subject: [PATCH 32/33] Add Appveyor integration --- .appveyor.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 000000000000..dd3d31f8f57c --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,22 @@ +version: '{build}' +os: Windows Server 2012 +install: + - cmd: choco install sbt -ia "INSTALLDIR=""C:\sbt""" + - cmd: SET PATH=C:\MinGW\msys\1.0\bin;C:\sbt\bin;%JAVA_HOME%\bin;%PATH% +clone_depth: 50 +build_script: + - cd %APPVEYOR_BUILD_FOLDER% + - git submodule update --init --recursive --depth 50 --jobs 3 + - git show + - pwd + - sbt "dotty-bootstrapped/compile" +test_script: + - pwd + # - bash project/scripts/sbt test + # - bash project/scripts/sbt "dotty-bootstrapped/test" + # - bash project/scripts/sbt "dotty-bootstrapped/testCompilation" + # - cmd: project/scripts/cmdTests.bat + - cmd: project/scripts/bootstrapCmdTests.bat +cache: + - C:\sbt\ + - C:\Users\appveyor\.ivy2 From eea9da95b6bfe1f6d751029bb5915e098f8332e3 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Sun, 9 Dec 2018 18:47:51 +0100 Subject: [PATCH 33/33] Fix batch scripts "tokens=*" is needed to handle spaces in path --- project/scripts/bootstrapCmdTests.bat | 6 +++--- project/scripts/common.bat | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/project/scripts/bootstrapCmdTests.bat b/project/scripts/bootstrapCmdTests.bat index f6d43eadb40e..c501d2d0ce64 100644 --- a/project/scripts/bootstrapCmdTests.bat +++ b/project/scripts/bootstrapCmdTests.bat @@ -42,8 +42,8 @@ call "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 -with-compiler compiler/ 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 %_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" +call "%_SBT_CMD%" ";dotty-compiler-bootstrapped/dotc tests/run-with-compiler/quote-run.scala; dotty-compiler-bootstrapped/dotr -with-compiler Test" if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end ) call :grep "val a: scala.Int = 3" "%_TMP_FILE%" if not %_EXITCODE%==0 goto end @@ -99,7 +99,7 @@ if exist "%__OUT_DIR%\" ( ) goto :eof -:grep +:grep set __PATTERN=%~1 set __FILE=%~2 diff --git a/project/scripts/common.bat b/project/scripts/common.bat index 09f61adcad3b..6e0756768ece 100644 --- a/project/scripts/common.bat +++ b/project/scripts/common.bat @@ -42,7 +42,7 @@ if not %ERRORLEVEL%==0 ( goto :eof ) rem full path is required for sbt to run successfully -for /f %%i in ('where sbt.bat') do set _SBT_CMD=%%i +for /f "tokens=*" %%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.