Skip to content

Fix dotr/dotc scripts #1957

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 8 commits into from
Feb 10, 2017
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
5 changes: 3 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ pipeline:
pull: true
commands:
- ln -s /var/cache/drone/scala-scala scala-scala
- ln -s /var/cache/drone/ivy2 "$HOME/.ivy2"
- ./scripts/update-scala-library
- sbt -J-Xmx4096m -J-XX:ReservedCodeCacheSize=512m -J-XX:MaxMetaspaceSize=1024m -Ddotty.drone.mem=4096m -ivy /var/cache/drone/ivy2 "${TEST}"
- sbt -J-Xmx4096m -J-XX:ReservedCodeCacheSize=512m -J-XX:MaxMetaspaceSize=1024m -Ddotty.drone.mem=4096m "${TEST}"
when:
branch:
exclude: gh-pages
Expand Down Expand Up @@ -33,7 +34,7 @@ pipeline:

matrix:
TEST:
- test
- ;test;dotty-bin-tests/test
- ;publishLocal;dotty-bootstrapped/test
- partest-only-no-bootstrap --show-diff --verbose
- partest-only --show-diff --verbose
2 changes: 1 addition & 1 deletion .drone.yml.sig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgdGVzdDoKICAgIGltYWdlOiBsYW1wZXBmbC9kb3R0eTpsYXRlc3QKICAgIHB1bGw6IHRydWUKICAgIGNvbW1hbmRzOgogICAgICAtIGxuIC1zIC92YXIvY2FjaGUvZHJvbmUvc2NhbGEtc2NhbGEgc2NhbGEtc2NhbGEKICAgICAgLSAuL3NjcmlwdHMvdXBkYXRlLXNjYWxhLWxpYnJhcnkKICAgICAgLSBzYn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AgLS1zaG93LWRpZmYgLS12ZXJib3NlCiAgICAtIHBhcnRlc3Qtb25seSAtLXNob3ctZGlmZiAtLXZlcmJvc2UK.VRqZiSgeE6OumPlEvs4TWfxIHNOEVjR_ZmyBmapxZ-U
33 changes: 17 additions & 16 deletions bin/common
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function getLastStringOnLineWith {
}

# Configuration
SCALA_VERSION=$(getLastStringOnLineWith "scalaVersion in")
SCALA_VERSION=$(getLastStringOnLineWith "val scalacVersion")
SCALA_BINARY_VERSION=2.11
SCALA_COMPILER_VERSION=$(getLastStringOnLineWith "scala-compiler")
SBT_VERSION=$(grep "sbt.version=" "$DOTTY_ROOT/project/build.properties" | sed 's/sbt.version=//')
Expand Down Expand Up @@ -40,9 +40,9 @@ ERROR_LOG=error.log
trap onTerminate SIGTERM

