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 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/bin/common.bat b/bin/common.bat new file mode 100644 index 000000000000..e23f13410943 --- /dev/null +++ b/bin/common.bat @@ -0,0 +1,115 @@ +@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 +call %* + +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..a77ad8be73a8 --- /dev/null +++ b/bin/dotc.bat @@ -0,0 +1,6 @@ +@echo off +setlocal + +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..015e234e99cb --- /dev/null +++ b/bin/dotd.bat @@ -0,0 +1,6 @@ +@echo off +setlocal + +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..2a25fd5da5c4 --- /dev/null +++ b/bin/dotr.bat @@ -0,0 +1,6 @@ +@echo off +setlocal + +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/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala b/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala index a761d746efdd..73702947a991 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 } @@ -207,7 +207,7 @@ case class DirectoryClassPath(dir: JFile) extends JFileDirectoryLookup[ClassFile def findClassFile(className: String): Option[AbstractFile] = { val relativePath = FileUtils.dirPath(className) - val classFile = new JFile(s"$dir/$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) @@ -232,7 +232,7 @@ case class DirectorySourcePath(dir: JFile) extends JFileDirectoryLookup[SourceFi private def findSourceFile(className: String): Option[AbstractFile] = { val relativePath = FileUtils.dirPath(className) val sourceFile = Stream("scala", "java") - .map(ext => new JFile(s"$dir/$relativePath.$ext")) + .map(ext => new JFile(dir, relativePath + "." + ext)) .collectFirst { case file if file.exists() => file } sourceFile.map { file => 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" 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) } diff --git a/compiler/src/dotty/tools/dotc/consumetasty/ConsumeTasty.scala b/compiler/src/dotty/tools/dotc/consumetasty/ConsumeTasty.scala index 6fd80cbe50e2..2e54866459be 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/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/dist/bin/common.bat b/dist/bin/common.bat new file mode 100644 index 000000000000..1d333d7b7a6f --- /dev/null +++ b/dist/bin/common.bat @@ -0,0 +1,59 @@ +rem ########################################################################## +rem ## Code common to dotc.bat, dotd.bat and dotr.bat + +if defined JAVACMD ( + set _JAVACMD=%JAVACMD% +) else if defined JAVA_HOME ( + set _JAVACMD=%JAVA_HOME%\bin\java.exe +) else if defined JDK_HOME ( + set _JAVACMD=%JDK_HOME%\bin\java.exe +) 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 ( + 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..9a4b353c28de --- /dev/null +++ b/dist/bin/dotc.bat @@ -0,0 +1,152 @@ +@echo off +setlocal enabledelayedexpansion + +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 +) +"%_JAVACMD%" %_JAVA_OPTS% %_JAVA_DEBUG% %_JAVA_ARGS% %_JVM_CP_ARGS% ^ +-Dscala.usejavacp=true ^ +%_PROG_NAME% %_SCALA_ARGS% %_RESIDUAL_ARGS% +if not %ERRORLEVEL%==0 ( + rem echo Error: Dotty compiler execution failed 1>&2 + set _EXITCODE=1 + goto end +) +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 "%__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:~2%" + call :addScala "%__ARG%" +) else ( + call :addResidual "%__ARG%" +) +shift +goto args_loop +:args_done +goto :eof + +rem output parameter: _SCALA_ARGS +:addScala +set _SCALA_ARGS=%_SCALA_ARGS% %~1 +goto :eof + +rem output parameter: _JAVA_ARGS +:addJava +set _JAVA_ARGS=%_JAVA_ARGS% %~1 +goto :eof + +rem output parameter: _RESIDUAL_ARGS +:addResidual +set _RESIDUAL_ARGS=%_RESIDUAL_ARGS% %~1 +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 +exit /b %_EXITCODE% +endlocal + diff --git a/dist/bin/dotd.bat b/dist/bin/dotd.bat new file mode 100644 index 000000000000..f1a40fbeca51 --- /dev/null +++ b/dist/bin/dotd.bat @@ -0,0 +1,99 @@ +@echo off +setlocal enabledelayedexpansion + +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 + +"%_JAVACMD%" -Dscala.usejavacp=true -classpath "%_CLASS_PATH%" dotty.tools.dottydoc.Main %* +if not %ERRORLEVEL%==0 ( + rem echo Error: Dottydoc execution failed 1>&2 + 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 +exit /b %_EXITCODE% +endlocal diff --git a/dist/bin/dotr.bat b/dist/bin/dotr.bat new file mode 100644 index 000000000000..23ecf372fdd9 --- /dev/null +++ b/dist/bin/dotr.bat @@ -0,0 +1,101 @@ +@echo off +setlocal enabledelayedexpansion + +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_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 +) 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!" %_JVM_OPTS% %_RESIDUAL_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_OPTS= +set _JAVA_OPTS= + +:args_loop +if "%~1"=="" goto args_done +set "__ARG=%~1" +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_OPTS=!_JVM_OPTS! %__ARG:~2% + set _JAVA_OPTS=!_JAVA_OPTS! %__ARG% +) else ( + set _RESIDUAL_ARGS=%_RESIDUAL_ARGS% %__ARG% +) +shift +goto args_loop +:args_done +goto :eof + +rem ########################################################################## +rem ## Cleanups + +:end +exit /b %_EXITCODE% +endlocal diff --git a/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala b/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala index 523f9ebe94ce..89a869e9492d 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,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('/').length - val assetLen = pageLocation.getAbsolutePath.split('/').length - "../" * (assetLen - rootLen - 1 + additionalDepth) + "." + val rootLen = root.toPath.normalize.getNameCount + val assetLen = pageLocation.toPath.normalize.getNameCount + "../" * (assetLen - rootLen + additionalDepth) + "." } DefaultParams( @@ -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 + 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 6980aca320bb..e0c022e06a06 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -628,8 +628,7 @@ object Build { 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(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, s"$dottyCompiler:$dottyInterfaces:$asm")) + run(insertClasspathInArgs(args1, List(dottyCompiler, dottyInterfaces, asm).mkString(File.pathSeparator))) } else run(args) }, @@ -1092,8 +1091,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", diff --git a/project/scripts/bootstrapCmdTests.bat b/project/scripts/bootstrapCmdTests.bat new file mode 100644 index 000000000000..c501d2d0ce64 --- /dev/null +++ b/project/scripts/bootstrapCmdTests.bat @@ -0,0 +1,133 @@ +@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. +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" +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 + +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 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 + +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 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 + +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 new file mode 100644 index 000000000000..a0cddc7e9848 --- /dev/null +++ b/project/scripts/build.bat @@ -0,0 +1,299 @@ +@echo off + +rem ########################################################################## +rem ## This batch file is based on configuration file .drone.yml + +setlocal enabledelayedexpansion + +rem only for interactive debugging +set _DEBUG=0 + +rem ########################################################################## +rem ## Environment setup + +set _BASENAME=%~n0 + +set _EXITCODE=0 + +for %%f in ("%~dp0..\..") do set _ROOT_DIR=%%~sf +set _SCRIPTS_DIR=%_ROOT_DIR%\project\scripts + +call %_SCRIPTS_DIR%\common.bat +if not %_EXITCODE%==0 goto end + +rem set _DRONE_BUILD_EVENT=pull_request +set _DRONE_BUILD_EVENT= +set _DRONE_REMOTE_URL= +set _DRONE_BRANCH= + +call :args %* +if not %_EXITCODE%==0 goto end +if defined _HELP call :help & exit /b %_EXITCODE% + +rem ########################################################################## +rem ## Main + +call :init +if not %_EXITCODE%==0 goto end + +if defined _CLEAN_ALL ( + call :clean_all + if not !_EXITCODE!==0 goto end +) +if defined _CLONE ( + call :clone + if not !_EXITCODE!==0 goto end +) +if defined _COMPILE ( + call :test + if not !_EXITCODE!==0 goto end +) +if defined _BOOTSTRAP ( + call :test_bootstrapped + rem if not !_EXITCODE!==0 goto end + if not !_EXITCODE!==0 ( + if defined _IGNORE ( echo ###### Warning: _EXITCODE=!_EXITCODE! ####### 1>&2 + ) else ( goto end + ) + ) +) +if defined _SBT ( + call :test_sbt + if not !_EXITCODE!==0 goto end +) +if defined _DOCUMENTATION ( + call :documentation + if not !_EXITCODE!==0 goto end +) +if defined _ARCHIVES ( + call :archives + if not !_EXITCODE!==0 goto end +) +goto end + +rem ########################################################################## +rem ## Subroutines + +rem input parameter: %* +rem output parameters: _CLONE, _COMPILE, _DOCUMENTATION, _SBT, _TIMER, _VERBOSE +:args +set _ARCHIVES= +set _BOOTSTRAP= +set _COMPILE= +set _CLEAN_ALL= +set _CLONE= +set _DOCUMENTATION= +set _HELP= +set _SBT= +set _TIMER=0 +set _VERBOSE=0 + +:args_loop +set __ARG=%~1 +if not defined __ARG goto args_done +if /i "%__ARG%"=="help" ( set _HELP=1& goto :eof +) else if /i "%__ARG%"=="-timer" ( set _TIMER=1 +) else if /i "%__ARG%"=="-verbose" ( set _VERBOSE=1 +) else if /i "%__ARG:~0,4%"=="arch" ( + if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _COMPILE=1& set _BOOTSTRAP=1 + set _ARCHIVES=1 +) else if /i "%__ARG:~0,4%"=="boot" ( + if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _COMPILE=1 + set _BOOTSTRAP=1 +) else if /i "%__ARG%"=="cleanall" ( set _CLEAN_ALL=1 +) else if /i "%__ARG%"=="clone" ( set _CLONE=1 +) else if /i "%__ARG:~0,7%"=="compile" ( + if not "%__ARG:~-5%"=="-only" set _CLONE=1 + set _COMPILE=1 +) else if /i "%__ARG:~0,3%"=="doc" ( + if not "%__ARG:~-5%"=="-only" set _CLONE=1& set _COMPILE=1& set _BOOTSTRAP=1 + set _DOCUMENTATION=1 +) else if /i "%__ARG%"=="sbt" ( + set _CLONE=1& set _COMPILE=1& set _BOOTSTRAP=1& set _SBT=1 +) else if /i "%__ARG%"=="sbt-only" ( + set _SBT=1 +) else ( + echo Error: Unknown subcommand %__ARG% 1>&2 + set _EXITCODE=1 + goto :eof +) +shift +goto args_loop +:args_done +goto :eof + +:help +echo Usage: %_BASENAME% { options ^| subcommands } +echo Options: +echo -timer display total execution time +echo -verbose display environment settings +echo Subcommands: +echo arch[ives] generate gz/zip archives (after bootstrap) +echo boot[strap] generate+test bootstrapped compiler (after compile) +echo cleanall clean project (sbt+git) and quit +echo clone update submodules +echo compile generate+test 1st stage compiler (after clone) +echo doc[umentation] generate documentation (after bootstrap) +echo help display this help message +echo sbt test sbt-dotty (after bootstrap) +echo Advanced subcommands (no deps): +echo arch[ives]-only generate ONLY gz/zip archives +echo boot[strap]-only generate+test ONLY bootstrapped compiler +echo compile-only generate+test ONLY 1st stage compiler +echo doc[umentation]-only] generate ONLY documentation +echo sbt-only test ONLY sbt-dotty + +goto :eof + +:init +if %_VERBOSE%==1 ( + for /f %%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 ( + for /f "delims=" %%i in ('powershell -c "(Get-Date)"') do set _TIMER_START=%%i +) +goto :eof + +:clean_all +echo run sbt clean and git clean -xdf --exclude=*.bat --exclude=*.ps1 +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" clean +call "%_SBT_CMD%" clean +if not %ERRORLEVEL%==0 ( + set _EXITCODE=1 + goto :eof +) +if %_DEBUG%==1 echo [%_BASENAME%] %_GIT_CMD% clean -xdf --exclude=*.bat --exclude=*.ps1 +%_GIT_CMD% clean -xdf --exclude=*.bat --exclude=*.ps1 +if not %ERRORLEVEL%==0 ( + set _EXITCODE=1 + goto :eof +) +goto :eof + +:clone +if "%_DRONE_BUILD_EVENT%"=="pull_request" if defined _DRONE_REMOTE_URL ( + %_GIT_CMD% config user.email "dotty.bot@epfl.ch" + %_GIT_CMD% config user.name "Dotty CI" + %_GIT_CMD% pull "%_DRONE_REMOTE_URL%" "%_DRONE_BRANCH%" +) +if %_DEBUG%==1 echo [%_BASENAME%] %_GIT_CMD% submodule update --init --recursive --jobs 3 +%_GIT_CMD% submodule update --init --recursive --jobs 3 +if not %ERRORLEVEL%==0 ( + echo Error: Failed to update Git submodules 1>&2 + set _EXITCODE=1 + goto :eof +) +goto :eof + +:test +echo sbt compile and sbt test +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";compile ;test" +call "%_SBT_CMD%" ";compile ;test" +if not %ERRORLEVEL%==0 ( + echo Error: Failed to build Dotty 1>&2 + set _EXITCODE=1 + goto :eof +) + +rem see shell script project/scripts/cmdTests +if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\cmdTests.bat +call %_SCRIPTS_DIR%\cmdTests.bat +if not %ERRORLEVEL%==0 ( + echo Error: Failed to run cmdTest.bat 1>&2 + set _EXITCODE=1 + goto :eof +) +goto :eof + +:test_bootstrapped +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" ";dotty-bootstrapped/compile ;dotty-bootstrapped/test" +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 +) + +rem see shell script project/scripts/bootstrapCmdTests +if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\bootstrapCmdTests.bat +call %_SCRIPTS_DIR%\bootstrapCmdTests.bat +if not %ERRORLEVEL%==0 ( + echo Error: Failed to run bootstrapCmdTests.bat 1>&2 + set _EXITCODE=1 + goto :eof +) +goto :eof + +: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 + +: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 +if %_DEBUG%==1 echo [%_BASENAME%] call "%_SBT_CMD%" dist-bootstrapped/packArchive +call "%_SBT_CMD%" dist-bootstrapped/packArchive +rem output directory for gz/zip archives +set __TARGET_DIR=%_ROOT_DIR%\dist-bootstrapped\target +if not exist "%__TARGET_DIR%\" ( + echo Error: Directory target not found 1>&2 + set _EXITCODE=1 + goto :eof +) +if %_DEBUG%==1 ( + echo. + echo Output directory: %__TARGET_DIR%\ + dir /b /a-d "%__TARGET_DIR%" +) +goto :eof + +rem output parameter: _DURATION +:duration +set __START=%~1 +set __END=%~2 + +for /f "delims=" %%i in ('powershell -c "$interval = New-TimeSpan -Start '%__START%' -End '%__END%'; Write-Host $interval"') do set _DURATION=%%i +goto :eof + +rem input parameter: 1=start time +:total +set __TIMER_START=%~1 + +for /f "delims=" %%i in ('powershell -c "(Get-Date)"') do set __TIMER_END=%%i +call :duration "%_TIMER_START%" "!__TIMER_END!" +echo Total execution time: %_DURATION% +goto :eof + +rem ########################################################################## +rem ## Cleanups + +:end +if %_TIMER%==1 call :total "%_TIMER_START%" +if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE% +exit /b %_EXITCODE% +endlocal diff --git a/project/scripts/cmdTests.bat b/project/scripts/cmdTests.bat new file mode 100644 index 000000000000..5cf974799262 --- /dev/null +++ b/project/scripts/cmdTests.bat @@ -0,0 +1,113 @@ +@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 + +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%" +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 -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 + +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 + +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..6e0756768ece --- /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 "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. +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