Skip to content

Quick&dirty bootstrap #837

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions bin/dotc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ SCALA_COMPILER_VERSION=$(getLastStringOnLineWith "scala-compiler")
DOTTY_VERSION=$(getLastStringOnLineWith "version in")
JLINE_VERSION=$(getLastStringOnLineWith "jline")
bootcp=true
bootstrapped=false
default_java_opts="-Xmx768m -Xms768m"
programName=$(basename "$0")
# uncomment next line to enable debug output
Expand All @@ -44,12 +45,14 @@ ReplMain=test.DottyRepl
# autodetecting the compiler jar. this is location where sbt 'packages' it
MAIN_JAR=$DOTTY_ROOT/target/scala-$SCALA_BINARY_VERSION/dotty_$SCALA_BINARY_VERSION-$DOTTY_VERSION.jar
TEST_JAR=$DOTTY_ROOT/target/scala-$SCALA_BINARY_VERSION/dotty_$SCALA_BINARY_VERSION-$DOTTY_VERSION-tests.jar
DOTTY_JAR=$DOTTY_ROOT/dotty.jar

function checkjar {
if [ ! -f "$1" ]
then
echo "The script is going to build the required jar file $1 by running \"sbt $2\""
cd $DOTTY_ROOT
sbt $2
sbt "$2"
cd -
if [ ! -f "$1" ]
then
Expand All @@ -64,7 +67,7 @@ function checkjar {
then
echo "new files detected. rebuilding"
cd $DOTTY_ROOT
sbt $2
sbt "$2"
touch "$1"
cd -
fi
Expand Down Expand Up @@ -189,7 +192,13 @@ trap onExit INT
# If using the boot classpath, also pass an empty classpath
# to java to suppress "." from materializing.
classpathArgs () {
toolchain="$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$JLINE_JAR"
if [[ -n $bootstrapped ]]; then
checkjar $DOTTY_JAR "test:runMain dotc.build" src
toolchain="$DOTTY_JAR:$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$JLINE_JAR"
else
toolchain="$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$JLINE_JAR"
fi

if [[ -n "$cygwin" ]]; then
if [[ "$OS" = "Windows_NT" ]] && cygpath -m .>/dev/null 2>/dev/null ; then
format=mixed
Expand Down Expand Up @@ -233,6 +242,7 @@ while [[ $# -gt 0 ]]; do
case "$1" in
--) shift; for arg; do addResidual "$arg"; done; set -- ;;
-h|-help) usage; exit 1 ;;
-bootstrapped) bootstrapped=true && shift ;;
-v|-verbose) verbose=true && shift ;;
-d|-debug) debug=true && shift ;;
-q|-quiet) quiet=true && shift ;;
Expand Down
28 changes: 28 additions & 0 deletions test/dotc/build.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dotc

import java.io.File

object build extends tests {

private def deleteFilesInFolder(folder: File, deleteFolder: Boolean = false): Unit = {
val files = folder.listFiles()
if(files != null) { //some JVMs return null for empty dirs
for(f <- files) {
if(f.isDirectory) {
deleteFilesInFolder(f, deleteFolder = true)
} else {
f.delete()
}
}
}
if(deleteFolder) folder.delete()
}

def main(args: Array[String]): Unit = {
deleteFilesInFolder(new File(defaultOutputDir)) // clear previous output
dotty // build output dir
val p = Runtime.getRuntime.exec(Array("jar", "cf", "dotty.jar", "-C", "out", "."))
p.waitFor()
p
}
}