onTerminate() {
if [ -f $ERROR_LOG ]; then
cat $ERROR_LOG
rm -f $ERROR_LOG
if [ -f "$ERROR_LOG" ]; then
cat "$ERROR_LOG"
rm -f "$ERROR_LOG"
fi
exit 1 # $? is lost from subprocess in command substitution.
}
Expand All @@ -52,7 +52,7 @@ function build_jar {
# build_jar package path/to/jar/dir ['/some/sed/command']
#
# Last arg is optional
cd $DOTTY_ROOT >& /dev/null
cd "$DOTTY_ROOT" >& /dev/null
local build_output=$(sbt "$1" || (echo "failed to run: sbt $1" >> $ERROR_LOG; kill -SIGTERM $$))
local jar=$(echo $build_output | sed -n 's/.*Packaging //g; s/ \.\.\..*//g; /^\/.*/p')

Expand All @@ -68,14 +68,14 @@ function build_jar {

cd - >& /dev/null

echo $jar
echo "$jar"
}

function update_packages {
echo "$INTERFACES_JAR" > $DOTTY_ROOT/.packages
echo "$MAIN_JAR" >> $DOTTY_ROOT/.packages
echo "$DOTTY_LIB_JAR" >> $DOTTY_ROOT/.packages
echo "$TEST_JAR" >> $DOTTY_ROOT/.packages
echo "$INTERFACES_JAR" > "$DOTTY_ROOT/.packages"
echo "$MAIN_JAR" >> "$DOTTY_ROOT/.packages"
echo "$DOTTY_LIB_JAR" >> "$DOTTY_ROOT/.packages"
echo "$TEST_JAR" >> "$DOTTY_ROOT/.packages"
}

function build_all {
Expand Down Expand Up @@ -122,19 +122,20 @@ function check_jar {
# Usage:
# check_jar "name" "path/to/package.jar" "sources/dir" 'lambda to exec on failure'
local new_files="$(find "$DOTTY_ROOT/$3" \( -iname "*.scala" -o -iname "*.java" \) -newer "$2")"
if [ ! -z "$new_files" ]; then
# If the find failed, or if it found new files...
if [ "$?" -ne 0 ] || [ ! -z "$new_files" ]; then
printf "New files detected in $1, rebuilding..."
rm $2
rm "$2"
eval "$4"
printf "done\n"
update_packages
fi
}

check_jar "dotty-interfaces" $INTERFACES_JAR "interfaces/src" 'INTERFACES_JAR=$(build_jar dotty-interfaces/package interfaces/target)'
check_jar "dotty-compiler" $MAIN_JAR "compiler/src" 'MAIN_JAR=$(build_jar dotty-compiler/package compiler/target/scala-$SCALA_BINARY_VERSION)'
check_jar "dotty-library" $DOTTY_LIB_JAR "library/src" 'DOTTY_LIB_JAR=$(build_jar dotty-library/package library/target/scala-$SCALA_BINARY_VERSION)'
check_jar "dotty-tests" $TEST_JAR "compiler/test" 'TEST_JAR=$(build_jar dotty-compiler/test:package compiler/target/scala-$SCALA_BINARY_VERSION /dotty.*-tests\.jar/p)'
check_jar "dotty-interfaces" "$INTERFACES_JAR" "interfaces/src" 'INTERFACES_JAR=$(build_jar dotty-interfaces/package interfaces/target)'
check_jar "dotty-compiler" "$MAIN_JAR" "compiler/src" 'MAIN_JAR=$(build_jar dotty-compiler/package compiler/target/scala-$SCALA_BINARY_VERSION)'
check_jar "dotty-library" "$DOTTY_LIB_JAR" "library/src" 'DOTTY_LIB_JAR=$(build_jar dotty-library/package library/target/scala-$SCALA_BINARY_VERSION)'
check_jar "dotty-tests" "$TEST_JAR" "compiler/test" 'TEST_JAR=$(build_jar dotty-compiler/test:package compiler/target/scala-$SCALA_BINARY_VERSION /dotty.*-tests\.jar/p)'

# Autodetecting the scala-library location, in case it wasn't provided by an environment variable
if [ "$SCALA_LIBRARY_JAR" == "" ]; then
Expand Down
37 changes: 19 additions & 18 deletions bin/dotc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash

# This script is used for running compiler standalone(outside of sbt)
# it's based on miniboxing script and paulp's launcher script

Expand All @@ -10,10 +11,10 @@ fi
DOTTY_ROOT="$(dirname "$DOTTY_ROOT")"
DOTTY_ROOT="$( cd "$DOTTY_ROOT" >& /dev/null && pwd )/.." # absolute

source $DOTTY_ROOT/bin/common
source "$DOTTY_ROOT/bin/common"

# dotc.build test places bootstrapped jar here
DOTTY_JAR=$DOTTY_ROOT/dotty.jar
DOTTY_JAR="$DOTTY_ROOT/dotty.jar"

CompilerMain=dotty.tools.dotc.Main
FromTasty=dotty.tools.dotc.FromTasty
Expand All @@ -29,13 +30,13 @@ then
fi

ifdebug () {
[[ -n $debug ]] && eval "$@"
[[ -n "$debug" ]] && eval "$@"
}
echoErr () {
echo >&2 "$@"
}
dlog () {
[[ -n $debug ]] && echoErr "$@"
[[ -n "$debug" ]] && echoErr "$@"
}

die() {
Expand All @@ -52,7 +53,7 @@ echoErr ""
execCommand () {
ifdebug echoArgs "$@"
ignore="$(cat "$HOME/.scala_ignore_crashes" 2>/dev/null)"
if [[ $ignore == "true" ]]; then
if [[ "$ignore" == "true" ]]; then
"$@" 2>&1 | scala-crash-filter
else
$@
Expand All @@ -62,11 +63,11 @@ execCommand () {
# restore stty settings (echo in particular)
restoreSttySettings () {
dlog "" && dlog "[restore stty] $saved_stty"
stty $saved_stty && saved_stty=""
stty "$saved_stty" && saved_stty=""
}

onExit () {
[[ -n $saved_stty ]] && restoreSttySettings
[[ -n "$saved_stty" ]] && restoreSttySettings
exit $scala_exit_status
}

Expand Down Expand Up @@ -103,7 +104,7 @@ addResidual () {
}

onExit() {
[[ -n $saved_stty ]] && restoreSttySettings
[[ -n "$saved_stty" ]] && restoreSttySettings
exit $scala_exit_status
}

Expand All @@ -113,8 +114,8 @@ trap onExit INT
# If using the boot classpath, also pass an empty classpath
# to java to suppress "." from materializing.
classpathArgs () {
if [[ "true" == $bootstrapped ]]; then
check_jar "dotty-bootstrapped" $DOTTY_JAR "target" 'build_jar "test:runMain dotc.build" target' &> /dev/null
if [[ "true" == "$bootstrapped" ]]; then
check_jar "dotty-bootstrapped" "$DOTTY_JAR" "target" 'build_jar "test:runMain dotc.build" target' &> /dev/null
toolchain="$DOTTY_JAR:$DOTTY_LIB_JAR:$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$SBT_INTERFACE_JAR"
else
toolchain="$SCALA_LIBRARY_JAR:$DOTTY_LIB_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$SBT_INTERFACE_JAR"
Expand All @@ -129,7 +130,7 @@ classpathArgs () {
format=windows
fi

if [[ -n $bootcp ]]; then
if [[ -n "$bootcp" ]]; then
boot_classpath="$(cygpath --path --$format "$toolchain:$bcpJars")"
classpath="$(cygpath --path --$format "$cpJars")"
cpArgs="-Xbootclasspath/a:$boot_classpath -classpath $classpath"
Expand All @@ -138,7 +139,7 @@ classpathArgs () {
cpArgs="-classpath $classpath"
fi
else
if [[ -n $bootcp ]]; then
if [[ -n "$bootcp" ]]; then
cpArgs="-Xbootclasspath/a:$toolchain:$bcpJars -classpath $cpJars"
else
cpArgs="-classpath $toolchain:$cpJars"
Expand All @@ -159,7 +160,7 @@ require_arg () {
}


main_class=$CompilerMain
main_class="$CompilerMain"

while [[ $# -gt 0 ]]; do
case "$1" in
Expand All @@ -172,11 +173,11 @@ case "$1" in

# Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222
-Oshort) addJava "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" && shift ;;
-repl) main_class=$ReplMain && shift ;;
-tasty) main_class=$FromTasty && shift ;;
-compile) main_class=$CompilerMain && shift ;;
-run) main_class=$ReplMain && shift ;;
-fsc) main_class=$FscMain && shift ;;
-repl) main_class="$ReplMain" && shift ;;
-tasty) main_class="$FromTasty" && shift ;;
-compile) main_class="$CompilerMain" && shift ;;
-run) main_class="$ReplMain" && shift ;;
-fsc) main_class="$FscMain" && shift ;;
-bootcp) bootcp=true && shift ;;
-nobootcp) unset bootcp && shift ;;
-colors) colors=true && shift ;;
Expand Down
6 changes: 3 additions & 3 deletions bin/dotr
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ DOTTY_ROOT="$(dirname "$DOTTY_ROOT")"
DOTTY_ROOT="$( cd "$DOTTY_ROOT" >& /dev/null && pwd )/.." # absolute

