diff --git a/com.oracle.truffle.r.native/run/Makefile b/com.oracle.truffle.r.native/run/Makefile index 13f2a596fb83f3d1578ddc3a0e4f1c01810ca520..24e74d213ae3b52e9de02a47ba464c5369d7e1cf 100644 --- a/com.oracle.truffle.r.native/run/Makefile +++ b/com.oracle.truffle.r.native/run/Makefile @@ -69,6 +69,8 @@ rcmds: $(FASTR_BIN_DIR)/R $(FASTR_BIN_DIR)/R: Makefile R.sh Rscript.sh Rscript_exec.sh Rclasspath.sh cp -r $(BIN_FILES) $(FASTR_BIN_DIR) + # cp $(FASTR_R_HOME)/com.oracle.truffle.r.native/gnur/patch/bin-patch/* $(FASTR_BIN_DIR) + # overide bin/R cp R.sh $(FASTR_BIN_DIR)/exec/R # override bin/Rscript @@ -77,8 +79,10 @@ $(FASTR_BIN_DIR)/R: Makefile R.sh Rscript.sh Rscript_exec.sh Rclasspath.sh # for embedded support cp Rclasspath.sh $(FASTR_BIN_DIR)/execRextras/Rclasspath chmod +x $(FASTR_BIN_DIR)/exec/R $(FASTR_BIN_DIR)/execRextras/Rscript $(FASTR_BIN_DIR)/Rscript $(FASTR_BIN_DIR)/execRextras/Rclasspath - # update R_HOME_DIR to FastR - (sed -e 's!^\(R_HOME_DIR=\)\(.*\)!\1"$(FASTR_R_HOME)"!' | sed -e 's/ -h.--help./ --r-help\)/') < $(R_SCRIPT) > $(FASTR_BIN_DIR)/R + # update R_HOME_DIR to FastR, --help to -r-help because --help is handled by FastR, and pass args to Rcmd (esp. --jvm) + (sed -e 's!^\(R_HOME_DIR=\)\(.*\)!\1"$(FASTR_R_HOME)"!' | \ + sed -e 's/ -h.--help./ --r-help\)/' | \ + sed -e 's! exec sh "$${R_HOME}/bin/Rcmd" "$${@}" ;;! FASTR_INTERNAL_ARGS="$${FASTR_INTERNAL_ARGS} $${args}" exec sh "$${R_HOME}/bin/Rcmd" "$${@}" ;;!') < $(R_SCRIPT) > $(FASTR_BIN_DIR)/R chmod +x $(FASTR_BIN_DIR)/R touch $(FASTR_ETC_DIR)/ldpaths sed -e "s|\(R_LIBS_USER=.*-'\)\(.*\)'}|\1$(FASTR_R_HOME)/library'}|" < $(GNUR_HOME_BINARY)/etc/Renviron > $(FASTR_ETC_DIR)/Renviron diff --git a/com.oracle.truffle.r.native/run/R.sh b/com.oracle.truffle.r.native/run/R.sh index 5f7471ef4171badae3b36ac7a056721203c29ea4..af7bf7df38d9862547f4936e6a42831426b6747a 100644 --- a/com.oracle.truffle.r.native/run/R.sh +++ b/com.oracle.truffle.r.native/run/R.sh @@ -46,4 +46,4 @@ else mx=`which mx` fi -exec $mx --primary-suite-path $PRIMARY_PATH $MX_R_GLOBAL_ARGS R $MX_R_CMD_ARGS "$@" +exec $mx --primary-suite-path $PRIMARY_PATH $MX_R_GLOBAL_ARGS R $FASTR_INTERNAL_ARGS $MX_R_CMD_ARGS "$@" diff --git a/com.oracle.truffle.r.native/run/Rscript_exec.sh b/com.oracle.truffle.r.native/run/Rscript_exec.sh index 950435e34dc03d991b00facbfa3450db7d2f56af..d60986df1135e5ca09b17546b1058d9a837fc3ff 100644 --- a/com.oracle.truffle.r.native/run/Rscript_exec.sh +++ b/com.oracle.truffle.r.native/run/Rscript_exec.sh @@ -42,4 +42,4 @@ else mx=`which mx` fi -exec $mx --primary-suite-path $PRIMARY_PATH $MX_R_GLOBAL_ARGS Rscript $MX_R_CMD_ARGS "$@" +exec $mx --primary-suite-path $PRIMARY_PATH $MX_R_GLOBAL_ARGS Rscript $FASTR_INTERNAL_ARGS $MX_R_CMD_ARGS "$@" diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java index 918258922b11787e2373b7d3f5e84f9095909863..d8d95185e10750ec16cffc9802e00e905ba022b2 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java @@ -73,6 +73,19 @@ public final class REnvVars implements RContext.ContextState { // Always read the system file FileSystem fileSystem = FileSystems.getDefault(); safeReadEnvironFile(fileSystem.getPath(rHome, "etc", "Renviron").toString()); + + String internalArgs = System.getenv("FASTR_INTERNAL_ARGS"); + if (context.getEnv().isHostLookupAllowed()) { + if (internalArgs == null) { + internalArgs = "--jvm"; + } else if (!internalArgs.contains("--jvm")) { + internalArgs += " --jvm"; + } + } + if (internalArgs != null) { + envVars.put("FASTR_INTERNAL_ARGS", internalArgs); + } + envVars.put("R_DOC_DIR", fileSystem.getPath(rHome, "doc").toString()); envVars.put("R_INCLUDE_DIR", fileSystem.getPath(rHome, "include").toString()); envVars.put("R_SHARE_DIR", fileSystem.getPath(rHome, "share").toString());