Skip to content

Commit 02a1424

Browse files
rsoeldnerallanrenucci
authored andcommitted
Add custom classpath, #3477
1 parent cc43c34 commit 02a1424

File tree

2 files changed

+57
-22
lines changed

2 files changed

+57
-22
lines changed

dist/bin/dotr

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bash
22

3+
IFS=""
34
# Try to autodetect real location of the script
45

56
if [ -z "$PROG_HOME" ] ; then
@@ -31,18 +32,52 @@ source "$PROG_HOME/bin/common"
3132

3233
CLASS_PATH=".$PSEP$DOTTY_LIB$PSEP$SCALA_LIB"
3334

34-
# -d must be the first option
35-
case "$1" in
36-
-d) DEBUG="$DEBUG_STR" && shift ;;
37-
esac
35+
addResidual () {
36+
residual_args+=("$1")
37+
}
3838

39-
first_arg="$1"
39+
addCustomClassPath () {
40+
classpath_args+=("$1:")
41+
}
4042

41-
if [ -z "$1" ]; then
43+
run_repl=false
44+
45+
while [[ $# -gt 0 ]]; do
46+
key=$1
47+
case $key in
48+
-repl)
49+
run_repl=true
50+
shift
51+
;;
52+
-classpath)
53+
addCustomClassPath "$2"
54+
shift
55+
shift
56+
;;
57+
-d)
58+
DEBUG="$DEBUG_STR"
59+
shift
60+
;;
61+
*)
62+
addResidual "$1"
63+
shift
64+
;;
65+
66+
esac
67+
done
68+
69+
if [ $run_repl == true ]; then
70+
echo "Starting dotty REPL"
71+
if [ -z $classpath_args ]; then
72+
classpath_args=""
73+
else
74+
classpath_args="-classpath \"${classpath_args[*]}\""
75+
fi
76+
eval "$PROG_HOME/bin/dotc $classpath_args -repl ${residual_args[@]}"
77+
elif [ -z $residual_args ]; then
4278
echo "Starting dotty REPL..."
4379
eval "$PROG_HOME/bin/dotc -repl"
44-
elif [[ ${first_arg:0:1} == "-" ]]; then
45-
eval "$PROG_HOME/bin/dotc -repl $@"
4680
else
47-
eval exec "\"$JAVACMD\"" "$DEBUG" "-classpath \"$CLASS_PATH\"" $@
81+
CLASS_PATH="${classpath_args[*]}$CLASS_PATH"
82+
eval exec "\"$JAVACMD\"" "$DEBUG" "-classpath \"$CLASS_PATH\"" "${residual_args[@]}"
4883
fi

project/scripts/sbtBootstrappedTests

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
echo "testing sbt dotc and dotr"
1212
mkdir out/scriptedtest0
1313
./bin/dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest0
14+
1415
# FIXME #3477
15-
#./bin/dotr -classpath out/scriptedtest0 dotrtest.Test" > sbtdotr1.out
16-
#if grep -e "dotr test ok" sbtdotr1.out; then
17-
# echo "output ok"
18-
#else
19-
# exit -1
20-
#fi
16+
./bin/dotr -classpath out/scriptedtest0 dotrtest.Test" > sbtdotr1.out
17+
if grep -e "dotr test ok" sbtdotr1.out; then
18+
echo "output ok"
19+
else
20+
exit -1
21+
fi
2122
2223
2324
# check that `dotc` compiles and `dotr` runs it
@@ -26,10 +27,9 @@ mkdir out/scriptedtest1
2627
mkdir out/scriptedtest2
2728
./bin/dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest1/
2829
./bin/dotc -from-tasty -classpath out/scriptedtest1/ -d out/scriptedtest2/ dotrtest.Test
29-
# FIXME #3477
30-
#./bin/dotr -classpath out/scriptedtest2/ dotrtest.Test" > sbtdotr2.out
31-
#if grep -e "dotr test ok" sbtdotr2.out; then
32-
# echo "output ok"
33-
#else
34-
# exit -1
35-
#fi
30+
./bin/dotr -classpath out/scriptedtest2/ dotrtest.Test" > sbtdotr2.out
31+
if grep -e "dotr test ok" sbtdotr2.out; then
32+
echo "output ok"
33+
else
34+
exit -1
35+
fi

0 commit comments

Comments
 (0)