diff --git a/com.oracle.truffle.r.native/run/R.sh b/com.oracle.truffle.r.native/run/R.sh index af88a96c74342f731447da788106d413ecf13341..dfc18472c430a571603e0d44dc6ad1fe3f130585 100644 --- a/com.oracle.truffle.r.native/run/R.sh +++ b/com.oracle.truffle.r.native/run/R.sh @@ -1,3 +1,4 @@ +#!/bin/bash # # This material is distributed under the GNU General Public License # Version 2. You may review the terms of this license at @@ -15,9 +16,13 @@ # GNUR=`which R` +source="${BASH_SOURCE[0]}" +while [ -h "$source" ] ; do source="$(readlink "$source")"; done +PRIMARY_PATH="$( cd -P "$( dirname "$source" )" && pwd )"/.. + case ${1} in CMD) exec $GNUR "$@";; *) - exec mx R "$@";; + exec mx --primary-suite-path $PRIMARY_PATH R "$@";; esac diff --git a/com.oracle.truffle.r.native/run/Rscript.sh b/com.oracle.truffle.r.native/run/Rscript.sh index 22968bece237e8c80075abf8691be65a6ffd081c..4ce11bef4e7ac6c0dfc379abf1ff23ac8312f8eb 100755 --- a/com.oracle.truffle.r.native/run/Rscript.sh +++ b/com.oracle.truffle.r.native/run/Rscript.sh @@ -1,3 +1,4 @@ +#!/bin/bash # # This material is distributed under the GNU General Public License # Version 2. You may review the terms of this license at @@ -12,4 +13,8 @@ # Fledgling Rscript command to startup FastR -mx Rscript "$@" +source="${BASH_SOURCE[0]}" +while [ -h "$source" ] ; do source="$(readlink "$source")"; done +PRIMARY_PATH="$( cd -P "$( dirname "$source" )" && pwd )"/.. + +mx --primary-suite-path $PRIMARY_PATH Rscript "$@" 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 a90120dbf7e9fc3e698cc2e201be9b5de561422f..4f9e63e5142f35e2c85ba8276bd908399f581103 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 @@ -124,11 +124,17 @@ public class REnvVars { public static String rHome() { // This can be called before initialize, "R RHOME" if (rHomePath == null) { - File file = new File(System.getProperty("user.dir")); - if (file.getName().endsWith("r.test")) { - file = file.getParentFile(); + + String path = System.getProperty("rhome.path"); + if (path != null) { + rHomePath = path; + } else { + File file = new File(System.getProperty("user.dir")); + if (file.getName().endsWith("r.test")) { + file = file.getParentFile(); + } + rHomePath = file.getAbsolutePath(); } - rHomePath = file.getAbsolutePath(); // Check any external setting is consistent String envRHomePath = getEnvVars().get("R_HOME"); if (envRHomePath != null) { diff --git a/mx.fastr/mx_fastr.py b/mx.fastr/mx_fastr.py index 1ef05cee144c4e0096905301cee6e74b53529af2..7de0f239e049071850476e26cca8f4fcd04137d1 100644 --- a/mx.fastr/mx_fastr.py +++ b/mx.fastr/mx_fastr.py @@ -36,6 +36,7 @@ def runR(args, className, nonZeroIsFatal=True, extraVmArgs=None, runBench=False) setREnvironment() project = className.rpartition(".")[0] vmArgs = ['-cp', mx.classpath(project)] + vmArgs = vmArgs + ["-Drhome.path=" + _fastr_suite.dir] if runBench == False: vmArgs = vmArgs + ['-ea', '-esa']