Skip to content

Pass JVM options to app. (#3509) #3660

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 3 commits into from
Jan 19, 2018
Merged
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
29 changes: 24 additions & 5 deletions dist/bin/dotr
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,32 @@ if [ -z "$PROG_HOME" ] ; then
cd "$saveddir"
fi

addJvmOptions () {
jvm_options+=("$1")
}

source "$PROG_HOME/bin/common"

declare -a residual_args
run_repl=false
execute_repl=false
execute_run=false
with_compiler=false
class_path_count=0
CLASS_PATH=""

while [[ $# -gt 0 ]]; do
case "$1" in
-repl)
run_repl=true
execute_repl=true
shift
;;
-run)
execute_run=true
shift
;;
-classpath)
CLASS_PATH="$2"
class_path_count+=1
shift
shift
;;
Expand All @@ -53,6 +64,9 @@ while [[ $# -gt 0 ]]; do
DEBUG="$DEBUG_STR"
shift
;;
-J*)
addJvmOptions "-${1:2}"
shift ;;
*)
residual_args+=("$1")
shift
Expand All @@ -61,21 +75,26 @@ while [[ $# -gt 0 ]]; do
esac
done

if [ $run_repl == true ] || [ ${#residual_args[@]} -eq 0 ]; then
if [ $execute_repl == true ] || ([ $execute_run == false ] && [ ${#residual_args[@]} -eq 0 ]); then
if [ "$CLASS_PATH" ]; then
cp_arg="-classpath \"$CLASS_PATH\""
fi
echo "Starting dotty REPL..."
eval "\"$PROG_HOME/bin/dotc\" $cp_arg -repl ${residual_args[@]}"
else
elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then
cp_arg="$DOTTY_LIB$PSEP$SCALA_LIB"
if [ -z "$CLASS_PATH" ]; then
cp_arg+="$PSEP."
else
cp_arg+="$PSEP$CLASS_PATH"
fi
if [ $class_path_count > 1 ]; then
echo "warning: multiple classpaths are found, dotr only use the last one."
fi
if [ $with_compiler == true ]; then
cp_arg+="$PSEP$DOTTY_COMP$PSEP$DOTTY_INTF$PSEP$SCALA_ASM"
fi
eval exec "\"$JAVACMD\"" "$DEBUG" "-classpath \"$cp_arg\"" "${residual_args[@]}"
eval exec "\"$JAVACMD\"" "$DEBUG" "-classpath \"$cp_arg\"" "${jvm_options[@]}" "${residual_args[@]}"
else
echo "warning: command option is not correct."
fi