Skip to content

Commit d19aec7

Browse files
committed
Merge pull request #837 from dotty-staging/bootstrapped
Quick&dirty bootstrap
2 parents 2e606a8 + bc3e499 commit d19aec7

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

bin/dotc

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ SCALA_COMPILER_VERSION=$(getLastStringOnLineWith "scala-compiler")
2424
DOTTY_VERSION=$(getLastStringOnLineWith "version in")
2525
JLINE_VERSION=$(getLastStringOnLineWith "jline")
2626
bootcp=true
27+
bootstrapped=false
2728
default_java_opts="-Xmx768m -Xms768m"
2829
programName=$(basename "$0")
2930
# uncomment next line to enable debug output
@@ -44,12 +45,14 @@ ReplMain=test.DottyRepl
4445
# autodetecting the compiler jar. this is location where sbt 'packages' it
4546
MAIN_JAR=$DOTTY_ROOT/target/scala-$SCALA_BINARY_VERSION/dotty_$SCALA_BINARY_VERSION-$DOTTY_VERSION.jar
4647
TEST_JAR=$DOTTY_ROOT/target/scala-$SCALA_BINARY_VERSION/dotty_$SCALA_BINARY_VERSION-$DOTTY_VERSION-tests.jar
48+
DOTTY_JAR=$DOTTY_ROOT/dotty.jar
49+
4750
function checkjar {
4851
if [ ! -f "$1" ]
4952
then
5053
echo "The script is going to build the required jar file $1 by running \"sbt $2\""
5154
cd $DOTTY_ROOT
52-
sbt $2
55+
sbt "$2"
5356
cd -
5457
if [ ! -f "$1" ]
5558
then
@@ -64,7 +67,7 @@ function checkjar {
6467
then
6568
echo "new files detected. rebuilding"
6669
cd $DOTTY_ROOT
67-
sbt $2
70+
sbt "$2"
6871
touch "$1"
6972
cd -
7073
fi
@@ -189,7 +192,13 @@ trap onExit INT
189192
# If using the boot classpath, also pass an empty classpath
190193
# to java to suppress "." from materializing.
191194
classpathArgs () {
192-
toolchain="$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$JLINE_JAR"
195+
if [[ -n $bootstrapped ]]; then
196+
checkjar $DOTTY_JAR "test:runMain dotc.build" src
197+
toolchain="$DOTTY_JAR:$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$JLINE_JAR"
198+
else
199+
toolchain="$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$JLINE_JAR"
200+
fi
201+
193202
if [[ -n "$cygwin" ]]; then
194203
if [[ "$OS" = "Windows_NT" ]] && cygpath -m .>/dev/null 2>/dev/null ; then
195204
format=mixed
@@ -233,6 +242,7 @@ while [[ $# -gt 0 ]]; do
233242
case "$1" in
234243
--) shift; for arg; do addResidual "$arg"; done; set -- ;;
235244
-h|-help) usage; exit 1 ;;
245+
-bootstrapped) bootstrapped=true && shift ;;
236246
-v|-verbose) verbose=true && shift ;;
237247
-d|-debug) debug=true && shift ;;
238248
-q|-quiet) quiet=true && shift ;;

test/dotc/build.scala

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package dotc
2+
3+
import java.io.File
4+
5+
object build extends tests {
6+
7+
private def deleteFilesInFolder(folder: File, deleteFolder: Boolean = false): Unit = {
8+
val files = folder.listFiles()
9+
if(files != null) { //some JVMs return null for empty dirs
10+
for(f <- files) {
11+
if(f.isDirectory) {
12+
deleteFilesInFolder(f, deleteFolder = true)
13+
} else {
14+
f.delete()
15+
}
16+
}
17+
}
18+
if(deleteFolder) folder.delete()
19+
}
20+
21+
def main(args: Array[String]): Unit = {
22+
deleteFilesInFolder(new File(defaultOutputDir)) // clear previous output
23+
dotty // build output dir
24+
val p = Runtime.getRuntime.exec(Array("jar", "cf", "dotty.jar", "-C", "out", "."))
25+
p.waitFor()
26+
p
27+
}
28+
}

0 commit comments

Comments
 (0)