Skip to content

Commit bfb65c6

Browse files
Merge pull request #3660 from jiminhsieh/wip/#3509
Pass JVM options to app. (#3509)
2 parents 79281da + b02da80 commit bfb65c6

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

dist/bin/dotr

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,32 @@ if [ -z "$PROG_HOME" ] ; then
2727
cd "$saveddir"
2828
fi
2929

30+
addJvmOptions () {
31+
jvm_options+=("$1")
32+
}
33+
3034
source "$PROG_HOME/bin/common"
3135

3236
declare -a residual_args
33-
run_repl=false
37+
execute_repl=false
38+
execute_run=false
3439
with_compiler=false
40+
class_path_count=0
3541
CLASS_PATH=""
3642

3743
while [[ $# -gt 0 ]]; do
3844
case "$1" in
3945
-repl)
40-
run_repl=true
46+
execute_repl=true
47+
shift
48+
;;
49+
-run)
50+
execute_run=true
4151
shift
4252
;;
4353
-classpath)
4454
CLASS_PATH="$2"
55+
class_path_count+=1
4556
shift
4657
shift
4758
;;
@@ -53,6 +64,9 @@ while [[ $# -gt 0 ]]; do
5364
DEBUG="$DEBUG_STR"
5465
shift
5566
;;
67+
-J*)
68+
addJvmOptions "-${1:2}"
69+
shift ;;
5670
*)
5771
residual_args+=("$1")
5872
shift
@@ -61,21 +75,26 @@ while [[ $# -gt 0 ]]; do
6175
esac
6276
done
6377

64-
if [ $run_repl == true ] || [ ${#residual_args[@]} -eq 0 ]; then
78+
if [ $execute_repl == true ] || ([ $execute_run == false ] && [ ${#residual_args[@]} -eq 0 ]); then
6579
if [ "$CLASS_PATH" ]; then
6680
cp_arg="-classpath \"$CLASS_PATH\""
6781
fi
6882
echo "Starting dotty REPL..."
6983
eval "\"$PROG_HOME/bin/dotc\" $cp_arg -repl ${residual_args[@]}"
70-
else
84+
elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then
7185
cp_arg="$DOTTY_LIB$PSEP$SCALA_LIB"
7286
if [ -z "$CLASS_PATH" ]; then
7387
cp_arg+="$PSEP."
7488
else
7589
cp_arg+="$PSEP$CLASS_PATH"
7690
fi
91+
if [ $class_path_count > 1 ]; then
92+
echo "warning: multiple classpaths are found, dotr only use the last one."
93+
fi
7794
if [ $with_compiler == true ]; then
7895
cp_arg+="$PSEP$DOTTY_COMP$PSEP$DOTTY_INTF$PSEP$SCALA_ASM"
7996
fi
80-
eval exec "\"$JAVACMD\"" "$DEBUG" "-classpath \"$cp_arg\"" "${residual_args[@]}"
97+
eval exec "\"$JAVACMD\"" "$DEBUG" "-classpath \"$cp_arg\"" "${jvm_options[@]}" "${residual_args[@]}"
98+
else
99+
echo "warning: command option is not correct."
81100
fi

0 commit comments

Comments
 (0)