Skip to content

Commit b5a9c8c

Browse files
authored
Merge pull request #1957 from dotty-staging/fix-dotc-dotr-scripts
Fix dotr/dotc scripts
2 parents e9c4942 + 40f4012 commit b5a9c8c

File tree

7 files changed

+60
-48
lines changed

7 files changed

+60
-48
lines changed

.drone.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ pipeline:
44
pull: true
55
commands:
66
- ln -s /var/cache/drone/scala-scala scala-scala
7+
- ln -s /var/cache/drone/ivy2 "$HOME/.ivy2"
78
- ./scripts/update-scala-library
8-
- sbt -J-Xmx4096m -J-XX:ReservedCodeCacheSize=512m -J-XX:MaxMetaspaceSize=1024m -Ddotty.drone.mem=4096m -ivy /var/cache/drone/ivy2 "${TEST}"
9+
- sbt -J-Xmx4096m -J-XX:ReservedCodeCacheSize=512m -J-XX:MaxMetaspaceSize=1024m -Ddotty.drone.mem=4096m "${TEST}"
910
when:
1011
branch:
1112
exclude: gh-pages
@@ -33,7 +34,7 @@ pipeline:
3334

3435
matrix:
3536
TEST:
36-
- test
37+
- ;test;dotty-bin-tests/test
3738
- ;publishLocal;dotty-bootstrapped/test
3839
- partest-only-no-bootstrap --show-diff --verbose
3940
- partest-only --show-diff --verbose

.drone.yml.sig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgdGVzdDoKICAgIGltYWdlOiBsYW1wZXBmbC9kb3R0eTpsYXRlc3QKICAgIHB1bGw6IHRydWUKICAgIGNvbW1hbmRzOgogICAgICAtIGxuIC1zIC92YXIvY2FjaGUvZHJvbmUvc2NhbGEtc2NhbGEgc2NhbGEtc2NhbGEKICAgICAgLSAuL3NjcmlwdHMvdXBkYXRlLXNjYWxhLWxpYnJhcnkKICAgICAgLSBzYnQgLUotWG14NDA5Nm0gLUotWFg6UmVzZXJ2ZWRDb2RlQ2FjaGVTaXplPTUxMm0gLUotWFg6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iAtLXZlcmJvc2UK.VRqZiSgeE6OumPlEvs4TWfxIHNOEVjR_ZmyBmapxZ-U

bin/common

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function getLastStringOnLineWith {
88
}
99

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

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

@@ -68,14 +68,14 @@ function build_jar {
6868

6969
cd - >& /dev/null
7070

71-
echo $jar
71+
echo "$jar"
7272
}
7373

7474
function update_packages {
75-
echo "$INTERFACES_JAR" > $DOTTY_ROOT/.packages
76-
echo "$MAIN_JAR" >> $DOTTY_ROOT/.packages
77-
echo "$DOTTY_LIB_JAR" >> $DOTTY_ROOT/.packages
78-
echo "$TEST_JAR" >> $DOTTY_ROOT/.packages
75+
echo "$INTERFACES_JAR" > "$DOTTY_ROOT/.packages"
76+
echo "$MAIN_JAR" >> "$DOTTY_ROOT/.packages"
77+
echo "$DOTTY_LIB_JAR" >> "$DOTTY_ROOT/.packages"
78+
echo "$TEST_JAR" >> "$DOTTY_ROOT/.packages"
7979
}
8080

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

134-
check_jar "dotty-interfaces" $INTERFACES_JAR "interfaces/src" 'INTERFACES_JAR=$(build_jar dotty-interfaces/package interfaces/target)'
135-
check_jar "dotty-compiler" $MAIN_JAR "compiler/src" 'MAIN_JAR=$(build_jar dotty-compiler/package compiler/target/scala-$SCALA_BINARY_VERSION)'
136-
check_jar "dotty-library" $DOTTY_LIB_JAR "library/src" 'DOTTY_LIB_JAR=$(build_jar dotty-library/package library/target/scala-$SCALA_BINARY_VERSION)'
137-
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)'
135+
check_jar "dotty-interfaces" "$INTERFACES_JAR" "interfaces/src" 'INTERFACES_JAR=$(build_jar dotty-interfaces/package interfaces/target)'
136+
check_jar "dotty-compiler" "$MAIN_JAR" "compiler/src" 'MAIN_JAR=$(build_jar dotty-compiler/package compiler/target/scala-$SCALA_BINARY_VERSION)'
137+
check_jar "dotty-library" "$DOTTY_LIB_JAR" "library/src" 'DOTTY_LIB_JAR=$(build_jar dotty-library/package library/target/scala-$SCALA_BINARY_VERSION)'
138+
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)'
138139

139140
# Autodetecting the scala-library location, in case it wasn't provided by an environment variable
140141
if [ "$SCALA_LIBRARY_JAR" == "" ]; then

bin/dotc

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
2+
23
# This script is used for running compiler standalone(outside of sbt)
34
# it's based on miniboxing script and paulp's launcher script
45

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

13-
source $DOTTY_ROOT/bin/common
14+
source "$DOTTY_ROOT/bin/common"
1415

1516
# dotc.build test places bootstrapped jar here
16-
DOTTY_JAR=$DOTTY_ROOT/dotty.jar
17+
DOTTY_JAR="$DOTTY_ROOT/dotty.jar"
1718

1819
CompilerMain=dotty.tools.dotc.Main
1920
FromTasty=dotty.tools.dotc.FromTasty
@@ -29,13 +30,13 @@ then
2930
fi
3031