# Load common functions and variables
source $DOTTY_ROOT/bin/common
source "$DOTTY_ROOT"/bin/common

CLASS_PATH="-classpath .:$DOTTY_LIB_JAR:.:$SCALA_LIBRARY_JAR"

function runMain {
local jbin=$(which "java")

if [ ! -z "$JAVA_BIN" ]; then
jbin=$JAVA_BIN
jbin="$JAVA_BIN"
fi

if [ "$jbin" == "" ]; then
Expand All @@ -28,7 +28,7 @@ function runMain {
fi
}

first_arg=$1
first_arg="$1"

if [ -z "$1" ]; then
echo "Starting dotty REPL..."
Expand Down
23 changes: 16 additions & 7 deletions bin/test/TestScripts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ class TestScripts {

private def executeScript(script: String): (Int, String) = {
val sb = new StringBuilder
val ret = Process(script) ! ProcessLogger(sb append _)
(ret, sb.toString)
val ret = Process(script) ! ProcessLogger { line => println(line); sb.append(line) }
val output = sb.toString
println(output) // For CI, otherwise "terminal inactive for 5m0s, build cancelled"
(ret, output)
}

private def deletePackages: Unit = {
def delete(path: String) = {
val file = new JFile(path)
if (file.exists) file.delete()
}
private def delete(path: String) = {
val file = new JFile(path)
if (file.exists) file.delete()
}

private def deletePackages: Unit = {
try {
for (jar <- Source.fromFile("./.packages").getLines())
delete(jar)
Expand Down Expand Up @@ -88,4 +90,11 @@ class TestScripts {
ret == 0 && !output.contains("rebuilding"),
s"Project recompiled when it didn't need to be. Status $ret, output:$lineSep$output")
}

/** dotc script should work after corrupting .packages */
@Test def reCreatesPackagesIfNecessary = doUnlessWindows {
executeScript("sed -i.old 's/2.1/2.X/' ./.packages") // That's going to replace 2.11 with 2.X1
val (retFirstBuild, _) = executeScript("./bin/dotc ./tests/pos/HelloWorld.scala")
assert(retFirstBuild == 0, "building dotc failed")
}
}
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import sbt.Package.ManifestAttributes

object DottyBuild extends Build {

val scalacVersion = "2.11.5"
val scalacVersion = "2.11.5" // Do not rename, this is grepped in bin/common.

val dottyOrganization = "ch.epfl.lamp"
val dottyVersion = {
Expand Down