@@ -40,19 +40,29 @@ fastr_home="$(dirname "$source")/.."
4040
4141silent=0
4242uninstall=0
43+ verbose=0
4344for arg in " $@ " ; do
4445 if [[ $arg == " --silent" ]]; then
4546 silent=1
47+ elif [[ $arg == " --verbose" ]]; then
48+ verbose=1
4649 elif [[ $arg == " uninstall" ]]; then
4750 uninstall=1
4851 elif [[ $arg == " --help" ]]; then
4952 echo " Usage: install_r_native_image [uninstall] [--silent]"
5053 echo " When 'uninstall' argument is not present: builds and installs native image of the R runtime."
5154 echo " When 'uninstall' argument is present: uninstalls previously installed native image of the R runtime."
5255 echo " Use the --silent option to turn off the confirmation when installing."
56+ echo " Use the --verbose option to turn on detailed logging."
5357 fi
5458done
5559
60+ function log {
61+ if [[ $verbose -eq 1 ]]; then
62+ echo $@
63+ fi
64+ }
65+
5666if [[ $uninstall -eq 1 ]]; then
5767 echo " Uninstalling native image of R runtime..."
5868 mv " $fastr_home /bin/exec_R.backup" " $fastr_home /bin/exec/R"
@@ -73,6 +83,7 @@ if [[ $silent -eq 0 ]]; then
7383 fi
7484fi
7585
86+ log " Changing directory to: $fastr_home /bin"
7687cd " $fastr_home /bin"
7788
7889fastr_launcher_ni_args=(
@@ -89,10 +100,18 @@ fastr_launcher_ni_args=(
89100 -Dorg.graalvm.launcher.classpath=jre/lib/graalvm/launcher-common.jar:jre/languages/R/fastr-launcher.jar
90101 -H:Class=com.oracle.truffle.r.launcher.RMain
91102)
103+ if [[ $verbose -eq 1 ]]; then
104+ fastr_launcher_ni_args+=(' --verbose' )
105+ fi
92106
107+ log " Running: ../../../../bin/native-image" " ${fastr_launcher_ni_args[@]} " -H:Name=RMain
93108../../../../bin/native-image " ${fastr_launcher_ni_args[@]} " -H:Name=RMain
109+
110+ log " Creating backup of the R and Rscript launchers"
94111cp " exec/R" " exec_R.backup"
95112cp " Rscript" " Rscript.backup"
113+
114+ log " Patching the R and Rscript launchers to dispatch to the generated native image"
96115sed -e ' /^## REMOVE FOR NATIVE IMAGE: BEGIN/,/^## REMOVE FOR NATIVE IMAGE: END/d;' " exec_R.backup" | \
97116 sed -e ' s|^exec "$JAVA_HOME/bin/java" .*|exec "$R_HOME/bin/RMain" R ${FASTR_INTERNAL_ARGS[@]} "$@"|' > " exec/R"
98117sed -e ' /^## REMOVE FOR NATIVE IMAGE: BEGIN/,/^## REMOVE FOR NATIVE IMAGE: END/d;' " Rscript.backup" | \
0 commit comments