3132
ifdebug () {
32-
[[ -n $debug ]] && eval "$@"
33+
[[ -n "$debug" ]] && eval "$@"
3334
}
3435
echoErr () {
3536
echo >&2 "$@"
3637
}
3738
dlog () {
38-
[[ -n $debug ]] && echoErr "$@"
39+
[[ -n "$debug" ]] && echoErr "$@"
3940
}
4041

4142
die() {
@@ -52,7 +53,7 @@ echoErr ""
5253
execCommand () {
5354
ifdebug echoArgs "$@"
5455
ignore="$(cat "$HOME/.scala_ignore_crashes" 2>/dev/null)"
55-
if [[ $ignore == "true" ]]; then
56+
if [[ "$ignore" == "true" ]]; then
5657
"$@" 2>&1 | scala-crash-filter
5758
else
5859
$@
@@ -62,11 +63,11 @@ execCommand () {
6263
# restore stty settings (echo in particular)
6364
restoreSttySettings () {
6465
dlog "" && dlog "[restore stty] $saved_stty"
65-
stty $saved_stty && saved_stty=""
66+
stty "$saved_stty" && saved_stty=""
6667
}
6768

6869
onExit () {
69-
[[ -n $saved_stty ]] && restoreSttySettings
70+
[[ -n "$saved_stty" ]] && restoreSttySettings
7071
exit $scala_exit_status
7172
}
7273

@@ -103,7 +104,7 @@ addResidual () {
103104
}
104105

105106
onExit() {
106-
[[ -n $saved_stty ]] && restoreSttySettings
107+
[[ -n "$saved_stty" ]] && restoreSttySettings
107108
exit $scala_exit_status
108109
}
109110

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

132-
if [[ -n $bootcp ]]; then
133+
if [[ -n "$bootcp" ]]; then
133134
boot_classpath="$(cygpath --path --$format "$toolchain:$bcpJars")"
134135
classpath="$(cygpath --path --$format "$cpJars")"
135136
cpArgs="-Xbootclasspath/a:$boot_classpath -classpath $classpath"
@@ -138,7 +139,7 @@ classpathArgs () {
138139
cpArgs="-classpath $classpath"
139140
fi
140141
else
141-
if [[ -n $bootcp ]]; then
142+
if [[ -n "$bootcp" ]]; then
142143
cpArgs="-Xbootclasspath/a:$toolchain:$bcpJars -classpath $cpJars"
143144
else
144145
cpArgs="-classpath $toolchain:$cpJars"
@@ -159,7 +160,7 @@ require_arg () {
159160
}
160161

161162

162-
main_class=$CompilerMain
163+
main_class="$CompilerMain"
163164

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

173174
# Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222
174175
-Oshort) addJava "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" && shift ;;
175-
-repl) main_class=$ReplMain && shift ;;
176-
-tasty) main_class=$FromTasty && shift ;;
177-
-compile) main_class=$CompilerMain && shift ;;
178-
-run) main_class=$ReplMain && shift ;;
179-
-fsc) main_class=$FscMain && shift ;;
176+
-repl) main_class="$ReplMain" && shift ;;
177+
-tasty) main_class="$FromTasty" && shift ;;
178+
-compile) main_class="$CompilerMain" && shift ;;
179+
-run) main_class="$ReplMain" && shift ;;
180+
-fsc) main_class="$FscMain" && shift ;;
180181
-bootcp) bootcp=true && shift ;;
181182
-nobootcp) unset bootcp && shift ;;
182183
-colors) colors=true && shift ;;

bin/dotr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ DOTTY_ROOT="$(dirname "$DOTTY_ROOT")"
99
DOTTY_ROOT="$( cd "$DOTTY_ROOT" >& /dev/null && pwd )/.." # absolute
1010

1111
# Load common functions and variables
12-
source $DOTTY_ROOT/bin/common
12+
source "$DOTTY_ROOT"/bin/common
1313

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

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

1919
if [ ! -z "$JAVA_BIN" ]; then
20-
jbin=$JAVA_BIN
20+
jbin="$JAVA_BIN"
2121
fi
2222

2323
if [ "$jbin" == "" ]; then
@@ -28,7 +28,7 @@ function runMain {
2828
fi
2929
}
3030

31-
first_arg=$1
31+
first_arg="$1"
3232

3333
if [ -z "$1" ]; then
3434
echo "Starting dotty REPL..."

bin/test/TestScripts.scala

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@ class TestScripts {
1717

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

24-
private def deletePackages: Unit = {
25-
def delete(path: String) = {
26-
val file = new JFile(path)
27-
if (file.exists) file.delete()
28-
}
26+
private def delete(path: String) = {
27+
val file = new JFile(path)
28+
if (file.exists) file.delete()
29+
}
2930

31+
private def deletePackages: Unit = {
3032
try {
3133
for (jar <- Source.fromFile("./.packages").getLines())
3234
delete(jar)
@@ -88,4 +90,11 @@ class TestScripts {
8890
ret == 0 && !output.contains("rebuilding"),
8991
s"Project recompiled when it didn't need to be. Status $ret, output:$lineSep$output")
9092
}
93+
94+
/** dotc script should work after corrupting .packages */
95+
@Test def reCreatesPackagesIfNecessary = doUnlessWindows {
96+
executeScript("sed -i.old 's/2.1/2.X/' ./.packages") // That's going to replace 2.11 with 2.X1
97+
val (retFirstBuild, _) = executeScript("./bin/dotc ./tests/pos/HelloWorld.scala")
98+
assert(retFirstBuild == 0, "building dotc failed")
99+
}
91100
}

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import sbt.Package.ManifestAttributes
1111

1212
object DottyBuild extends Build {
1313

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

1616
val dottyOrganization = "ch.epfl.lamp"
1717
val dottyVersion = {

0 commit comments

Comments
 (0)